2015-01-16 23:21:47 +00:00
|
|
|
/**
|
|
|
|
* fn_limitMovementSpeed.sqf
|
|
|
|
* @Descr: Limits the movement speed of a unit
|
|
|
|
* @Author: Glowbal
|
|
|
|
*
|
|
|
|
* @Arguments: [unit OBJECT, fallDown BOOL (Optional)]
|
|
|
|
* @Return: void
|
|
|
|
* @PublicAPI: true
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-01-17 11:53:23 +00:00
|
|
|
private ["_unit","_carriedObj"];
|
|
|
|
_unit = _this select 0;
|
|
|
|
_fallDown = false;
|
|
|
|
if (count _this > 1) then {
|
2015-01-18 19:09:19 +00:00
|
|
|
_fallDown = _this select 1;
|
2015-01-17 11:53:23 +00:00
|
|
|
};
|
|
|
|
|
2015-01-17 12:35:03 +00:00
|
|
|
if ((_unit getvariable [QGVAR(limitMovementSpeed),false])) exitwith {
|
2015-01-18 19:09:19 +00:00
|
|
|
_unit setvariable [QGVAR(limitMovementSpeed),nil,true];
|
2015-01-17 11:53:23 +00:00
|
|
|
};
|
|
|
|
|
2015-01-17 12:35:03 +00:00
|
|
|
[{
|
2015-01-18 19:09:19 +00:00
|
|
|
private["_unit","_fallDown","_carriedObj"];
|
|
|
|
_unit = (_this select 0) select 0;
|
|
|
|
_fallDown = (_this select 0) select 1;
|
|
|
|
|
|
|
|
_carriedObj = [_unit] call FUNC(getCarriedObj);
|
|
|
|
|
|
|
|
if !(_unit getvariable [QGVAR(limitMovementSpeed),false]) exitwith {
|
|
|
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
|
|
|
};
|
|
|
|
if !((!isNull _carriedObj) && (alive _unit)) exitwith {
|
|
|
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (speed _unit > 12 && vehicle _unit == _unit && isTouchingGround _unit) then {
|
|
|
|
|
|
|
|
_unit setVelocity [0,0,0];
|
|
|
|
|
|
|
|
if (_fallDown) then {
|
|
|
|
_unit playMove "amovppnemstpsraswrfldnon";
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_carriedObj isKindOf "Man") then {
|
|
|
|
hint "You can not move this fast while transporting this person.";
|
|
|
|
} else {
|
|
|
|
hint "You can not move this fast while carrying this object";
|
|
|
|
};
|
|
|
|
[_unit,ObjNull] call FUNC(carryObj);
|
|
|
|
};
|
2015-01-17 11:53:23 +00:00
|
|
|
}, 0.5, [_unit,_fallDown] ] call CBA_fnc_addPerFrameHandler;
|