mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
added forceWalk and setCaptive events
This commit is contained in:
parent
53cb63ec1d
commit
cf59a3c2d4
@ -1,11 +1,6 @@
|
|||||||
// 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);
|
||||||
@ -264,4 +259,16 @@ PREP(makeCopyOfBody_F);
|
|||||||
PREP(unloadPerson_F);
|
PREP(unloadPerson_F);
|
||||||
PREP(cleanUpCopyOfBody_F);
|
PREP(cleanUpCopyOfBody_F);
|
||||||
|
|
||||||
|
PREP(setStatusEffect);
|
||||||
|
PREP(applyStatusEffects);
|
||||||
|
PREP(getStatusEffects);
|
||||||
|
PREP(statusEffectSetCaptive);
|
||||||
|
PREP(statusEffectForceWalk);
|
||||||
|
|
||||||
|
|
||||||
|
["setCaptive", {_this call FUNC(statusEffectSetCaptive)}] call FUNC(addEventHandler);
|
||||||
|
["forceWalk", {_this call FUNC(statusEffectForceWalk)}] call FUNC(addEventHandler);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ADDON = true;
|
ADDON = true;
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
#define HASH_INDEX(hash,key) ((hash select 0) find key)
|
#define HASH_INDEX(hash,key) ((hash select 0) find key)
|
||||||
|
|
||||||
xx3 = _this;
|
|
||||||
|
|
||||||
PARAMS_1(_unit);
|
PARAMS_1(_unit);
|
||||||
DEFAULT_PARAM(1,_isJip, false);
|
DEFAULT_PARAM(1,_isJip, false);
|
||||||
DEFAULT_PARAM(2,_isRespawn, false);
|
DEFAULT_PARAM(2,_isRespawn, false);
|
||||||
@ -13,7 +11,9 @@ DEFAULT_PARAM(2,_isRespawn, false);
|
|||||||
_unitEffects = _unit getVariable ["ACE_statusEffects", 0];
|
_unitEffects = _unit getVariable ["ACE_statusEffects", 0];
|
||||||
_statusHashList = missionNamespace getVariable ["ACE_statusHashList", []];
|
_statusHashList = missionNamespace getVariable ["ACE_statusHashList", []];
|
||||||
|
|
||||||
if (!local _unit) exitWith {};
|
if (!local _unit) exitWith {
|
||||||
|
["applyStatusEffects", _unit, _this] call FUNC(targetEvent);
|
||||||
|
};
|
||||||
if (_unitEffects == 0) exitWith {};
|
if (_unitEffects == 0) exitWith {};
|
||||||
if (!(VALIDHASH(_statusHashList))) exitWith {};
|
if (!(VALIDHASH(_statusHashList))) exitWith {};
|
||||||
|
|
||||||
@ -21,9 +21,9 @@ _effectTypeHash = HASHLIST_SELECT(_statusHashList, 0);
|
|||||||
_removeOnJipHash = HASHLIST_SELECT(_statusHashList, 1);
|
_removeOnJipHash = HASHLIST_SELECT(_statusHashList, 1);
|
||||||
_removeOnRespawn = HASHLIST_SELECT(_statusHashList, 2);
|
_removeOnRespawn = HASHLIST_SELECT(_statusHashList, 2);
|
||||||
|
|
||||||
_unitStatusBoolArray = [_unitEffects, (count (_effectTypeHash select 0))] call EFUNC(common,binarizeNumber);
|
_unitStatusBoolArray = [_unitEffects, (count (_effectTypeHash select 0))] call FUNC(binarizeNumber);
|
||||||
|
|
||||||
_allEffects = [(_effectTypeHash select 1)] call EFUNC(common,uniqueElementsOnly);
|
_allEffects = [(_effectTypeHash select 1)] call FUNC(uniqueElementsOnly);
|
||||||
_activeEffects = [];
|
_activeEffects = [];
|
||||||
_updated = false;
|
_updated = false;
|
||||||
{
|
{
|
||||||
@ -40,14 +40,13 @@ _updated = false;
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
} forEach _unitStatusBoolArray;
|
} forEach _unitStatusBoolArray;
|
||||||
TRACE_2("Updaing unit?",_unit,_updated);
|
TRACE_2("Updaing unit",_unit,_updated);
|
||||||
if (_updated) then {
|
if (_updated) then {
|
||||||
_unitStatusNumber = _unitStatusBoolArray call EFUNC(common,toBitmask);
|
_unitStatusNumber = _unitStatusBoolArray call FUNC(toBitmask);
|
||||||
_unit setVariable ["ACE_statusEffects", _unitStatusNumber, true];
|
_unit setVariable ["ACE_statusEffects", _unitStatusNumber, true];
|
||||||
};
|
};
|
||||||
|
|
||||||
TRACE_3("Updaing All Effects",_unit,_allEffects,_activeEffects);
|
TRACE_3("Updaing All Effects",_unit,_allEffects,_activeEffects);
|
||||||
{
|
{
|
||||||
[_x, [_unit, (_x in _activeEffects)]] call EFUNC(common,localEvent);
|
[_x, [_unit, (_x in _activeEffects)]] call FUNC(localEvent);
|
||||||
} forEach _allEffects;
|
} forEach _allEffects;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ _statusHashList = missionNamespace getVariable ["ACE_statusHashList", []];
|
|||||||
if (!(VALIDHASH(_statusHashList))) exitWith {[]};
|
if (!(VALIDHASH(_statusHashList))) exitWith {[]};
|
||||||
|
|
||||||
_effectTypeHash = HASHLIST_SELECT(_statusHashList, 0);
|
_effectTypeHash = HASHLIST_SELECT(_statusHashList, 0);
|
||||||
_unitStatusBoolArray = [_unitEffects] call EFUNC(common,binarizeNumber); //create bool array
|
_unitStatusBoolArray = [_unitEffects] call FUNC(binarizeNumber); //create bool array
|
||||||
|
|
||||||
_returnValue = [];
|
_returnValue = [];
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
//[this, "fattie", "forceWalk", true, false, false] call ace_common_fnc_setStatusEffect;
|
||||||
|
//[this, "carrying jerrycan", "forceWalk", true, false, false] call ace_common_fnc_setStatusEffect;
|
||||||
|
|
||||||
#define HASH_INDEX(hash,key) ((hash select 0) find key)
|
#define HASH_INDEX(hash,key) ((hash select 0) find key)
|
||||||
|
|
||||||
PARAMS_4(_unit,_effectName,_effectType,_isEnabled);
|
PARAMS_4(_unit,_effectName,_effectType,_isEnabled);
|
||||||
@ -22,9 +25,7 @@ _effectTypeHash = HASHLIST_SELECT(_statusHashList, 0);
|
|||||||
_removeOnJipHash = HASHLIST_SELECT(_statusHashList, 1);
|
_removeOnJipHash = HASHLIST_SELECT(_statusHashList, 1);
|
||||||
_removeOnRespawnHash = HASHLIST_SELECT(_statusHashList, 2);
|
_removeOnRespawnHash = HASHLIST_SELECT(_statusHashList, 2);
|
||||||
|
|
||||||
|
if ((HASH_INDEX(_statusHashList,_effectName)) == -1) then {// If effect name isn't in hashList
|
||||||
if ((!HASH_HASKEY(_effectTypeHash,_effectType)) || {!HASH_HASKEY(_effectTypeHash,_effectType)}) then {
|
|
||||||
// If effect name isn't in hashList
|
|
||||||
HASH_SET(_effectTypeHash,_effectName,_effectType);
|
HASH_SET(_effectTypeHash,_effectName,_effectType);
|
||||||
HASHLIST_SET(_statusHashList, 0, _effectTypeHash);
|
HASHLIST_SET(_statusHashList, 0, _effectTypeHash);
|
||||||
HASH_SET(_removeOnJipHash,_effectName,_removeOnJIP);
|
HASH_SET(_removeOnJipHash,_effectName,_removeOnJIP);
|
||||||
@ -38,11 +39,15 @@ if ((!HASH_HASKEY(_effectTypeHash,_effectType)) || {!HASH_HASKEY(_effectTypeHash
|
|||||||
|
|
||||||
_effectIndex = HASH_INDEX(_statusHashList, _effectName);
|
_effectIndex = HASH_INDEX(_statusHashList, _effectName);
|
||||||
|
|
||||||
_unitStatusBoolArray = [_unitEffects, (count (_effectTypeHash select 0))] call EFUNC(common,binarizeNumber); //create bool array
|
_unitStatusBoolArray = [_unitEffects, (count (_effectTypeHash select 0))] call FUNC(binarizeNumber); //create bool array
|
||||||
|
|
||||||
_unitStatusBoolArray set [_effectIndex, _isEnabled]; //set new status
|
_unitStatusBoolArray set [_effectIndex, _isEnabled]; //set new status
|
||||||
_unitStatusNumber = _unitStatusBoolArray call EFUNC(common,toBitmask);
|
_unitStatusNumber = _unitStatusBoolArray call FUNC(toBitmask);
|
||||||
|
|
||||||
_unit setVariable ["ACE_statusEffects", _unitStatusNumber, true];
|
_unit setVariable ["ACE_statusEffects", _unitStatusNumber, true];
|
||||||
|
|
||||||
[_unit, false, false] call EFUNC(common,applyStatusEffects);
|
if (local _unit) then {
|
||||||
|
[_unit] call FUNC(applyStatusEffects);
|
||||||
|
} else {
|
||||||
|
["applyStatusEffects", _unit, [_unit]] call FUNC(targetEvent);
|
||||||
|
};
|
||||||
|
7
addons/common/functions/fnc_statusEffectForceWalk.sqf
Normal file
7
addons/common/functions/fnc_statusEffectForceWalk.sqf
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#define DEBUG_MODE_FULL
|
||||||
|
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
PARAMS_2(_unit,_isEnabled);
|
||||||
|
|
||||||
|
_unit forceWalk _isEnabled;
|
12
addons/common/functions/fnc_statusEffectSetCaptive.sqf
Normal file
12
addons/common/functions/fnc_statusEffectSetCaptive.sqf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#define DEBUG_MODE_FULL
|
||||||
|
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
PARAMS_2(_unit,_isEnabled);
|
||||||
|
DEFAULT_PARAM(2,_isGlobal, false);
|
||||||
|
|
||||||
|
if (!_isGlobal) exitWith {
|
||||||
|
["setCaptive", [_unit, _isEnabled, true]] call FUNC(globalEvent);
|
||||||
|
} else {
|
||||||
|
_unit setCaptive _isEnabled;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user