Explosives are now placed first and then the trigger is set afterwards.

This commit is contained in:
Garth L-H de Wet 2015-02-20 03:28:16 +02:00
parent 477d8c9dec
commit 9d1b1e1b12
10 changed files with 93 additions and 94 deletions

View File

@ -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));
};
};
};
};

View File

@ -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;

View File

@ -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);
};
};

View File

@ -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);

View File

@ -3,24 +3,39 @@
* Opens the UI for timer setting of an explosive
*
* Arguments:
* 0: Magazine <STRING>
* 0: Explosive <OBJECT>
* 1: Magazine <STRING>
*
* 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]];

View File

@ -4,12 +4,13 @@
*
* Arguments:
* 0: Explosive Magazine <STRING>
* 1: Explosive <OBJECT>
*
* 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);
};

View File

@ -7,9 +7,9 @@
* 1: Position to place explosive <POSITION>
* 2: Rotation <NUMBER>
* 3: Magazine class <STRING>
* 4: Config of trigger <CONFIG>
* 4: Config of trigger <STRING>
* 5: Variables required for the trigger type <ARRAY>
* 6: Should direction be set <BOOL>
* 6: Explosive placeholder <OBJECT> <OPTIONAL>
*
* Return Value:
* Placed explosive <OBJECT>
@ -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

View File

@ -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);
*/

View File

@ -3,26 +3,27 @@
* Selects a trigger for an explosive.
*
* Arguments:
* 0: Magazine <STRING>
* 1: Trigger mode <STRING>
* 0: Explosive <OBJECT>
* 1: Magazine <STRING>
* 2: Trigger mode <STRING>
*
* 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;

View File

@ -5,43 +5,36 @@
* Arguments:
* 0: Unit <OBJECT>
* 1: Classname of explosive to place. (CfgMagazine class) <STRING>
* 2: Trigger Config <CONFIG>
* 3: Timer (optional) <NUMBER>
*
* 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",