mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
statusEffect prototype
This commit is contained in:
parent
6731a8e1d6
commit
53cb63ec1d
@ -24,8 +24,11 @@ class Extended_InitPost_EventHandlers {
|
|||||||
class GVAR(setName) {
|
class GVAR(setName) {
|
||||||
init = QUOTE(if (local (_this select 0)) then {_this call FUNC(setName)};);
|
init = QUOTE(if (local (_this select 0)) then {_this call FUNC(setName)};);
|
||||||
};
|
};
|
||||||
class GVAR(forceWalk) {
|
// class GVAR(forceWalk) {
|
||||||
init = QUOTE(if (local (_this select 0)) then {_this call FUNC(applyForceWalkStatus);};);
|
// init = QUOTE(if (local (_this select 0)) then {_this call FUNC(applyForceWalkStatus);};);
|
||||||
|
// };
|
||||||
|
class GVAR(statusEffects) {
|
||||||
|
init = QUOTE(if (local (_this select 0)) then {[ARR_3(_this select 0, SLX_XEH_MACHINE select 1, false)] call FUNC(applyStatusEffects);};);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -42,4 +45,9 @@ class Extended_Respawn_EventHandlers {
|
|||||||
respawn = QUOTE(_this call FUNC(resetAllDefaults_F));
|
respawn = QUOTE(_this call FUNC(resetAllDefaults_F));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
class CAManBase {
|
||||||
|
class GVAR(statusEffects) {
|
||||||
|
respawn = QUOTE(if (local (_this select 0)) then {[ARR_3(_this select 0, SLX_XEH_MACHINE select 1, true)] call FUNC(applyStatusEffects);};);
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
// by commy2
|
// by commy2
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
PREP(setStatusEffect);
|
||||||
|
PREP(applyStatusEffects);
|
||||||
|
PREP(getStatusEffects);
|
||||||
|
|
||||||
|
|
||||||
// ACE Common Function
|
// ACE Common Function
|
||||||
PREP(addActionEventHandler);
|
PREP(addActionEventHandler);
|
||||||
PREP(addActionMenuEventHandler);
|
PREP(addActionMenuEventHandler);
|
||||||
|
53
addons/common/functions/fnc_applyStatusEffects.sqf
Normal file
53
addons/common/functions/fnc_applyStatusEffects.sqf
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#define DEBUG_MODE_FULL
|
||||||
|
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
#define HASH_INDEX(hash,key) ((hash select 0) find key)
|
||||||
|
|
||||||
|
xx3 = _this;
|
||||||
|
|
||||||
|
PARAMS_1(_unit);
|
||||||
|
DEFAULT_PARAM(1,_isJip, false);
|
||||||
|
DEFAULT_PARAM(2,_isRespawn, false);
|
||||||
|
|
||||||
|
_unitEffects = _unit getVariable ["ACE_statusEffects", 0];
|
||||||
|
_statusHashList = missionNamespace getVariable ["ACE_statusHashList", []];
|
||||||
|
|
||||||
|
if (!local _unit) exitWith {};
|
||||||
|
if (_unitEffects == 0) exitWith {};
|
||||||
|
if (!(VALIDHASH(_statusHashList))) exitWith {};
|
||||||
|
|
||||||
|
_effectTypeHash = HASHLIST_SELECT(_statusHashList, 0);
|
||||||
|
_removeOnJipHash = HASHLIST_SELECT(_statusHashList, 1);
|
||||||
|
_removeOnRespawn = HASHLIST_SELECT(_statusHashList, 2);
|
||||||
|
|
||||||
|
_unitStatusBoolArray = [_unitEffects, (count (_effectTypeHash select 0))] call EFUNC(common,binarizeNumber);
|
||||||
|
|
||||||
|
_allEffects = [(_effectTypeHash select 1)] call EFUNC(common,uniqueElementsOnly);
|
||||||
|
_activeEffects = [];
|
||||||
|
_updated = false;
|
||||||
|
{
|
||||||
|
if (_x) then {
|
||||||
|
TRACE_4("wtf", _isJip, _removeOnJipHash select 1 select _forEachIndex, _isRespawn, _removeOnRespawn select 1 select _forEachIndex);
|
||||||
|
if ((_isJip && {(_removeOnJipHash select 1) select _forEachIndex}) || {_isRespawn && {(_removeOnRespawn select 1) select _forEachIndex}}) then {
|
||||||
|
_updated = true;
|
||||||
|
_unitStatusBoolArray set [_forEachIndex, false];
|
||||||
|
} else {
|
||||||
|
_effectType = (_effectTypeHash select 1) select _forEachIndex;
|
||||||
|
if (!(_effectType in _activeEffects)) then {
|
||||||
|
_activeEffects pushBack _effectType;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} forEach _unitStatusBoolArray;
|
||||||
|
TRACE_2("Updaing unit?",_unit,_updated);
|
||||||
|
if (_updated) then {
|
||||||
|
_unitStatusNumber = _unitStatusBoolArray call EFUNC(common,toBitmask);
|
||||||
|
_unit setVariable ["ACE_statusEffects", _unitStatusNumber, true];
|
||||||
|
};
|
||||||
|
|
||||||
|
TRACE_3("Updaing All Effects",_unit,_allEffects,_activeEffects);
|
||||||
|
{
|
||||||
|
[_x, [_unit, (_x in _activeEffects)]] call EFUNC(common,localEvent);
|
||||||
|
} forEach _allEffects;
|
||||||
|
|
28
addons/common/functions/fnc_getStatusEffects.sqf
Normal file
28
addons/common/functions/fnc_getStatusEffects.sqf
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#define DEBUG_MODE_FULL
|
||||||
|
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
#define HASH_INDEX(hash,key) ((hash select 0) find key)
|
||||||
|
|
||||||
|
|
||||||
|
PARAMS_2(_unit,_effectType);
|
||||||
|
|
||||||
|
_unitEffects = _unit getVariable ["ACE_statusEffects", 0];
|
||||||
|
_statusHashList = missionNamespace getVariable ["ACE_statusHashList", []];
|
||||||
|
|
||||||
|
if (!(VALIDHASH(_statusHashList))) exitWith {[]};
|
||||||
|
|
||||||
|
_effectTypeHash = HASHLIST_SELECT(_statusHashList, 0);
|
||||||
|
_unitStatusBoolArray = [_unitEffects] call EFUNC(common,binarizeNumber); //create bool array
|
||||||
|
|
||||||
|
_returnValue = [];
|
||||||
|
|
||||||
|
{
|
||||||
|
if ((_unitStatusBoolArray select _forEachIndex) && {((_effectTypeHash select 1) select _forEachIndex) == _effectType}) then {
|
||||||
|
_returnValue pushBack _x;
|
||||||
|
};
|
||||||
|
} forEach (_effectTypeHash select 0);
|
||||||
|
|
||||||
|
TRACE_3("Effects:", _unit, _effectType, _returnValue);
|
||||||
|
|
||||||
|
_returnValue
|
48
addons/common/functions/fnc_setStatusEffect.sqf
Normal file
48
addons/common/functions/fnc_setStatusEffect.sqf
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#define DEBUG_MODE_FULL
|
||||||
|
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
#define HASH_INDEX(hash,key) ((hash select 0) find key)
|
||||||
|
|
||||||
|
PARAMS_4(_unit,_effectName,_effectType,_isEnabled);
|
||||||
|
DEFAULT_PARAM(4,_removeOnJIP, false);
|
||||||
|
DEFAULT_PARAM(5,_removeOnRespawn, false);
|
||||||
|
|
||||||
|
_unitEffects = _unit getVariable ["ACE_statusEffects", 0];
|
||||||
|
_statusHashList = missionNamespace getVariable ["ACE_statusHashList", []];
|
||||||
|
|
||||||
|
if (!(VALIDHASH(_statusHashList))) then {
|
||||||
|
_statusHashList = HASHLIST_CREATELIST([]);
|
||||||
|
HASHLIST_PUSH(_statusHashList, HASHLIST_CREATEHASH(_statusHashList));
|
||||||
|
HASHLIST_PUSH(_statusHashList, HASHLIST_CREATEHASH(_statusHashList));
|
||||||
|
HASHLIST_PUSH(_statusHashList, HASHLIST_CREATEHASH(_statusHashList));
|
||||||
|
};
|
||||||
|
|
||||||
|
_effectTypeHash = HASHLIST_SELECT(_statusHashList, 0);
|
||||||
|
_removeOnJipHash = HASHLIST_SELECT(_statusHashList, 1);
|
||||||
|
_removeOnRespawnHash = HASHLIST_SELECT(_statusHashList, 2);
|
||||||
|
|
||||||
|
|
||||||
|
if ((!HASH_HASKEY(_effectTypeHash,_effectType)) || {!HASH_HASKEY(_effectTypeHash,_effectType)}) then {
|
||||||
|
// If effect name isn't in hashList
|
||||||
|
HASH_SET(_effectTypeHash,_effectName,_effectType);
|
||||||
|
HASHLIST_SET(_statusHashList, 0, _effectTypeHash);
|
||||||
|
HASH_SET(_removeOnJipHash,_effectName,_removeOnJIP);
|
||||||
|
HASHLIST_SET(_statusHashList, 1, _removeOnJipHash);
|
||||||
|
HASH_SET(_removeOnRespawnHash,_effectName,_removeOnRespawn);
|
||||||
|
HASHLIST_SET(_statusHashList, 2, _removeOnRespawnHash);
|
||||||
|
|
||||||
|
missionNamespace setVariable ["ACE_statusHashList", _statusHashList];
|
||||||
|
publicVariable "ACE_statusHashList";
|
||||||
|
};
|
||||||
|
|
||||||
|
_effectIndex = HASH_INDEX(_statusHashList, _effectName);
|
||||||
|
|
||||||
|
_unitStatusBoolArray = [_unitEffects, (count (_effectTypeHash select 0))] call EFUNC(common,binarizeNumber); //create bool array
|
||||||
|
|
||||||
|
_unitStatusBoolArray set [_effectIndex, _isEnabled]; //set new status
|
||||||
|
_unitStatusNumber = _unitStatusBoolArray call EFUNC(common,toBitmask);
|
||||||
|
|
||||||
|
_unit setVariable ["ACE_statusEffects", _unitStatusNumber, true];
|
||||||
|
|
||||||
|
[_unit, false, false] call EFUNC(common,applyStatusEffects);
|
Loading…
Reference in New Issue
Block a user