Pally - Atacar Bichos de Longe
Pally - Atacar Bichos de Longe
Const
SQM = 3 // Quantos SQM de distancia?
function GetCreatureByID(ID: integer): TCreature;
var
x: integer;
begin
Result := nil;
for x := 0 to Creatures.Count - 1 do
begin
if x >= Creatures.Count then Break;
if Creatures.Creature[x].ID = ID then
begin
Result := Creatures.Creature[x];
Exit;
end;
end;
end;
UpdateWorld;
KnightID := Self.Following;
while not terminated do
begin
UpdateWorld;
Knight := GetCreatureByID(KnightID);
if Knight <> nil then
if Knight.Z = self.z then
begin
if self.following then
if (abs(Self.X-Knight.X) < SQM + 1) and (abs(Self.Y-Knight.Y) < SQM + 1) then
begin
Knight.Following := false;
UpdateWorld;
Self.MoveTo(Self.X,Self.Y,Self.Z);
end;
if not self.following then
begin
if (abs(Self.X-Knight.X) > SQM) or (abs(Self.Y-Knight.Y) > SQM) then
Knight.Following := true;
end;
if (not self.following) and (abs(Self.X - Knight.X) < 2) and (ABS(Self.Y - Knight.Y) < 2) then
begin
Knight.Following := true;
sleep(100);
Knight.Following := false;
sleep(1000);
end;
end;
else self.displaytext('Target is not on the same floor!');
else self.displaytext('Target losed!!!');
sleep(100);
end;