diff --git a/addons/common/CfgEventHandlers.hpp b/addons/common/CfgEventHandlers.hpp index 2609b0d6a8..cf325934a7 100644 --- a/addons/common/CfgEventHandlers.hpp +++ b/addons/common/CfgEventHandlers.hpp @@ -1,53 +1,50 @@ class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit)); - serverInit = QUOTE(call COMPILE_FILE(scripts\readParameters)); - disableModuload = true; - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + serverInit = QUOTE(call COMPILE_FILE(scripts\readParameters)); + disableModuload = true; + }; }; class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); - disableModuload = true; - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + disableModuload = true; + }; }; class Extended_InitPost_EventHandlers { - class All { - class GVAR(executePersistent) { - init = QUOTE([_this select 0] call FUNC(executePersistent)); - }; + class All { + class GVAR(executePersistent) { + init = QUOTE([_this select 0] call FUNC(executePersistent)); }; - class CAManBase { - class GVAR(setName) { - init = QUOTE(if (local (_this select 0)) then {_this call FUNC(setName)};); - }; - // class GVAR(forceWalk) { - // 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);};); - }; + }; + class CAManBase { + class GVAR(setName) { + init = QUOTE(if (local (_this select 0)) then {_this call FUNC(setName)};); }; + 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);};); + }; + }; }; class Extended_Respawn_EventHandlers { - class All { - class GVAR(restoreVariablesJIP) { - respawn = QUOTE(_this call FUNC(restoreVariablesJIP)); - }; - class GVAR(setName) { - respawn = QUOTE(_this call FUNC(setName)); - }; - class GVAR(RESETDefaults) { - respawn = QUOTE(_this call FUNC(resetAllDefaults_F)); - }; + class All { + class GVAR(restoreVariablesJIP) { + respawn = QUOTE(_this call FUNC(restoreVariablesJIP)); }; - 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);};); - }; + class GVAR(setName) { + respawn = QUOTE(_this call FUNC(setName)); }; + class GVAR(RESETDefaults) { + 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, false, true)] call FUNC(applyStatusEffects);};); + }; + }; }; diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 91c586c43d..544e7204ed 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -61,17 +61,18 @@ call COMPILE_FILE(scripts\KeyInput\initScrollWheel); enableCamShake true; -// Set the name for the current player + ["playerChanged", { EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer); - + // Set the name for the current player if (alive _newPlayer) then { [_newPlayer] call FUNC(setName) }; if (alive _oldPlayer) then { [_oldPlayer] call FUNC(setName) }; - + //Apply effects to new unit + ["applyStatusEffects", [_newPlayer]] call FUNC(localEvent); }] call FUNC(addEventhandler); GVAR(OldPlayerInventory) = ACE_player call FUNC(getAllGear); diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 807f09c006..9437b6028e 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -10,7 +10,6 @@ PREP(addMapMarkerCreatedEventHandler); PREP(addScrollWheelEventHandler); PREP(adminKick); PREP(ambientBrightness); -PREP(applyForceWalkStatus); PREP(binarizeNumber); PREP(callCustomEventHandlers); PREP(callCustomEventHandlersGlobal); @@ -38,12 +37,10 @@ PREP(executePersistent); PREP(filter); PREP(fixLoweredRifleAnimation); PREP(getAllGear); -PREP(getCaptivityStatus); PREP(getConfigCommander); PREP(getConfigGunner); PREP(getDefaultAnim); PREP(getDoorTurrets); -PREP(getForceWalkStatus); PREP(getHitPoints); PREP(getHitPointsWithSelections); PREP(getInPosition); @@ -106,8 +103,6 @@ PREP(restoreVariablesJIP); PREP(revertKeyCodeLocalized); PREP(sanitizeString); PREP(serverLog); -PREP(setCaptivityStatus); -PREP(setForceWalkStatus); PREP(setKeyDefault); PREP(setName); PREP(setParameter); @@ -265,10 +260,8 @@ PREP(getStatusEffects); PREP(statusEffectSetCaptive); PREP(statusEffectForceWalk); - ["setCaptive", {_this call FUNC(statusEffectSetCaptive)}] call FUNC(addEventHandler); ["forceWalk", {_this call FUNC(statusEffectForceWalk)}] call FUNC(addEventHandler); - ADDON = true; diff --git a/addons/common/functions/fnc_applyForceWalkStatus.sqf b/addons/common/functions/fnc_applyForceWalkStatus.sqf deleted file mode 100644 index 0f8ffb58ea..0000000000 --- a/addons/common/functions/fnc_applyForceWalkStatus.sqf +++ /dev/null @@ -1,25 +0,0 @@ -/* -Name: FUNC(applyForceWalkStatus) - -Author: Pabst Mirror - -Description: - Applys the forceWalk status of an unit. Called from Extended_InitPost_EventHandlers. - -Parameters: - 0: OBJECT - Unit - -Returns: - None - -Example: - [ACE_Player] call FUNC(applyForceWalkStatus) -*/ -#include "script_component.hpp" - -private ["_unit", "_forceWalkNumber"]; - -_unit = _this select 0; -_forceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0]; - -_unit forceWalk (_forceWalkNumber > 0); diff --git a/addons/common/functions/fnc_applyStatusEffects.sqf b/addons/common/functions/fnc_applyStatusEffects.sqf index 7c8805dffc..9cd985ac25 100644 --- a/addons/common/functions/fnc_applyStatusEffects.sqf +++ b/addons/common/functions/fnc_applyStatusEffects.sqf @@ -1,3 +1,19 @@ +/* +Name: applyStatusEffect + +Author: Pabst Mirror + +Description: + Sets the status effect on a unit. + +Parameters: + 0: OBJECT - Unit + +Returns: + None + +*/ + #define DEBUG_MODE_FULL #include "script_component.hpp" diff --git a/addons/common/functions/fnc_getCaptivityStatus.sqf b/addons/common/functions/fnc_getCaptivityStatus.sqf deleted file mode 100644 index dcd3d6b0ff..0000000000 --- a/addons/common/functions/fnc_getCaptivityStatus.sqf +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Author: commy2 - * - * Return the captivity status of an unit. - * - * Argument: - * 0: Unit (Object) - * - * Return value: - * Reasons, why the unit is a captive. An empty array is returned if the unit is not a captive (Array of Strings) - */ -#include "script_component.hpp" - -private ["_unit", "_captivityReasons", "_unitCaptivityStatus", "_unitCaptivityReasons"]; - -_unit = _this select 0; - -_captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []]; - -_unitCaptivityStatus = [captiveNum _unit, count _captivityReasons] call FUNC(binarizeNumber); - -_unitCaptivityReasons = []; -{ - if (_unitCaptivityStatus select _forEachIndex) then { - _unitCaptivityReasons pushBack _x; - }; -} forEach _captivityReasons; - -_unitCaptivityReasons diff --git a/addons/common/functions/fnc_getForceWalkStatus.sqf b/addons/common/functions/fnc_getForceWalkStatus.sqf deleted file mode 100644 index 10a70546fb..0000000000 --- a/addons/common/functions/fnc_getForceWalkStatus.sqf +++ /dev/null @@ -1,37 +0,0 @@ -/* -Name: FUNC(getForceWalkStatus) - -Author: Pabst Mirror (from captivity by commy2) - -Description: - Returns reasons why the unit is forceWalk-ing, empty if not forced. - -Parameters: - 0: OBJECT - Unit - -Returns: - ARRAY(of strings) - Reason why the unit is force walking - -Example: - [ACE_Player] call FUNC(getForceWalkStatus) -*/ -#include "script_component.hpp" - -private ["_unit", "_forceWalkReasons", "_unitForceWalkNumber", "_unitForceWalkStatus", "_unitForceWalkReasons"]; - -_unit = _this select 0; - -_forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []]; - -_unitForceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0]; - -_unitForceWalkStatus = [_unitForceWalkNumber, count _forceWalkReasons] call FUNC(binarizeNumber); - -_unitForceWalkReasons = []; -{ - if (_unitForceWalkStatus select _forEachIndex) then { - _unitForceWalkReasons pushBack _x; - }; -} forEach _forceWalkReasons; - -_unitForceWalkReasons diff --git a/addons/common/functions/fnc_getStatusEffects.sqf b/addons/common/functions/fnc_getStatusEffects.sqf index cd9b118394..9db98102c7 100644 --- a/addons/common/functions/fnc_getStatusEffects.sqf +++ b/addons/common/functions/fnc_getStatusEffects.sqf @@ -1,3 +1,20 @@ +/* +Name: getStatusEffect + +Author: Pabst Mirror + +Description: + Sets the status effect on a unit. + +Parameters: + 0: OBJECT - Unit + 1: STRING - Effect Type ("forceWalk") + +Returns: + ARRAY of strings of the active Effect Names + +*/ + #define DEBUG_MODE_FULL #include "script_component.hpp" diff --git a/addons/common/functions/fnc_setCaptivityStatus.sqf b/addons/common/functions/fnc_setCaptivityStatus.sqf deleted file mode 100644 index b943fce4ab..0000000000 --- a/addons/common/functions/fnc_setCaptivityStatus.sqf +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Author: commy2 - * - * Set the captivity status of an unit. This allows the handling of more than one reason to set a unit captive. - * - * Argument: - * 0: Unit (Object) - * 1: The reason of the captivity (String) - * 2: Is the reason still valid? True for setting this reason, false for removing it (Bool) - * - * Return value: - * None. - */ -#include "script_component.hpp" - -private ["_unit", "_reason", "_status", "_captivityReasons", "_unitCaptivityReasons", "_captivityReasonsBooleans", "_bitmask"]; - -_unit = _this select 0; -_reason = _this select 1; -_status = _this select 2; - -_captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []]; - -// register new reason (these reasons are shared publicly, since units can change ownership, but keep their captivity status) -if !(_reason in _captivityReasons) then { - _captivityReasons pushBack _reason; - - ACE_captivityReasons = _captivityReasons; - publicVariable "ACE_captivityReasons"; -}; - -// get reasons why the unit is captive already and update to the new status -_unitCaptivityReasons = [_unit] call FUNC(getCaptivityStatus); - -_captivityReasonsBooleans = []; -{ - _captivityReasonsBooleans set [_forEachIndex, (_captivityReasons select _forEachIndex) in _unitCaptivityReasons]; -} forEach _captivityReasons; - -_captivityReasonsBooleans set [_captivityReasons find _reason, _status]; - -_bitmask = _captivityReasonsBooleans call FUNC(toBitmask); - -// actually apply the setCaptive command globaly -[[_unit, _bitmask], "{(_this select 0) setCaptive (_this select 1)}", _unit] call FUNC(execRemoteFnc); diff --git a/addons/common/functions/fnc_setForceWalkStatus.sqf b/addons/common/functions/fnc_setForceWalkStatus.sqf deleted file mode 100644 index 52b674015f..0000000000 --- a/addons/common/functions/fnc_setForceWalkStatus.sqf +++ /dev/null @@ -1,53 +0,0 @@ -/* -Name: FUNC(setForceWalkStatus) - -Author: Pabst Mirror (from captivity by commy2) - -Description: - Sets the forceWalk status of an unit. This allows the handling of more than one reason to set forceWalk. - Unit will force walk until all reasons are removed. - -Parameters: - 0: OBJECT - Unit - 1: STRING - Reason for forcing walking - 2: BOOL - Is the reason still valid. True to force walk, false to remove restriction. - -Returns: - None - -Example: - [ACE_Player, "BrokenLeg", true] call FUNC(setForceWalkStatus) -*/ -#include "script_component.hpp" - -private ["_unit", "_reason", "_status", "_forceWalkReasons", "_unitForceWalkReasons", "_forceWalkReasonsBooleans", "_bitmaskNumber"]; - -_unit = _this select 0; -_reason = _this select 1; -_status = _this select 2; - -_forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []]; - -// register new reason (these reasons are shared publicly, since units can change ownership, but keep their forceWalk status) -if !(_reason in _forceWalkReasons) then { - _forceWalkReasons pushBack _reason; - ACE_forceWalkReasons = _forceWalkReasons; - publicVariable "ACE_forceWalkReasons"; -}; - -// get reasons why the unit is forceWalking already and update to the new status -_unitForceWalkReasons = [_unit] call FUNC(getForceWalkStatus); - -_forceWalkReasonsBooleans = []; -{ - _forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons]; -} forEach _forceWalkReasons; - -_forceWalkReasonsBooleans set [_forceWalkReasons find _reason, _status]; - -_bitmaskNumber = _forceWalkReasonsBooleans call FUNC(toBitmask); - -_unit setVariable ["ACE_forceWalkStatusNumber", _bitmaskNumber, true]; - -// actually apply the forceWalk command globaly -[[_unit], QUOTE(FUNC(applyForceWalkStatus)), _unit] call FUNC(execRemoteFnc); diff --git a/addons/common/functions/fnc_setStatusEffect.sqf b/addons/common/functions/fnc_setStatusEffect.sqf index 64fe5f5d56..381878579c 100644 --- a/addons/common/functions/fnc_setStatusEffect.sqf +++ b/addons/common/functions/fnc_setStatusEffect.sqf @@ -1,10 +1,32 @@ +/* +Name: setStatusEffect + +Author: Pabst Mirror + +Description: + Sets the status effect on a unit. + Note: the JIP/Respawn settings are global, so use different names. + +Parameters: + 0: OBJECT - Unit + 1: STRING - Effect Name ("brokenLeg") + 2: STRING - Effect Type ("forceWalk") + 3: BOOL - Enabled + 4: BOOL - Remove on JIP + 5: BOOL - Remove on Respawn + +Returns: + None + +Example: + [this, "fattie", "forceWalk", true, false, false] call ace_common_fnc_setStatusEffect; //permenetnt effect + [this, "carrying jerrycan", "forceWalk", true, true, true] call ace_common_fnc_setStatusEffect; //will be removed if the disconnectAndJIP or respawn +*/ + #define DEBUG_MODE_FULL #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) PARAMS_4(_unit,_effectName,_effectType,_isEnabled); diff --git a/addons/common/functions/fnc_statusEffectForceWalk.sqf b/addons/common/functions/fnc_statusEffectForceWalk.sqf index 6095472b50..e2c682104f 100644 --- a/addons/common/functions/fnc_statusEffectForceWalk.sqf +++ b/addons/common/functions/fnc_statusEffectForceWalk.sqf @@ -1,7 +1,28 @@ +/* +Name: statusEffectForceWalk + +Author: Pabst Mirror + +Description: + Handles the "forceWalk" event + +Parameters: + 0: OBJECT - Unit + 1: BOOL - Enabled + +Returns: + None +*/ + #define DEBUG_MODE_FULL #include "script_component.hpp" PARAMS_2(_unit,_isEnabled); -_unit forceWalk _isEnabled; +if (!local _unit) then { + WARNING("statusEffectForceWalk with non local unit"); + ["forceWalk", _unit, [_unit, _isEnabled]] call FUNC(targetEvent); +} else { + _unit forceWalk _isEnabled; +}; diff --git a/addons/common/functions/fnc_statusEffectSetCaptive.sqf b/addons/common/functions/fnc_statusEffectSetCaptive.sqf index 8051c00434..80c6ca3a43 100644 --- a/addons/common/functions/fnc_statusEffectSetCaptive.sqf +++ b/addons/common/functions/fnc_statusEffectSetCaptive.sqf @@ -1,12 +1,28 @@ +/* +Name: statusEffectSetCaptive + +Author: Pabst Mirror + +Description: + Handles the "setCaptive" event + +Parameters: + 0: OBJECT - Unit + 1: BOOL - Enabled + +Returns: + None +*/ + #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); +if (!local _unit) then { + WARNING("statusEffectSetCaptive with non local unit"); + ["setCaptive", _unit, [_unit, _isEnabled]] call FUNC(targetEvent); } else { _unit setCaptive _isEnabled; -}; \ No newline at end of file +}; diff --git a/addons/explosives/functions/fnc_place_Approve.sqf b/addons/explosives/functions/fnc_place_Approve.sqf index c906aa777d..7f0eb4695f 100644 --- a/addons/explosives/functions/fnc_place_Approve.sqf +++ b/addons/explosives/functions/fnc_place_Approve.sqf @@ -24,7 +24,8 @@ if (GVAR(pfeh_running)) then { private ["_mag", "_setup", "_player"]; _setup = GVAR(Setup); GVAR(Setup) = objNull; -[GVAR(placer), "ACE_Explosives", false] call EFUNC(Common,setForceWalkStatus); +// [GVAR(placer), "ACE_Explosives", false] call EFUNC(Common,setForceWalkStatus); +[GVAR(placer), "ACE_Explosives_Walk", "forceWalk", false, true, true] call EFUNC(common,setStatusEffect); GVAR(placer) = objNull; _player = ACE_player; [_player, "DefaultAction", _player getVariable [QGVAR(Place), -1]] call EFUNC(Common,removeActionEventHandler); diff --git a/addons/explosives/functions/fnc_place_Cancel.sqf b/addons/explosives/functions/fnc_place_Cancel.sqf index 3f56e35ff6..a89ffedd69 100644 --- a/addons/explosives/functions/fnc_place_Cancel.sqf +++ b/addons/explosives/functions/fnc_place_Cancel.sqf @@ -28,7 +28,8 @@ GVAR(Setup) = objNull; if (isNil {GVAR(placer)}) then { GVAR(placer) = objNull; }; -[GVAR(placer), "ACE_Explosives", false] call EFUNC(Common,setForceWalkStatus); +// [GVAR(placer), "ACE_Explosives", false] call EFUNC(Common,setForceWalkStatus); +[GVAR(placer), "ACE_Explosives_Walk", "forceWalk", false, true, true] call EFUNC(common,setStatusEffect); GVAR(placer) = objNull; call EFUNC(interaction,hideMouseHint); [ACE_player, "DefaultAction", ACE_player getVariable [QGVAR(Place), -1]] call EFUNC(Common,removeActionEventHandler); diff --git a/addons/explosives/functions/fnc_setupExplosive.sqf b/addons/explosives/functions/fnc_setupExplosive.sqf index 8221109838..3304ed899a 100644 --- a/addons/explosives/functions/fnc_setupExplosive.sqf +++ b/addons/explosives/functions/fnc_setupExplosive.sqf @@ -43,7 +43,8 @@ if (!isNil "_timer") then { GVAR(Setup) setVariable [QGVAR(Timer), _timer]; }; -[_unit, "ACE_Explosives", true] call EFUNC(common,setForceWalkStatus); +// [_unit, "ACE_Explosives", true] call EFUNC(common,setForceWalkStatus); +[GVAR(placer), "ACE_Explosives_Walk", "forceWalk", true, true, true] call EFUNC(common,setStatusEffect); GVAR(TweakedAngle) = 180; [QGVAR(Placement),"OnEachFrame", { private "_player"; diff --git a/addons/switchunits/functions/fnc_initPlayer.sqf b/addons/switchunits/functions/fnc_initPlayer.sqf index 81e4fc259f..6967f1c9ce 100644 --- a/addons/switchunits/functions/fnc_initPlayer.sqf +++ b/addons/switchunits/functions/fnc_initPlayer.sqf @@ -44,7 +44,8 @@ if (vehicle _playerUnit == _playerUnit) then { _playerUnit linkItem "ItemMap"; removeUniform _playerUnit; - [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); + // [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); + [_playerUnit, "ACE_SwitchUnits_Walk", "forceWalk", true, true, true] call EFUNC(common,setStatusEffect); //does anything disable this? [_playerUnit, _sides] call FUNC(addMapFunction); };