Log in

View Full Version : How To Detect Player Below Line..



Brandon
01-31-2012, 06:09 AM
K so how do I detect if my character is below a line on the minimap?

I've tried getting all the points on a line segment then checking if my character's X & Y is less than any of the corresponding values for the points.. but that takes forever!! AND it doesn't always work.. My math might have a bug :S

I'm basically trying to use the minimap as a graph/Cartesian plane to check if a player is out of bounds..


Function CrossedTheLine: Boolean;
var
LineSeg, AllPoints: TPointArray;
Slope, Len: Extended;
I, NumPoints, Dist, StepX, StepY, PX, PY: Integer;
begin
LineSeg:= [Point(54, 105), Point(49, 123)];

//Slope:= (LineSeg[1].Y - LineSeg[0].Y) div (LineSeg[1].X - LineSeg[0].X);
//B:= LineSeg[0].Y - (Slope * LineSeg[0].X);
//Y:= (Slope * X) + B;

Len:= Hypot(((LineSeg[0].X - LineSeg[1].X) * 1.0), ((LineSeg[0].Y - LineSeg[1].Y) * 1.0)); //Length Of Segment.
Dist:= Distance(LineSeg[0].X, LineSeg[0].Y, LineSeg[1].X, LineSeg[1].Y);
NumPoints:= Floor(Len div Dist);

if (NumPoints = 0) then
NumPoints:= 1; //Prevent Division By 0.

StepX:= Floor((LineSeg[1].X - LineSeg[0].X)/NumPoints);
StepY:= Floor((LineSeg[1].Y - LineSeg[0].Y)/NumPoints);

PX:= StepX + LineSeg[0].X;
PY:= StepY + LineSeg[0].Y;

For I:= 0 To NumPoints do
begin
SetLength(AllPoints, Length(AllPoints) + 1);
AllPoints[I]:= Point(PX, PY);
PX := PX + StepX;
PY := PY + StepY;
end;
writeln(AllPoints);
end;

tls
01-31-2012, 06:55 AM
Add a picture or two. I'm thinking if those points are constant, you could just create a box and do TPAFromBox and check to see if MMCX, MMCY is in the tpa.

Spiker
01-31-2012, 07:30 AM
If you are trying to recognize when a player goes "out of bounds" use the symbol finding method (if there's a symbol nearby). Then, have it logout out if symbol ______ is not found.

Good Luck

Brandon
01-31-2012, 12:12 PM
http://i.imgur.com/lEMBb.png

In the above, that little circle is a pillar.. the grey area is walls.. P1 and P2 form a line using SPS points if the player crosses the line into the orange then I'm out of bounds.. I just can't figure it out.. Oh and there is a symbol at P2..

I didn't think about the tpa in box.. I'll go try that when I get home. Thanks :)

DemiseScythe
01-31-2012, 12:27 PM
DTM anchor

Narcle
01-31-2012, 12:33 PM
GetTPAFromBox(minimap)
FilterPointsPie from Symbol/SPS point (from that pictures looks like from 30/40 degrees to 210/220)
if TPA not in TPAarray then
your out of bounds or w/e

Unless that Point isn't always on minimap.

DemiseScythe
01-31-2012, 12:44 PM
To be honest, make it so that if you go too far south, it runs back. I would detect the green color on the Green Brutal Dragons or on the FireBlast

if see any of those too, SPS walk to a safe spot.

Check for those colors on the screen, if seen, run back, you will also get "you are terribly burnt" if you get too far south.

jakeyboy29
01-31-2012, 01:30 PM
//offtopic, in your sig, try the mm to ms

DemiseScythe
01-31-2012, 03:21 PM
No, its a WaterFiend bot and if he passes that line, he gets killed by Brutal Green Dragons, so thats the whole point of this thread, how to avoid running over to the Dragons in the Ancient Cavern Dungeon

Brandon
01-31-2012, 03:24 PM
^That.. I have all the fighting and code written.. it currently gets to the waterfiends and fights them.. it's just I thought the best idea would be to detect if I'm below the line.. Anything below those points gets destroyed by those brutals..

I'll try all the suggestions.

jakeyboy29
01-31-2012, 03:30 PM
No, its a WaterFiend bot and if he passes that line, he gets killed by Brutal Green Dragons, so thats the whole point of this thread, how to avoid running over to the Dragons in the Ancient Cavern Dungeon

1. Thats why i said //offtopic....

2. I was talking about his sig, sorry, wasnt sure how to make it any clearer

footballjds
01-31-2012, 03:35 PM
Using TPA's or DTM's you can easily find out where you are(using the wall)
Stolen from tip.it:
http://www.tip.it/runescape/images/maps/Ancient_Cavern_2.png



1. Thats why i said //offtopic....

2. I was talking about his sig, sorry, wasnt sure how to make it any clearer

My suggestion is to use MM to MS conversion to get a MS point then do a spiral color search from that point. Only spiral out about 50 pixels or so. That'd be a pretty fast item detection system :D

DemiseScythe
01-31-2012, 03:41 PM
1. Thats why i said //offtopic....

2. I was talking about his sig, sorry, wasnt sure how to make it any clearer

Sorry, I taught your Signature was part of your post and you were asking if this was a GDK.

Offtopic Nice picture ggzz, I like it