Jump to content
Melody_Mike

Restricting Dismissed Waypoint

Recommended Posts

Heya everyone,

It is my aim to have a target OPFOR unit, dressed in civilian clothes, wander randomly around a town. The mission would be for players to find and eliminate said unit. 

The "DISMISSED" waypoint provides excellent randomized behavior. However, as the BIKI states, dismissed units keep wandering without bounds until meeting an enemy. I would like to give the unit boundaries. 

Because I am a beginner in scripting, my first thought was to make a trigger of appropriate size activate "when unit not present", with the unit starting in the middle of the trigger area. The trigger activation field would create a "MOVE" waypoint back to the center and cycle back to the "DISMISSED" waypoint. But I am having a lot of trouble with this. Using addWaypoint and setting the new "MOVE" waypoint at index 0 causes the unit to twitch on activation, but keeps it dismissed. Deleting and setting a new waypoint (regardless of index) makes the unit stop. I think I am missing an important part of waypoint scripting.

Or, perhaps there is a more efficient way of keeping a unit wandering randomly inside a village area. The Civilian Presence modules would be ideal, but of course, this target unit is not civilian (and must coexist with civilians).

Much thanks! 

 

 

Share this post


Link to post
Share on other sites

You could use something simple as this:

 

TAG_fnc_wander = {
	params ["_unit",["_centerPos",[]],"_distance","_minWait","_midWait","_maxWait"];
	if (_centerPos isEqualTo []) then {_centerPos = getPosATL _unit};
	while {alive _unit} do {
		_unit doMove (_centerPos getPos [random _distance,random 360]);
		waitUntil {unitReady _unit};
		sleep random [_minWait,_midWait,_maxWait];
	};
};
_wander = [this,[],25,3,8,15] spawn TAG_fnc_wander

Can modify it and should get you started.

You can replace the while loop condition with a global variable handled by a trigger, to abort the wandering behavior.

 

Cheers

  • 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

×