SOG Compat - Fix remote punji traps not causing damage (#8755)

* Initial commit

* derp

* fix derp

* fix derp again

* don't code without coffee

* damage locality is weird, bi pls fix

* Update fnc_handlePunjiTrapTrigger.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
GhostIsSpooky 2022-03-07 15:25:55 -03:00 committed by GitHub
parent b1451d75f0
commit 3b62af6131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 10 deletions

View File

@ -42,7 +42,7 @@ class vn_mine_punji_01_ammo: APERSBoundingMine_Range_Ammo {
class EventHandlers { class EventHandlers {
class ADDON { class ADDON {
AmmoHit = QUOTE(call FUNC(handlePunjiTrapDamage)); AmmoHit = QUOTE(call FUNC(handlePunjiTrapTrigger));
}; };
}; };
}; };
@ -57,7 +57,7 @@ class vn_mine_punji_03_ammo: vn_mine_punji_01_ammo {
class EventHandlers { class EventHandlers {
class ADDON { class ADDON {
AmmoHit = QUOTE(call FUNC(handlePunjiTrapDamage)); AmmoHit = QUOTE(call FUNC(handlePunjiTrapTrigger));
}; };
}; };
}; };

View File

@ -10,6 +10,12 @@ class Extended_PreInit_EventHandlers {
}; };
}; };
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};
class Extended_InitPost_EventHandlers { class Extended_InitPost_EventHandlers {
class GVAR(spiderhole_01_nogeo) { class GVAR(spiderhole_01_nogeo) {
class ADDON { class ADDON {

View File

@ -1,2 +1,3 @@
PREP(disableCookoff); PREP(disableCookoff);
PREP(handlePunjiTrapDamage); PREP(handlePunjiTrapDamage);
PREP(handlePunjiTrapTrigger);

View File

@ -0,0 +1 @@
[QGVAR(handlePunjiTrapDamage), LINKFUNC(handlePunjiTrapDamage)] call CBA_fnc_addEventHandler;

View File

@ -5,6 +5,7 @@
* *
* Arguments: * Arguments:
* 0: Punji trap <OBJECT> * 0: Punji trap <OBJECT>
* 1: Affected units <ARRAY of OBJECT>
* *
* Return Value: * Return Value:
* None * None
@ -14,16 +15,10 @@
* *
* Public: No * Public: No
*/ */
params ["_trap"]; params ["_trap", "_affectedUnits"];
if (!(["ACE_Medical"] call EFUNC(common,isModLoaded))) exitWith {};
private _radius = getNumber (configOf _trap >> "indirectHitRange");
private _affectedUnits = (_trap nearEntities ["CAManBase", _radius]) select {local _x} select {isDamageAllowed _x};
(getShotParents _trap) params ["", "_instigator"]; (getShotParents _trap) params ["", "_instigator"];
if (_affectedUnits isEqualTo []) exitWith {};
private _bodyParts = []; private _bodyParts = [];
private _stabCount = 0; private _stabCount = 0;
@ -49,4 +44,4 @@ switch (typeOf _trap select [0, 16]) do {
for "_i" from 0 to _stabCount do { for "_i" from 0 to _stabCount do {
[_x, random [1, 2, 3], selectRandom _bodyParts, "stab", _instigator] call EFUNC(medical,addDamageToUnit); [_x, random [1, 2, 3], selectRandom _bodyParts, "stab", _instigator] call EFUNC(medical,addDamageToUnit);
}; };
} forEach _affectedUnits; } forEach _affectedUnits select {isDamageAllowed _x}; // isDamageAllowed already does local check

View File

@ -0,0 +1,25 @@
#include "script_component.hpp"
/*
* Author: GhostIsSpooky
* Handler for 'detonation' of a local punji trap. Workaround for local-only ammo hit event.
*
* Arguments:
* 0: Punji trap <OBJECT>
*
* Return Value:
* None
*
* Example:
* [trap] call ace_compat_sog_fnc_handlePunjiTrapTrigger
*
* Public: No
*/
params ["_trap"];
if (!(["ACE_Medical"] call EFUNC(common,isModLoaded))) exitWith {};
private _radius = getNumber (configOf _trap >> "indirectHitRange");
private _affectedUnits = (_trap nearEntities ["CAManBase", _radius]);
if (_affectedUnits isEqualTo []) exitWith {};
[QGVAR(handlePunjiTrapDamage), [_trap, _affectedUnits], _affectedUnits] call CBA_fnc_targetEvent;