mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Update common status effect framework
Instead of changing the event names to match the new standards and also changing every single call to `FUNC(statusEffect_set)`/`FUNC(statusEffect_get)` I figured it made sense to only change the event names and the internal workings of `FUNC(statusEffect_sendEffects)` to automatically add the appropriate prefix.
This commit is contained in:
parent
bd985d57ff
commit
5b8fa4d4f1
@ -18,29 +18,29 @@
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//Status Effect EHs:
|
||||
["ace_setStatusEffect", {_this call FUNC(statusEffect_set)}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(setStatusEffect), {_this call FUNC(statusEffect_set)}] call CBA_fnc_addEventHandler;
|
||||
["forceWalk", false, ["ACE_SwitchUnits", "ACE_Attach", "ACE_dragging", "ACE_Explosives", "ACE_Ladder", "ACE_Sandbag", "ACE_refuel", "ACE_rearm", "ACE_dragging"]] call FUNC(statusEffect_addType);
|
||||
["blockSprint", false, []] call FUNC(statusEffect_addType);
|
||||
["setCaptive", true, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered), "ace_unconscious"]] call FUNC(statusEffect_addType);
|
||||
["blockDamage", false, ["fixCollision"]] call FUNC(statusEffect_addType);
|
||||
["blockEngine", false, ["ACE_Refuel"]] call FUNC(statusEffect_addType);
|
||||
|
||||
["ace_forceWalk", {
|
||||
[QGVAR(forceWalk), {
|
||||
params ["_object", "_set"];
|
||||
TRACE_2("forceWalk EH",_object,_set);
|
||||
_object forceWalk (_set > 0);
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
["ace_blockSprint", { //Name reversed from `allowSprint` because we want NOR logic
|
||||
[QGVAR(blockSprint), { //Name reversed from `allowSprint` because we want NOR logic
|
||||
params ["_object", "_set"];
|
||||
TRACE_2("blockSprint EH",_object,_set);
|
||||
_object allowSprint (_set == 0);
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
["setCaptive", {
|
||||
[QGVAR(setCaptive), {
|
||||
params ["_object", "_set"];
|
||||
TRACE_2("setCaptive EH",_object,_set);
|
||||
_object setCaptive (_set > 0);
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
["blockDamage", { //Name reversed from `allowDamage` because we want NOR logic
|
||||
[QGVAR(blockDamage), { //Name reversed from `allowDamage` because we want NOR logic
|
||||
params ["_object", "_set"];
|
||||
if ((_object isKindOf "CAManBase") && {(["ace_medical"] call FUNC(isModLoaded))}) then {
|
||||
TRACE_2("blockDamage EH (using medical)",_object,_set);
|
||||
@ -50,7 +50,7 @@
|
||||
_object allowDamage (_set == 0);
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
["blockEngine", {
|
||||
[QGVAR(blockEngine), {
|
||||
params ["_vehicle", "_set"];
|
||||
_vehicle setVariable [QGVAR(blockEngine), _set > 0, true];
|
||||
_vehicle engineOn false;
|
||||
|
@ -15,9 +15,12 @@ class CfgPatches {
|
||||
|
||||
// This class will be deprecated in version 3.8.0
|
||||
class ACE_newEvents {
|
||||
blockSprint = "ace_blockSprint";
|
||||
forceWalk = "ace_forceWalk";
|
||||
PlayerJip = "ace_playerJip";
|
||||
forceWalk = QGVAR(forceWalk);
|
||||
blockSprint = QGVAR(blockSprint);
|
||||
setCaptive = QGVAR(setCaptive);
|
||||
blockDamage = QGVAR(blockDamage);
|
||||
blockEngine = QGVAR(blockEngine);
|
||||
|
||||
useItem = "ace_useItem";
|
||||
displayTextPicture = "ace_displayTextPicture";
|
||||
displayTextStructured = "ace_displayTextStructured";
|
||||
@ -53,7 +56,7 @@ class ACE_newEvents {
|
||||
fixPosition = "ace_fixPosition";
|
||||
fixFloating = "ace_fixFloating";
|
||||
fixCollision = "ace_fixCollision";
|
||||
setStatusEffect = "ace_setStatusEffect";
|
||||
setStatusEffect = QGVAR(setStatusEffect);
|
||||
SettingChanged = "ace_settingChanged";
|
||||
HeadbugFixUsed = "ace_headbugFixUsed";
|
||||
blockDamage = "ace_blockDamage";
|
||||
|
@ -21,7 +21,7 @@ if (!local _object) exitWith {};
|
||||
if (_object isKindOf "CAManBase") exitWith {};
|
||||
|
||||
//We need to manually set allowDamage to true for setHitIndex to function
|
||||
["ace_blockDamage", [_object, 0]] call CBA_fnc_localEvent;
|
||||
[QGVAR(blockDamage), [_object, 0]] call CBA_fnc_localEvent;
|
||||
|
||||
// save and restore hitpoints, see below why
|
||||
private _hitPointDamages = getAllHitPointsDamage _object;
|
||||
@ -41,4 +41,4 @@ _object setDamage damage _object;
|
||||
//manually re-enable allowDamage to previous setting (ref statusEffect_funcs)
|
||||
private _effectVarName = format [QGVAR(effect_%1), "blockDamage"];
|
||||
private _effectNumber = _object getVariable [_effectVarName, 0];
|
||||
["ace_blockDamage", [_object, _effectNumber]] call CBA_fnc_localEvent;
|
||||
[QGVAR(blockDamage), [_object, _effectNumber]] call CBA_fnc_localEvent;
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Adds a status effect that will be handled.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Status Effect Name, this should match a corisponding event name <STRING>
|
||||
* 0: Status Effect Name, this should match a corresponding event name <STRING>
|
||||
* 1: Send event globaly <BOOL>
|
||||
* 2: Common Effect Reaons to pre-seed durring init <ARRAY>
|
||||
*
|
||||
@ -30,8 +30,6 @@ GVAR(statusEffect_isGlobal) pushBack _isGlobal;
|
||||
//We add reasons at any time, but more efficenet to add all common ones at one time during init
|
||||
if (isServer && {!(_commonReasonsArray isEqualTo [])}) then {
|
||||
//Switch case to lower:
|
||||
{
|
||||
_commonReasonsArray set [_forEachIndex, toLower _x];
|
||||
} forEach _commonReasonsArray;
|
||||
_commonReasonsArray = _commonReasonsArray apply { toLower _x };
|
||||
missionNamespace setVariable [(format [QGVAR(statusEffects_%1), _name]), _commonReasonsArray, true];
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Object <OBJECT>
|
||||
* 1: Effect name (or "" or send all) <STRING>
|
||||
* 1: Effect name (or "" to send all) <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
@ -30,18 +30,13 @@ if (isNull _object) exitWith {};
|
||||
//We only do anything if the effect has been defined at some point in the game for this unit
|
||||
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);
|
||||
[_x, [_object, _effectNumber]] call CBA_fnc_globalEvent;
|
||||
[_eventName, [_object, _effectNumber]] call CBA_fnc_globalEvent;
|
||||
} else {
|
||||
if (local _object) then {
|
||||
//If local, send directly to bypass network delay of targetEvent call
|
||||
TRACE_2("Sending Target Local Event", _object, _effectNumber);
|
||||
[_x, [_object, _effectNumber]] call CBA_fnc_localEvent;
|
||||
} else {
|
||||
TRACE_2("Sending Target Non-Local Event", _object, _effectNumber);
|
||||
[_x, [_object, _effectNumber], [_object]] call CBA_fnc_targetEvent;
|
||||
};
|
||||
TRACE_2("Sending Target Event", _object, _effectNumber);
|
||||
[_eventName, [_object, _effectNumber], _object] call CBA_fnc_targetEvent;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user