diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index c2d1ac8..744bea3 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -24,15 +24,16 @@ class DOUBLES(PREFIX,client) { class functions { file = "framework\client\functions"; class initClient {}; + class addDraw3DPFH {}; + class addGetNearMenPFH {}; class addMicroDAGRWaypoints {}; class addZenModules {}; class bindEventHandlers {}; - class bindUnconsciousListener {}; class bindVehicleActions {}; - class addGetNearMenPFH {}; - class addDraw3DPFH {}; - class registerPFHCode {}; class clearPFHCode {}; + class logRespawnButtonUse {}; + class registerPFHCode {}; + class staticLineProtection {}; }; }; diff --git a/framework/client/functions/fn_bindEventHandlers.sqf b/framework/client/functions/fn_bindEventHandlers.sqf index 6d03e93..53b2162 100644 --- a/framework/client/functions/fn_bindEventHandlers.sqf +++ b/framework/client/functions/fn_bindEventHandlers.sqf @@ -2,48 +2,6 @@ if ( !hasInterface ) exitWith {}; -["ace_killed", { - params ["_unit", "_causeOfDeath", "_killer", "_instigator"]; - - if (!local _unit) exitWith {}; - - if (_causeOfDeath == "respawn_button") then { - private _timeWentUnconscious = _corpse getVariable [QGVARMAIN(lastTimeKnockedOut), -1]; - private _durationSpentUnconscious = -1; - if (_timeWentUnconscious > -1) then { - _durationSpentUnconscious = diag_tickTime - _timeWentUnconscious; - }; - - [ - LEVEL_INFO, - QUOTE(COMPONENT), - "RESPAWNED WHILE UNCONSCIOUS", - [_unit, [ - ["durationSpentUnconscious", _durationSpentUnconscious] - ]] call EFUNC(common,addPlayerInfoToArray) - ] remoteExec [QEFUNC(common,log), 2]; - // format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0]; - }; -}] call CBA_fnc_addEventHandler; - - -// Add GetOutMan event handler to grant temporary invincibility to players ejecting from vehicles -// Only for players who have "hooked up" using VS static line -// and are ejecting from a plane or helicopter above 100m -player addEventHandler ["GetOutMan", { - params ["_unit", "_role", "_vehicle", "_turret", "_isEject"]; - if (!isEject) exitWith {}; - if (isNil {_unit getVariable "VS_Jump"}) exitWith {}; - if ( - not (_vehicle isKindOf "Plane" || _vehicle isKindOf "Helicopter") || - ((getPosATL _vehicle)#2) < 100 - ) exitWith {}; - - _unit allowDamage false; - [{_this allowDamage true}, _unit, 5] call CBA_fnc_waitAndExecute; -}]; - - [ { params ["_unit", "_object", "_cost"]; diff --git a/framework/client/functions/fn_bindUnconsciousListener.sqf b/framework/client/functions/fn_bindUnconsciousListener.sqf deleted file mode 100644 index 35785fe..0000000 --- a/framework/client/functions/fn_bindUnconsciousListener.sqf +++ /dev/null @@ -1,13 +0,0 @@ -#include "..\script_component.hpp" - -if (!hasInterface) exitWith {}; - -["ace_medical_knockOut", { // local event that's also used directly by the ACE medical statemachine - private _unit = _this; - _this setVariable [QGVARMAIN(lastTimeKnockedOut), diag_tickTime, true]; -}] call CBA_fnc_addEventHandler; - -["ace_medical_WakeUp", { // local event that's also used directly by the ACE medical statemachine - private _unit = _this; - _this setVariable [QGVARMAIN(lastTimeKnockedOut), nil, true]; -}] call CBA_fnc_addEventHandler; \ No newline at end of file diff --git a/framework/client/functions/fn_initClient.sqf b/framework/client/functions/fn_initClient.sqf index 357d6ec..b60a487 100644 --- a/framework/client/functions/fn_initClient.sqf +++ b/framework/client/functions/fn_initClient.sqf @@ -8,13 +8,17 @@ call FUNC(addZenModules); call FUNC(bindEventHandlers); call FUNC(bindVehicleActions); +// add core getNearMenPFH handler localNamespace setVariable [QGVAR(nearMen), []]; call FUNC(addGetNearMenPFH); +// add core draw3dPFH handler localNamespace setVariable [QGVAR(pfhCode), []]; call FUNC(addDraw3DPFH); -// add listener that tracks when the player goes unconscious and saves a variable with time -call FUNC(bindUnconsciousListener); +// add listener that tracks using the respawn button while unconscious +call FUNC(logRespawnButtonUse); +// add conditional eject-from-vehicle handler to apply temp invincibility when static line jumping +call FUNC(staticLineProtection); [ LEVEL_DEBUG, diff --git a/framework/client/functions/fn_logRespawnButtonUse.sqf b/framework/client/functions/fn_logRespawnButtonUse.sqf new file mode 100644 index 0000000..ec085e6 --- /dev/null +++ b/framework/client/functions/fn_logRespawnButtonUse.sqf @@ -0,0 +1,56 @@ +#include "..\script_component.hpp" + +if ( !hasInterface ) exitWith {}; + +["ace_killed", { + params ["_unit", "_causeOfDeath", "_killer", "_instigator"]; + + if (not (local _unit)) exitWith {}; + + private _causeOfDeath = _unit getVariable ["ace_medical_causeOfDeath", "#scripted"]; + + if (_causeOfDeath != "respawn_button") exitWith {}; + private _timeWentUnconscious = _unit getVariable [QGVARMAIN(lastTimeKnockedOut), -1]; + private _durationSpentUnconscious = -1; + if (_timeWentUnconscious != -1) then { + _durationSpentUnconscious = diag_tickTime - _timeWentUnconscious; + }; + + [ + LEVEL_INFO, + QUOTE(COMPONENT), + "RESPAWNED WHILE UNCONSCIOUS", + [_unit, [ + ["durationSpentUnconscious", _durationSpentUnconscious] + ]] call EFUNC(common,addPlayerInfoToArray) + ] remoteExec [QEFUNC(common,log), 2]; + // format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0]; +}] call CBA_fnc_addEventHandler; + + +["ace_medical_knockOut", { // local event for module & epi event + // systemChat format["ace_medical_knockOut: %1", _this]; + private _unit = _this; + if (not (local _unit)) exitWith {}; + _this setVariable [QGVARMAIN(lastTimeKnockedOut), diag_tickTime]; +}] call CBA_fnc_addEventHandler; + +["ace_medical_WakeUp", { // local event for module & epi event + // systemChat format["ace_medical_WakeUp: %1", _this]; + private _unit = _this; + if (not (local _unit)) exitWith {}; + _this setVariable [QGVARMAIN(lastTimeKnockedOut), nil]; +}] call CBA_fnc_addEventHandler; + +["ace_unconscious", { // used when applying damage + params ["_unit", "_isUnconscious"]; + if (not (local _unit)) exitWith {}; + + if (_isUnconscious && isNil {_unit getVariable QGVARMAIN(lastTimeKnockedOut)}) then { + // systemChat format["%1 is unconscious", _unit]; + _unit setVariable [QGVARMAIN(lastTimeKnockedOut), diag_tickTime]; + } else { + // systemChat format["%1 is conscious", _unit]; + _unit setVariable [QGVARMAIN(lastTimeKnockedOut), nil]; + }; +}] call CBA_fnc_addEventHandler; \ No newline at end of file diff --git a/framework/client/functions/fn_staticLineProtection.sqf b/framework/client/functions/fn_staticLineProtection.sqf new file mode 100644 index 0000000..752a533 --- /dev/null +++ b/framework/client/functions/fn_staticLineProtection.sqf @@ -0,0 +1,23 @@ +#include "..\script_component.hpp" + +if ( !hasInterface ) exitWith {}; + +// Add GetOutMan event handler to grant temporary invincibility to players ejecting from vehicles +// Only for players who have "hooked up" using VS static line +// and are ejecting from a plane or helicopter above 100m +player addEventHandler ["GetOutMan", { + params ["_unit", "_role", "_vehicle", "_turret", "_isEject"]; + if (!isEject) exitWith {}; + if (isNil {_unit getVariable "VS_Jump"}) exitWith {}; + if ( + not (_vehicle isKindOf "Plane" || _vehicle isKindOf "Helicopter") || + ((getPosATL _vehicle)#2) < 100 + ) exitWith {}; + + _unit allowDamage false; + (vehicle _unit) allowDamage false; + [{ + _this allowDamage true; + (vehicle _this) allowDamage true; + }, _unit, 5] call CBA_fnc_waitAndExecute; +}]; \ No newline at end of file