Skip to content

Commit 152fc35

Browse files
committed
Modified mapclickarty.sqf with new support timeout system
Added documentation and cleaned up code-style Made small refactors and optimizations to code flow Included new guard and countdown for prevention of artillery spam
1 parent c3b2dd2 commit 152fc35

File tree

1 file changed

+60
-27
lines changed

1 file changed

+60
-27
lines changed

source/support/mapclickarty.sqf

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,81 @@
1-
// _null = [salvos, radius, interval between salvos(in seconds), shots per salvo, support type, CP cost, ammotype] execVM "support\arty.sqf"
2-
// AMMO TYPES: R_60mm_HE / R_80mm_HE /Bo_Air_LGB(no sounds)/ Grenade / Bo_Mk82
3-
// SUPPORT TYPE: 1 = arty, 2 = mortar, 3 = jdam
1+
/*
2+
File: mapclickarty.sqf
43
5-
_salvos = _this select 0;
6-
_radius = _this select 1;
7-
_interval = _this select 2;
8-
_rps = _this select 3;
9-
_supportype = _this select 4; // 1 = arty, 2 = mortar, 3 = jdam
10-
_cost = _this select 5;
11-
_ammotype = _this select 6;
4+
Author: Kibot
125
6+
Description:
7+
Guards and determines the position of a strike, based on location provided by the player, for arty.sqf
138
9+
Parameter(s):
10+
_this select 0 - NUMBER - Number of ordinance salvos
11+
_this select 1 - NUMBER - Radius of 'Strike Area'
12+
_this select 2 - NUMBER - Interval between salvos (in seconds)
13+
_this select 3 - NUMBER - Number of ordinance rounds per salvo
14+
_this select 4 - NUMBER - Support type enumerator (1 - Artillery, 2 - Mortar Shell, 3 - JDAM)
15+
_this select 6 - NUMBER - Cost of Support type
16+
_this select 7 - STRING - Ammo type used for salvos
1417
18+
Returns:
19+
- Nil -
20+
*/
21+
22+
params["_salvos", "_radius", "_interval", "_rps", "_supportype", "_cost", "_ammotype"];
1523
_timer = 60;
24+
_pos = [];
1625
clicked = false;
1726

27+
// Guard against calling UAV Recon too often
28+
if (_supportype == 1 && {support_arty_timeout > 0}) exitWith {
29+
["info",["Support is on Cooldown",format ["Artillery will be ready to fire again in %1 seconds", support_arty_timeout]]] call bis_fnc_showNotification;
30+
};
31+
if (_supportype == 2 && {support_mortar_timeout > 0}) exitWith {
32+
["info",["Support is on Cooldown",format ["Mortar team will be ready again in %1 seconds", support_mortar_timeout]]] call bis_fnc_showNotification;
33+
};
34+
if (_supportype == 3 && {support_jdam_timeout > 0}) exitWith {
35+
["info",["Support is on Cooldown",format ["JDAM drop will be ready again in %1 seconds", support_jdam_timeout]]] call bis_fnc_showNotification;
36+
};
37+
1838
// IF NOT ENOUGH PTS
1939
if (commandpointsblu1<_cost) exitWith {
2040
["info",["Support","You don't have enough command points"]] call bis_fnc_showNotification;
2141
};
2242

23-
_pos = [];
2443
hint "Click on your map to give the coordinates or wait 60 seconds to cancel the strike";
2544
OnMapSingleClick format["_null = [_pos,%2,%3,%4,%5,%6,%7,'%8'] execVM 'support\arty.sqf';clicked=true;onMapSingleClick ''",_pos,_salvos,_radius,_interval,_rps,_supportype,_cost,_ammotype];
26-
//hint format["Position: %1\nSalvos:%2\nRadius:%3\nInterval:%4\nRPS:%5\nSupport type:%6\nCost:%7\nAmmo type:'%8'", _position, _salvos, _radius, _interval, _rps, _supportype, _cost, _ammotype];
2745

2846
// TIMER
29-
while {_timer>0 AND !clicked} do {
30-
31-
_timer = _timer-1; // remove 1 to timer
32-
sleep 1;
47+
while {_timer > 0 AND !clicked} do {
48+
_timer = _timer-1; // remove 1 to timer
49+
sleep 1;
3350
};
51+
3452
// TIMER ELLAPSED OR CLICKED
35-
sleep 60;
3653
OnMapSingleClick "";
3754

38-
if (_supportype==1) exitWith {
39-
_art = [player1,"artillery"] call BIS_fnc_addCommMenuItem;
40-
};
41-
42-
if (_supportype==2) exitWith {
43-
_art = [player1,"mortar"] call BIS_fnc_addCommMenuItem;
44-
};
45-
46-
if (_supportype==3) exitWith {
47-
_art = [player1,"JDAM"] call BIS_fnc_addCommMenuItem;
55+
// Tickdown timeout guards
56+
switch(_supportype) do {
57+
case 1: {
58+
support_arty_timeout = 60;
59+
while {support_arty_timeout > 0} do {
60+
sleep 1;
61+
support_arty_timeout = support_arty_timeout - 1;
62+
publicVariable "support_arty_timeout";
63+
};
64+
};
65+
case 2: {
66+
support_mortar_timeout = 60;
67+
while {support_mortar_timeout > 0} do {
68+
sleep 1;
69+
support_mortar_timeout = support_mortar_timeout - 1;
70+
publicVariable "support_mortar_timeout";
71+
};
72+
};
73+
case 3: {
74+
support_jdam_timeout = 60;
75+
while {support_jdam_timeout > 0} do {
76+
sleep 1;
77+
support_jdam_timeout = support_jdam_timeout - 1;
78+
publicVariable "support_jdam_timeout";
79+
};
80+
};
4881
};

0 commit comments

Comments
 (0)