mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Hit Reactions - Prevent AI's hitpart EH running on all clients (#10057)
also dynamically add ehs
This commit is contained in:
parent
565d64d50e
commit
130348d3a5
@ -1,27 +1,35 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
["ace_firedNonPlayer", {
|
||||
if (GVAR(weaponDropChanceArmHitPlayer) + GVAR(weaponDropChanceArmHitAI) == 0) exitWith {};
|
||||
|
||||
[QGVAR(updateFiredEHs), {
|
||||
TRACE_2("updateFiredEH",GVAR(weaponDropChanceArmHitPlayer),GVAR(weaponDropChanceArmHitAI));
|
||||
if (GVAR(weaponDropChanceArmHitPlayer) + GVAR(weaponDropChanceArmHitAI) == 0) then {
|
||||
if (isNil QGVAR(firedEHs)) exitWith {};
|
||||
{
|
||||
_x call CBA_fnc_removeEventHandler;
|
||||
} forEach GVAR(firedEHs);
|
||||
GVAR(firedEHs) = nil;
|
||||
TRACE_1("removed EHs",GVAR(firedEHs));
|
||||
} else {
|
||||
if (!isNil QGVAR(firedEHs)) exitWith {};
|
||||
private _firedEH = {
|
||||
if (!local (_this select 0)) exitWith {};
|
||||
(_this select 6) addEventHandler ["HitPart", {
|
||||
params ["", "_entity", "", "", "", "", "_selections"];
|
||||
|
||||
[_entity, _selections] call FUNC(checkWeaponDrop);
|
||||
}];
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
["ace_firedPlayer", {
|
||||
if (GVAR(weaponDropChanceArmHitPlayer) + GVAR(weaponDropChanceArmHitAI) == 0) exitWith {};
|
||||
|
||||
(_this select 6) addEventHandler ["HitPart", {
|
||||
params ["", "_entity", "", "", "", "", "_selections"];
|
||||
|
||||
[_entity, _selections] call FUNC(checkWeaponDrop);
|
||||
}];
|
||||
};
|
||||
GVAR(firedEHs) = [];
|
||||
{
|
||||
GVAR(firedEHs) pushBack [_x, [_x, _firedEH] call CBA_fnc_addEventHandler];
|
||||
} forEach ["ace_firedNonPlayer", "ace_firedPlayer"];
|
||||
TRACE_1("added EHs",GVAR(firedEHs));
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
[QGVAR(dropWeapon), {
|
||||
params ["_unit"];
|
||||
TRACE_1("dropWeaponEH",_unit);
|
||||
|
||||
if !(_unit getVariable [QGVAR(canDropWeapon), true]) exitWith {};
|
||||
|
||||
|
@ -8,8 +8,6 @@ PREP_RECOMPILE_END;
|
||||
|
||||
#include "initSettings.inc.sqf"
|
||||
|
||||
ADDON = true;
|
||||
|
||||
GVAR(armSelections) = [
|
||||
"leftshoulder",
|
||||
"rightshoulder",
|
||||
@ -21,3 +19,5 @@ GVAR(armSelections) = [
|
||||
"righthand",
|
||||
"rightarm"
|
||||
];
|
||||
|
||||
ADDON = true;
|
||||
|
@ -15,7 +15,8 @@ private _category = [LELSTRING(common,categoryUncategorized), QUOTE(COMPONENT_BE
|
||||
LSTRING(weaponDropChanceArmHitPlayer_displayName),
|
||||
_category,
|
||||
[0, 1, 0, 2, true],
|
||||
1
|
||||
1,
|
||||
{[QGVAR(updateFiredEHs)] call CBA_fnc_localEvent}
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
@ -24,5 +25,6 @@ private _category = [LELSTRING(common,categoryUncategorized), QUOTE(COMPONENT_BE
|
||||
LSTRING(weaponDropChanceArmHitAI_displayName),
|
||||
_category,
|
||||
[0, 1, 0, 2, true],
|
||||
1
|
||||
1,
|
||||
{[QGVAR(updateFiredEHs)] call CBA_fnc_localEvent}
|
||||
] call CBA_fnc_addSetting;
|
||||
|
Loading…
Reference in New Issue
Block a user