Skip to content

Commit

Permalink
Merge pull request #167 from ultranoobian/master
Browse files Browse the repository at this point in the history
Add Dynamic Support Menu (DSM)
  • Loading branch information
ultranoobian authored Mar 14, 2018
2 parents 75a6598 + 2ba636b commit b1fad07
Show file tree
Hide file tree
Showing 21 changed files with 447 additions and 190 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/*
.vscode/*

DUWS-R.iml
localDevDeploy.properties
Expand Down
3 changes: 3 additions & 0 deletions source/INIT.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ for[{_x = 2},{_x <= 20},{_x = _x + 1}] do {
};
};


_dynam = [player,"DynamicSupportMenu"] call BIS_fnc_addCommMenuItem;

//Loading player position and gear.
//TODO: Add bought supports.
/*
Expand Down
2 changes: 1 addition & 1 deletion source/WARCOM/WARCOM_gps_marker.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WARCOM_marker_num = WARCOM_marker_num + 1;
if (_units_alive<=0) exitWith { // IF ALL DEAD, EXIT.
str(_markername) setMarkerColor "ColorRed";
str(_markername) setMarkerType "waypoint";
PAPABEAR sidechat format["To all units, this is HQ, Task force %1 just got wiped out. Stay alert",_TFname];
[west, "PAPA_BEAR"] sidechat format["To all units, this is HQ, Task force %1 just got wiped out. Stay alert",_TFname];
sleep 600;
deleteMarker str(_markername);
};
Expand Down
10 changes: 0 additions & 10 deletions source/dialog/request_support.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ switch (_index2) do {
if (!support_supplydrop_available) then {
commandpointsblu1 = commandpointsblu1 - 5;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_supplydrop = [player,"ammo"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_supply, [0, 1, 0, 1]];
playSound "boots";
support_supplydrop_available = true;
Expand All @@ -22,7 +21,6 @@ switch (_index2) do {
if (!support_arty_available) then {
commandpointsblu1 = commandpointsblu1 - 20;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_supplydrop = [player,"artillery"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_arty, [0, 1, 0, 1]];
playSound "boots";
support_arty_available = true;
Expand All @@ -38,7 +36,6 @@ switch (_index2) do {
if (!support_mortar_available) then {
commandpointsblu1 = commandpointsblu1 - 10;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_supplydrop = [player,"mortar"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_mortar, [0, 1, 0, 1]];
playSound "boots";
support_mortar_available = true;
Expand All @@ -54,7 +51,6 @@ switch (_index2) do {
if (!support_paradrop_available) then {
commandpointsblu1 = commandpointsblu1 - 20;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_supplydrop = [player,"paradrop"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_paradrop, [0, 1, 0, 1]];
playSound "boots";
support_paradrop_available = true;
Expand All @@ -70,7 +66,6 @@ switch (_index2) do {
if (!support_jdam_available) then {
commandpointsblu1 = commandpointsblu1 - 15;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_supplydrop = [player,"jdam"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_jdam, [0, 1, 0, 1]];
playSound "boots";
support_jdam_available = true;
Expand Down Expand Up @@ -125,7 +120,6 @@ switch (_index2) do {
if (!support_uav_recon_available) then {
commandpointsblu1 = commandpointsblu1 - 10;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_uav_recon = [player,"uav_recon"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_uavrecon, [0, 1, 0, 1]];
playSound "boots";
support_uav_recon_available = true;
Expand All @@ -141,7 +135,6 @@ switch (_index2) do {
if (!support_veh_refit_available) then {
commandpointsblu1 = commandpointsblu1 - 3;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_veh_refit = [player,"vehicle_refit"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_refit, [0, 1, 0, 1]];
playSound "loadgun";
support_veh_refit_available = true;
Expand All @@ -157,7 +150,6 @@ switch (_index2) do {
if (!support_helotaxi_available) then {
commandpointsblu1 = commandpointsblu1 - 3;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_veh_refit = [player,"helo_taxi"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_helotaxi, [0, 1, 0, 1]];
playSound "boots";
support_helotaxi_available = true;
Expand All @@ -173,7 +165,6 @@ switch (_index2) do {
if (!support_cluster_available) then {
commandpointsblu1 = commandpointsblu1 - 25;
ctrlSetText [1000, format["%1",commandpointsblu1]];
_cluster = [player1,"cluster"] call BIS_fnc_addCommMenuItem;
lbSetColor [2103, index_support_cluster, [0, 1, 0, 1]];
playSound "boots";
support_cluster_available = true;
Expand Down Expand Up @@ -210,7 +201,6 @@ switch (_index2) do {
ctrlSetText [1000, format["%1",commandpointsblu1]];
lbSetColor [2103, index_support_boattaxi, [0, 1, 0, 1]];
support_boattaxi_available = true;
_supplydrop = [player,"boat_taxi"] call BIS_fnc_addCommMenuItem;
playSound "boots";
} else {
hint "This support is already available";
Expand Down
17 changes: 16 additions & 1 deletion source/dialog/supports_init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,19 @@ if (isNil "support_specialized_training_available") then {

if (isNil "support_armory_available") then {
support_armory_available = false;
};
};

/*
Support Timeout variables
Variables that hold the next VALID time to use that supports (in seconds)
Supports should set the next valid time as:
support_exampleSupport_timeout = *now* + xyz seconds;
*/

