Jump to content
Sign in to follow this  
anthonyfromtheuk

How to make my scripted waypoints loop?

Recommended Posts

I am using a script kindly donated by cobra4v320 the script is

if (!isServer) exitwith {};
_side = createCenter EAST;
_groupSquad1 = [getMarkerPos "Group", _side, ["o_soldier_TL_F", 

"O_soldier_AA_F", "o_soldier_AA_F", "o_soldier_AA_F"], [], [], 

[0.3, 0.6]] call BIS_fnc_spawnGroup;
_leader = leader _groupSquad1;

_waypoint1 = _groupSquad1 addWaypoint [(getPos player),2];
_waypoint1 setWaypointType "SAD";
sleep 200;
_waypoint2 = _groupSquad1 addWaypoint [(getPos player),2];
_waypoint2 setWaypointType "SAD";

waitUntil { { alive _x} count (units _groupSquad1) == 0 or player 

distance _leader > 500};

{deleteVehicle _x} forEach units _groupsquad1;
deleteGroup _groupSquad1;  

What i would like is instead of having to put a sleep in the middle of the two waypoints for them to just repeat, can anybody help please?

I want the AI to hunt me constantly but at current they go to my last known position and stay there until the sleep timer is over and then they go to my position at the time the timer was over.

Share this post


Link to post
Share on other sites

Oh ya, forgot that it will only move the squad leader (the rest of the group will regroup after the leader have arrived). I must have sunday evening syndrome...

Use deleteWaypoint and create a new one every once in a while. Right now can't think of anything else. Personally, I blame the wine. :)

Share this post


Link to post
Share on other sites

I would recommend 'move'. It technically adds a waypoint but without any extra code.

http://community.bistudio.com/wiki/move

You also do not have to worry about what waypoint is current or what order they are in. You can give the command to a group or a group leader and his squad will follow. You can then set things like speed and combat mode with a few more commands, but you need to set them again every time move is used. This allows for infinite loops of move orders and only that last one given will be seem by the AI. Also, you can make each move position random very easily without editing a fixed number of waypoints that are being cycled through.

Share this post


Link to post
Share on other sites

That seems to do exactly the same thing as the way point it just moves them to the place i was when they were spawned in.

---------- Post added at 21:44 ---------- Previous post was at 21:43 ----------

Is there no way to make the script jump back a few lines of code? or even use waypoint cycle?

Edited by Anthonyfromtheuk

Share this post


Link to post
Share on other sites

When I said infinite loop I meant infinite loop.

if (!isServer) exitwith {};
private ["_side", "_groupSquad1", "_leader"];
_side = createCenter EAST;
_groupSquad1 = [getMarkerPos "Group", _side, ["o_soldier_TL_F", "O_soldier_AA_F", "o_soldier_AA_F", "o_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;

_leader = leader _groupSquad1;
_leader move (getPosATL player);
_groupSquad1 setCombatMode "RED";
_groupSquad1 setBehaviour "Aware";

0 = _groupSquad1 spawn {
   while {true} do {
       sleep 5;
       if ((player distance (leader _this)) > 500) exitWith {
           {
               deleteVehicle _x;
           } forEach (units _this);
       };
   };
};

while {true} do {
   sleep 5;

   if (({ alive _x} count (units _groupSquad1)) == 0) exitWith {
       {
           deleteVehicle _x;
       } forEach (units _groupsquad1);
       deleteGroup _groupSquad1;
   };

   _leader = leader _groupSquad1;
   if ((unitReady _leader) && {(alive _leader)}) then {
       sleep 200;
       if (({ alive _x} count (units _groupSquad1)) != 0) then {
           _leader = leader _groupSquad1;
           _leader move (getPosATL player);
           _groupSquad1 setCombatMode "RED";
           _groupSquad1 setBehaviour "Aware";
       };
   };
};

This is not tested and may require some changes, but it gives you a good idea on how to do this.

Share this post


Link to post
Share on other sites

_groupsquad1 reveal ["main",4];

_waypoint1 = _groupSquad1 addWaypoint [(getPos player),2];

_waypoint1 setWaypointType "SAD";

_waypoint1 setCombatMode "RED";

thats what i just came up with seems to work but i will try out your advanced script as well thank you very much Zenophon

---------- Post added at 22:30 ---------- Previous post was at 22:20 ----------

Zenophon your script works beautifully thank you and thanks for everyone else that helped me. :rthumb:

Edited by Anthonyfromtheuk
main being player name

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×