Sir R. M8gic1an
2009-09-10 02:16:01
Ok guys, i got a lil ahead of myself thinking of the walking system :)
This is not completly scripted up to MSI Standards yet, as this was just me gathering ideas. I also chucked a couple of misc functions in here, which would actually be in some other part of the include but i needed them to have a clear picture of what to do :)
Looking good?
~RM
This is not completly scripted up to MSI Standards yet, as this was just me gathering ideas. I also chucked a couple of misc functions in here, which would actually be in some other part of the include but i needed them to have a clear picture of what to do :)
type
TheWalk = record;
City: integer;
Loc: integer;
Path: TPointArray;
end;
var
MyWalk: TheWalk;
const
City_Varrock = 0;
Loc_VEBank = 0;
Loc_VWBank = 1;
Loc_GEBank = 2;
Loc_VEM = 3;
Loc_NETree = 4;
Loc_ChurchYew = 5;
Loc_SWTree = 6;
Loc_GEYew = 7;
City_Falador = 1;
Loc_Bank = 0;
Loc_MGuild = 1;
Loc_Furnace = 2;
Function SetUpWalk(City, WhereTo: integer): TheWalk;
begin
case City of
City_Varrock:
begin
case WhereTo of
Loc_VEM:
begin
with Result do
begin
City := City_Varrock;
Loc := Loc_VEM;
Path := [
Point(3011, 3355), Point(3008, 3345), Point(3008, 3335), Point(3008, 3325),
Point(3017, 3321), Point(3026, 3316), Point(3033, 3314)
];
end;
end; //of Loc_VEM case
Loc_NETree:
begin
with Result do
begin
City := City_Varrock;
Loc := Loc_NETree;
Path := [
Point(3011, 3355), Point(3008, 3345), Point(3008, 3335), Point(3008, 3325),
Point(3017, 3321), Point(3026, 3316), Point(3033, 3314)
];
end;
end; // of Loc_NETree
end; // of WhereTo case
end; //of City_Varrock case
end; //end of City case
end;
Function WalkPath(Path: TPointArray): boolean;
begin
if not (Players[CurrentPlayer].Integers[P_Loc] = Loc_Bank) then
InvertTPA(Path);
//...
end;
Function LocationPoint(City, Loc: integer):TPoint;
begin
case City of
City_Varrock:
case Loc of
Loc_VEB: Result := Point(123, 345);
Loc_VWB: Result := Point(234, 456);
//...
end;
City_Falador:
case Loc of
Loc_FEB: Result := Point(123, 345);
Loc_FWB: Result := Point(234, 456);
end;
end;
end;
Function WhereAmI: TheWalk;
var
i, j, Dis, Closest_Dis: integer;
TP, Pos, Closest_TP, Closest_Info: TPoint;
begin
Pos := GetMyPos;
Dis_Closest := 1000;
for i:= 0 to HowManyCities do
for j:= HowManyLocs(i) do
begin
TP := LocationPoint(i, j);
Dis := (sqr(abs(Pos.X - TP.X)) + sqr(abs(Pos.Y - TP.Y)));
if (Dis < 7) then
begin
Result := SetUpWalk(i, j);
exit;
end;
if Dis < Closest_Dis then
begin
Closest_Dis := Dis;
Closest_Info := Point(i, j)
Closest_TP := TP;
end;
end;
//if we are here, it means we are too far from any point
//therefore, we will walk to the closest
Result := SetUpWalk(Closest_Info.x, Closest_Info.y);
WalkToInvisiblePoint(Closest_TP);
//WalkToInvisiblePoint = a function that'll generate it's own path and walk there.
end;
Procedure PlayerStringsToConstants;
begin
with Players[CurrentPlayer] do
begin
case lowercase(Loc) of
'varrock':
begin
Integers[P_City] := City_Varrock;
case lowercase(Strings[P_Loc]) do
begin
'netree' : Integers[P_Loc] := Loc_NETree;
'vem' : Integers[P_Loc] := Loc_VEM;
'churchyew' : Integers[P_Loc] := Loc_ChurchYew;
end;
end;
'falador':
begin
Integers[P_City] := City_Falador;
//...
end;
end;
end;
end;
//....
begin
PlayerStringsToConstants;
MyWalk := SetUpWalk(Players[CurrentPlayer].Integers[P_City], Players[CurrentPlayer].Integers[P_Loc]);
WalkPath(MyWalk.Path);
end.
Looking good?
~RM