Jump to content
avibird 1

How can you setup a trigger to switch particular infantry groups back into Safe and limited speed if that group is not moving for 60

Recommended Posts

Hello I am trying to get UPMONS and UPS working a little better with infantry groups.  I was just wondering if there is a code that I could but into a trigger that covers my AO that would switch particular units back into SAFE  behavior and LIMITED speed for groups of units for example patrol 1 patrol 2 and patrol 3 and patrol 4 if the group is not moving after 6O seconds.  

 

This has been an issue with these two scripts for a while once a group goes into combat once contact has been made or know information of enemy units the groups will never go back into safe or limited speed again. 

 

 

Share this post


Link to post
Share on other sites

I think I could use this as a first part. But now how can I see if a group has a waypoint still attached or how can I issues this command from a trigger setup ?

 

{ _x setCombatMode "COMBAT"; _x setSpeedMode "FULL"; } forEach [group1, group2, group3];

Share this post


Link to post
Share on other sites

,{ _x setCombatMode "BLUE"; _x set behavior"SAFE"; setSpeedMode "LIMITED"; } forEach [group1, group2, group3];

 

 

Not working ? 

Share this post


Link to post
Share on other sites
{
	_x setCombatMode "BLUE";
	_x set behavior"SAFE";  //  should be setBehaviour, need space between setBehaviour and "SAFE"
	setSpeedMode "LIMITED";  // no magic variable _x
} forEach [group1, group2, group3];

So:

{
	_x setCombatMode "BLUE";
	_x setBehaviour "SAFE";
	_x setSpeedMode "LIMITED";
} forEach [group1, group2, group3];

//single line:

{_x setCombatMode "BLUE";_x setBehaviour "SAFE";_x setSpeedMode "LIMITED";} forEach [group1, group2, group3];

 

Share this post


Link to post
Share on other sites

@Harzach thanks for the correct syn text for that part. How would I call this in if the group are not actively moving ie having a waypoint generated issued or attached to it. What would I ever look at to put into the trigger condition ?

 

Share this post


Link to post
Share on other sites

You could check their current waypoint type against an array of unwanted types, something like:

_groups = [group1, group2, group3];			//  define arrays at top for easy editing
_typeArray = ["MOVE","CYCLE"];				//  add wp types that you want to check for

{
	_index = currentWaypoint _x;			//  get index of current waypoint
	_type = waypointType [_x, _index];		//  get type of current waypoint
	if !(_type in _typeArray) then			//  if type is not in _typeArray, then do the things
	{  
		_x setCombatMode "BLUE";
		_x setBehaviour "SAFE";
		_x setSpeedMode "LIMITED";
	};
} forEach _groups;

Sort of tested.

Share this post


Link to post
Share on other sites

You could try something like that:

{
 _x addEventHandler ["KnowsAboutChanged", {
     params ["_group", "_targetUnit", "_newKnowsAbout", "_oldKnowsAbout"];
    if (_targetUnit inArea yourAO && _newKnowsAbout < 0.5) then {
       _group setBehaviourStrong "SAFE";
    };
   }];
} forEach [grp1,grp2,grp3];

 

or, probably more reliable

{
  _x addEventHandler ["CommandChanged", {
    params ["_group", "_newCommand"];
    if (_newCommand in ["NO CMD","MOVE","WAIT"]) then {
      _group setBehaviourStrong "SAFE";
    };
  }];
} forEach [grp1,grp2,grp3];

 

seems not too bad at test.

  • Like 2

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

×