pwnaz0r
2008-10-10 03:59:17
function LoadWebWalker: Boolean;
begin
try
WebWalkerpath := [Point(3222, 3217), Point(3236, 3209), Point(3236, 3200),
Point(3236, 3209), Point(3236, 3223), Point(3252, 3224),
Point(3260, 3235), Point(3267, 3226), Point(3255, 3248),
Point(3251, 3261), Point(3244, 3275), Point(3240, 3289),
Point(3239, 3304), Point(3250, 3315), Point(3262, 3323),
Point(3269, 3330), Point(3254, 3332), Point(3239, 3335),
Point(3226, 3343), Point(3220, 3358), Point(3212, 3372),
Point(3212, 3387), Point(3212, 3400), Point(3211, 3414),
Point(3213, 3428), Point(3197, 3428), Point(3181, 3428),
Point(3167, 3425), Point(3154, 3416), Point(3138, 3416),
Point(3122, 3414), Point(3108, 3420), Point(3098, 3419),
Point(3085, 3420), Point(3071, 3417), Point(3057, 3412),
Point(3042, 3416), Point(3032, 3426), Point(3017, 3426),
Point(3017, 3427), Point(3002, 3430), Point(2988, 3425),
Point(2980, 3415), Point(2967, 3411), Point(2966, 3395),
Point(2965, 3379), Point(2980, 3377), Point(2952, 3380),
Point(2946, 3368), Point(2989, 3370), Point(3001, 3362),
Point(3012, 3362), Point(3013, 3355), Point(3007, 3345),
Point(3006, 3331), Point(3007, 3316), Point(3005, 3301),
Point(3004, 3286), Point(3014, 3275), Point(3030, 3276),
Point(3001, 3277), Point(2987, 3276), Point(2976, 3270),
Point(2969, 3256), Point(2958, 3245), Point(2956, 3230),
Point(2956, 3217), Point(2956, 3208), Point(2972, 3280),
Point(2958, 3286), Point(2949, 3298), Point(2936, 3300),
Point(2933, 3288), Point(3020, 3260), Point(3029, 3269),
Point(3019, 3246), Point(3041, 3274), Point(3055, 3275),
Point(3068, 3276), Point(3076, 3287), Point(3092, 3289),
Point(3106, 3293), Point(3106, 3277), Point(3118, 3295),
Point(3112, 3305), Point(3104, 3265), Point(3104, 3252),
Point(3093, 3241), Point(3105, 3233), Point(3113, 3221),
Point(3115, 3208), Point(3114, 3196), Point(3114, 3180),
Point(3111, 3167), Point(3126, 3221), Point(3140, 3226),
Point(3154, 3232), Point(3167, 3236), Point(3180, 3245),
Point(3195, 3249), Point(3211, 3245), Point(3222, 3236),
Point(3232, 3229), Point(3220, 3246), Point(3217, 3258),
Point(3230, 3260), Point(3244, 3261), Point(3216, 3271),
Point(3204, 3277), Point(3190, 3281), Point(3176, 3285),
Point(3162, 3286), Point(3149, 3294), Point(3138, 3294),
Point(3128, 3295), Point(3280, 3330), Point(3280, 3319),
Point(3277, 3305), Point(3275, 3291), Point(3275, 3276),
Point(3276, 3260), Point(3278, 3247), Point(3278, 3232),
Point(3277, 3216), Point(3275, 3203), Point(3282, 3190),
Point(3279, 3175), Point(3270, 3164)]; result:= true; WebwalkerLoaded:= true;
except
result:= false;
end;
end;
function ClosestPointOnPath(Point: TPoint): TPoint;
begin
if not WebWalkerLoaded then LoadwebWalker;
SortTPAFrom(WebWalkerPath, Point);
result:= WebWalkerPath[0];
end;
function FindGreatestDistIn(var TP1, TP2: TPoint; TPA: TPointArray; StartPoint: TPoint ): boolean;// will return true when finished
var
I, L, M: integer;
Dist: integer;
begin
M:= Distance(3171, 3150, 3166, 3164);
SortTPAFrom(TPA, StartPoint);
for I:= 1 to high(TPA) do
begin
L:= Distance(TPA[(I-1)].X, TPA[(I-1)].Y, TPA[I].X, TPA[I].Y);
if (Dist < L)then
begin
TP1:= TPA[(I-1)];
TP2:= TPA[I];
Dist:= L;
end;
end;
if (Dist <= M)then
result:= true;
end;
procedure RemoveTPA(Var TPA: TpointArray; ThePoint: TPoint);
var
i: integer;
begin
if PointInTPA(ThePoint, TPA)then
begin
for i:= 0 to high(TPA) do
if (TPA[I].X= ThePoint.X) and (TPA[I].Y = ThePoint.Y)then
begin
tSwap(TPA[i], TPa[(high(TPA))]);
SetArrayLength(TPA, GetArrayLength(TPA)-1);
end;
end;
end;
procedure AddPointToWW(var TPA: array of TPoint; ThePoint: TPoint);
begin
SetLength(Points, GetArrayLength(Points)+1);
Points[(High(Points))]:= ThePoint;
RemoveTPA(PossiblePoints, ThePoint);
end ;
function BuildPath(SPoint, EPoint: TPoint): boolean;
var
CtrlP: Array [0..1] of TPoint;
Mdp, P1, P2, Mdpt: TPoint;
MyDis: integer;
begin
CtrlP:=[ SPoint, EPoint ];
Mdp:= MiddleTPA(CtrlP);
MyDis:= Round(max(Distance(mdp.X, mdp.Y, Ctrlp[0].x, Ctrlp[0].Y), Distance(mdp.X, mdp.Y, Ctrlp[1].x, Ctrlp[1].Y)));
PossiblePoints:= RemoveDistTPointArray(mdp.x, mdp.y, MyDis, webWalkerPath, true);
repeat
result:= FindGreatestDistIn(P1, P2, PossiblePoints, Mdp);
if (result = true) then break;
Mdpt := MiddleTPA([P1, P2]);
AddPointToWW(Points, ClosestPointOnPath(Mdpt));
until(false);
SortTPAFrom(Points, SPoint);
end;
procedure WriteAllPoints(TPA: TpointArray);
var
I: integer;
begin
if (GetArraylength(TPA) <= 0) then
Writeln('No Points in TPA');
for I:= 0 to High(Points) do
Writeln('Point['+IntToStr(I)+'] --> ('+IntToStr(Points[I].X)+', '+IntToStr(Points[I].Y)+');');
end;
hey Worked on this a bit tonight. Should work. Only thing left is using a windpath type algorithm to do points under 30 distance, AKA going from start to on path and on path to endpoint.
I will have to make walkign specific functions for this, aka no UIDs at tiles, else find another tile within 3 x 3 square or something.
How it works –> basically, i went with sumillion's walker helper and made points within range of each other on the path all around free world. Then I narrowed down the points that could be in the path by taking the midpoint of the start and end, took the larger distance from mdpt. start and mdpt. end, and removed all that were further away. Then I started at midpoint, worked my way out using find furthest Point in TPA (my own function, would be great if someone could throw these math functions into a plugin), and as I went down finding the midpoints between the largest distance and adding the closest point to the midpoint, I believe it will end up with the path. The end is just sorting from start, which I might need to make a specific function but i think that will work unless there is just a huge curve in the path, (AKharid. not going through gate). So yeah that problem needs to be fixed. Any comments?