mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add getter, readd old public funcs, add blockSprint
This commit is contained in:
parent
d2e006397d
commit
7e84a9d9b0
@ -61,6 +61,7 @@
|
||||
//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);
|
||||
["blockSprint", false, []] 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);
|
||||
|
||||
@ -69,12 +70,17 @@
|
||||
TRACE_2("forceWalk EH",_object,_set);
|
||||
_object forceWalk (_set > 0);
|
||||
}] call FUNC(addEventHandler);
|
||||
["blockSprint", { //Name reversed from `allowSprint` because we want NOR logic
|
||||
params ["_object", "_set"];
|
||||
TRACE_2("blockSprint EH",_object,_set);
|
||||
_object allowSprint (_set == 0);
|
||||
}] call FUNC(addEventHandler);
|
||||
["setCaptive", {
|
||||
params ["_object", "_set"];
|
||||
TRACE_2("forceWalk EH",_object,_set);
|
||||
TRACE_2("setCaptive EH",_object,_set);
|
||||
_object setCaptive (_set > 0);
|
||||
}] call FUNC(addEventHandler);
|
||||
["blockDamage", {
|
||||
["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);
|
||||
|
@ -53,12 +53,14 @@ PREP(fixPosition);
|
||||
PREP(getAllDefinedSetVariables);
|
||||
PREP(getAllGear);
|
||||
PREP(getDeathAnim);
|
||||
PREP(getCaptivityStatus);
|
||||
PREP(getDefaultAnim);
|
||||
PREP(getDefinedVariable);
|
||||
PREP(getDefinedVariableDefault);
|
||||
PREP(getDefinedVariableInfo);
|
||||
PREP(getFirstObjectIntersection);
|
||||
PREP(getFirstTerrainIntersection);
|
||||
PREP(getForceWalkStatus);
|
||||
PREP(getGunner);
|
||||
PREP(getInPosition);
|
||||
PREP(getMapGridData);
|
||||
@ -168,6 +170,7 @@ PREP(setVolume);
|
||||
PREP(sortAlphabeticallyBy);
|
||||
PREP(showHud);
|
||||
PREP(statusEffect_addType);
|
||||
PREP(statusEffect_get);
|
||||
PREP(statusEffect_localEH);
|
||||
PREP(statusEffect_resetVariables);
|
||||
PREP(statusEffect_respawnEH);
|
||||
|
19
addons/common/functions/fnc_getCaptivityStatus.sqf
Normal file
19
addons/common/functions/fnc_getCaptivityStatus.sqf
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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"];
|
||||
|
||||
//Now just a wrapper for FUNC(statusEffect_get)
|
||||
|
||||
([player, "setCaptive"] call FUNC(statusEffect_get)) select 1
|
22
addons/common/functions/fnc_getForceWalkStatus.sqf
Normal file
22
addons/common/functions/fnc_getForceWalkStatus.sqf
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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"];
|
||||
|
||||
//Now just a wrapper for FUNC(statusEffect_get)
|
||||
|
||||
([player, "forceWalk"] call FUNC(statusEffect_get)) select 1
|
@ -18,4 +18,4 @@ params ["_unit", "_reason", "_status"];
|
||||
|
||||
//Now just a wrapper for FUNC(statusEffect_set)
|
||||
|
||||
[_unit, "setCaptive", _reason, _status] call FUNC(statusEffect_set);
|
||||
[_unit, "setCaptive", _reason, _status] call FUNC(statusEffect_set);
|
||||
|
63
addons/common/functions/fnc_statusEffect_get.sqf
Normal file
63
addons/common/functions/fnc_statusEffect_get.sqf
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Retrives list of current status effects
|
||||
*
|
||||
* Arguments:
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 1: Effect Name <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Effect status <ARRAY>
|
||||
* 0: is activly set (if false, the effect is ignored and never modified) <BOOL>
|
||||
* 1: reasons why it is set true (list of strings, count of 0 = false, 1+ = true) <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [player, "forceWalk"] call ace_common_fnc_statusEffect_get
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params [["_object", objNull, [objNull]], ["_effectName", "", [""]]];
|
||||
TRACE_2("params",_object,_effectName);
|
||||
|
||||
if (isNull _object) exitWith {
|
||||
TRACE_1("null",_object);
|
||||
[false, []]
|
||||
};
|
||||
|
||||
[_object, false] call FUNC(statusEffect_resetVariables); //Check for mismatch
|
||||
|
||||
//List of reasons
|
||||
private _statusReasons = missionNamespace getVariable [(format [QGVAR(statusEffects_%1), _effectName]), []];
|
||||
if (_statusReasons isEqualTo []) exitWith {
|
||||
TRACE_1("no reasons - bad effect?",_statusReasons);
|
||||
[false, []]
|
||||
};
|
||||
|
||||
//Get Effect Number
|
||||
private _effectVarName = format [QGVAR(effect_%1), _effectName];
|
||||
private _effectNumber = _object getVariable [_effectVarName, -1];
|
||||
TRACE_2("current",_effectVarName,_effectNumber);
|
||||
|
||||
if (_effectNumber == -1) exitWith { //Nil array - no effect
|
||||
[false, []]
|
||||
};
|
||||
if (_effectNumber == 0) exitWith { //empty array - false effect
|
||||
[true, []]
|
||||
};
|
||||
|
||||
//if no change: skip sending publicVar and events
|
||||
private _effectBoolArray = [_effectNumber, count _statusReasons] call FUNC(binarizeNumber);
|
||||
TRACE_2("bitArray",_statusIndex,_effectBoolArray);
|
||||
|
||||
private _activeEffects = [];
|
||||
{
|
||||
if (_x) then {
|
||||
_activeEffects pushBack (_statusReasons select _forEachIndex);
|
||||
};
|
||||
} forEach _effectBoolArray;
|
||||
|
||||
//non-empty array - true effect
|
||||
[true, _activeEffects]
|
@ -28,7 +28,7 @@ if !(GVAR(settingsInitFinished)) exitWith {
|
||||
GVAR(runAtSettingsInitialized) pushBack [FUNC(statusEffect_set), _this];
|
||||
};
|
||||
|
||||
if (isNull _object) exitWith {ACE_LOGERROR_1("setStatusEffect - Bad Input %1", _this)};
|
||||
if (isNull _object) exitWith {TRACE_1("null",_object);};
|
||||
|
||||
[_object, true] call FUNC(statusEffect_resetVariables); //Check for mismatch, and set object ref
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user