Skip to content

Commit

Permalink
Common - Add JIP support to status effects (#9740)
Browse files Browse the repository at this point in the history
* add JIP support to status effects

* fix TRACE

* typo
  • Loading branch information
LinkIsGrim committed Jan 16, 2024
1 parent b02d95c commit 42e2e08
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
["blockRadio", false, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered), "ace_unconscious"]] call FUNC(statusEffect_addType);
["blockSpeaking", false, ["ace_unconscious"]] call FUNC(statusEffect_addType);
["disableWeaponAssembly", false, ["ace_common", "ace_common_lockVehicle", "ace_csw"]] call FUNC(statusEffect_addType);
["lockInventory", true, []] call FUNC(statusEffect_addType);
["lockInventory", true, [], true] call FUNC(statusEffect_addType);

[QGVAR(forceWalk), {
params ["_object", "_set"];
Expand Down
7 changes: 5 additions & 2 deletions addons/common/functions/fnc_statusEffect_addType.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
*
* Arguments:
* 0: Status Effect Name, this should match a corresponding event name <STRING>
* 1: Send event globaly <BOOL>
* 1: Send event globally <BOOL>
* 2: Common Effect Reaons to pre-seed durring init <ARRAY>
* 3: Send event to JIP (requires sending event globally) <BOOL>
*
* Return Value:
* None
Expand All @@ -17,14 +18,16 @@
* Public: No
*/

params [["_name", "", [""]], ["_isGlobal", false, [false]], ["_commonReasonsArray", [], [[]]]];
params [["_name", "", [""]], ["_isGlobal", false, [false]], ["_commonReasonsArray", [], [[]]], ["_sendJIP", false, [false]]];
TRACE_3("params",_name,_isGlobal,_commonReasonsArray);

if (_name == "") exitWith {ERROR_1("addStatusEffect - Bad Name %1", _this)};
if (_name in GVAR(statusEffect_Names)) exitWith {WARNING_1("addStatusEffect - Effect Already Added (note, will not update global bit) %1", _this)};
if (_sendJIP && !_isGlobal) exitWith {WARNING_1("addStatusEffect - Trying to add non-global JIP effect %1",_this)};

GVAR(statusEffect_Names) pushBack _name;
GVAR(statusEffect_isGlobal) pushBack _isGlobal;
GVAR(statusEffect_sendJIP) pushBack _sendJIP;

//We add reasons at any time, but more efficenet to add all common ones at one time during init
if (isServer && {_commonReasonsArray isNotEqualTo []}) then {
Expand Down
21 changes: 15 additions & 6 deletions addons/common/functions/fnc_statusEffect_sendEffects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@ if (isNull _object) exitWith {};
TRACE_2("checking if event is nil",_x,_effectNumber);
if (_effectNumber != -1) then {
private _eventName = format [QGVAR(%1), _x];
if (GVAR(statusEffect_isGlobal) select _forEachIndex) then {
TRACE_2("Sending Global Event", _object, _effectNumber);
[_eventName, [_object, _effectNumber]] call CBA_fnc_globalEvent;
} else {
TRACE_2("Sending Target Event", _object, _effectNumber);
[_eventName, [_object, _effectNumber], _object] call CBA_fnc_targetEvent;
switch (true) do {
case (GVAR(statusEffect_sendJIP) select _forEachIndex): {
TRACE_2("Sending Global JIP Event", _object, _effectNumber);
private _jipID = format [QGVAR(effect_%1_%2), _eventName, hashValue _object];
[_eventName, [_object, _effectNumber], _jipID] call CBA_fnc_globalEventJIP;
[_jipID, _object] call CBA_fnc_removeGlobalEventJIP;
};
case (GVAR(statusEffect_isGlobal) select _forEachIndex): {
TRACE_2("Sending Global Event", _object, _effectNumber);
[_eventName, [_object, _effectNumber]] call CBA_fnc_globalEvent;
};
default {
TRACE_2("Sending Target Event", _object, _effectNumber);
[_eventName, [_object, _effectNumber], _object] call CBA_fnc_targetEvent;
};
};
};
};
Expand Down

0 comments on commit 42e2e08

Please sign in to comment.