From 409851dd8ce9faeb352d7f88f6fdc2762e90ea3a Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 28 Apr 2015 23:57:11 -0500 Subject: [PATCH] Attach the real explosive --- addons/explosives/functions/fnc_onLanded.sqf | 9 ++++++++- .../explosives/functions/fnc_placeExplosive.sqf | 15 ++++++++++++--- addons/explosives/functions/fnc_startTimer.sqf | 1 + addons/explosives/functions/fnc_triggerType.sqf | 5 ++++- addons/explosives/script_component.hpp | 2 ++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/addons/explosives/functions/fnc_onLanded.sqf b/addons/explosives/functions/fnc_onLanded.sqf index 59487e651c..f2ed729b1a 100644 --- a/addons/explosives/functions/fnc_onLanded.sqf +++ b/addons/explosives/functions/fnc_onLanded.sqf @@ -1,7 +1,10 @@ /* * Author: Garth 'L-H' de Wet + * Handles the "EpeContactStart" event when placing the explosive. * * Arguments: + * 0: Explosive Placing Object + * 1: Colliding Object * * Return Value: * None @@ -14,19 +17,23 @@ #include "script_component.hpp" EXPLODE_2_PVT(_this,_explosive,_hitTarget); +TRACE_2("Explosive EpeContactStart",_explosive,_hitTarget); + if ((_explosive getVariable [QGVAR(Handled), false])) exitWith {}; _explosive setVariable [QGVAR(Handled), true]; if (!isNull _hitTarget && {_hitTarget isKindOf "AllVehicles"}) then { + TRACE_1("Attaching to",_hitTarget); _explosive attachTo [_hitTarget]; private "_dir"; - _dir = _setup getVariable [QGVAR(Direction), 0]; + _dir = _explosive getVariable [QGVAR(Direction), 0]; _dir = _dir - (getDir _hitTarget); [[_explosive, _dir, 0], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc); } else { [{ EXPLODE_2_PVT(_this,_player,_explosive); private "_pos"; + _pos = getPosASL _explosive; if (surfaceIsWater _pos) then { _pos = getPosASL _explosive; _explosive setPosASL _pos; diff --git a/addons/explosives/functions/fnc_placeExplosive.sqf b/addons/explosives/functions/fnc_placeExplosive.sqf index 228e8eef23..4bed019d47 100644 --- a/addons/explosives/functions/fnc_placeExplosive.sqf +++ b/addons/explosives/functions/fnc_placeExplosive.sqf @@ -21,10 +21,14 @@ * Public: Yes */ #include "script_component.hpp" -private ["_ammo", "_explosive"]; +private ["_ammo", "_explosive", "_attachedTo", "_expPos", "_magazineTrigger"]; EXPLODE_6_PVT(_this,_unit,_pos,_dir,_magazineClass,_triggerConfig,_triggerSpecificVars); -if (count _this > 6) then { - deleteVehicle (_this select 6); +DEFAULT_PARAM(6,_setupPlaceholderObject,objNull); + +_attachedTo = objNull; +if (!isNull _setupPlaceholderObject) then { + _attachedTo = attachedTo _setupPlaceholderObject; + deleteVehicle _setupPlaceholderObject; }; if (isNil "_triggerConfig") exitWith { @@ -57,6 +61,11 @@ _expPos = getPosATL _explosive; _defuseHelper setPosATL (((getPosATL _defuseHelper) vectorAdd (_pos vectorDiff _expPos))); _explosive setPosATL _pos; +if (!isNull _attachedTo) then { + TRACE_1("Attaching Live Explosive",_attachedTo); + _explosive attachTo [_attachedTo]; +}; + if (isText(_triggerConfig >> "onPlace") && {[_unit,_explosive,_magazineClass,_triggerSpecificVars] call compile (getText (_triggerConfig >> "onPlace"))}) exitWith {_explosive}; [[_explosive, _dir, getNumber (_magazineTrigger >> "pitch")], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc); diff --git a/addons/explosives/functions/fnc_startTimer.sqf b/addons/explosives/functions/fnc_startTimer.sqf index 13da62ec29..9d2ca0aee4 100644 --- a/addons/explosives/functions/fnc_startTimer.sqf +++ b/addons/explosives/functions/fnc_startTimer.sqf @@ -19,6 +19,7 @@ EXPLODE_2_PVT(_this,_explosive,_delay); [{ + private ["_explosive"]; _explosive = _this; if (!isNull _explosive) then { [_explosive, -1, [_explosive, 0]] call FUNC(detonateExplosive); diff --git a/addons/explosives/functions/fnc_triggerType.sqf b/addons/explosives/functions/fnc_triggerType.sqf index fc6a0b90c1..f9d8790a56 100644 --- a/addons/explosives/functions/fnc_triggerType.sqf +++ b/addons/explosives/functions/fnc_triggerType.sqf @@ -14,7 +14,10 @@ * Public: Yes */ #include "script_component.hpp" -private "_result"; + +private["_result", "_config", "_count", "_index", "_supports"]; +// IGNORE_PRIVATE_WARNING(_supports); + _result = []; _config = getArray (ConfigFile >> "CfgMagazines" >> (_this select 0) >> "ACE_Triggers" >> "SupportedTriggers"); _count = count _config; diff --git a/addons/explosives/script_component.hpp b/addons/explosives/script_component.hpp index 60c7e88d06..5ff12b8ba3 100644 --- a/addons/explosives/script_component.hpp +++ b/addons/explosives/script_component.hpp @@ -1,6 +1,8 @@ #define COMPONENT explosives #include "\z\ace\addons\main\script_mod.hpp" +// #define DEBUG_MODE_FULL + #ifdef DEBUG_ENABLED_EXPLOSIVES #define DEBUG_MODE_FULL #endif