2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-09-19 18:55:35 +00:00
|
|
|
* Author: Pabst Mirror (from captivity by commy2)
|
|
|
|
* Sets the forceWalk status of an unit. This allows the handling of more than one reason to set forceWalk.
|
|
|
|
* Unit will force walk until all reasons are removed.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Reason for forcing walking <STRING>
|
|
|
|
* 2: Is the reason still valid. True to force walk, false to remove restriction. <BOOL>
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [ACE_Player, "BrokenLeg", true] call FUNC(setForceWalkStatus)
|
|
|
|
*
|
2015-12-14 12:08:19 +00:00
|
|
|
* Public: Yes
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-19 18:55:35 +00:00
|
|
|
params ["_unit", "_reason", "_status"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-12-14 12:08:19 +00:00
|
|
|
private _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// register new reason (these reasons are shared publicly, since units can change ownership, but keep their forceWalk status)
|
|
|
|
if !(_reason in _forceWalkReasons) then {
|
2015-09-19 18:55:35 +00:00
|
|
|
_forceWalkReasons pushBack _reason;
|
|
|
|
ACE_forceWalkReasons = _forceWalkReasons;
|
|
|
|
publicVariable "ACE_forceWalkReasons";
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// get reasons why the unit is forceWalking already and update to the new status
|
2015-12-14 12:08:19 +00:00
|
|
|
private _unitForceWalkReasons = [_unit] call FUNC(getForceWalkStatus);
|
|
|
|
|
|
|
|
private _forceWalkReasonsBooleans = [];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
{
|
2015-09-19 18:55:35 +00:00
|
|
|
_forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons];
|
2015-01-11 16:42:31 +00:00
|
|
|
} forEach _forceWalkReasons;
|
|
|
|
|
|
|
|
_forceWalkReasonsBooleans set [_forceWalkReasons find _reason, _status];
|
|
|
|
|
2015-12-14 12:08:19 +00:00
|
|
|
private _bitmaskNumber = _forceWalkReasonsBooleans call FUNC(toBitmask);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
_unit setVariable ["ACE_forceWalkStatusNumber", _bitmaskNumber, true];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// actually apply the forceWalk command globaly
|
2015-09-19 18:55:35 +00:00
|
|
|
[[_unit], QFUNC(applyForceWalkStatus), 2] call FUNC(execRemoteFnc);
|