SRL Archive - OSR Help

Relocation without knowing location ;)


nickrules

2012-02-26 21:17:49

I'm making an AIO fighter which will hopefully include relocation.

This is what I have:
Procedure Relocate;
var x,y,i,testval:integer;
MP:TPoint;
TPA:TPointArray;
ATPA:Array of TPointArray;
begin
if not doRelocate then exit;
if not loggedin then exit;
FindNormalRandoms;
TPA:=GetMiniMapDots('y'); //get MM dots, store to array
SortTPAFrom(TPA,Point(mmcx,mmcy));

if (distance(MMCx,MMCy,TPA[0].x,TPA[0].y) < 30) then exit; //quick check if we actually need to

atpa := SplitTPA(tpa,30); //break into parts
testVal := 0;
for i:= 0 to high(atpa) do //basically, it finds the TPA in the ATPA with the most dots
begin
if High(atpa[i]) > testVal then
begin
TestVal := I; //and stores the index of that TPA here
end;
end;
MP := MiddleTPA(atpa[testval]); //calculates the middle of that TPA
SMART_DrawDots(atpa[testval]);
mouse(MP.x,MP.y,5,5,mouse_left); //click
FFlag(5); //wait
end;

TL;DR it finds the area of highest concentration of yellow MM dots, and clicks there. The problem is when a dot gets in the very edge and messes everything (middle of the area then moves to somewhere we may not want to go).

Thus, I had a few ideas on how to solve this issue:
1) Generate an objectDTM right off the bat.
2) SPS? Wouldn't necessarily work underground, unless the user set it to do so. And would you have to load every single area too?
3) Create a bitmap, filtering out all minimap dots (and symbols?)
4) Somehow improve my current method's accuracy
5) Filter out dots that are behind minimap walls, like so:

(orange area would be filtered out, btw.)
I don't know how, or if it could be done (ideally with minimal resource use)

The problem is, while all of these ideas would likely work, I want to minimize resource consumption if possible. And then there's also the actual doing it.

So, what do you think is the best way to do it? And how would you go about it?

nickrules

2012-02-27 22:43:50

Bump. Any ideas or help appreciated, really :redface:

Brandon

2012-02-27 23:18:20

Make an abstract box/polygon or shape using sps points.. and filter them from the minimap..
Now Filter TPA using ur npc points.

Coh3n

2012-02-27 23:43:19

You could use findColorsTolerance on the yellow NPC dot color, then call splitTPA(tpa, sizeOfFightArea), then loop through the resulting atpa, setting a maxLength (which would act as the most dense area of the NPC color on the MM). Then, click in the middle of that tpa. Just quickly wrote this up, not sure if it'll actually work. :p

const
_NPC_COLOR = 0;
_NPC_TOL = 10;

_FIGHTING_AREA_SIZE = 50;

function relocate(): boolean;
var
i, l, maxDensityIndex: integer;
p: TPoint;
tpa: TPointArray;
atpa: T2DPointArray;
begin
if (not loggedIn()) then
exit;

if (findColorsTolerance(tpa, _NPC_COLOR, MMX1, MMY1, MMX2, MMY2, _NPC_TOL)) then
begin
atpa := splitTPA(tpa, _FIGHTING_AREA_SIZE);
maxDensityIndex := -1;

for i := 0 to high(atpa) do
begin
l := length(atpa[i]);

if (l > maxDensityIndex) then
maxDensityIndex := i;
end;

p := middleTPA(atpa[maxDensityIndex]);
mouse(p.x, p.y, 5, 5, mouse_Move);
result := true;
end;
end;

nickrules

2012-02-27 23:46:39

From: ggzz
Make an abstract box/polygon or shape using sps points.. and filter them from the minimap..
Now Filter TPA using ur npc points.


Wouldn't it be easier to get the players location, and just walk back when the distance is too great? Remember, we're talking everywhere, not just the place in the picture.

Can you get the location without loading every SPS map section into memory? I'd check, but I'm not on my PC right now.

E: @Coh3n, aside from the dynamic fight area size, we have basically the same thing, except rather than manipulate all yellow pixels, I only use a single point for each dot.

Unless you do something different, and I don't see it.