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"; vehicleClass = "Cargo";
ACE_offset[] = {0,0,0}; ACE_offset[] = {0,0,0};
class ACE_Actions { class ACE_Actions {
selection = ""; class ACE_MainActions {
class ACE_SetTrigger {
selection = ""; selection = "";
displayName = "$STR_ACE_Explosives_TriggerMenu"; distance = 5;
distance = 4; condition = "true";
condition = QUOTE(true); class ACE_SetTrigger {
statement = QUOTE([_target getVariable QUOTE(QGVAR(class))] call FUNC(openTriggerSelectionUI);); selection = "";
showDisabled = 0; displayName = "$STR_ACE_Explosives_TriggerMenu";
exceptions[] = {}; distance = 4;
priority = 0.3; condition = "true";
icon = QUOTE(PATHTOF(UI\Explosives_Menu_ca.paa)); 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[] = {}; units[] = {};
weapons[] = {"ACE_Clacker", "ACE_DefusalKit", "ACE_M26_Clacker", "ACE_DeadManSwitch", "ACE_Cellphone"}; weapons[] = {"ACE_Clacker", "ACE_DefusalKit", "ACE_M26_Clacker", "ACE_DeadManSwitch", "ACE_Cellphone"};
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common", "ace_interaction"}; requiredAddons[] = {"ace_interaction", "ace_interact_menu"};
author[] = {"Garth 'L-H' de Wet"}; author[] = {"Garth 'L-H' de Wet"};
authorUrl = "http://garth.snakebiteink.co.za/"; authorUrl = "http://garth.snakebiteink.co.za/";
VERSION_CONFIG; VERSION_CONFIG;

View File

@ -13,40 +13,26 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
if (!((_this select 0) getVariable [QGVAR(Handled), false])) then { 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]; (_this select 0) setVariable [QGVAR(Handled), true];
_attachTo = objNull;
if (!isNull (_this select 1) && {(_this select 1) isKindOf "AllVehicles"}) then { if (!isNull (_this select 1) && {(_this select 1) isKindOf "AllVehicles"}) then {
_attachTo = (_this select 1); _player RemoveMagazine _mag;
}; _explosive attachTo [(_this select 1)];
private "_delay"; _dir = _dir - (getDir (_this select 1));
_delay = getNumber(ConfigFile >> "CfgMagazines" >> ((_this select 0) getVariable [QGVAR(Class), ""]) >> "ACE_DelayTime"); [[_explosive, _dir, 0], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc);
[{ } else {
private ["_mag", "_setup", "_dir", "_player"]; [{
_setup = _this select 0; EXPLODE_2_PVT(_this,_player,_explosive);
_player = ACE_player; private ["_pos"];
_mag = _setup getVariable [QGVAR(Class), ""]; _player setVariable [QGVAR(PlantingExplosive), false];
_dir = _setup getVariable [QGVAR(Direction), 0]; _pos = getPosATL _explosive;
_explosive = [_player, _this select 2, _dir, _mag, _setup getVariable QGVAR(Trigger), //_explosive enableSimulationGlobal false;
[_setup getVariable QGVAR(Timer)], isNull (_this select 1)] call FUNC(placeExplosive); if (surfaceIsWater _pos) then {
deleteVehicle _setup; _pos = getPosASL _explosive;
if (!isNull(_explosive)) then { _explosive setPosASL _pos;
_player RemoveMagazine _mag; }else{
if (!isNull (_this select 1)) then { _explosive setPosATL _pos;
_explosive attachTo [(_this select 1)];
_dir = _dir - (getDir (_this select 1));
[[_explosive, _dir, 0], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc);
}; };
}; _player RemoveMagazine _mag;
}, [(_this select 0),_attachTo, _pos], _delay, 0.1] call EFUNC(common,waitAndExecute); }, [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, _actions,
{ {
[_this] call FUNC(openTriggerSelectionUI); [ACE_player, _this] call FUNC(setupExplosive);
}, },
{ {
call EFUNC(interaction,hideMenu); call EFUNC(interaction,hideMenu);

View File

@ -3,24 +3,39 @@
* Opens the UI for timer setting of an explosive * Opens the UI for timer setting of an explosive
* *
* Arguments: * Arguments:
* 0: Magazine <STRING> * 0: Explosive <OBJECT>
* 1: Magazine <STRING>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* ["SatchelCharge_Remote_Mag"] call ACE_Explosives_fnc_openTimerSetUI; * [_explosive, "SatchelCharge_Remote_Mag"] call ACE_Explosives_fnc_openTimerSetUI;
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_mag"]; EXPLODE_2_PVT(_this,_explosive,_mag);
_mag = _this select 0;
createDialog "RscACE_SelectTimeUI"; createDialog "RscACE_SelectTimeUI";
sliderSetRange [8845, 5, 900]; // 5seconds - 15minutes sliderSetRange [8845, 5, 900]; // 5seconds - 15minutes
sliderSetPosition [8845, 30]; sliderSetPosition [8845, 30];
buttonSetAction [8860, format[QUOTE([ARR_4(ACE_player,'%1','Timer',floor sliderPosition 8845)] call FUNC(setupExplosive);closeDialog 0;), _mag]]; GVAR(explosive) = _explosive;
buttonSetAction [8855, format[QUOTE(['%1'] call FUNC(openTriggerSelectionUI);), _mag]];
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]]; ctrlSetText [8870, format[localize "STR_ACE_Explosives_TimerMenu",0, 30]];

View File

@ -4,12 +4,13 @@
* *
* Arguments: * Arguments:
* 0: Explosive Magazine <STRING> * 0: Explosive Magazine <STRING>
* 1: Explosive <OBJECT>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [lbData [8866, lbCurSel 8866]] call ACE_Explosives_fnc_openTriggerSelectionUI; * [lbData [8866, lbCurSel 8866], _explosive] call ACE_Explosives_fnc_openTriggerSelectionUI;
* *
* Public: No * Public: No
*/ */
@ -43,15 +44,15 @@ _count = 0;
} count _triggerTypes; } count _triggerTypes;
if (_count == 0) then { if (_count == 0) then {
[ACE_player] call FUNC(openPlaceUI);
[format[localize "STR_ACE_Explosives_NoTriggersAvailable", [format[localize "STR_ACE_Explosives_NoTriggersAvailable",
getText(configFile >> "CfgMagazines" >> _magazine >> "DisplayName")]] call EFUNC(Common,displayTextStructured); getText(configFile >> "CfgMagazines" >> _magazine >> "DisplayName")]] call EFUNC(Common,displayTextStructured);
}else{ }else{
GVAR(explosive) = _this select 1;
[ [
_actions, _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); ] call EFUNC(interaction,openSelectMenu);
}; };

View File

@ -7,9 +7,9 @@
* 1: Position to place explosive <POSITION> * 1: Position to place explosive <POSITION>
* 2: Rotation <NUMBER> * 2: Rotation <NUMBER>
* 3: Magazine class <STRING> * 3: Magazine class <STRING>
* 4: Config of trigger <CONFIG> * 4: Config of trigger <STRING>
* 5: Variables required for the trigger type <ARRAY> * 5: Variables required for the trigger type <ARRAY>
* 6: Should direction be set <BOOL> * 6: Explosive placeholder <OBJECT> <OPTIONAL>
* *
* Return Value: * Return Value:
* Placed explosive <OBJECT> * Placed explosive <OBJECT>
@ -28,9 +28,8 @@ _dir = _this select 2;
_magazineClass = _this select 3; _magazineClass = _this select 3;
_triggerConfig = _this select 4; _triggerConfig = _this select 4;
_triggerSpecificVars = _this select 5; _triggerSpecificVars = _this select 5;
_setDir = true;
if (count _this > 6) then { if (count _this > 6) then {
_setDir = _this select 6; deleteVehicle (_this select 6);
}; };
if (isNil "_triggerConfig") exitWith { if (isNil "_triggerConfig") exitWith {
@ -52,10 +51,8 @@ if (isText(_magazineTrigger >> "ammo")) then {
}; };
_triggerSpecificVars pushBack _triggerConfig; _triggerSpecificVars pushBack _triggerConfig;
_explosive = createVehicle [_ammo, _pos, [], 0, "NONE"]; _explosive = createVehicle [_ammo, _pos, [], 0, "NONE"];
if (isText(_triggerConfig >> "onPlace") && {[_unit,_explosive,_magazineClass,_triggerSpecificVars] if (isText(_triggerConfig >> "onPlace") && {[_unit,_explosive,_magazineClass,_triggerSpecificVars]
call compile (getText (_triggerConfig >> "onPlace"))}) exitWith {_explosive}; 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 _explosive

View File

@ -23,10 +23,10 @@ private ["_mag", "_setup", "_player"];
_setup = GVAR(Setup); _setup = GVAR(Setup);
GVAR(Setup) = objNull; GVAR(Setup) = objNull;
[GVAR(placer), "ACE_Explosives", false] call EFUNC(Common,setForceWalkStatus); [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; GVAR(placer) = objNull;
_player = ACE_player; _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); call EFUNC(interaction,hideMouseHint);
if ((_setup getVariable [QGVAR(Class), ""]) == "") exitWith { if ((_setup getVariable [QGVAR(Class), ""]) == "") exitWith {
deleteVehicle _setup; deleteVehicle _setup;
@ -43,6 +43,7 @@ _setup addEventHandler ["EpeContactStart", FUNC(onLanded)];
_setup enableSimulationGlobal true; _setup enableSimulationGlobal true;
_player playActionNow "MedicOther"; _player playActionNow "MedicOther";
/*
[{ [{
private ["_setup", "_player"]; private ["_setup", "_player"];
_setup = _this; _setup = _this;
@ -63,3 +64,4 @@ _player playActionNow "MedicOther";
_player RemoveMagazine _mag; _player RemoveMagazine _mag;
}; };
}, _setup, 5, 0.5] call EFUNC(common,waitAndExecute); }, _setup, 5, 0.5] call EFUNC(common,waitAndExecute);
*/

View File

@ -3,26 +3,27 @@
* Selects a trigger for an explosive. * Selects a trigger for an explosive.
* *
* Arguments: * Arguments:
* 0: Magazine <STRING> * 0: Explosive <OBJECT>
* 1: Trigger mode <STRING> * 1: Magazine <STRING>
* 2: Trigger mode <STRING>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* ["SatchelCharge_Remote_Mag","Timer"] call ACE_Explosives_fnc_selectTrigger; * [_explosive, "SatchelCharge_Remote_Mag","Timer"] call ACE_Explosives_fnc_selectTrigger;
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_magazine","_trigger"]; private ["_magazine","_trigger"];
closeDialog 0; closeDialog 0;
_magazine = _this select 0;
_trigger = _this select 1;
_config = ConfigFile >> "CfgACE_Triggers" >> _trigger;
call EFUNC(interaction,hideMenu); 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 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: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Classname of explosive to place. (CfgMagazine class) <STRING> * 1: Classname of explosive to place. (CfgMagazine class) <STRING>
* 2: Trigger Config <CONFIG>
* 3: Timer (optional) <NUMBER>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [player, "SatchelCharge_Remote_Mag", "Command"] call ACE_Explosives_fnc_SetupExplosive; * [player, "SatchelCharge_Remote_Mag"] call ACE_Explosives_fnc_SetupExplosive;
* *
* Public: Yes * Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit", "_class", "_config", "_timer"]; closeDialog 0;
private ["_unit", "_class"];
_unit = _this select 0; _unit = _this select 0;
_class = _this select 1; _class = _this select 1;
_config = _this select 2;
_timer = _this select 3;
GVAR(placer) = _unit; 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. // TODO: check MP performance and MP compatible.
// Would require custom config entries (ACE_ExplosiveSpecialist/ACE_Specialist) which excludes custom mods. GVAR(Setup) = createVehicle [getText(ConfigFile >> "CfgMagazines" >> _class >> "ACE_SetupObject"),[0,0,-10000],[], 0, "NONE"];
//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];
GVAR(Setup) enableSimulationGlobal false; GVAR(Setup) enableSimulationGlobal false;
GVAR(Setup) setVariable [QGVAR(Class), _class]; GVAR(Setup) setVariable [QGVAR(class), _class];
GVAR(Setup) setVariable [QGVAR(Trigger), _config]; private "_container";
//GVAR(Setup) setVariable [QGVAR(Offset), GetArray(ConfigFile >> "CfgVehicles" >> typeof GVAR(Setup) >> "ACE_Offset")]; _container = [GVAR(Setup),"",QUOTE(PATHTOF(UI\Explosives_Menu_ca.paa)),"",{}, {true}, 4] call EFUNC(interact_menu,addAction);
if (!isNil "_timer") then { [_container,"Set Trigger", QUOTE(PATHTOF(UI\Explosives_Menu_ca.paa)),"",
GVAR(Setup) setVariable [QGVAR(Timer), _timer]; {[_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); [_unit, "ACE_Explosives", true] call EFUNC(common,setForceWalkStatus);
GVAR(TweakedAngle) = 180; GVAR(TweakedAngle) = 180;
[QGVAR(Placement),"OnEachFrame", { [QGVAR(Placement),"OnEachFrame", {
private "_player"; private "_player";
_player = ACE_player; _player = ACE_player;
@ -50,12 +43,12 @@ GVAR(TweakedAngle) = 180;
}; };
GVAR(pfeh_running) = true; GVAR(pfeh_running) = true;
_pos = (ASLtoATL eyePos _player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]); _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; GVAR(Setup) setPosATL _pos;
if (ACE_Modifier == 0) then { if (ACE_Modifier == 0) then {
GVAR(Setup) setDir (GVAR(TweakedAngle) + getDir _player); GVAR(Setup) setDir (GVAR(TweakedAngle) + getDir _player);
}; };
}] call CALLSTACK(BIS_fnc_addStackedEventHandler); }] call CALLSTACK(BIS_fnc_addStackedEventHandler);
[localize "STR_ACE_Explosives_PlaceAction", localize "STR_ACE_Explosives_CancelAction", [localize "STR_ACE_Explosives_PlaceAction", localize "STR_ACE_Explosives_CancelAction",
localize "STR_ACE_Explosives_ScrollAction"] call EFUNC(interaction,showMouseHint); localize "STR_ACE_Explosives_ScrollAction"] call EFUNC(interaction,showMouseHint);
_unit setVariable [QGVAR(Place), [_unit, "DefaultAction", _unit setVariable [QGVAR(Place), [_unit, "DefaultAction",