Skip to content

Commit 67f9763

Browse files
committed
Added - Zeus Module: Add Filtered Arsenal ability to spawn object
What ================= Added: ability for the existing Zeus arsenal to now spawn an object from a dropdown list if module is not placed on an object. Bear in mind that, it the selection list is kept blank, the module will fall back to allowing a selection of multiple objects on which to apply the arsenal. End result: A completely flexible module. Issue ID: #27
1 parent d2e6096 commit 67f9763

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

addons/core/XEH_preInit.sqf

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ private _bnb_e_settings = [
2727
"2BNB Utilities",
2828
false
2929
],
30+
[
31+
"bnb_e_arsenal_objects",
32+
"EDITBOX",
33+
["Arsenal Objects", "Classnames, separated by commas and without double quotations, of objects that are spawnable by ""Add Filtered Arsenal"" module"],
34+
["2BNB Zeus", "Arsenal"],
35+
"C_supplyCrate_F,B_Slingload_01_Ammo_F"
36+
],
3037
[
3138
"bnb_e_contam_aiDamage",
3239
"CHECKBOX",

addons/core/functions/zeus_modules/fn_addArsenal.sqf

+39-14
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ Description:
66
to an object.
77
88
Parameters:
9-
None
9+
0: _position - of the module <ARRAY>
10+
1: _objectUnderCursor - object the module was placed on <OBJECT>
1011
1112
Returns:
1213
Nothing
1314
1415
Examples:
15-
call bnb_e_core_fnc_addArsenal;
16+
[_position, _objectUnderCursor] call bnb_e_core_fnc_addArsenal;
1617
1718
Author:
1819
Arend
@@ -21,14 +22,6 @@ params [["_position", [0,0,0], [[]], 3], ["_objectUnderCursor", objNull, [objNul
2122

2223
private _objects = [_objectUnderCursor];
2324

24-
// Check if module placed on an object!
25-
if (isNull (_objects select 0)) then
26-
{
27-
_objects = [localize "STR_AMAE_OBJECTS"] call Achilles_fnc_SelectUnits;
28-
};
29-
if (isNil "_objects") exitWith {};
30-
if (_objects isEqualTo []) exitWith {[localize "STR_AMAE_NO_OBJECT_SELECTED"] call Achilles_fnc_ShowZeusErrorMessage};
31-
3225
// Show Filter Dialog
3326
private _availableFilters = [
3427
"None",
@@ -39,18 +32,50 @@ private _availableFilters = [
3932
"Mission"
4033
];
4134

42-
private _dialogResult = [
43-
"Add Contaminated Area", [["Filter", _availableFilters, 0]]
44-
] call Ares_fnc_showChooseDialog;
35+
private _arsenalObjects = [bnb_e_arsenal_objects, true] call bnb_e_core_fnc_strToArray;
36+
37+
private _dialogOptions = [["Filter", _availableFilters, 0]];
38+
private _dialogControls = [["_filter", 0]];
39+
40+
if (isNull (_objects select 0)) then {
41+
_dialogOptions = [[
42+
"Select object to spawn",
43+
[""] + (_arsenalObjects apply {getText (configfile >> "CfgVehicles" >> _x >> "displayName")})
44+
]] + _dialogOptions;
45+
46+
_dialogControls = [["_arsenalObject", 0]] + _dialogControls;
47+
};
48+
49+
private _dialogResult = ["Add Filtered Arsenal", _dialogOptions] call Ares_fnc_showChooseDialog;
4550

4651
// If the dialog was closed.
4752
if (_dialogResult isEqualTo []) exitWith {};
4853

4954
// Get the selected data
50-
_dialogResult params [["_filter", 0]];
55+
_dialogResult params _dialogControls;
56+
57+
58+
// Check if module placed on an object
59+
if (isNull (_objects select 0)) then {
60+
if (_arsenalObject == 0) then {
61+
// No object selected to be spawned
62+
_objects = [localize "STR_AMAE_OBJECTS"] call Achilles_fnc_SelectUnits;
63+
if (_objects isEqualTo []) exitWith {[localize "STR_AMAE_NO_OBJECT_SELECTED"] call Achilles_fnc_ShowZeusErrorMessage};
64+
65+
} else {
66+
// Object selected to be spawned
67+
private _type = _arsenalObjects select (_arsenalObject - 1);
68+
_object = _type createVehicle _position;
69+
[[_object]] call Ares_fnc_AddUnitsToCurator;
70+
_objects = [_object];
71+
};
72+
};
73+
74+
if (_objects isEqualTo []) exitWith {};
5175

5276
// Add Arsenal - Remotely, since only the server has 2BNB Framework loaded
5377
[[_availableFilters select _filter, _objects], bnb_f_core_fnc_arsenal, 2] call Achilles_fnc_spawn;
78+
[format ["Added %1 filtered arsenal to %2",_availableFilters select _filter, _objects], "core\functions\zeus_modules\fn_addArsenal.sqf"] call bnb_e_core_fnc_log;
5479

5580
// Show Message
5681
[localize "STR_AMAE_ARSENAL_ADDED"] call Ares_fnc_ShowZeusMessage;

addons/core/functions/zeus_modules/fn_addContaminationArea.sqf

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Description:
66
77
Parameters:
88
0: _position - of the module <ARRAY>
9-
0: _objectUnderCursor - object the module was placed on <OBJECT>
9+
1: _objectUnderCursor - object the module was placed on <OBJECT>
1010
1111
Returns:
1212
Nothing

0 commit comments

Comments
 (0)