diff --git a/addons/explosives/CfgVehicles.hpp b/addons/explosives/CfgVehicles.hpp index 2ef6dd77c0..ececb3b012 100644 --- a/addons/explosives/CfgVehicles.hpp +++ b/addons/explosives/CfgVehicles.hpp @@ -66,7 +66,7 @@ class CfgVehicles { condition = "true"; class ACE_Defuse { displayName = $STR_ACE_Explosives_Defuse; - condition = QUOTE([_player] call FUNC(canDefuse)); + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canDefuse)); statement = QUOTE([ARR_2(_player,_target)] call FUNC(startDefuse);); exceptions[] = {"isNotSwimming"}; showDisabled = 0; diff --git a/addons/explosives/functions/fnc_addClacker.sqf b/addons/explosives/functions/fnc_addClacker.sqf index 4746dc66f5..778afc8ae5 100644 --- a/addons/explosives/functions/fnc_addClacker.sqf +++ b/addons/explosives/functions/fnc_addClacker.sqf @@ -17,10 +17,8 @@ * Public: Yes */ #include "script_component.hpp" -private ["_unit", "_explosive", "_clacker", "_config", "_magazineClass", "_requiredItems", "_hasRequired"]; -_unit = _this select 0; -_explosive = _this select 1; -_magazineClass = _this select 2; +private ["_clacker", "_config", "_requiredItems", "_hasRequired"]; +EXPLODE_3_PVT(_this,_unit,_explosive,_magazineClass); // Config is the last item in the list of passed in items. _config = (_this select 3) select (count (_this select 3) - 1); diff --git a/addons/explosives/functions/fnc_addDetonateActions.sqf b/addons/explosives/functions/fnc_addDetonateActions.sqf index 65077323e5..745fab7b48 100644 --- a/addons/explosives/functions/fnc_addDetonateActions.sqf +++ b/addons/explosives/functions/fnc_addDetonateActions.sqf @@ -15,10 +15,9 @@ * Public: No */ #include "script_component.hpp" -private ["_unit","_result", "_item", "_children"]; +private ["_result", "_item", "_children"]; call EFUNC(interaction,hideMenu); -_unit = _this select 0; -_detonator = _this select 1; +EXPLODE_2_PVT(_this,_unit,_detonator); _range = GetNumber (ConfigFile >> "CfgWeapons" >> _detonator >> "ACE_Range"); _result = [_unit] call FUNC(getPlacedExplosives); diff --git a/addons/explosives/functions/fnc_addTriggerActions.sqf b/addons/explosives/functions/fnc_addTriggerActions.sqf index b95ae88134..fb8cb60f81 100644 --- a/addons/explosives/functions/fnc_addTriggerActions.sqf +++ b/addons/explosives/functions/fnc_addTriggerActions.sqf @@ -15,9 +15,9 @@ * Public: No */ #include "script_component.hpp" -private ["_magazine", "_hasRequiredItems","_triggerTypes", "_children", "_detonators", "_required", "_magTriggers"]; -_magazine = _this select 0; -_explosive = _this select 1; +private ["_hasRequiredItems","_triggerTypes", "_children", + "_detonators", "_required", "_magTriggers"]; +EXPLODE_2_PVT(_this,_magazine,_explosive); _detonators = [ACE_player] call FUNC(getDetonators); _triggerTypes = [_magazine] call FUNC(triggerType); @@ -37,9 +37,11 @@ _children = []; [ format ["Trigger_%1", _forEachIndex], if(isText(_magTriggers >> configName _x >> "displayName"))then - {getText(_magTriggers >> configName _x >> "displayName")}else{getText(_x >> "displayName")}, + {getText(_magTriggers >> configName _x >> "displayName")} + else{getText(_x >> "displayName")}, if(isText(_magTriggers >> configName _x >> "picture"))then - {getText(_magTriggers >> configName _x >> "picture")}else{getText(_x >> "picture")}, + {getText(_magTriggers >> configName _x >> "picture")} + else{getText(_x >> "picture")}, {(_this select 2) call FUNC(selectTrigger);}, {true}, {}, diff --git a/addons/explosives/functions/fnc_canDefuse.sqf b/addons/explosives/functions/fnc_canDefuse.sqf index 9ef0c14838..cd04564a9f 100644 --- a/addons/explosives/functions/fnc_canDefuse.sqf +++ b/addons/explosives/functions/fnc_canDefuse.sqf @@ -14,8 +14,12 @@ * Public: Yes */ #include "script_component.hpp" -private "_unit"; -_unit = _this select 0; +private ["_specialist"]; +EXPLODE_2_PVT(_this,_unit,_target); +if (isNull(_target getVariable [QGVAR(Explosive),objNull])) exitWith { + deleteVehicle _target; + false +}; if (vehicle _unit != _unit || {!("ACE_DefusalKit" in (items _unit))}) exitWith {false}; _isSpecialist = [_unit] call EFUNC(Common,isEOD); diff --git a/addons/explosives/functions/fnc_defuseExplosive.sqf b/addons/explosives/functions/fnc_defuseExplosive.sqf index 6df661a802..9f4b2045b3 100644 --- a/addons/explosives/functions/fnc_defuseExplosive.sqf +++ b/addons/explosives/functions/fnc_defuseExplosive.sqf @@ -15,18 +15,16 @@ * Public: Yes */ #include "script_component.hpp" -private ["_unit", "_explosive"]; -_unit = _this select 0; -_explosive = _this select 1; +EXPLODE_2_PVT(_this,_unit,_explosive); if (getNumber (ConfigFile >> "CfgAmmo" >> typeof _explosive >> "ACE_explodeOnDefuse") == 1) exitWith { [_unit, -1, [_explosive, 1], true] call FUNC(detonateExplosive); }; -_helper = (attachedTo _explosive); -if (!isNull(_helper)) then { - detach _explosive; - deleteVehicle _helper; -}; +{ + detach _x; + deleteVehicle _x; + false +} count (attachedObjects (_explosive)); _unit action ["Deactivate", _unit, _explosive]; diff --git a/addons/explosives/functions/fnc_detonateExplosive.sqf b/addons/explosives/functions/fnc_detonateExplosive.sqf index c1cf1d86db..90e40694e3 100644 --- a/addons/explosives/functions/fnc_detonateExplosive.sqf +++ b/addons/explosives/functions/fnc_detonateExplosive.sqf @@ -19,10 +19,8 @@ * Public: Yes */ #include "script_component.hpp" -private ["_item","_result", "_ignoreRange", "_unit", "_range"]; -_unit = _this select 0; -_range = _this select 1; -_item = _this select 2; +private ["_result", "_ignoreRange", "_helper"]; +EXPLODE_3_PVT(_this,_unit,_range,_item); _ignoreRange = (_range == -1); _result = true; diff --git a/addons/explosives/functions/fnc_getPlacedExplosives.sqf b/addons/explosives/functions/fnc_getPlacedExplosives.sqf index 4ebcdb8f0b..fce8e4334a 100644 --- a/addons/explosives/functions/fnc_getPlacedExplosives.sqf +++ b/addons/explosives/functions/fnc_getPlacedExplosives.sqf @@ -27,7 +27,7 @@ _adjustedList = false; _clackerList = _unit getVariable [QGVAR(Clackers), []]; _list = []; { - if isNull (_x select 0) then { + if (isNull (_x select 0)) then { _clackerList set [_foreachIndex, "X"]; _adjustedList = true; } else { diff --git a/addons/explosives/functions/fnc_handleScrollWheel.sqf b/addons/explosives/functions/fnc_handleScrollWheel.sqf index 8c842b8a05..3bef53e196 100644 --- a/addons/explosives/functions/fnc_handleScrollWheel.sqf +++ b/addons/explosives/functions/fnc_handleScrollWheel.sqf @@ -14,7 +14,6 @@ * Public: No */ #include "script_component.hpp" -private ["_obj"]; if (isNull(GVAR(Setup)) || {ACE_Modifier == 0} || !GVAR(pfeh_running)) exitWith {false}; _this = _this * 5; GVAR(Setup) setDir ((getDir GVAR(Setup)) + _this); diff --git a/addons/explosives/functions/fnc_onLanded.sqf b/addons/explosives/functions/fnc_onLanded.sqf index f55098fa36..bba841b36f 100644 --- a/addons/explosives/functions/fnc_onLanded.sqf +++ b/addons/explosives/functions/fnc_onLanded.sqf @@ -12,27 +12,28 @@ * Public: No */ #include "script_component.hpp" -if (!((_this select 0) getVariable [QGVAR(Handled), false])) then { - (_this select 0) setVariable [QGVAR(Handled), true]; - if (!isNull (_this select 1) && {(_this select 1) isKindOf "AllVehicles"}) then { - _player RemoveMagazine _mag; - _explosive attachTo [(_this select 1)]; - _dir = _dir - (getDir (_this select 1)); - [[_explosive, _dir, 0], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc); - } else { - [{ - EXPLODE_2_PVT(_this,_player,_explosive); - private ["_pos"]; - _player setVariable [QGVAR(PlantingExplosive), false]; +EXPLODE_2_PVT(_this,_explosive,_hitTarget); + +if ((_explosive getVariable [QGVAR(Handled), false])) exitWith {}; + +_explosive setVariable [QGVAR(Handled), true]; +if (!isNull _hitTarget && {_hitTarget isKindOf "AllVehicles"}) then { + _explosive attachTo [_hitTarget]; + private "_dir"; + _dir = _setup 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"; + _player setVariable [QGVAR(PlantingExplosive), false]; + if (surfaceIsWater _pos) then { + _pos = getPosASL _explosive; + _explosive setPosASL _pos; + }else{ _pos = getPosATL _explosive; - //_explosive enableSimulationGlobal false; - if (surfaceIsWater _pos) then { - _pos = getPosASL _explosive; - _explosive setPosASL _pos; - }else{ - _explosive setPosATL _pos; - }; - _player RemoveMagazine _mag; - }, [ACE_player, _this select 0], 0.5, 0.1] call EFUNC(common,waitAndExecute); - }; + _explosive setPosATL _pos; + }; + }, [ACE_player, _explosive], 0.5, 0.1] call EFUNC(common,waitAndExecute); }; diff --git a/addons/explosives/functions/fnc_placeExplosive.sqf b/addons/explosives/functions/fnc_placeExplosive.sqf index f91f448a55..efd566611c 100644 --- a/addons/explosives/functions/fnc_placeExplosive.sqf +++ b/addons/explosives/functions/fnc_placeExplosive.sqf @@ -21,13 +21,8 @@ * Public: Yes */ #include "script_component.hpp" -private ["_pos", "_dir", "_magazineClass", "_ammo", "_triggerSpecificVars", "_unit", "_triggerConfig", "_explosive"]; -_unit = _this select 0; -_pos = _this select 1; -_dir = _this select 2; -_magazineClass = _this select 3; -_triggerConfig = _this select 4; -_triggerSpecificVars = _this select 5; +private ["_ammo", "_explosive"]; +EXPLODE_6_PVT(_this,_unit,_pos,_dir,_magazineClass,_triggerConfig,_triggerSpecificVars); if (count _this > 6) then { deleteVehicle (_this select 6); }; @@ -55,13 +50,12 @@ _defuseHelper = createVehicle ["ACE_DefuseObject", _pos, [], 0, "NONE"]; _defuseHelper setPosATL _pos; _explosive = createVehicle [_ammo, _pos, [], 0, "NONE"]; -_explosive attachTo [_defuseHelper, [0,0,0], ""]; +_defuseHelper attachTo [_explosive, [0,0,0], ""]; +_defuseHelper setVariable [QGVAR(Explosive),_explosive,true]; _expPos = getPosATL _explosive; -_defuseHelper enableSimulationGlobal false; _defuseHelper setPosATL (((getPosATL _defuseHelper) vectorAdd (_pos vectorDiff _expPos))); _explosive setPosATL _pos; -_dir = (getDir _defuseHelper) - _dir; if (isText(_triggerConfig >> "onPlace") && {[_unit,_explosive,_magazineClass,_triggerSpecificVars] call compile (getText (_triggerConfig >> "onPlace"))}) exitWith {_explosive}; diff --git a/addons/explosives/functions/fnc_place_Approve.sqf b/addons/explosives/functions/fnc_place_Approve.sqf index 3b61d2572e..d39b6bc340 100644 --- a/addons/explosives/functions/fnc_place_Approve.sqf +++ b/addons/explosives/functions/fnc_place_Approve.sqf @@ -43,26 +43,3 @@ _setup addEventHandler ["EpeContactStart", FUNC(onLanded)]; _setup enableSimulationGlobal true; _player playActionNow "MedicOther"; _player removeMagazine (_setup getVariable [QGVAR(Class), ""]); - -/* -[{ - private ["_setup", "_player"]; - _setup = _this; - _player = ACE_player; - _player setVariable [QGVAR(PlantingExplosive), false]; - if (!isNull _setup) then { - private ["_mag", "_dir", "_delayTime"]; - _mag = _setup getVariable [QGVAR(Class), ""]; - _dir = _setup getVariable [QGVAR(Direction), 0]; - // TODO: Might need to handle this at some point? - //_delayTime = (getNumber(ConfigFile >> "CfgMagazines" >> _mag >> "ACE_DelayTime")) - 5; - //if (_delayTime > 0) then { - // sleep _delayTime; - //}; - [_player, GetPosATL _setup, _dir, _mag, _setup getVariable QGVAR(Trigger), - [_setup getVariable QGVAR(Timer)], true] call FUNC(placeExplosive); - deleteVehicle _setup; - _player RemoveMagazine _mag; - }; -}, _setup, 5, 0.5] call EFUNC(common,waitAndExecute); -*/ diff --git a/addons/explosives/functions/fnc_place_Cancel.sqf b/addons/explosives/functions/fnc_place_Cancel.sqf index c149d35584..3df4228c16 100644 --- a/addons/explosives/functions/fnc_place_Cancel.sqf +++ b/addons/explosives/functions/fnc_place_Cancel.sqf @@ -29,4 +29,4 @@ if (isNil {GVAR(placer)}) then { GVAR(placer) = objNull; call EFUNC(interaction,hideMouseHint); [ACE_player, "DefaultAction", ACE_player getVariable [QGVAR(Place), -1]] call EFUNC(Common,removeActionEventHandler); -[ACE_player, "MenuBack", ACE_player getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); +[ACE_player, "zoomtemp", ACE_player getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); diff --git a/addons/explosives/functions/fnc_setPosition.sqf b/addons/explosives/functions/fnc_setPosition.sqf index 2f61c522aa..035d47a6c3 100644 --- a/addons/explosives/functions/fnc_setPosition.sqf +++ b/addons/explosives/functions/fnc_setPosition.sqf @@ -16,10 +16,8 @@ * Public: Yes */ #include "script_component.hpp" -private "_ex"; -_ex = _this select 0; -_ex setDir (_this select 1); -if ((_this select 2) != 0) then { - [_ex, _this select 2, 0] call CALLSTACK(BIS_fnc_setPitchBank); +EXPLODE_3_PVT(_this,_explosive,_direction,_pitch); +_explosive setDir _direction; +if (_pitch != 0) then { + [_explosive, _pitch, 0] call CALLSTACK(BIS_fnc_setPitchBank); }; -//_ex setVectorUp (surfaceNormal _pos); diff --git a/addons/explosives/functions/fnc_setupExplosive.sqf b/addons/explosives/functions/fnc_setupExplosive.sqf index 479cefa3cf..a8af7e044b 100644 --- a/addons/explosives/functions/fnc_setupExplosive.sqf +++ b/addons/explosives/functions/fnc_setupExplosive.sqf @@ -16,9 +16,7 @@ */ #include "script_component.hpp" closeDialog 0; -private ["_unit", "_class"]; -_unit = _this select 0; -_class = _this select 1; +EXPLODE_2_PVT(_this,_unit,_class); GVAR(placer) = _unit; // TODO: check MP performance and MP compatible. GVAR(Setup) = createVehicle [getText(ConfigFile >> "CfgMagazines" >> _class >> "ACE_SetupObject"),[0,0,-10000],[], 0, "NONE"]; @@ -47,5 +45,5 @@ GVAR(TweakedAngle) = 180; localize "STR_ACE_Explosives_ScrollAction"] call EFUNC(interaction,showMouseHint); _unit setVariable [QGVAR(Place), [_unit, "DefaultAction", {GVAR(pfeh_running) AND !isNull (GVAR(Setup))}, {call FUNC(place_Approve);}] call EFUNC(common,AddActionEventHandler)]; -_unit setVariable [QGVAR(Cancel), [_unit, "MenuBack", +_unit setVariable [QGVAR(Cancel), [_unit, "zoomtemp", {GVAR(pfeh_running) AND !isNull (GVAR(Setup))}, {call FUNC(place_Cancel);}] call EFUNC(common,AddActionEventHandler)]; diff --git a/addons/explosives/functions/fnc_startDefuse.sqf b/addons/explosives/functions/fnc_startDefuse.sqf index 28dc639e9a..caf75b8519 100644 --- a/addons/explosives/functions/fnc_startDefuse.sqf +++ b/addons/explosives/functions/fnc_startDefuse.sqf @@ -15,18 +15,17 @@ * Public: Yes */ #include "script_component.hpp" -private ["_unit","_target"]; -_unit = _this select 0; -_target = (attachedObjects (_this select 1)) select 0; +EXPLODE_2_PVT(_this,_unit,_target); +_target = attachedTo (_target); _fnc_DefuseTime = { - _target = _this select 1; + EXPLODE_2_PVT(_this,_specialist,_target); _defuseTime = 5; if (isNumber(ConfigFile >> "CfgAmmo" >> typeOf (_target) >> "ACE_DefuseTime")) then { _defuseTime = getNumber(ConfigFile >> "CfgAmmo" >> typeOf (_target) >> "ACE_DefuseTime"); }; - if (!(_this select 0) && {GVAR(PunishNonSpecialists)}) then { + if (!_specialist && {GVAR(PunishNonSpecialists)}) then { _defuseTime = _defuseTime * 1.5; }; _defuseTime diff --git a/addons/explosives/functions/fnc_startTimer.sqf b/addons/explosives/functions/fnc_startTimer.sqf index f4b0876866..13da62ec29 100644 --- a/addons/explosives/functions/fnc_startTimer.sqf +++ b/addons/explosives/functions/fnc_startTimer.sqf @@ -21,6 +21,6 @@ EXPLODE_2_PVT(_this,_explosive,_delay); [{ _explosive = _this; if (!isNull _explosive) then { - [_explosive, -1, [_explosive, 0], true] call FUNC(detonateExplosive); + [_explosive, -1, [_explosive, 0]] call FUNC(detonateExplosive); }; }, _explosive, _delay, 0] call EFUNC(common,waitAndExecute);