forked from LexTheGreat/TLX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bombs.sqf
452 lines (386 loc) · 17.8 KB
/
bombs.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
_art = _this select 0;
if (_art == "init") then {
INV_ServerBombArray = [];
INV_LocalBombArray = [];
if (time > 120) then {
INV_BombGetServerArray = true;
publicVariable "INV_BombGetServerArray";
}
else {
INV_BombGetServerArray = false;
};
INV_BombSpawn = {
if ((typeName _this) == "OBJECT") then {
if (not(isNull _this)) then {
if (((getPosATL _this) select 2) < 5) then {
createVehicle ["Bo_GBU12_LGB", (getPosATL _this), [], 0, "NONE"];
//if (player distance _this < 25) then {player setdamage 1;}; // All players within 25m die instantly
// _this setDamage 1;
if (!(_this isKindOf "Man")) then {
_men1 = (crew _this);
{
_has_admin_camera = _x getVariable ["has_admin_camera", false];
if !(_has_admin_camera) then {
_x setDamage 1;
};
} forEach _men1;
};
_men2 = nearestObjects[getPosATL _this, ["Man", "LandVehicle", "Air"], 25];
{
if(!isNil "_has_admin_camera") then {
_has_admin_camera = _x getVariable "has_admin_camera";
};
if ( !(isnil "_has_admin_camera") && _has_admin_camera) then {
}
else {
_x setDamage 1;
};
if(!(_x isKindOf "Man")) then {
_men3 = crew _x;
{
_liafu = true;
if(!isNil "_has_admin_camera") then {
_has_admin_camera = _x getVariable "has_admin_camera";};
if ( !(isnil "_has_admin_camera") && _has_admin_camera) then {
} else {
_x setDamage 1;
};
} forEach _men3;
};
} forEach _men2;
};
};
}
else {
createVehicle ["Bo_GBU12_LGB", (_this), [], 0, "NONE"];
//if (player distance _this < 25) then {player setdamage 1;}; // All players within 25m die instantly
_men2 = nearestObjects[_this, ["Man", "LandVehicle", "Air"], 25];
{
_x setDamage 1;
if(!(_x isKindOf "Man")) then {
_men3 = crew _x;
{
_liafu = true;
_x setDamage 1;
} forEach _men3;
};
} forEach _men2;
};
};
INV_BombIdExists = {
private["_result", "_i"];
_result = false;
for [{_i=0}, {_i < (count INV_ServerBombArray)}, {_i=_i+1}] do {
if (((INV_ServerBombArray select _i) select 0) == _this) exitWith {_result = true;};
};
_result;
};
INV_BombAdd = {
INV_ServerBombArray = INV_ServerBombArray + [[ (_this select 1), (_this select 2), (_this select 3), (_this select 4), (_this select 5) ]];
if (player == (_this select 0)) then {
INV_LocalBombArray = INV_LocalBombArray + [[ (_this select 1), (_this select 2), (_this select 3), [] ]];
};
};
INV_BombDelete = {
private["_name", "_id", "_i", "_j", "_actionArr"];
_id = _this;
for [{_i=0}, {_i < (count INV_ServerBombArray)}, {_i=_i+1}] do {
if (((INV_ServerBombArray select _i) select 0) == _id) exitWith {
INV_ServerBombArray set [_i, ""];
INV_ServerBombArray = INV_ServerBombArray - [""];
};
};
for [{_i=0}, {_i < (count INV_LocalBombArray)}, {_i=_i+1}] do {
if (((INV_LocalBombArray select _i) select 0) == _id) exitWith {
if (alive(vehicle player)) then {
_actionArr = ((INV_LocalBombArray select _i) select 3);
for [{_j=0}, {_j < (count _actionArr)}, {_j=_j+1}] do {
(vehicle player) removeAction (_actionArr select _j);
};
};
INV_LocalBombArray set [_i, ""];
INV_LocalBombArray = INV_LocalBombArray - [""];
};
};
};
INV_BombEdit = {
private["_id", "_settings", "_i"];
_id = (_this select 0);
_settings = (_this select 1);
for [{_i=0}, {_i < (count INV_ServerBombArray)}, {_i=_i+1}] do {
if (((INV_ServerBombArray select _i) select 0) == _id) exitWith {
(INV_ServerBombArray select _i) set [4, _settings];
};
};
};
INV_BombVehicle = {
private["_id", "_vehicle", "_i"];
_id = _this select 0;
_vehicle = objNull;
for [{_i=0}, {_i < (count INV_ServerBombArray)}, {_i=_i+1}] do {
if (((INV_ServerBombArray select _i) select 0) == _id) exitWith {
_vehicle = ((INV_ServerBombArray select _i) select 1);
};
};
_vehicle
};
if (isServer) then {["server"] spawn A_SCRIPT_BOMBS;};
["client"] spawn A_SCRIPT_BOMBS;
};
if (_art == "server") then {
_lastLength = 0;
while {true} do {
_skipWait = false;
if (count INV_ServerBombArray > 0) then {
for [{_i=0}, {_i < (count INV_ServerBombArray)}, {_i=_i+1}] do {
_array = (INV_ServerBombArray select _i);
_id = _array select 0;
_vehicle = _array select 1;
_name = _array select 2;
_status = _array select 3;
_settings = _array select 4;
if (isNull(_vehicle)) exitWith {
format["""%1"" call INV_BombDelete", _id] call broadcast;
_skipWait = true;
};
if (not(alive(_vehicle))) exitWith {
format["""%1"" call INV_BombDelete", _id] call broadcast;
_skipWait = true;
};
switch (_name) do {
case "fernzuenderbombe": {
if (_settings select 0) then {
_vehicle spawn INV_BombSpawn;
};
if (_status == "defused") then {
format["""%1"" call INV_BombDelete", _id] call broadcast;
};
};
case "zeitzuenderbombe": {
if (_settings select 0 < time) then {
_vehicle spawn INV_BombSpawn;
};
if (_status == "defused") then {
format["""%1"" call INV_BombDelete", _id] call broadcast;
};
};
case "aktivierungsbombe": {
if (!(_settings select 0)) then {
_vehicle addEventHandler ["engine", { _vehicle = _this select 0; if (isEngineOn _vehicle) then { _vehicle removeAllEventHandlers "engine"; _vehicle spawn INV_BombSpawn; }; }];
};
if (_status == "defused") then {
format["""%1"" call INV_BombDelete", _id] call broadcast;
_vehicle removeAllEventHandlers "engine";
};
};
case "geschwindigkeitsbombe": {
_active = (_settings select 1);
_speed = speed _vehicle;
if ((_active) and (_speed < (_settings select 0))) then {
_vehicle spawn INV_BombSpawn;
};
if (_status == "defused") then {
format["""%1"" call INV_BombDelete", _id] call broadcast;
};
if ( (!_active) and (_speed > (_settings select 0)) ) then {
_settings set [1, true];
_newtime = time + (_settings select 2);
_settings set [3, ((round(time))+(_settings select 2))];
format["if (player in %1) then {player groupChat ""Watch out, the carbomb has been activated. You are not allowed to drive slower than %2 km/h!"";};", _vehicle, round(_settings select 0), (_settings select 2)] call broadcast;
};
if(!isNil "_newtime") then {
if (time > _newtime) then {
_array set [3, "defused"];
format["if (player in %1) then {player groupChat localize ""STRS_inv_item_vehiclebomb_deactivated"";};", _vehicle] call broadcast;
};};
};
};
};
if ( (INV_BombGetServerArray) ) then {
_lastLength = count INV_ServerBombArray;
INV_BombGetServerArray = false;
publicVariable "INV_ServerBombArray";
};};
if (!_skipWait) then {
sleep 1;
};
};
};
if (_art == "client") then {
_a1=0; _a2=0; _a3=0; _a4=0; _a5=0; _v=0;
while {true} do {
_skipWait = false;
for [{_i=0}, {_i < (count INV_LocalBombArray)}, {_i=_i+1}] do {
_array = (INV_LocalBombArray select _i);
_id = _array select 0;
_vehicle = _array select 1;
_item = _array select 2;
_actionArr= _array select 3;
if (isNull(_vehicle)) exitWith {
format["""%1"" call INV_BombDelete", _id] call broadcast; _skipWait = true;
};
if (not(alive(_vehicle))) exitWith {
format["""%1"" call INV_BombDelete", _id] call broadcast; _skipWait = true;
};
if ( (vehicle player == _vehicle) and ((count _actionArr) == 0) ) then {
_v = vehicle player;
switch _item do {
case "fernzuenderbombe": {
_a1 = _v addAction [localize "STRS_inv_item_vehiclebomb_action_deactivate", "noscript.sqf", format["[""config"", ""defuse"", ""%1"", ""%2""] spawn A_SCRIPT_BOMBS;", _item, _id ]];
_actionArr = _actionArr + [_a1];
};
case "zeitzuenderbombe": {
_a1 = _v addAction [localize "STRS_inv_item_vehiclebomb_action_deactivate", "noscript.sqf", format["[""config"", ""defuse"", ""%1"", ""%2""] spawn A_SCRIPT_BOMBS;", _item, _id ]];
_a2 = _v addAction [localize "STRS_inv_item_vehiclebomb_action_changetimer", "noscript.sqf", format["[""config"", ""Timer"", ""%1"", ""%2""] spawn A_SCRIPT_BOMBS;", _item, _id ]];
_actionArr = _actionArr + [_a1, _a2];
};
case "aktivierungsbombe": {
_a1 = _v addAction [localize "STRS_inv_item_vehiclebomb_action_deactivate", "noscript.sqf", format["[""config"", ""defuse"", ""%1"", ""%2""] spawn A_SCRIPT_BOMBS;", _item, _id ]];
_actionArr = _actionArr + [_a1];
};
case "geschwindigkeitsbombe": {
_a1 = _v addAction [localize "STRS_inv_item_vehiclebomb_action_deactivate", "noscript.sqf", format["[""config"", ""defuse"", ""%1"", ""%2""] spawn A_SCRIPT_BOMBS;", _item, _id ]];
_actionArr = _actionArr + [_a1];
};
};
};
if (vehicle player != _vehicle) then {
for [{_j=0}, {_j < (count _actionArr)}, {_j=_j+1}] do { _vehicle removeAction (_actionArr select _j); };
_actionArr = [];
};
(INV_LocalBombArray select _i) set [3, _actionArr];
};
if (!_skipWait) then {
sleep 3;
};
};
};
if (_art == "use") then {
_item = _this select 1;
_anzahl = _this select 2;
if (_item == "zeitzuenderbombe") then {
if (!(createDialog "timebombconfig")) exitWith {
hint "Dialog Error!";
};
sliderSetRange [1, zeitbombe_mintime, zeitbombe_maxtime];
sliderSetSpeed [1, 1, 10];
buttonSetAction [4, "[""plant"", ""zeitzuenderbombe"", sliderPosition 1] spawn A_SCRIPT_BOMBS; closedialog 0;"];
while {ctrlVisible 1011} do {
ctrlSetText [3, format[localize "STRS_inv_item_vehiclebomb_timebombconfig_sec", (round(sliderPosition 1))]];
sleep 0.3;
};
};
if (_item == "aktivierungsbombe") then {
["plant", "aktivierungsbombe"] spawn A_SCRIPT_BOMBS;
};
if (_item == "geschwindigkeitsbombe") then {
if (!(createDialog "speedbombconfig")) exitWith {
hint "Dialog Error!";
};
sliderSetRange [1, speedbomb_minspeed, speedbomb_maxspeed];
sliderSetSpeed [1, 1, 10];
sliderSetRange [8, speedbomb_mindur, speedbomb_maxdur];
sliderSetSpeed [8, 1, 10];
buttonSetAction [4, "[""plant"", ""geschwindigkeitsbombe"", sliderPosition 1, sliderPosition 8] spawn A_SCRIPT_BOMBS; closedialog 0;"];
while {ctrlVisible 1010} do {
ctrlSetText [3, format[localize "STRS_inv_item_vehiclebomb_speedbombconfig_kmh", (round(sliderPosition 1))]];
ctrlSetText [10, format["%1 Sec.", (round(sliderPosition 8))]];
sleep 0.3;
};
};
if (_item == "fernzuenderbombe") then {
["plant", "fernzuenderbombe"] spawn A_SCRIPT_BOMBS;
};
if (_item == "fernzuender") then {
if (!(createDialog "remotebomb_remote")) exitWith {hint "Dialog Error!";};
};
};
if (_art == "plant") then {
_item = _this select 1;
_id = format["%1_%2", player, round(time)];
_vcl = vehicle player;
_settings = [];
_exit = 0;
_explosion = 0;
if (vehicle player == player) exitWith {
player groupChat localize "STRS_inv_item_vehiclebomb_notinvehicle";
};
format ["if (player in %1) then {player groupChat format[localize ""STRS_inv_item_vehiclebomb_legen_gesehen"", %2];};", _vcl, player] call broadcast;
player groupChat format[localize "STRS_inv_item_vehiclebomb_planted", _id];
switch _item do {
case "fernzuenderbombe": {
_settings = [ false ];
};
case "zeitzuenderbombe": {
_settings = [ ((round(time))+(_this select 2)) ];
};
case "aktivierungsbombe": {
_settings = [ false ];
};
case "geschwindigkeitsbombe": {
_settings = [ (_this select 2), false, (_this select 3), 0 ];
};
};
format[ "[%1, ""%2"", %3, ""%4"", ""%5"", %6] call INV_BombAdd;", player, _id, _vcl, _item, "planted", _settings] call broadcast;
[player, _item, (-1)] call INV_AddInventoryItem;
};
if (_art == "config") then {
_art = _this select 1;
_name = _this select 2;
_id = _this select 3;
if (!(_id call INV_BombIdExists)) exitWith {player groupChat localize "STRS_inv_item_vehiclebomb_notexist,";};
switch _name do {
case "fernzuenderbombe": {
if (_art == "defuse") then {
format["""%1"" call INV_BombDelete", _id] call broadcast;
[player, _name, 1] call INV_AddInventoryItem;
player groupChat localize "STRS_inv_item_vehiclebomb_defused";
};
if (_art == "activate") then {
format["if (isServer) then {[""%1"", [%2]] call INV_BombEdit;};", _id, true] call broadcast;
};
};
case "zeitzuenderbombe": {
if (_art == "defuse") then {
format["""%1"" call INV_BombDelete", _id] call broadcast;
[player, _name, 1] call INV_AddInventoryItem;
player groupChat localize "STRS_inv_item_vehiclebomb_defused";
};
if (_art == "timer") exitWith {
if (!(createDialog "timebombconfig")) exitWith {
hint "Dialog Error!";
};
_sliderpos = 0;ctrlSetText [4, localize "STRS_inv_item_vehiclebomb_changetimer"];
sliderSetRange [1, zeitbombe_mintime, zeitbombe_maxtime];sliderSetSpeed [1, 1, 10];
buttonSetAction [4, "zeitbombencounterchanged = 1; closedialog 0;"];
zeitbombencounterchanged = 0;
while {ctrlVisible 2} do {
_sliderpos = round(sliderPosition 1);
ctrlSetText [3, format[localize "STRS_inv_item_vehiclebomb_sec", _sliderpos]];
sleep 0.3;
};
if (zeitbombencounterchanged == 1) then {
format["if (isServer) then {[""%1"", [%2]] call INV_BombEdit;};", _id, (time+_sliderpos)] call broadcast;
player groupChat format [localize "STRS_inv_item_vehiclebomb_changed", _sliderpos];
};
};
};
case "aktivierungsbombe": {
if (_art == "defuse") then {
private["_vehicle", "_i"];
_vehicle = objNull;
_vehicle = ([_id] call INV_BombVehicle);
_vehicle removeAllEventHandlers "engine";
format['%1 removeAllEventHandlers "engine";', _vehicle] call broadcast;
format["""%1"" call INV_BombDelete", _id] call broadcast;
[player, _name, 1] call INV_AddInventoryItem;player groupChat localize "STRS_inv_item_vehiclebomb_defused";
};
};
case "geschwindigkeitsbombe": {
if (_art == "defuse") then {
format["""%1"" call INV_BombDelete", _id] call broadcast;
[player, _name, 1] call INV_AddInventoryItem;player groupChat localize "STRS_inv_item_vehiclebomb_defused";
};
};
};
};