support_mortar_timeout = 0;
support_jdam_timeout = 0;
support_arty_timeout = 0;
support_cluster_timeout = 0;
support_uav_recon_timeout = 0;
//support_helotaxi_timeout = 0; format may not be suitable
//support_boattaxi_timeout = 0;
2 changes: 2 additions & 0 deletions source/duws_revive/respawnClicked.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ if(!staminaEnabled) then {
player enableStamina false;
};

_dynam = [player,"DynamicSupportMenu"] call BIS_fnc_addCommMenuItem;

closedialog 0;
160 changes: 160 additions & 0 deletions source/dynamic_menu.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
Author: UltraNoobian (Brenden Cai)
Description:
Dynamically generate and update the Support menus, then display the root menu.
Parameter(s):
None.
Usage:
[] call "dynamic_menu.sqf";
Returns:
- Nil -
*/
menuItemFormatter = {
format [
"[""%1"", [%2], """", -5, [[""expression"", ""%3""]], ""1"", ""%4""]",
_this select 0,
_this select 1,
_this select 2,
_this select 3
];
};

_itemsCount = 0;
_offensiveItems = [];
_logisticsItems = [];
_transportItems = [];

// Critical note: If you use escape quotes as part of your params to menuItemFormatter,
// You must double-escape those quotes
// eg. "Hello ""mate""" -> "Hello """"mate"""""
// eg. 'Hello "mate"' -> "Hello ""mate""'


//Offensive Submenu checks
if(support_mortar_available) then {
_text = ["Mortar (2 CP)", 2, '_null = [8, 50, 5, 3, 2, 2, ""grenade""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter;
_offensiveItems pushBack _text;
} else {
_text = ["Mortar (N/A)", 2, "", 0] call menuItemFormatter;
_offensiveItems pushBack _text;
};

if(support_arty_available) then {
_text = ["Artillery Strike (4 CP)", 3, '_null = [6, 100, 8, 3, 1, 4, ""R_80mm_HE""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter;
_offensiveItems pushBack _text;
} else {
_text = ["Artillery Strike (N/A)", 3, "", 0] call menuItemFormatter;
_offensiveItems pushBack _text;
};

if(support_cluster_available) then {
_text = ["Cluster Bomb (6 CP)", 4, '_null = [1, 250, 1, 90, 1, 6, ""grenade""] execVM ""support\cluster\mapclickcluster.sqf""', 1] call menuItemFormatter;
_offensiveItems pushBack _text;
} else {
_text = ["Cluster Bomb (N/A)", 4, "", 0] call menuItemFormatter;
_offensiveItems pushBack _text;
};

if(support_jdam_available) then {
_text = ["JDAM Strike (1 CP)", 5, '_null = [1, 2, 1, 1, 3, 1, ""Bo_Mk82""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter;
_offensiveItems pushBack _text;
} else {
_text = ["JDAM (N/A)", 5, "", 0] call menuItemFormatter;
_offensiveItems pushBack _text;
};

// Compilaton and Call for Offensive SubMenu
_finalString = "offensive_SubMenu = [[""Offensive Supports"",true],";
_offensiveItemsClassString = _offensiveItems joinString ",";
_finalString = _finalString + _offensiveItemsClassString;
_finalString = _finalString + "];";

_myCode = compile _finalString;
call _myCode;


//Logistics Submenu Checks
if(support_supplydrop_available) then {
_text = ["Supply Drop (2 CP)", 2, '_null = [player] execVM ""support\ammobox.sqf""', 1] call menuItemFormatter;
_logisticsItems pushBack _text;
} else {
_text = ["Supply Drop ((N/A)", 2, '', 0] call menuItemFormatter;
_logisticsItems pushBack _text;
};

if(support_paradrop_available) then {
_text = ["Airborne troops (25 CP)", 3, '_null = [player] execVM ""support\paradrop.sqf""', 1] call menuItemFormatter;
_logisticsItems pushBack _text;
} else {
_text = ["Airborne troops (N/A)", 3, '', 0] call menuItemFormatter;
_logisticsItems pushBack _text;
};

if(support_uav_recon_available) then {
_text = ["UAV Recon (3 CP)", 4, '_null = [player] execVM ""support\mapclickuav.sqf""', 1] call menuItemFormatter;
_logisticsItems pushBack _text;
} else {
_text = ["UAV Recon (N/A)", 4, '', 0] call menuItemFormatter;
_logisticsItems pushBack _text;
};

if(support_veh_refit_available) then {
_text = ["Vehicle Refit (2 CP)", 5, '_null = [player] execVM ""support\veh_refit.sqf""', 1] call menuItemFormatter;
_logisticsItems pushBack _text;
} else {
_text = ["Vehicle Refit (N/A)", 5, '', 0] call menuItemFormatter;
_logisticsItems pushBack _text;
};


// Compilaton and Call for Logistics SubMenu
_finalString = "logistic_SubMenu = [[""Logistical Supports"",true],";
_logisticsItemsClassString = _logisticsItems joinString ",";
_finalString = _finalString + _logisticsItemsClassString;
_finalString = _finalString + "];";

_myCode = compile _finalString;
call _myCode;

//Transport Submenu check
if(support_helotaxi_available) then {
_text = ["Helicopter taxi(1 CP)", 2, '_nill = [getpos player,50] execVM ""support\taxi\helotaxi.sqf""', 1] call menuItemFormatter;
_transportItems pushBack _text;
} else {
_text = ["Helicopter taxi(N/A)", 2, '', 0] call menuItemFormatter;
_transportItems pushBack _text;
};

if(support_boattaxi_available) then {
_text = ["Boat taxi (1 CP)", 3, '_null = [getpos player,10] execVM ""support\taxi\boattaxi.sqf""', 1] call menuItemFormatter;
_transportItems pushBack _text;
} else {
_text = ["Boat taxi (N/A)", 3, '', 0] call menuItemFormatter;
_transportItems pushBack _text;
};


// Compilaton and Call for Transport SubMenu
_finalString = "transport_SubMenu = [[""Transport Supports"",true],";
_transportItemsClassString = _transportItems joinString ",";
_finalString = _finalString + _transportItemsClassString;
_finalString = _finalString + "];";

_myCode = compile _finalString;
call _myCode;


//Construct and show Support Menu root
supportMenu =
[
["Support Menu",false],
["Offensive", [2], "#USER:offensive_SubMenu", -5, [["expression", ""]], "1", "1"],
["Logistics", [3], "#USER:logistic_SubMenu", -5, [["expression", ""]], "1", "1"],
["Transport", [4], "#USER:transport_SubMenu", -5, [["expression", ""]], "1", "1"]
];

showCommandingMenu "#USER:supportMenu";
2 changes: 1 addition & 1 deletion source/initHQ/BluHQinit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _trg5 setTriggerStatements["this", format["[""%1"",thislist] execvm 'enterlocati
_trgWarning=createTrigger["EmptyDetector",_hqblu];
_trgWarning setTriggerArea[300,300,0,false];
_trgWarning setTriggerActivation["EAST","PRESENT",true];
_trgWarning setTriggerStatements["this","PAPABEAR sidechat 'This is HQ, there are enemies near our main base!'", ""];
_trgWarning setTriggerStatements["this","[west, ""PAPA_BEAR""] sidechat 'This is HQ, there are enemies near our main base!'", ""];

// CREATE THE OFFICER
_group = createGroup west;
Expand Down
2 changes: 1 addition & 1 deletion source/missions/stratmap.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _allFound = false;
_counter = 0;

if (isnil ("Mission_timeout_request")) then {Mission_timeout_request = true;};
if (!Mission_timeout_request) exitWith {PAPABEAR=[West,"HQ"]; PAPABEAR SideChat "We don't have any other missions for you right now.";};
if (!Mission_timeout_request) exitWith {[west, "PAPA_BEAR"] SideChat "We don't have any other missions for you right now.";};
if (!((vehiclevarname player) in game_master)) exitWith {hint "Only the host can request side missions for now"};

startLoadingScreen ["Loading zones..."];
Expand Down
1 change: 0 additions & 1 deletion source/serverinit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ can_get_mission = true;publicVariable "can_get_mission";
failsafe_zones_not_found = false;publicVariable "failsafe_zones_not_found";
createcenter sideLogic;
LogicGroup = createGroup SideLogic;publicVariable "LogicGroup";
PAPABEAR=[West,"HQ"];publicVariable "PAPABEAR";
locator_hq_actived = false;publicVariable "locator_hq_actived";
op_zones_index = 0;publicVariable "op_zones_index";
clientisSync = false;publicVariable "clientisSync";
Expand Down
28 changes: 21 additions & 7 deletions source/support/ammobox.sqf
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
/*
File: ammobox.sqf
Author: Kibot
Description:
Air-deploys a NATO ammobox with a parachute at a assigned location.
Parameter(s):
_this select 0 - OBJECT - A non-nil object with a physical location.
Usage:
_scriptHandle = [player] execVM 'ammobox.sqf';
Returns:
- Nil -
*/

_target = _this select 0;

_location = getpos _target;

if (commandpointsblu1<2) exitWith
{
if (commandpointsblu1<2) exitWith {
["info",["Not enough command points","Not enough Command Points (2CP required)"]] call bis_fnc_showNotification;
};
commandpointsblu1 = commandpointsblu1 - 2;
publicVariable "commandpointsblu1";

hint "A supply crate has been dropped near your location";

// Create the parachute
_parachute = "Steerable_Parachute_F" CreateVehicle _location;
_parachute setPos [_location select 0, _location select 1, (_location select 2)+100];

// Create the supply crate
_ammo = "B_supplyCrate_F" CreateVehicle [_location select 0,_location select 1,(_location select 2)+50];
_ammo attachTo [_parachute,[0,0,0]];

Expand All @@ -34,10 +52,6 @@ _ammo addBackpackCargo ["B_AssaultPack_khk",10];

if (support_armory_available) then {[[_ammo,["<t color='#ff1111'>Armory</t>","bisArsenal.sqf",[], 0, false, false, "", "_this distance _target < 4"]],"addAction",true,true] call BIS_fnc_MP;};


// magazines[] = {"1Rnd_HE_Grenade_shell","UGL_FlareWhite_F","UGL_FlareGreen_F","UGL_FlareRed_F","UGL_FlareYellow_F","UGL_FlareCIR_F","1Rnd_Smoke_Grenade_shell","1Rnd_SmokeRed_Grenade_shell","1Rnd_SmokeGreen_Grenade_shell","1Rnd_SmokeYellow_Grenade_shell","1Rnd_SmokePurple_Grenade_shell","1Rnd_SmokeBlue_Grenade_shell","1Rnd_SmokeOrange_Grenade_shell","3Rnd_HE_Grenade_shell","3Rnd_UGL_FlareWhite_F","3Rnd_UGL_FlareGreen_F","3Rnd_UGL_FlareRed_F","3Rnd_UGL_FlareYellow_F","3Rnd_UGL_FlareCIR_F","3Rnd_Smoke_Grenade_shell","3Rnd_SmokeRed_Grenade_shell","3Rnd_SmokeGreen_Grenade_shell","3Rnd_SmokeYellow_Grenade_shell","3Rnd_SmokePurple_Grenade_shell","3Rnd_SmokeBlue_Grenade_shell","3Rnd_SmokeOrange_Grenade_shell"};


waitUntil {sleep 1; getpos _ammo select 2<0.2};
_smoke = "SmokeShellGreen" CreateVehicle (getpos _ammo);
["info",["Supply delivered","The supply crate has been marked with green smokes"]] call bis_fnc_showNotification;
Loading

0 comments on commit b1fad07

Please sign in to comment.