From 9d1b1e1b1270e31daa34f5b14db06ef6c68b032c Mon Sep 17 00:00:00 2001 From: Garth L-H de Wet Date: Fri, 20 Feb 2015 03:28:16 +0200 Subject: [PATCH] Explosives are now placed first and then the trigger is set afterwards. --- addons/explosives/CfgVehicles.hpp | 24 +++++---- addons/explosives/config.cpp | 2 +- addons/explosives/functions/fnc_onLanded.sqf | 52 +++++++------------ .../explosives/functions/fnc_openPlaceUI.sqf | 2 +- .../functions/fnc_openTimerSetUI.sqf | 27 +++++++--- .../functions/fnc_openTriggerSelectionUI.sqf | 9 ++-- .../functions/fnc_placeExplosive.sqf | 13 ++--- .../functions/fnc_place_Approve.sqf | 6 ++- .../functions/fnc_selectTrigger.sqf | 17 +++--- .../functions/fnc_setupExplosive.sqf | 35 +++++-------- 10 files changed, 93 insertions(+), 94 deletions(-) diff --git a/addons/explosives/CfgVehicles.hpp b/addons/explosives/CfgVehicles.hpp index dc4bcf2bdc..6fa150a1e4 100644 --- a/addons/explosives/CfgVehicles.hpp +++ b/addons/explosives/CfgVehicles.hpp @@ -75,17 +75,21 @@ class CfgVehicles { vehicleClass = "Cargo"; ACE_offset[] = {0,0,0}; class ACE_Actions { - selection = ""; - class ACE_SetTrigger { + class ACE_MainActions { selection = ""; - displayName = "$STR_ACE_Explosives_TriggerMenu"; - distance = 4; - condition = QUOTE(true); - statement = QUOTE([_target getVariable QUOTE(QGVAR(class))] call FUNC(openTriggerSelectionUI);); - showDisabled = 0; - exceptions[] = {}; - priority = 0.3; - icon = QUOTE(PATHTOF(UI\Explosives_Menu_ca.paa)); + distance = 5; + condition = "true"; + class ACE_SetTrigger { + selection = ""; + displayName = "$STR_ACE_Explosives_TriggerMenu"; + distance = 4; + condition = "true"; + statement = QUOTE([_target getVariable QUOTE(QGVAR(class))] call FUNC(openTriggerSelectionUI);); + showDisabled = 0; + exceptions[] = {}; + priority = 5; + icon = QUOTE(PATHTOF(UI\Explosives_Menu_ca.paa)); + }; }; }; }; diff --git a/addons/explosives/config.cpp b/addons/explosives/config.cpp index da95d45e7e..428d0352b1 100644 --- a/addons/explosives/config.cpp +++ b/addons/explosives/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {"ACE_Clacker", "ACE_DefusalKit", "ACE_M26_Clacker", "ACE_DeadManSwitch", "ACE_Cellphone"}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common", "ace_interaction"}; + requiredAddons[] = {"ace_interaction", "ace_interact_menu"}; author[] = {"Garth 'L-H' de Wet"}; authorUrl = "http://garth.snakebiteink.co.za/"; VERSION_CONFIG; diff --git a/addons/explosives/functions/fnc_onLanded.sqf b/addons/explosives/functions/fnc_onLanded.sqf index 9846580d60..f55098fa36 100644 --- a/addons/explosives/functions/fnc_onLanded.sqf +++ b/addons/explosives/functions/fnc_onLanded.sqf @@ -13,40 +13,26 @@ */ #include "script_component.hpp" if (!((_this select 0) getVariable [QGVAR(Handled), false])) then { - private ["_player", "_pos", "_attachTo"]; - _player = ACE_player; - _player setVariable [QGVAR(PlantingExplosive), false]; - _pos = getPosATL (_this select 0); - (_this select 0) enableSimulationGlobal false; - if (surfaceIsWater _pos) then { - _pos = getPosASL (_this select 0); - (_this select 0) setPosASL _pos; - }else{ - (_this select 0) setPosATL _pos; - }; (_this select 0) setVariable [QGVAR(Handled), true]; - _attachTo = objNull; if (!isNull (_this select 1) && {(_this select 1) isKindOf "AllVehicles"}) then { - _attachTo = (_this select 1); - }; - private "_delay"; - _delay = getNumber(ConfigFile >> "CfgMagazines" >> ((_this select 0) getVariable [QGVAR(Class), ""]) >> "ACE_DelayTime"); - [{ - private ["_mag", "_setup", "_dir", "_player"]; - _setup = _this select 0; - _player = ACE_player; - _mag = _setup getVariable [QGVAR(Class), ""]; - _dir = _setup getVariable [QGVAR(Direction), 0]; - _explosive = [_player, _this select 2, _dir, _mag, _setup getVariable QGVAR(Trigger), - [_setup getVariable QGVAR(Timer)], isNull (_this select 1)] call FUNC(placeExplosive); - deleteVehicle _setup; - if (!isNull(_explosive)) then { - _player RemoveMagazine _mag; - if (!isNull (_this select 1)) then { - _explosive attachTo [(_this select 1)]; - _dir = _dir - (getDir (_this select 1)); - [[_explosive, _dir, 0], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc); + _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]; + _pos = getPosATL _explosive; + //_explosive enableSimulationGlobal false; + if (surfaceIsWater _pos) then { + _pos = getPosASL _explosive; + _explosive setPosASL _pos; + }else{ + _explosive setPosATL _pos; }; - }; - }, [(_this select 0),_attachTo, _pos], _delay, 0.1] call EFUNC(common,waitAndExecute); + _player RemoveMagazine _mag; + }, [ACE_player, _this select 0], 0.5, 0.1] call EFUNC(common,waitAndExecute); + }; }; diff --git a/addons/explosives/functions/fnc_openPlaceUI.sqf b/addons/explosives/functions/fnc_openPlaceUI.sqf index 5ad79381b1..619bd5bb08 100644 --- a/addons/explosives/functions/fnc_openPlaceUI.sqf +++ b/addons/explosives/functions/fnc_openPlaceUI.sqf @@ -47,7 +47,7 @@ _actions = [localize "STR_ACE_Explosives_PlaceMenu", localize "STR_ACE_Explosive [ _actions, { - [_this] call FUNC(openTriggerSelectionUI); + [ACE_player, _this] call FUNC(setupExplosive); }, { call EFUNC(interaction,hideMenu); diff --git a/addons/explosives/functions/fnc_openTimerSetUI.sqf b/addons/explosives/functions/fnc_openTimerSetUI.sqf index d7f6ef30d8..e37bef06e3 100644 --- a/addons/explosives/functions/fnc_openTimerSetUI.sqf +++ b/addons/explosives/functions/fnc_openTimerSetUI.sqf @@ -3,24 +3,39 @@ * Opens the UI for timer setting of an explosive * * Arguments: - * 0: Magazine + * 0: Explosive + * 1: Magazine * * Return Value: * None * * Example: - * ["SatchelCharge_Remote_Mag"] call ACE_Explosives_fnc_openTimerSetUI; + * [_explosive, "SatchelCharge_Remote_Mag"] call ACE_Explosives_fnc_openTimerSetUI; * * Public: No */ #include "script_component.hpp" -private ["_mag"]; -_mag = _this select 0; +EXPLODE_2_PVT(_this,_explosive,_mag); createDialog "RscACE_SelectTimeUI"; sliderSetRange [8845, 5, 900]; // 5seconds - 15minutes sliderSetPosition [8845, 30]; -buttonSetAction [8860, format[QUOTE([ARR_4(ACE_player,'%1','Timer',floor sliderPosition 8845)] call FUNC(setupExplosive);closeDialog 0;), _mag]]; -buttonSetAction [8855, format[QUOTE(['%1'] call FUNC(openTriggerSelectionUI);), _mag]]; +GVAR(explosive) = _explosive; + +DFUNC(SetTimer) = { + [ + ACE_player, + getPosATL GVAR(explosive), + GVAR(explosive) getVariable QGVAR(Direction), + GVAR(explosive) getVariable QGVAR(class), + "Timer", + [floor sliderPosition 8845], + GVAR(explosive) + ] call FUNC(placeExplosive); + closeDialog 0; +}; + +buttonSetAction [8860, QUOTE(call DFUNC(SetTimer);)]; +buttonSetAction [8855, QUOTE(closeDialog 0;)]; ctrlSetText [8870, format[localize "STR_ACE_Explosives_TimerMenu",0, 30]]; diff --git a/addons/explosives/functions/fnc_openTriggerSelectionUI.sqf b/addons/explosives/functions/fnc_openTriggerSelectionUI.sqf index 011bda9bee..3b818c7877 100644 --- a/addons/explosives/functions/fnc_openTriggerSelectionUI.sqf +++ b/addons/explosives/functions/fnc_openTriggerSelectionUI.sqf @@ -4,12 +4,13 @@ * * Arguments: * 0: Explosive Magazine + * 1: Explosive * * Return Value: * None * * Example: - * [lbData [8866, lbCurSel 8866]] call ACE_Explosives_fnc_openTriggerSelectionUI; + * [lbData [8866, lbCurSel 8866], _explosive] call ACE_Explosives_fnc_openTriggerSelectionUI; * * Public: No */ @@ -43,15 +44,15 @@ _count = 0; } count _triggerTypes; if (_count == 0) then { - [ACE_player] call FUNC(openPlaceUI); [format[localize "STR_ACE_Explosives_NoTriggersAvailable", getText(configFile >> "CfgMagazines" >> _magazine >> "DisplayName")]] call EFUNC(Common,displayTextStructured); }else{ + GVAR(explosive) = _this select 1; [ _actions, { - [_this select 1, _this select 0] call FUNC(selectTrigger); + [GVAR(explosive),_this select 1, _this select 0] call FUNC(selectTrigger); }, - {[ACE_player] call FUNC(openPlaceUI);} + {closeDialog 0;GVAR(explosive) = objNull;} ] call EFUNC(interaction,openSelectMenu); }; diff --git a/addons/explosives/functions/fnc_placeExplosive.sqf b/addons/explosives/functions/fnc_placeExplosive.sqf index 1e1ac44bdf..59e8d33959 100644 --- a/addons/explosives/functions/fnc_placeExplosive.sqf +++ b/addons/explosives/functions/fnc_placeExplosive.sqf @@ -7,9 +7,9 @@ * 1: Position to place explosive * 2: Rotation * 3: Magazine class - * 4: Config of trigger + * 4: Config of trigger * 5: Variables required for the trigger type - * 6: Should direction be set + * 6: Explosive placeholder * * Return Value: * Placed explosive @@ -28,9 +28,8 @@ _dir = _this select 2; _magazineClass = _this select 3; _triggerConfig = _this select 4; _triggerSpecificVars = _this select 5; -_setDir = true; if (count _this > 6) then { - _setDir = _this select 6; + deleteVehicle (_this select 6); }; if (isNil "_triggerConfig") exitWith { @@ -52,10 +51,8 @@ if (isText(_magazineTrigger >> "ammo")) then { }; _triggerSpecificVars pushBack _triggerConfig; _explosive = createVehicle [_ammo, _pos, [], 0, "NONE"]; + if (isText(_triggerConfig >> "onPlace") && {[_unit,_explosive,_magazineClass,_triggerSpecificVars] call compile (getText (_triggerConfig >> "onPlace"))}) exitWith {_explosive}; -if (_setDir) then { - [[_explosive, _dir, getNumber (_magazineTrigger >> "pitch")], QFUNC(setPosition)] - call EFUNC(common,execRemoteFnc); -}; +[[_explosive, _dir, getNumber (_magazineTrigger >> "pitch")], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc); _explosive diff --git a/addons/explosives/functions/fnc_place_Approve.sqf b/addons/explosives/functions/fnc_place_Approve.sqf index c416e198bf..0142b28702 100644 --- a/addons/explosives/functions/fnc_place_Approve.sqf +++ b/addons/explosives/functions/fnc_place_Approve.sqf @@ -23,10 +23,10 @@ private ["_mag", "_setup", "_player"]; _setup = GVAR(Setup); GVAR(Setup) = objNull; [GVAR(placer), "ACE_Explosives", false] call EFUNC(Common,setForceWalkStatus); +[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); GVAR(placer) = objNull; _player = ACE_player; -[_player, "DefaultAction", _player getVariable [QGVAR(Place), -1]] call EFUNC(Common,removeActionEventHandler); -[_player, "MenuBack", _player getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); call EFUNC(interaction,hideMouseHint); if ((_setup getVariable [QGVAR(Class), ""]) == "") exitWith { deleteVehicle _setup; @@ -43,6 +43,7 @@ _setup addEventHandler ["EpeContactStart", FUNC(onLanded)]; _setup enableSimulationGlobal true; _player playActionNow "MedicOther"; +/* [{ private ["_setup", "_player"]; _setup = _this; @@ -63,3 +64,4 @@ _player playActionNow "MedicOther"; _player RemoveMagazine _mag; }; }, _setup, 5, 0.5] call EFUNC(common,waitAndExecute); +*/ diff --git a/addons/explosives/functions/fnc_selectTrigger.sqf b/addons/explosives/functions/fnc_selectTrigger.sqf index 8c51fd2c9c..8afcfbb03b 100644 --- a/addons/explosives/functions/fnc_selectTrigger.sqf +++ b/addons/explosives/functions/fnc_selectTrigger.sqf @@ -3,26 +3,27 @@ * Selects a trigger for an explosive. * * Arguments: - * 0: Magazine - * 1: Trigger mode + * 0: Explosive + * 1: Magazine + * 2: Trigger mode * * Return Value: * None * * Example: - * ["SatchelCharge_Remote_Mag","Timer"] call ACE_Explosives_fnc_selectTrigger; + * [_explosive, "SatchelCharge_Remote_Mag","Timer"] call ACE_Explosives_fnc_selectTrigger; * * Public: No */ #include "script_component.hpp" private ["_magazine","_trigger"]; closeDialog 0; -_magazine = _this select 0; -_trigger = _this select 1; -_config = ConfigFile >> "CfgACE_Triggers" >> _trigger; call EFUNC(interaction,hideMenu); +EXPLODE_3_PVT(_this,_explosive,_magazine,_trigger); +_config = ConfigFile >> "CfgACE_Triggers" >> _trigger; +GVAR(explosive) = objNull; // If the onSetup function returns true, it is handled elsewhere -if (isText(_config >> "onSetup") && {[_magazine] call compile getText (_config >> "onSetup")}) exitWith {}; +if (isText(_config >> "onSetup") && {[_explosive,_magazine] call compile getText (_config >> "onSetup")}) exitWith {}; -[ACE_player, _magazine, _trigger] call FUNC(setupExplosive); +[ACE_player, getPosATL _explosive, _explosive getVariable [QGVAR(Direction), 0],_magazine, _trigger, [], _explosive] call ACE_Explosives_fnc_placeExplosive; diff --git a/addons/explosives/functions/fnc_setupExplosive.sqf b/addons/explosives/functions/fnc_setupExplosive.sqf index 7f80ba7e63..504f0e3f04 100644 --- a/addons/explosives/functions/fnc_setupExplosive.sqf +++ b/addons/explosives/functions/fnc_setupExplosive.sqf @@ -5,43 +5,36 @@ * Arguments: * 0: Unit * 1: Classname of explosive to place. (CfgMagazine class) - * 2: Trigger Config - * 3: Timer (optional) * * Return Value: * None * * Example: - * [player, "SatchelCharge_Remote_Mag", "Command"] call ACE_Explosives_fnc_SetupExplosive; + * [player, "SatchelCharge_Remote_Mag"] call ACE_Explosives_fnc_SetupExplosive; * * Public: Yes */ #include "script_component.hpp" -private ["_unit", "_class", "_config", "_timer"]; +closeDialog 0; +private ["_unit", "_class"]; _unit = _this select 0; _class = _this select 1; -_config = _this select 2; -_timer = _this select 3; GVAR(placer) = _unit; -// Commented out due to the fact there is a distinction between who can deactivate mines and who can plant them in standard configs. -// Would require custom config entries (ACE_ExplosiveSpecialist/ACE_Specialist) which excludes custom mods. -//if (ACE_Explosives_RequireSpecialist && {!([_unit] call ACE_Core_fnc_isEOD)}) exitWith {}; -if (isNil "_config") then { - _config = getArray(ConfigFile >> "CfgMagazines" >> _class >> "ACE_Triggers" >> "SupportedTriggers") select 0; -}; - -GVAR(Setup) = getText(ConfigFile >> "CfgMagazines" >> _class >> "ACE_SetupObject") createVehicleLocal [0,0,-10000]; +// TODO: check MP performance and MP compatible. +GVAR(Setup) = createVehicle [getText(ConfigFile >> "CfgMagazines" >> _class >> "ACE_SetupObject"),[0,0,-10000],[], 0, "NONE"]; GVAR(Setup) enableSimulationGlobal false; -GVAR(Setup) setVariable [QGVAR(Class), _class]; -GVAR(Setup) setVariable [QGVAR(Trigger), _config]; -//GVAR(Setup) setVariable [QGVAR(Offset), GetArray(ConfigFile >> "CfgVehicles" >> typeof GVAR(Setup) >> "ACE_Offset")]; -if (!isNil "_timer") then { - GVAR(Setup) setVariable [QGVAR(Timer), _timer]; -}; +GVAR(Setup) setVariable [QGVAR(class), _class]; +private "_container"; +_container = [GVAR(Setup),"",QUOTE(PATHTOF(UI\Explosives_Menu_ca.paa)),"",{}, {true}, 4] call EFUNC(interact_menu,addAction); +[_container,"Set Trigger", QUOTE(PATHTOF(UI\Explosives_Menu_ca.paa)),"", +{[_target getVariable QGVAR(class),_target] call FUNC(openTriggerSelectionUI)}, {true}, 4] call EFUNC(interact_menu,addAction); +[_container,"Pick up", QUOTE(PATHTOF(UI\Explosives_Menu_ca.paa)),"", +{ACE_Player addMagazine (_target getVariable QGVAR(class));deleteVehicle _target;}, {true}, 4] call EFUNC(interact_menu,addAction); [_unit, "ACE_Explosives", true] call EFUNC(common,setForceWalkStatus); GVAR(TweakedAngle) = 180; + [QGVAR(Placement),"OnEachFrame", { private "_player"; _player = ACE_player; @@ -50,12 +43,12 @@ GVAR(TweakedAngle) = 180; }; GVAR(pfeh_running) = true; _pos = (ASLtoATL eyePos _player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]); - //_pos = _pos vectorAdd ((VectorDir GVAR(Setup)) vectorCrossProduct (GVAR(Setup) getVariable [QGVAR(Offset), [0,0,0]])); GVAR(Setup) setPosATL _pos; if (ACE_Modifier == 0) then { GVAR(Setup) setDir (GVAR(TweakedAngle) + getDir _player); }; }] call CALLSTACK(BIS_fnc_addStackedEventHandler); + [localize "STR_ACE_Explosives_PlaceAction", localize "STR_ACE_Explosives_CancelAction", localize "STR_ACE_Explosives_ScrollAction"] call EFUNC(interaction,showMouseHint); _unit setVariable [QGVAR(Place), [_unit, "DefaultAction",