SRL Archive - Research & Development Lounge

AtPos


MylesMadness

2009-06-26 05:20:14

{.include srl/srl.scar}
type
TPostion = record
TPA: TPointArray;
Colors: TIntegerArray;
end;
Procedure RemoveTPointFromArray(Index:Integer; Var Arr:TPointArray);
begin
tSwap(Arr[Index], Arr[High(Arr)]);
SetArrayLength(Arr, High(Arr));
end;

Procedure RemoveIntFromArray(Index:Integer; Var Arr:TIntegerArray);
begin
Swap(Arr[Index], Arr[High(Arr)]);
SetArrayLength(Arr, High(Arr));
end;

Procedure FilterUnWantedPoints(var Stuff:TPostion);
var
Skip:TIntegerArray;
I:Integer;
begin
Skip:= [65536, 16711422, 12961221, 14869218, 16777215, 15527148, 195836, 56797, 60909, 52428,
13816530, 982782, 1310462, 62965, 2105598, 395004, 789758, 3553023, 217, 188, 241,
206, 233, 64768, 58880, 51456, 49152, 44800, 61440, 16215571, 9716750, 13129742];
For I:=0 to high(Stuff.colors)do
If InIntArray(Skip, Stuff.Colors[i]) then
begin
RemoveTPointFromArray(I, Stuff.TPA);
RemoveIntFromArray(I, Stuff.Colors);
end;
end;

Function MakePostionFinder:String;
var
I:Integer;
Postion:TPostion;
begin
FindColorsTolerance(Postion.TPA, 0, MMX1, MMY1, MMX2, MMY2, 421);
Postion.TPA:=RemoveDistTPointArray(MMCX, MMCY, 79, Postion.TPA, True);
Postion.Colors:=GetColors(Postion.TPA);
FilterUnWantedPoints(Postion);
Result:='''';
For I:=0 to high(Postion.TPA) do
begin
If I mod 40 = 0 then
Result:=Result+IntToStr(Postion.TPA[i].x)+','+IntToStr(Postion.TPA[i].y)+','+IntToStr(Postion.Colors[i])+'|';
If I mod 240 = 0 then
Result:=Result+''' +'+#13+' ''';
end;
result:=Result+'''';
end;

Function StringToPostion(Loc:String):TPostion;
var
Strs, Strs2:TStringArray;
I:Integer;
begin
Strs:=Explode('|', Loc);
SetArrayLength(Result.Colors, High(Strs)+1);
SetArrayLength(Result.TPA, High(Strs)+1);
For I:=0 to high(Strs)do
begin
Strs2:=Explode(',', Strs[i]);
Result.Colors[i]:=StrToInt(Strs2[2]);
Result.TPA[i]:=Point(StrToInt(Strs2[0]), StrToInt(Strs2[1]))
end;
end;

Function AtPos(Loc:String):Boolean;
var
MP: TDTMPointDef;
SP: array of TDTMPointDef;
DDTM: TDTM;
I:Integer;
P:TPostion;
Dtm, x, y:Integer;
begin
P:=StringToPostion(Loc);
MP.x := MMCX;
MP.y := MMCY;
MP.areasize := 3;
MP.color := GetColor(MMCX, MMCY);
MP.tolerance := 50;
SetArrayLength(SP, High(P.TPA)+1);
for I := 0 to High(P.TPA) do
begin
SP[i].x := P.TPA[i].x;
SP[i].y := P.TPA[i].y;
SP[i].areasize := 3;
SP[i].areashape := 0;
SP[i].color := P.Colors[i];
SP[i].tolerance := 0;
end;
DDTM.MainPoint :=MP;
DDTM.SubPoints :=SP;
DTM:=AddDTM(DDTM);
result:= DTMRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2);
FreeDTM(DTM);
end;

Basicly you run
Writeln(MakePostionFinder);
then you do
  S:='TheCrapYouGotAbove';
If AtPos(S) then
Writeln('yays')
else
Writeln('boos');
Also it seems that symbols make it not work. If anyone has ideas to fix this please post

ian.

2009-06-26 05:27:59

I don't get it. 'o.O lol what's this do? :] And it should be..


s := 'TheCrapYouGotAbove';
If(AtPos(s))then
Writeln('yays')
else
Writeln('boos');
;]

MylesMadness

2009-06-26 05:29:21

From: 99_
I don't get it. 'o.O lol what's this do? :] And it should be..


s := 'TheCrapYouGotAbove';
If(AtPos(s))then
Writeln('yays')
else
Writeln('boos');
;]
It checks if your at a position on the map.

ian.

2009-06-26 05:31:20

I didn't move and it said I did? D:

MylesMadness

2009-06-26 05:32:59

From: 99_
I didn't move and it said I did? D:
It just checks if your at a position, not moves there.

ian.

2009-06-26 05:34:59

No I know, but I ran it and then re-ran it with the stuff that it outputted as S, and it said Boos.

MylesMadness

2009-06-26 05:59:08

From: 99_
No I know, but I ran it and then re-ran it with the stuff that it outputted as S, and it said Boos.
It worked for me when I tested it. Werid

ian.

2009-06-26 06:15:10

Might be because I was at GE in a pretty full world :p

MylesMadness

2009-06-26 15:07:03

From: 99_
Might be because I was at GE in a pretty full world :p
That would do it.

Do Atpos(MakePostionFinder); It might work better for testing

marpis

2009-06-27 15:08:21

this gets pos in world map?

Shuttleu

2009-06-27 15:11:24

i ran Writeln(MakePostionFinder);
and it gave a 100 line string
is that what its supposed to do?
because it seems pretty long

~shut

ian.

2009-06-27 15:17:32

Yeah, it's pretty long. Could you shorten it somehow? :D (Like how they shortened bitmaps).

Sir R. M8gic1an

2009-06-27 15:22:38

Have a look at IsMoving, perhaps you can steal an idea or two from there, to ignore points that move on their own such as NPCs, Players and symbols?

Seems like a very good project, although i haven't read through it.

Also, perhaps 3-5 points would be enough and faster?

~RM

MylesMadness

2009-06-28 03:50:37

Update, uses less points and uses Rasta's suggestion

ian.

2009-06-28 04:15:28

So will it be less lines of random nonsense? :p

MylesMadness

2009-06-28 05:05:54

From: 99_
So will it be less lines of random nonsense? :p
yeah… depending on where it is there will be TONS less

Edit: I did it in the middle of wild and for got lines

ian.

2009-06-28 05:07:42

Mmkay! :D I'm excited to use this <3 I will later tonight and tell you how it goes ;D