From 5379503772d81f3dee476a1b75a8359412d23e3a Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 14 Dec 2016 14:06:32 -0600 Subject: [PATCH] Fix deadman range, fix clacker transfer, use setShotParents (#4689) --- addons/explosives/XEH_postInit.sqf | 13 +++++++++++++ .../explosives/functions/fnc_detonateExplosive.sqf | 9 ++------- addons/explosives/functions/fnc_onIncapacitated.sqf | 11 +++++++---- .../explosives/functions/fnc_onInventoryChanged.sqf | 8 +++----- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/addons/explosives/XEH_postInit.sqf b/addons/explosives/XEH_postInit.sqf index 1ddd52cc53..7cc99bf921 100644 --- a/addons/explosives/XEH_postInit.sqf +++ b/addons/explosives/XEH_postInit.sqf @@ -22,6 +22,19 @@ //When getting knocked out in medical, trigger deadman explosives: //Event is global, only run on server (ref: ace_medical_fnc_setUnconscious) if (isServer) then { + [QGVAR(detonate), { + params ["_unit", "_explosive", "_delay"]; + TRACE_3("server detonate EH",_unit,_explosive,_delay); + _explosive setShotParents [_unit, _unit]; + [{ + params ["_explosive"]; + TRACE_1("exploding",_explosive); + if (!isNull _explosive) then { + _explosive setDamage 1; + }; + }, _explosive, _delay] call CBA_fnc_waitAndExecute; + }] call CBA_fnc_addEventHandler; + ["ace_unconscious", { params ["_unit", "_isUnconscious"]; if (!_isUnconscious) exitWith {}; diff --git a/addons/explosives/functions/fnc_detonateExplosive.sqf b/addons/explosives/functions/fnc_detonateExplosive.sqf index b7f4893e52..0b7f9f3fa4 100644 --- a/addons/explosives/functions/fnc_detonateExplosive.sqf +++ b/addons/explosives/functions/fnc_detonateExplosive.sqf @@ -43,12 +43,7 @@ if (getNumber (ConfigFile >> "CfgAmmo" >> typeOf (_item select 0) >> "TriggerWhe _exp setPosASL _pos; }; }; -[{ - params ["_explosive"]; - TRACE_1("exploding",_explosive); - if (!isNull _explosive) then { - _explosive setDamage 1; - }; -}, [_item select 0], (_item select 1)] call CBA_fnc_waitAndExecute; + +[QGVAR(detonate), [_unit, _item select 0, _item select 1]] call CBA_fnc_serverEvent; _result diff --git a/addons/explosives/functions/fnc_onIncapacitated.sqf b/addons/explosives/functions/fnc_onIncapacitated.sqf index 6bbf6152d3..96949e7719 100644 --- a/addons/explosives/functions/fnc_onIncapacitated.sqf +++ b/addons/explosives/functions/fnc_onIncapacitated.sqf @@ -19,11 +19,14 @@ params ["_unit"]; TRACE_1("params",_unit); -private ["_deadman"]; +// Exit if no item: +if (({_x == "ACE_DeadManSwitch"} count (items _unit)) == 0) exitWith {}; -_deadman = [_unit, "DeadManSwitch"] call FUNC(getPlacedExplosives); +private _range = getNumber (configFile >> "CfgWeapons" >> "ACE_DeadManSwitch" >> QGVAR(range)); +private _deadman = [_unit, "DeadManSwitch"] call FUNC(getPlacedExplosives); +TRACE_2("placed",_deadman,_range); { - [_unit, -1, _x, true] call FUNC(detonateExplosive); + [_unit, _range, _x, true] call FUNC(detonateExplosive); } forEach _deadman; //Handle deadman connected to explosive in inventory @@ -44,5 +47,5 @@ if (_connectedInventoryExplosive != "") then { private _explosive = createVehicle [_ammo, (getPos _unit), [], 0, "NONE"]; _explosive setPosASL (getPosASL _unit); - [_unit, -1, [_explosive, -1]] call FUNC(detonateExplosive); //Explode, ignoring range, with a random 0-1 second delay + [_unit, -1, [_explosive, 0.5]] call FUNC(detonateExplosive); //Explode, ignoring range, with a 0.5 second delay }; diff --git a/addons/explosives/functions/fnc_onInventoryChanged.sqf b/addons/explosives/functions/fnc_onInventoryChanged.sqf index 889e9e2186..f67995b1c9 100644 --- a/addons/explosives/functions/fnc_onInventoryChanged.sqf +++ b/addons/explosives/functions/fnc_onInventoryChanged.sqf @@ -21,17 +21,15 @@ params ["_receiver", "_giver", "_item"]; TRACE_3("params",_receiver,_giver,_item); -private ["_config", "_detonators"]; +if ((_receiver != ace_player) && {_giver != ace_player}) exitWith {}; -if (_receiver != ace_player) exitWith {}; - -_config = ConfigFile >> "CfgWeapons" >> _item; +private _config = ConfigFile >> "CfgWeapons" >> _item; if (isClass _config && {getNumber(_config >> QGVAR(Detonator)) == 1}) then { private ["_clackerItems"]; _clackerItems = _giver getVariable [QGVAR(Clackers), []]; _receiver setVariable [QGVAR(Clackers), (_receiver getVariable [QGVAR(Clackers), []]) + _clackerItems, true]; - _detonators = [_giver] call FUNC(getDetonators); + private _detonators = [_giver] call FUNC(getDetonators); if (count _detonators == 0) then { _giver setVariable [QGVAR(Clackers), nil, true]; };