Made explosives use children action points rather than the listbox at all points.

Added the ability to defuse on explosives. "on explosives", there is a helper object that handles defusing.

Known issue, it appears that the attachTo explosives don't detonate. This means the currently approach should be changed to a object variable method, instead of an attached object method.
This commit is contained in:
Garth L-H de Wet 2015-03-31 23:20:32 +02:00
parent 613257141b
commit c020128f0e
11 changed files with 133 additions and 112 deletions

View File

@ -15,7 +15,8 @@ class CfgVehicles {
class ACE_Detonate {
displayName = $STR_ACE_Explosives_Detonate;
condition = QUOTE([_player] call FUNC(canDetonate));
statement = QUOTE([_player] call FUNC(openTransmitterUI););
statement = "";
insertChildren = QUOTE([_player] call FUNC(openTransmitterUI););
exceptions[] = {"isNotSwimming"};
showDisabled = 1;
icon = PATHTOF(UI\Explosives_Menu_ca.paa);
@ -33,16 +34,6 @@ class CfgVehicles {
priority = 1;
hotkey = "P";
};
class ACE_Defuse {
displayName = $STR_ACE_Explosives_Defuse;
condition = QUOTE([_player] call FUNC(canDefuse));
statement = QUOTE([ARR_2(_player,EGVAR(Interaction,Target))] call FUNC(startDefuse););
exceptions[] = {"isNotSwimming"};
showDisabled = 0;
icon = PATHTOF(UI\Defuse_ca.paa);
priority = 0.8;
hotkey = "F";
};
class ACE_Cellphone {
displayName = $STR_ACE_Explosives_cellphone_displayName;
condition = "('ACE_Cellphone' in (items ace_player))";
@ -57,6 +48,36 @@ class CfgVehicles {
};
class Items_base_F;
class ACE_DefuseObject: Items_base_F {
XEH_ENABLED;
author = "ACE";
_generalMacro = "ACE_DefuseObject";
displayName = "ACE Defuse Helper";
mapSize = 0.2;
icon = "iconObject_1x2";
model = "\A3\Weapons_f\dummyweapon.p3d";
scope = 2;
scopeCurator = 1;
vehicleClass = "Cargo";
class ACE_Actions {
class ACE_MainActions {
selection = "";
distance = 5;
condition = "true";
class ACE_Defuse {
displayName = $STR_ACE_Explosives_Defuse;
condition = QUOTE([_player] call FUNC(canDefuse));
statement = QUOTE([ARR_2(_player,_target)] call FUNC(startDefuse););
exceptions[] = {"isNotSwimming"};
showDisabled = 0;
icon = PATHTOF(UI\Defuse_ca.paa);
priority = 0.8;
hotkey = "F";
distance = 5;
};
};
};
};
class ACE_Explosives_Place: Items_base_F {
XEH_ENABLED;
author = "ACE";
@ -79,7 +100,8 @@ class CfgVehicles {
displayName = "$STR_ACE_Explosives_TriggerMenu";
distance = 4;
condition = "true";
statement = QUOTE([_target getVariable QUOTE(QGVAR(class))] call FUNC(openTriggerSelectionUI););
statement = "";
insertChildren = QUOTE([ARR_3(_target getVariable QUOTE(QGVAR(class)),_target,_player)] call FUNC(openTriggerSelectionUI););
showDisabled = 0;
exceptions[] = {};
priority = 5;

View File

@ -11,7 +11,7 @@
* Public: No
*/
#include "script_component.hpp"
private ["_mags", "_item", "_index", "_actions"];
private ["_mags", "_item", "_index", "_children"];
EXPLODE_1_PVT(_this,_unit);
@ -34,22 +34,20 @@ _itemCount = [];
_children = [];
{
_action = [
[format ["Explosive_%1", _forEachIndex]],
format [getText(_x >> "displayName") + " (%1)", _itemCount select _foreachIndex],
getText(_x >> "picture"),
"",
{(_this select 2) call FUNC(openTriggerSelectionUI)},
{true},
2,
[false,false,false,false],
{},
[configName _x]
] call EFUNC(interact_menu,createAction);
_action pushBack _unit;
_children pushBack _action
_children pushBack
[
[
format ["Explosive_%1", _forEachIndex],
format [getText(_x >> "displayName") + " (%1)", _itemCount select _foreachIndex],
getText(_x >> "picture"),
{(_this select 2) call FUNC(setupExplosive);},
{true},
{},
[_unit, configName _x]
] call EFUNC(interact_menu,createAction),
[],
_unit
];
} foreach _list;
_children

View File

@ -21,18 +21,4 @@ _isSpecialist = [_unit] call EFUNC(Common,isEOD);
if (GVAR(RequireSpecialist) && {!_isSpecialist}) exitWith {false};
_timeBombCore = nearestObject [_unit, "TimeBombCore"];
_mineBase = nearestObject [_unit, "MineBase"];
_distCore = _unit distance _timeBombCore;
_distBase = _unit distance _mineBase;
_distance = 10;
if (_distCore < _distBase) then {
_distance = _distCore;
EGVAR(interaction,Target) = _timeBombCore;
}else{
_distance = _distBase;
EGVAR(interaction,Target) = _mineBase;
};
if (isNil "_distance") exitWith {false};
_distance < 4
true

View File

@ -23,4 +23,10 @@ if (getNumber (ConfigFile >> "CfgAmmo" >> typeof _explosive >> "ACE_explodeOnDef
[_unit, -1, [_explosive, 1], true] call FUNC(detonateExplosive);
};
_helper = (attachedTo _explosive);
if (!isNull(_helper)) then {
detach _explosive;
deleteVehicle _helper;
};
_unit action ["Deactivate", _unit, _explosive];

View File

@ -28,6 +28,12 @@ _result = true;
if (!_ignoreRange && {(_unit distance (_item select 0)) > _range}) exitWith {false};
_helper = (attachedTo (_item select 0));
if (!isNull(_helper)) then {
detach (_item select 0);
deleteVehicle _helper;
};
if (getNumber (ConfigFile >> "CfgAmmo" >> typeof (_item select 0) >> "TriggerWhenDestroyed") == 0) then {
private ["_exp", "_previousExp"];
_previousExp = _item select 0;
@ -44,7 +50,7 @@ if (getNumber (ConfigFile >> "CfgAmmo" >> typeof (_item select 0) >> "TriggerWhe
[{
_explosive = _this;
if (!isNull _explosive) then {
_explosive setDamage 1;
_explosive setDamage 1;
};
}, _item select 0, _item select 1, 0] call EFUNC(common,waitAndExecute);

View File

@ -15,47 +15,42 @@
* Public: No
*/
#include "script_component.hpp"
private ["_unit","_result", "_item"];
private ["_unit","_result", "_item", "_children"];
call EFUNC(interaction,hideMenu);
_unit = _this select 0;
_detonator = _this select 1;
_range = GetNumber (ConfigFile >> "CfgWeapons" >> _detonator >> "ACE_Range");
_result = [_unit] call FUNC(getPlacedExplosives);
_actions = [localize "STR_ACE_Explosives_DetonateMenu", localize "STR_ACE_Explosives_Detonate"]
call EFUNC(interaction,prepareSelectMenu);
_children = [];
_count = 0;
{
if (!isNull(_x select 0)) then {
_required = getArray (ConfigFile >> "CfgACE_Triggers" >> (_x select 4) >> "requires");
if (_detonator in _required) then {
_item = ConfigFile >> "CfgMagazines" >> (_x select 3);
_actions = [
_actions,
_x select 2,
getText(_item >> "picture"),
[_foreachIndex, _range]
] call EFUNC(interaction,AddSelectableItem);
_children pushBack
[
[
format ["Explosive_%1", _forEachIndex],
_x select 2,
getText(_item >> "picture"),
{(_this select 2) call FUNC(detonateExplosive);},
{true},
{},
[ACE_player,_range,_x]
] call EFUNC(interact_menu,createAction),
[],
ACE_Player
];
_count = _count + 1;
};
};
} foreach _result;
if (_count > 0) then {
[
_actions,
{
[
ACE_player,
[_this select 1] call EFUNC(common,toNumber),
(ACE_player getVariable [QGVAR(Clackers), []]) select ([_this select 0] call EFUNC(common,toNumber)),
false
] call FUNC(detonateExplosive);
call EFUNC(interaction,hideMenu);
},
{[ACE_player] call FUNC(openTransmitterUI);}
] call EFUNC(interaction,openSelectMenu);
}else{
if (_count == 0) then {
call EFUNC(interaction,hideMenu);
[ACE_player] call FUNC(openTransmitterUI);
[localize "STR_ACE_Explosives_NoExplosivesAvailable"] call EFUNC(common,displayTextStructured);
};
_children

View File

@ -14,35 +14,32 @@
* Public: No
*/
#include "script_component.hpp"
private ["_items", "_unit", "_count", "_actions", "_config"];
private ["_items", "_unit", "_count", "_children", "_config"];
_unit = _this select 0;
_items = (items _unit);
_actions = [localize "STR_ACE_Explosives_TriggerMenu", localize "STR_ACE_Explosives_SelectTrigger"]
call EFUNC(interaction,prepareSelectMenu);
_detonators = [_unit] call FUNC(getDetonators);
_children = [];
{
_config = ConfigFile >> "CfgWeapons" >> _x;
_actions = [
_actions,
getText(_config >> "displayName"),
getText(_config >> "picture"),
_x
] call EFUNC(interaction,addSelectableItem);
} count _detonators;
_children pushBack
[
[
format ["Trigger_%1", _forEachIndex],
getText(_config >> "displayName"),
getText(_config >> "picture"),
{},
{true},
{(_this select 2) call FUNC(openDetonateUI);},
[ACE_player,_x]
] call EFUNC(interact_menu,createAction),
[],
ACE_Player
];
} foreach _detonators;
if (count _detonators == 0) then {
call EFUNC(interaction,hideMenu);
"ACE_Explosives" call EFUNC(interaction,openMenuSelf);
[format[localize "STR_ACE_Explosives_NoTriggersAvailable", "player"]] call EFUNC(Common,displayTextStructured);
}else{
[
_actions,
{
[ACE_player, _this] call FUNC(openDetonateUI);
},
{
call EFUNC(interaction,hideMenu);
}
] call EFUNC(interaction,openSelectMenu);
};
_children

View File

@ -15,15 +15,15 @@
* Public: No
*/
#include "script_component.hpp"
private ["_magazine", "_hasRequiredItems","_triggerTypes", "_actions", "_detonators", "_required", "_magTriggers"];
private ["_magazine", "_hasRequiredItems","_triggerTypes", "_children", "_detonators", "_required", "_magTriggers"];
_magazine = _this select 0;
_explosive = _this select 1;
_detonators = [ACE_player] call FUNC(getDetonators);
_triggerTypes = [_magazine] call FUNC(triggerType);
_magTriggers = ConfigFile >> "CfgMagazines" >> _magazine >> "ACE_Triggers";
_actions = [localize "STR_ACE_Explosives_TriggerMenu", localize "STR_ACE_Explosives_SelectTrigger"]
call EFUNC(interaction,prepareSelectMenu);
_count = 0;
_children = [];
{
_required = getArray (_x >> "requires");
_hasRequiredItems = true;
@ -33,12 +33,20 @@ _count = 0;
};
} count _required;
if (_hasRequiredItems) then {
_actions = [
_actions,
if(isText(_magTriggers >> configName _x >> "displayName"))then{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")},
[configName _x, _magazine]
] call EFUNC(interaction,addSelectableItem);
_children pushBack
[
[
format ["Trigger_%1", _forEachIndex],
if(isText(_magTriggers >> configName _x >> "displayName"))then{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")},
{(_this select 2) call FUNC(selectTrigger);},
{true},
{},
[_explosive, _magazine, configName _x]
] call EFUNC(interact_menu,createAction),
[],
ACE_Player
];
_count = _count + 1;
};
} count _triggerTypes;
@ -46,13 +54,6 @@ _count = 0;
if (_count == 0) then {
[format[localize "STR_ACE_Explosives_NoTriggersAvailable",
getText(configFile >> "CfgMagazines" >> _magazine >> "DisplayName")]] call EFUNC(Common,displayTextStructured);
}else{
GVAR(explosive) = _this select 1;
[
_actions,
{
[GVAR(explosive),_this select 1, _this select 0] call FUNC(selectTrigger);
},
{closeDialog 0;GVAR(explosive) = objNull;}
] call EFUNC(interaction,openSelectMenu);
};
_children

View File

@ -50,7 +50,18 @@ if (isText(_magazineTrigger >> "ammo")) then {
_ammo = getText (_magazineTrigger >> "ammo");
};
_triggerSpecificVars pushBack _triggerConfig;
private ["_defuseHelper"];
_defuseHelper = createVehicle ["ACE_DefuseObject", _pos, [], 0, "NONE"];
_defuseHelper setPosATL _pos;
_explosive = createVehicle [_ammo, _pos, [], 0, "NONE"];
_explosive attachTo [_defuseHelper, [0,0,0], ""];
_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};

View File

@ -21,7 +21,6 @@ closeDialog 0;
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") && {[_explosive,_magazine] call compile getText (_config >> "onSetup")}) exitWith {};

View File

@ -17,7 +17,7 @@
#include "script_component.hpp"
private ["_unit","_target"];
_unit = _this select 0;
_target = _this select 1;
_target = (attachedObjects (_this select 1)) select 0;
_fnc_DefuseTime = {
_target = _this select 1;