mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Unified Status Effect Handler
This commit is contained in:
parent
b99be6122b
commit
9a3972de76
@ -49,7 +49,7 @@ if (_unit == _attachToVehicle) then { //Self Attachment
|
||||
} else {
|
||||
GVAR(placeAction) = PLACE_WAITING;
|
||||
|
||||
[_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus);
|
||||
[_unit, "ACE_Attach", true] call EFUNC(common,setForceWalkStatus);
|
||||
|
||||
[{[localize LSTRING(PlaceAction), ""] call EFUNC(interaction,showMouseHint)}, []] call EFUNC(common,execNextFrame);
|
||||
_unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {true}, {GVAR(placeAction) = PLACE_APPROVE;}] call EFUNC(common,AddActionEventHandler)];
|
||||
@ -88,7 +88,7 @@ if (_unit == _attachToVehicle) then { //Self Attachment
|
||||
{!([_attachToVehicle, _unit, _itemClassname] call FUNC(canAttach))}) then {
|
||||
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
[_unit, "ACE_Attach", false] call EFUNC(common,setForceWalkStatus);
|
||||
[] call EFUNC(interaction,hideMouseHint);
|
||||
[_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler);
|
||||
_unit removeAction _actionID;
|
||||
|
@ -23,9 +23,6 @@ class Extended_InitPost_EventHandlers {
|
||||
class GVAR(setName) {
|
||||
init = QUOTE(if (local (_this select 0)) then {_this call FUNC(setName)};);
|
||||
};
|
||||
class GVAR(forceWalk) {
|
||||
init = QUOTE(_this call FUNC(applyForceWalkStatus));
|
||||
};
|
||||
class GVAR(muteUnit) {
|
||||
init = QUOTE(_this call FUNC(muteUnitHandleInitPost));
|
||||
};
|
||||
@ -43,6 +40,9 @@ class Extended_Respawn_EventHandlers {
|
||||
class GVAR(RESETDefaults) {
|
||||
respawn = QUOTE(_this call FUNC(resetAllDefaults));
|
||||
};
|
||||
class GVAR(statusEffect) {
|
||||
respawn = QUOTE(_this call FUNC(statusEffect_respawnEH));
|
||||
};
|
||||
};
|
||||
class CAManBase {
|
||||
class GVAR(muteUnit) {
|
||||
@ -50,3 +50,12 @@ class Extended_Respawn_EventHandlers {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Local_EventHandlers {
|
||||
class All {
|
||||
class GVAR(statusEffect) {
|
||||
local = QUOTE(_this call FUNC(statusEffect_localEH));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// ACE - Common
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
||||
@ -57,6 +58,33 @@
|
||||
// Eventhandlers
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//Status Effect EHs:
|
||||
["setStatusEffect", {_this call FUNC(statusEffect_set)}] call FUNC(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);
|
||||
["setCaptive", true, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered), QEGVAR(medical,unconscious)]] call FUNC(statusEffect_addType);
|
||||
["blockDamage", false, ["fixCollision"]] call FUNC(statusEffect_addType);
|
||||
|
||||
["forceWalk", {
|
||||
params ["_object", "_set"];
|
||||
TRACE_2("forceWalk EH",_object,_set);
|
||||
_object forceWalk (_set > 0);
|
||||
}] call FUNC(addEventHandler);
|
||||
["setCaptive", {
|
||||
params ["_object", "_set"];
|
||||
TRACE_2("forceWalk EH",_object,_set);
|
||||
_object setCaptive (_set > 0);
|
||||
}] call FUNC(addEventHandler);
|
||||
["blockDamage", {
|
||||
params ["_object", "_set"];
|
||||
if ((_object isKindOf "CAManBase") && {(["ace_medical"] call FUNC(isModLoaded))}) then {
|
||||
TRACE_2("blockDamage EH (using medical)",_object,_set);
|
||||
_object setvariable [QEGVAR(medical,allowDamage), (_set == 0), true];
|
||||
} else {
|
||||
TRACE_2("blockDamage EH (using allowDamage)",_object,_set);
|
||||
_object allowDamage (_set == 0);
|
||||
};
|
||||
}] call FUNC(addEventHandler);
|
||||
|
||||
//Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit
|
||||
//This variable is used for isPlayer checks
|
||||
if (isServer) then {
|
||||
@ -431,9 +459,6 @@ if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then {
|
||||
// Eventhandlers for player controlled machines
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
// @todo still needed?
|
||||
[QGVAR(StateArrested), false, true, QUOTE(ADDON)] call FUNC(defineVariable);
|
||||
|
||||
["displayTextStructured", {_this call FUNC(displayTextStructured)}] call FUNC(addEventhandler);
|
||||
["displayTextPicture", {_this call FUNC(displayTextPicture)}] call FUNC(addEventhandler);
|
||||
|
||||
|
@ -10,7 +10,6 @@ PREP(addToInventory);
|
||||
PREP(assignedItemFix);
|
||||
PREP(assignObjectsInList);
|
||||
PREP(ambientBrightness);
|
||||
PREP(applyForceWalkStatus);
|
||||
PREP(ASLToPosition);
|
||||
PREP(binarizeNumber);
|
||||
PREP(blurScreen);
|
||||
@ -53,7 +52,6 @@ PREP(fixLoweredRifleAnimation);
|
||||
PREP(fixPosition);
|
||||
PREP(getAllDefinedSetVariables);
|
||||
PREP(getAllGear);
|
||||
PREP(getCaptivityStatus);
|
||||
PREP(getDeathAnim);
|
||||
PREP(getDefaultAnim);
|
||||
PREP(getDefinedVariable);
|
||||
@ -61,7 +59,6 @@ PREP(getDefinedVariableDefault);
|
||||
PREP(getDefinedVariableInfo);
|
||||
PREP(getFirstObjectIntersection);
|
||||
PREP(getFirstTerrainIntersection);
|
||||
PREP(getForceWalkStatus);
|
||||
PREP(getGunner);
|
||||
PREP(getInPosition);
|
||||
PREP(getMapGridData);
|
||||
@ -170,6 +167,12 @@ PREP(setVariablePublic);
|
||||
PREP(setVolume);
|
||||
PREP(sortAlphabeticallyBy);
|
||||
PREP(showHud);
|
||||
PREP(statusEffect_addType);
|
||||
PREP(statusEffect_localEH);
|
||||
PREP(statusEffect_resetVariables);
|
||||
PREP(statusEffect_respawnEH);
|
||||
PREP(statusEffect_sendEffects);
|
||||
PREP(statusEffect_set);
|
||||
PREP(stringCompare);
|
||||
PREP(stringToColoredText);
|
||||
PREP(stringRemoveWhiteSpace);
|
||||
@ -316,6 +319,8 @@ if (isServer) then {
|
||||
call FUNC(loadSettingsOnServer);
|
||||
};
|
||||
|
||||
GVAR(statusEffect_Names) = [];
|
||||
GVAR(statusEffect_isGlobal) = [];
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Set up PlayerChanged eventhandler for pre init
|
||||
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Author: Pabst Mirror
|
||||
* Applys the forceWalk status of an unit. Called from Extended_InitPost_EventHandlers.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_Player] call ace_common_fnc_applyForceWalkStatus
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private _forceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0];
|
||||
|
||||
_unit forceWalk (_forceWalkNumber > 0);
|
@ -15,8 +15,8 @@
|
||||
// allowDamage requires local object
|
||||
if (!local _this) exitWith {};
|
||||
|
||||
// prevent collision damage, @todo allowDamage API
|
||||
_this allowDamage false;
|
||||
// prevent collision damage
|
||||
[_this, "blockDamage", "fixCollision", true] call FUNC(statusEffect_set);
|
||||
|
||||
// re-allow damage after 2 seconds
|
||||
[{_this allowDamage true}, _this, 2, 0] call EFUNC(common,waitAndExecute);
|
||||
[{[_this, "blockDamage", "fixCollision", false] call FUNC(statusEffect_set);}, _this, 2] call EFUNC(common,waitAndExecute);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Attempt to fix floating physx with disabled damage after setPosXXX commands.
|
||||
* Handles the "fixFloating" event
|
||||
*
|
||||
* Arguments:
|
||||
* PhysX object <OBJECT>
|
||||
@ -16,6 +17,11 @@ params ["_object"];
|
||||
|
||||
// setHitPointDamage requires local object
|
||||
if (!local _object) exitWith {};
|
||||
//Ignore mans
|
||||
if (_object isKindOf "CAManBase") exitWith {};
|
||||
|
||||
//We need to manually set allowDamage to true for setHitIndex to function
|
||||
["blockDamage", [_object, 0]] call FUNC(localEvent);
|
||||
|
||||
// save and restore hitpoints, see below why
|
||||
private _hitPointDamages = getAllHitPointsDamage _object;
|
||||
@ -31,3 +37,8 @@ _object setDamage damage _object;
|
||||
{
|
||||
_object setHitIndex [_forEachIndex, _x];
|
||||
} forEach (_hitPointDamages select 2);
|
||||
|
||||
//manually re-enable allowDamage to previous setting (ref statusEffect_funcs)
|
||||
private _effectVarName = format [QGVAR(effect_%1), "blockDamage"];
|
||||
private _effectNumber = _object getVariable [_effectVarName, 0];
|
||||
["blockDamage", [_object, _effectNumber]] call FUNC(localEvent);
|
||||
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Return the captivity status of an unit.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Captivity Reasons, empty if not captive <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private _captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []];
|
||||
private _unitCaptivityStatus = [captiveNum _unit, count _captivityReasons] call FUNC(binarizeNumber);
|
||||
|
||||
private _unitCaptivityReasons = [];
|
||||
|
||||
{
|
||||
if (_unitCaptivityStatus select _forEachIndex) then {
|
||||
_unitCaptivityReasons pushBack _x;
|
||||
};
|
||||
} forEach _captivityReasons;
|
||||
|
||||
_unitCaptivityReasons
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Author: PabstMirror, commy2
|
||||
* Returns reasons why the unit is forceWalk-ing.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Force Walk reasons <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [ACE_Player] call ace_common_fnc_getForceWalkStatus
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []];
|
||||
private _unitForceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0];
|
||||
private _unitForceWalkStatus = [_unitForceWalkNumber, count _forceWalkReasons] call FUNC(binarizeNumber);
|
||||
|
||||
private _unitForceWalkReasons = [];
|
||||
|
||||
{
|
||||
if (_unitForceWalkStatus select _forEachIndex) then {
|
||||
_unitForceWalkReasons pushBack _x;
|
||||
};
|
||||
} forEach _forceWalkReasons;
|
||||
|
||||
_unitForceWalkReasons
|
@ -19,11 +19,6 @@ _unit setVariable ["ACE_isUnconscious", nil, true];
|
||||
|
||||
if (isPlayer _unit) then {
|
||||
[true] call FUNC(setVolume);
|
||||
// [false] call FUNC(disableKeyInput); //func does not exist
|
||||
|
||||
if (["ace_medical"] call FUNC(isModLoaded)) then {
|
||||
// [false] call EFUNC(medical,effectBlackOut); //func does not exist
|
||||
};
|
||||
|
||||
if !(isNil QGVAR(DISABLE_USER_INPUT_COLLECTION)) then {
|
||||
// clear all disable user input
|
||||
@ -40,5 +35,3 @@ if (isPlayer _unit) then {
|
||||
};
|
||||
false
|
||||
} count ([_unit] call FUNC(getAllDefinedSetVariables));
|
||||
|
||||
_unit setVariable ["ACE_forceWalkStatusNumber", 0, true];
|
||||
|
@ -16,28 +16,6 @@
|
||||
|
||||
params ["_unit", "_reason", "_status"];
|
||||
|
||||
private _captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []];
|
||||
//Now just a wrapper for FUNC(statusEffect_set)
|
||||
|
||||
// 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
|
||||
private _unitCaptivityReasons = _unit call FUNC(getCaptivityStatus);
|
||||
|
||||
private _captivityReasonsBooleans = [];
|
||||
|
||||
{
|
||||
_captivityReasonsBooleans set [_forEachIndex, (_captivityReasons select _forEachIndex) in _unitCaptivityReasons];
|
||||
} forEach _captivityReasons;
|
||||
|
||||
_captivityReasonsBooleans set [_captivityReasons find _reason, _status];
|
||||
|
||||
private _bitmask = _captivityReasonsBooleans call FUNC(toBitmask);
|
||||
|
||||
// actually apply the setCaptive command globaly
|
||||
[[_unit, _bitmask], "{(_this select 0) setCaptive (_this select 1)}", _unit] call FUNC(execRemoteFnc);
|
||||
[_unit, "setCaptive", _reason, _status] call FUNC(statusEffect_set);
|
@ -20,29 +20,6 @@
|
||||
|
||||
params ["_unit", "_reason", "_status"];
|
||||
|
||||
private _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []];
|
||||
//Now just a wrapper for FUNC(statusEffect_set)
|
||||
|
||||
// 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
|
||||
private _unitForceWalkReasons = [_unit] call FUNC(getForceWalkStatus);
|
||||
|
||||
private _forceWalkReasonsBooleans = [];
|
||||
|
||||
{
|
||||
_forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons];
|
||||
} forEach _forceWalkReasons;
|
||||
|
||||
_forceWalkReasonsBooleans set [_forceWalkReasons find _reason, _status];
|
||||
|
||||
private _bitmaskNumber = _forceWalkReasonsBooleans call FUNC(toBitmask);
|
||||
|
||||
_unit setVariable ["ACE_forceWalkStatusNumber", _bitmaskNumber, true];
|
||||
|
||||
// actually apply the forceWalk command globaly
|
||||
[[_unit], QFUNC(applyForceWalkStatus), 2] call FUNC(execRemoteFnc);
|
||||
[_unit, "forceWalk", _reason, _status] call FUNC(statusEffect_set);
|
||||
|
37
addons/common/functions/fnc_statusEffect_addType.sqf
Normal file
37
addons/common/functions/fnc_statusEffect_addType.sqf
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Adds a status effect that will be handled.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Status Effect Name, this should match a corisponding event name <STRING>
|
||||
* 1: Send event globaly <BOOL>
|
||||
* 2: Common Effect Reaons to pre-seed durring init <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* ["setCaptive", true, []] call ace_common_fnc_statusEffect_addType
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params [["_name", "", [""]], ["_isGlobal", false, [false]], ["_commonReasonsArray", [], [[]]]];
|
||||
TRACE_3("params",_name,_isGlobal,_commonReasonsArray);
|
||||
|
||||
if (_name == "") exitWith {ACE_LOGERROR_1("addStatusEffect - Bad Name %1", _this)};
|
||||
if (_name in GVAR(statusEffect_Names)) exitWith {ACE_LOGWARNING_1("addStatusEffect - Effect Already Added (note, will not update global bit) %1", _this)};
|
||||
|
||||
GVAR(statusEffect_Names) pushBack _name;
|
||||
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;
|
||||
missionNamespace setVariable [(format [QGVAR(statusEffects_%1), _name]), _commonReasonsArray, true];
|
||||
};
|
36
addons/common/functions/fnc_statusEffect_localEH.sqf
Normal file
36
addons/common/functions/fnc_statusEffect_localEH.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
*
|
||||
*
|
||||
* Arguments:
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [player, true] call ace_common_fnc_statusEffect_localEH
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_object", "_isLocal"];
|
||||
TRACE_2("params",_object,_isLocal);
|
||||
|
||||
//Only run this after the settings are initialized
|
||||
//Need to wait for all EH to be installed (local event will happen between pre and post init)
|
||||
if !(GVAR(settingsInitFinished)) exitWith {
|
||||
TRACE_1("pushing to runAtSettingsInitialized", _this);
|
||||
GVAR(runAtSettingsInitialized) pushBack [FUNC(statusEffect_localEH), _this];
|
||||
};
|
||||
|
||||
if (!_isLocal) exitWith {TRACE_1("object no longer local", _this)};
|
||||
if (isNull _object) exitWith {TRACE_1("object null", _this)};
|
||||
|
||||
//Reset any variables because of respawn
|
||||
[_object, false] call FUNC(statusEffect_resetVariables);
|
||||
|
||||
//Send all Variables to client
|
||||
[_object, ""] call FUNC(statusEffect_sendEffects);
|
45
addons/common/functions/fnc_statusEffect_resetVariables.sqf
Normal file
45
addons/common/functions/fnc_statusEffect_resetVariables.sqf
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
*
|
||||
*
|
||||
* Arguments:
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [player, true] call ace_common_fnc_statusEffect_resetVariables
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params [["_object", objNull, [objNull]], ["_setObjectRef", false, [false]]];
|
||||
TRACE_2("params",_object,_setObjectRef);
|
||||
|
||||
if (isNull _object) exitWith {};
|
||||
|
||||
private _objectRef = _object getVariable QGVAR(statusEffect_object);
|
||||
TRACE_2("testing",_object,_objectRef);
|
||||
|
||||
// If nothing was ever set, or objects match, exit (always true unless respawned)
|
||||
if (isNil "_objectRef") exitWith {
|
||||
if (_setObjectRef) then {
|
||||
_object setVariable [QGVAR(statusEffect_object), _object, true]; //explicitly set new object ref
|
||||
};
|
||||
};
|
||||
if (_object == _objectRef) exitWith {};
|
||||
|
||||
//Mismatch, so if effect has ever been defined, reset to 0
|
||||
{
|
||||
private _effectVarName = format [QGVAR(effect_%1), _x];
|
||||
private _effectNumber = _object getVariable [_effectVarName, -1];
|
||||
if (_effectNumber != -1) then {
|
||||
TRACE_2("forced reset defined array on object mismatch",_x,_effectNumber);
|
||||
_object setVariable [_effectVarName, 0, true]; //This always resets to 0 (not -1/nil)!
|
||||
};
|
||||
} forEach GVAR(statusEffect_Names);
|
||||
|
||||
_object setVariable [QGVAR(statusEffect_object), _object, true];
|
36
addons/common/functions/fnc_statusEffect_respawnEH.sqf
Normal file
36
addons/common/functions/fnc_statusEffect_respawnEH.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Handles the Respawn Event Handler to reset effects.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [player, objNull] call ace_common_fnc_statusEffect_respawnEH
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_object"];
|
||||
TRACE_1("params",_object);
|
||||
|
||||
//Only run this after the settings are initialized
|
||||
//Need to wait for all EH to be installed (local event will happen between pre and post init)
|
||||
if !(GVAR(settingsInitFinished)) exitWith {
|
||||
TRACE_1("pushing to runAtSettingsInitialized", _this);
|
||||
GVAR(runAtSettingsInitialized) pushBack [FUNC(statusEffect_respawnEH), _this];
|
||||
};
|
||||
|
||||
if (!local _object) exitWith {TRACE_1("object no longer local", _this)};
|
||||
if (isNull _object) exitWith {TRACE_1("object null", _this)};
|
||||
|
||||
//Reset any variables on "real" respawn
|
||||
[_object, false] call FUNC(statusEffect_resetVariables);
|
||||
|
||||
//Send all Variables to client
|
||||
[_object, ""] call FUNC(statusEffect_sendEffects);
|
48
addons/common/functions/fnc_statusEffect_sendEffects.sqf
Normal file
48
addons/common/functions/fnc_statusEffect_sendEffects.sqf
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Sends all status effects for an object (can be run on non-local objects)
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Object <OBJECT>
|
||||
* 1: Effect name (or "" or send all) <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [player, ""] call ace_common_fnc_statusEffect_sendEffects
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params [["_object", objNull, [objNull]], ["_effectName", "", [""]]];
|
||||
TRACE_2("params",_object,_effectName);
|
||||
|
||||
if (isNull _object) exitWith {};
|
||||
|
||||
{
|
||||
if ((_effectName == "") || {_effectName == _x}) then {
|
||||
private _effectVarName = format [QGVAR(effect_%1), _x];
|
||||
private _effectNumber = _object getVariable [_effectVarName, -1];
|
||||
|
||||
//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 {
|
||||
if (GVAR(statusEffect_isGlobal) select _forEachIndex) then {
|
||||
TRACE_2("Sending Global Event", _object, _effectNumber);
|
||||
[_x, [_object, _effectNumber]] call FUNC(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 FUNC(localEvent);
|
||||
} else {
|
||||
TRACE_2("Sending Target Non-Local Event", _object, _effectNumber);
|
||||
[_x, [_object], [_object, _effectNumber]] call FUNC(targetEvent);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach GVAR(statusEffect_Names);
|
64
addons/common/functions/fnc_statusEffect_set.sqf
Normal file
64
addons/common/functions/fnc_statusEffect_set.sqf
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Adds or removes an id to a status effect and then updates the value
|
||||
*
|
||||
* Arguments:
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 1: Effect Name <STRING>
|
||||
* 2: Unique Reason ID <STRING>
|
||||
* 3: Is Set (true adds/false removes) <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [player, "setCaptive", "reason1", true] call ace_common_fnc_statusEffect_set
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params [["_object", objNull, [objNull]], ["_effectName", "", [""]], ["_ID", "", [""]], ["_set", true, [false]]];
|
||||
TRACE_4("params",_object,_effectName,_ID,_set);
|
||||
|
||||
//Only run this after the settings are initialized
|
||||
if !(GVAR(settingsInitFinished)) exitWith {
|
||||
TRACE_1("pushing to runAtSettingsInitialized", _this);
|
||||
GVAR(runAtSettingsInitialized) pushBack [FUNC(statusEffect_set), _this];
|
||||
};
|
||||
|
||||
if (isNull _object) exitWith {ACE_LOGERROR_1("setStatusEffect - Bad Input %1", _this)};
|
||||
|
||||
[_object, true] call FUNC(statusEffect_resetVariables); //Check for mismatch, and set object ref
|
||||
|
||||
//check ID case and set globaly if not already set:
|
||||
_ID = toLower _ID;
|
||||
private _statusReasons = missionNamespace getVariable [(format [QGVAR(statusEffects_%1), _effectName]), []];
|
||||
private _statusIndex = _statusReasons find _ID;
|
||||
if (_statusIndex == -1) then {
|
||||
TRACE_2("ID not in global reasons, adding",_statusReasons,_ID);
|
||||
_statusIndex = _statusReasons pushBack _ID;
|
||||
missionNamespace setVariable [(format [QGVAR(statusEffects_%1), _effectName]), _statusReasons, true];
|
||||
};
|
||||
|
||||
private _effectVarName = format [QGVAR(effect_%1), _effectName];
|
||||
private _effectNumber = _object getVariable [_effectVarName, -1];
|
||||
TRACE_2("current",_effectVarName,_effectNumber);
|
||||
|
||||
if ((_effectNumber == -1) && {!_set}) exitWith {
|
||||
//Optimization for modules that always set an ID to false even if never set true
|
||||
TRACE_2("Set False on nil array, exiting",_set,_effectNumber);
|
||||
};
|
||||
|
||||
if (_effectNumber == -1) then {_effectNumber = 0};
|
||||
|
||||
private _effectBoolArray = [_effectNumber, count _statusReasons] call FUNC(binarizeNumber);
|
||||
TRACE_3("Setting New Value", _set, _statusIndex, _effectBoolArray);
|
||||
_effectBoolArray set [_statusIndex, _set];
|
||||
_effectNumber = _effectBoolArray call FUNC(toBitmask);
|
||||
|
||||
TRACE_2("Saving globaly",_effectVarName,_effectNumber);
|
||||
_object setVariable [_effectVarName, _effectNumber, true];
|
||||
|
||||
[_object, _effectName] call FUNC(statusEffect_sendEffects);
|
@ -2,6 +2,7 @@
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
// #define CBA_DEBUG_SYNCHRONOUS
|
||||
|
||||
#ifdef DEBUG_ENABLED_COMMON
|
||||
#define DEBUG_MODE_FULL
|
||||
|
@ -48,7 +48,7 @@ _unit removeWeapon "ACE_FakePrimaryWeapon";
|
||||
// reselect weapon and re-enable sprint
|
||||
_unit selectWeapon primaryWeapon _unit;
|
||||
|
||||
[_unit, "isDragging", false] call EFUNC(common,setforceWalkStatus);
|
||||
[_unit, "ACE_dragging", false] call EFUNC(common,setforceWalkStatus);
|
||||
|
||||
// prevent object from flipping inside buildings
|
||||
if (_inBuilding) then {
|
||||
|
@ -53,7 +53,7 @@ if (_target isKindOf "CAManBase") then {
|
||||
_unit action ["SwitchWeapon", _unit, _unit, 99];
|
||||
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);
|
||||
|
||||
[_unit, "isDragging", true] call EFUNC(common,setforceWalkStatus);
|
||||
[_unit, "ACE_dragging", true] call EFUNC(common,setforceWalkStatus);
|
||||
|
||||
};
|
||||
|
||||
|
@ -6,6 +6,6 @@ _unit = _this select 0;
|
||||
|
||||
if !(local _unit) exitWith {};
|
||||
|
||||
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
[_unit, "ACE_refuel", false] call EFUNC(common,setForceWalkStatus);
|
||||
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
|
||||
_unit setVariable [QGVAR(isRefueling), false];
|
||||
|
@ -80,7 +80,7 @@ _endPosTestOffset set [2, (_startingOffset select 2)];
|
||||
_args params ["_unit", "_nozzle", "_target", "_endPosTestOffset"];
|
||||
_unit setVariable [QGVAR(nozzle), nil];
|
||||
_unit setVariable [QGVAR(isRefueling), false];
|
||||
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
[_unit, "ACE_refuel", false] call EFUNC(common,setForceWalkStatus);
|
||||
REFUEL_UNHOLSTER_WEAPON
|
||||
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
||||
if (_actionID != -1) then {
|
||||
|
@ -22,7 +22,7 @@ if (!local _unit || {!_isUnconscious}) exitWith {};
|
||||
|
||||
private "_nozzle";
|
||||
|
||||
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
[_unit, "ACE_refuel", false] call EFUNC(common,setForceWalkStatus);
|
||||
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
|
||||
if !(isNull _nozzle) then {
|
||||
[_unit, _nozzle] call FUNC(dropNozzle);
|
||||
|
@ -33,7 +33,7 @@ if (isNull _nozzle || {_source != _target}) exitWith {false};
|
||||
_args params ["_unit", "_nozzle", "_target"];
|
||||
_unit setVariable [QGVAR(nozzle), nil];
|
||||
detach _nozzle;
|
||||
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
[_unit, "ACE_refuel", false] call EFUNC(common,setForceWalkStatus);
|
||||
REFUEL_UNHOLSTER_WEAPON
|
||||
_unit setVariable [QGVAR(isRefueling), false];
|
||||
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
||||
|
@ -21,7 +21,7 @@
|
||||
private ["_endPosOffset"],
|
||||
params ["_unit", "_target", ["_nozzle", objNull]];
|
||||
|
||||
[_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus);
|
||||
[_unit, "ACE_refuel", true] call EFUNC(common,setForceWalkStatus);
|
||||
|
||||
REFUEL_HOLSTER_WEAPON
|
||||
|
||||
@ -70,7 +70,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
|
||||
};
|
||||
_actionID = _unit addAction [
|
||||
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
|
||||
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON',
|
||||
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, "ACE_refuel", false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON',
|
||||
nil,
|
||||
20,
|
||||
false,
|
||||
@ -107,7 +107,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
|
||||
};
|
||||
_actionID = _unit addAction [
|
||||
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
|
||||
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON',
|
||||
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, "ACE_refuel", false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON',
|
||||
nil,
|
||||
20,
|
||||
false,
|
||||
@ -138,7 +138,7 @@ if !(_nozzle getVariable [QGVAR(jerryCan), false]) then {
|
||||
[_unit, _nozzle] call FUNC(dropNozzle);
|
||||
REFUEL_UNHOLSTER_WEAPON
|
||||
|
||||
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
[_unit, "ACE_refuel", false] call EFUNC(common,setForceWalkStatus);
|
||||
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
[_pfID] call cba_fnc_removePerFrameHandler;
|
||||
|
Loading…
Reference in New Issue
Block a user