Czenio, you forgot to write "then" at the end of "if sentence".
Good catch, bad copying and pasting on my end
Seemingly, this script seems to work.
The script operates more quickly than movement of the unit.
So, the movement place data of the unit changes continually regardless of the unit's position.
I see what you are saying... I assumed QCmd is not executed until the preceeding Cmd is completed, but this is not the case. I tested my script with two waypoints (and it worked in that instace) but it would probably not function properly with 2+ waypoints.
As long as the unit 301 is alive, function Patrol_1 is repeated infinitely.
I worry that this continues consuming a memory.
I can see that.
Furthermore, if the unit 301 moves to places other than area "patrol_1", this script will not function.
My approach was that the last waypoint is withint he area "patrol_1" which will restart the cycle. Again, this will probably be invalidated in a patrol route with multiple waypoints. Now I am thinking about playing with a code that checks waypoints before sending them on to the next one. More of a global function, where individual patrol routes are created by assigning a unite an array of waypoints.
The following is my proposal. The area "patrol_2" is newly added.
function Patrol_1()
if GetNUnitsInScriptGroup (301) > 0 then
Cmd(3, 301, GetScriptAreaParams ("patrol_2"));
QCmd(3, 301, GetScriptAreaParams ("patrol_1"));
RunScript (Patrol_2, 2000);
Suicide ();
end;
end;
function Patrol_2()
if GetNScriptUnitsInArea (301, "patrol_1") > 0 then
RunScript (Patrol_1, 2000);
Suicide ();
end;
end;
In this example, the unit 301 continues a patrol, as long as the unit 301 is alive.
And even if unit 301 is anywhere, it start patrol by function Patrol_1.