gruppe-adler / TvT_Catch_The_Flight.Stratis

low tech TvT scenario with focus on player interactions
0 stars 0 forks source link

prevent INDEP C from swimming away #23

Closed Fusselwurm closed 7 years ago

Fusselwurm commented 7 years ago
_unit = player;
_drowningTimeout = 900;
_interval = 45;
_unit setVariable ["Mission_fnc_limitSwimming_dangerStart", time];

_drownLoop = {
    params ["_params"];
    _unit = _params select 0;
    _drowningTimeout = _params select 1;
    _interval = _params select 2;
    _timer = _unit getVariable "Mission_fnc_limitSwimming_dangerStart";

    _pos = position _unit;
    if (alive _unit && (_pos distance nearestLand _pos < 200 /*todo*/ || vehicle _unit != _unit)) then {
        _unit setVariable ["Mission_fnc_limitSwimming_timer", time];
    } 
   if (_timer + _timeout < time) then {
        [_unit] call ACE_setUnconscious; // or something
   };
};

[_drownLoop, _interval, [_unit, _drowningTimeout, _interval]] call CBA_fnc_addPerFrameHandler;