Page 1 of 1

SAIL - Sprawdzanie czy cel jest osiągalny

Posted: Sun Sep 03, 2017 10:45 pm
by zoNE
Serpent wrote: Sun Sep 03, 2017 10:34 pm Napisałem kodzik który sprawdza czy cel jest osiągalny. Jeśli tak to jednostka podąża w podane miejsce i funkcja zwraca TRUE, w przeciwnym razie funkcja zwraca FALSE.

Code: Select all

//Destination Reachable Function by Serpent
Export unreachableList;
On DestinationUnreachable(unit) Do
begin
if not unit in unreachableList then
   unreachableList := Insert(unreachableList, unreachableList+1, unit);
end;

Export Function DestinationReachable(unit, x, y);
begin
if unit in unreachableList then
  unreachableList := unreachableList diff unit;

   ComMoveXY(unit, x, y);

   Wait(1);

if unit in unreachableList then
   result := false
    else
     result := true;
End;
Author: Serpent
Topic: https://forum.original-war.net/viewtopi ... =42&t=5633