Jump to content
Sign in to follow this  

Getting precise control of "Fleeing"

Recommended Posts


While attempting to write a small "Kill the Collaborator" sub-mission today, it occurred to me that it would be very useful to have precise control of a unit's "fleeing". Did some searches... then ran some tests. I quickly reviewed the two most obvious related commands (both which have been around since OFP 1.0):

1. allowFleeing: Sets a unit or groups propensity to flee the scene and run away.

2. fleeing: Checks whether a unit is currently fleeing.

So we can easily allow fleeing by using something like "Loon allowFleeing 1". (Actually this forces fleeing, provided the unit knows he's in any danger.) And we can run a loop to monitor how long he stays in a fleeing state. And we can allow the fleeing unit to eventually stop fleeing by something like "Loon allowFleeing 0".

However, so far I have been unable to make the unit stop fleeing immediately on command. He just keeps fleeing for what seems like ages, until he is good and ready, despite the "Loon allowFleeing 0". :eek: I have even tried to getting a unit fleeing, disabling all AI components, then "Loon allowFleeing 0", then re-enabling all AI components... no dice. :confused:

Too bad really... Fleeing adds some great dynamics and can be harnessed to produce unique mission elements without having to script elaborate "escape" sequences (and figure out where to send the escapees running... cumbersome in dynamic missions).

Does anyone have any idea how to get a unit to stop fleeing immediately on command?

And if not, maybe if BIS is reading, perhaps add a quick command for this, something like "forceFleeing"?

Any help is much appreciated, as always. :)

Share this post

Link to post
Share on other sites

Solved this old problem. To get a group to stop fleeing, one way (the only way I know of) is to re-group them, like this:

MRU_Regroup = {
private ["_group","_resetFleeing","_newFleeVal","_newGroup"];

_group = _this select 0;
_resetFleeing = false;
_newFleeVal = 0.5;
if ((count _this) > 1) then { _resetFleeing = _this select 1 }; // Optional
if ((count _this) > 2) then { _newFleeVal = _this select 2 }; // Optional

_newGroup = createGroup (side _group);
if (_resetFleeing) then { _newGroup allowFleeing 0 };
(units _group) joinSilent _newGroup;
if (_resetFleeing) then { _newGroup allowFleeing _newFleeVal };
deleteGroup _group;


Hope this helps someone. :)

Edited by MadRussian
  • Thanks 1

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