-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathXEH_postInit.sqf
524 lines (467 loc) · 15 KB
/
XEH_postInit.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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
#include "\MG8\AVFEVFX\cTab\has_cTab.hpp"
//- Init Discord Webhook Settings
#if __has_include("\MG8\DiscordMessageAPI\config.bin")
#ifdef cTAB_Installed
call BCE_fnc_Discord_GetWebhooks;
#endif
#endif
if (!hasInterface) exitWith {};
//- Init cache holder
private _map = createHashMap;
{
_map set [_x , createHashMap];
} foreach ["BCE_Camera_Cache","BCE_IRLaser_Cache"];
localNamespace setVariable ["BCE_System_Caches", _map];
_map = nil;
TGP_View_Unit_List = [];
TGP_View_Marker_List = [];
TGP_View_TouchMark_List = [];
TGP_View_Camera = [];
TGP_View_Turret_List = [];
IR_LaserLight_UnitList = [];
IR_LaserLight_UnitList_LastUpdate = 0;
BCE_TGP_LastUpdate = 0;
if (isnil {BCE_SYSTEM_Handler}) then {
BCE_SYSTEM_Handler = "";
};
private _mapCenter = worldSize / 2;
private _landmarks = ["NameVillage", "NameCity", "NameCityCapital", "NameLocal", "NameMarine", "Hill"];
private _BCE_LandMarks = (nearestLocations [
[_mapCenter, _mapCenter],
_landmarks,
worldSize
]) apply {
private ["_config","_tex","_pos","_color"];
_config = configFile >> "CfgLocationTypes" >> type _x;
_tex = getText (_config >> "texture");
_pos = getPos _x;
_color = (getArray (_config >> "color")) apply {
[_x,1] select (_x == 0);
};
_color set [3,0.85];
_pos set [2,0.5];
[
[_tex,"\a3\ui_f\data\Map\Markers\Military\dot_CA.paa"] select (_tex == ""),
_color,
_pos,
text _x,
(getNumber (_config >> "textSize")) min 0.04
]
};
uiNamespace setVariable ["BCE_LandMarks",_BCE_LandMarks];
#if __has_include("\z\ace\addons\hearing\config.bin")
BCE_have_ACE_earPlugs = false;
#endif
//PostInit
call BCE_fnc_init;
//-Add map eventhandler
["visibleMap", {
[findDisplay 12, -1] call BCE_fnc_Update_MapCtrls;
}] call CBA_fnc_addPlayerEventHandler;
#define SetTitle(A,B) (localize A) + (localize B)
#define IsPilot_CAM_ON ((player getVariable ["AHUD_Actived",-1]) != -1)
#define getTurret (call BCE_fnc_getTurret)
#define SwitchSound playSound (format ["switch_mod_0%1",(selectRandom [1,2,3,4,5])])
#define isCtrlTurret ({count (_x getVariable ["TGP_View_Turret_Control",[]]) > 0} count (crew _vehicle)) > 0
#define IsTGP_CAM_ON ((player getVariable ["TGP_View_EHs", -1]) != -1)
#define IsPhoneCAM_ON !isnull (uiNamespace getVariable ["BCE_PhoneCAM_View",displayNull])
#define IsHCAM_ON !isnull (uiNamespace getVariable ["BCE_HCAM_View",displayNull])
#ifdef cTAB_Installed
[] spawn {
waitUntil {!isnil {cTabSettings}};
call BCE_fnc_cTab_postInit;
};
//- Phone Camera
[
"Better CAS Environment (cTab ATAK Camera)","ScreenShot",
localize "STR_BCE_Take_ScreenShot",
{
if (IsPhoneCAM_ON && isnil{ctabifopen}) then {
call BCE_fnc_ATAK_TakePicture;
};
},
"",
[0xF0, [false, false, false]]
] call cba_fnc_addKeybind;
//- Flash Light
[
"Better CAS Environment (cTab ATAK Camera)","FlashLight",
localize "STR_BCE_ATAK_FlashLight",
{
if (IsPhoneCAM_ON && isnil{ctabifopen}) then {
private _light = localNamespace getVariable ["BCE_ATAK_Camera_FlashLight",objNull];
if (isnull _light) then {
_light = "Reflector_Cone_Phone_FlashLight_BCE_F" createVehicle [0,0,0]; //- As Global object
localNamespace setVariable ["BCE_ATAK_Camera_FlashLight",_light];
//- Attach to player's head
private _unit = player;
if (vehicle _unit != _unit) then {
private _veh = vehicle _unit;
private _offset = _veh worldToModelVisual (ASLToAGL (eyePos _unit));
_light attachTo [_veh,_offset vectorAdd [0,0.4,0]];
} else {
_light attachTo [_unit, [0,0.4,0.2], "head"];
};
} else {
deleteVehicle _light;
localNamespace setVariable ["BCE_ATAK_Camera_FlashLight",nil];
};
};
},
"",
[0xF1, [false, false, false]]
] call cba_fnc_addKeybind;
#endif
//- Optic Mode
[
"Better CAS Environment (TGP)","OpticMode",
localize "STR_BCE_Optic_Mode",
{
if (IsTGP_CAM_ON) then {
SwitchSound;
(call BCE_fnc_Next_VisionMode) call BCE_fnc_OpticMode;
};
},
"",
[0x31, [false, false, false]]
] call cba_fnc_addKeybind;
//- Exit
[
"Better CAS Environment (TGP)","Exit",
localize "STR_BCE_Exit_Camera",
{
if (IsTGP_CAM_ON) exitwith {
camUseNVG false;
call BCE_fnc_Cam_Delete;
[2] call BCE_fnc_OpticMode;
if (isclass(configFile >> "CfgPatches" >> "A3TI")) then {
if ((call A3TI_fnc_getA3TIVision) != "") then {
uiNamespace setVariable ["A3TI_FLIR_VisionMode",-1];
call A3TI_fnc_ppEffects
};
};
};
//- Exit Phone Camera
if (IsPhoneCAM_ON || IsHCAM_ON) exitWith {
558 cutRsc ["default","PLAIN"];
cutText ["", "BLACK IN",0.5];
};
},
"",
[0x39, [false, false, false]]
] call cba_fnc_addKeybind;
//- Zoom
[
"Better CAS Environment (TGP)","ZoomIn",
localize "STR_BCE_Zoom_In",
{
//- TGP Camera
1 call BCE_fnc_Switch_Zoom;
},
"",
[0x4E, [false, false, false]],
true
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","ZoomOut",
localize "STR_BCE_Zoom_Out",
{
//- TGP Camera
-1 call BCE_fnc_Switch_Zoom;
},
"",
[0x4A, [false, false, false]],
true
] call cba_fnc_addKeybind;
//- Swich Turret
[
"Better CAS Environment (TGP)","SwichView_L",
localize "STR_BCE_Swich_View_Left",
{
if (IsTGP_CAM_ON) then {
getTurret params ["_cam","_vehicle","_Optic_LODs","_current_turret"];
if (count _Optic_LODs < 1) exitWith {};
SwitchSound;
if (count _Optic_LODs == 1) exitWith {};
_current_turret = [_current_turret - 1,(count _Optic_LODs) - 1] select (_current_turret < 1);
_turret_select = _Optic_LODs # _current_turret;
_turret = _turret_select # 1;
_turret_Unit = _vehicle turretUnit _turret;
if ((isCtrlTurret) && ((_turret # 0) < 0)) exitWith {};
//call BCE_fnc_UpdateCameraUI;
_cam attachTo [_vehicle, [0,0,0],_turret_select # 0,!(_turret_select # 2)];
player setVariable ["TGP_View_Selected_Optic",[_turret_select,_vehicle],true];
//UI
_gunner = [name _turret_Unit,"--"] select ((_turret_Unit isEqualTo objNull) || (name (driver _vehicle) == name _turret_Unit));
((uiNameSpace getVariable "BCE_TGP") displayCtrl 1029) ctrlSetText (format ["Gunner: %1", _gunner]);
};
},
"",
[0xCB, [false, false, false]],
true
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","SwichView_R",
localize "STR_BCE_Swich_View_Right",
{
if (IsTGP_CAM_ON) then {
getTurret params ["_cam","_vehicle","_Optic_LODs","_current_turret"];
if (count _Optic_LODs < 1) exitWith {};
SwitchSound;
if (count _Optic_LODs == 1) exitWith {};
_current_turret = [_current_turret + 1,0] select (_current_turret >= ((count _Optic_LODs) - 1));
_turret_select = _Optic_LODs # _current_turret;
_turret = _turret_select # 1;
_turret_Unit = _vehicle turretUnit _turret;
if ((isCtrlTurret) && ((_turret # 0) < 0)) exitWith {};
//call BCE_fnc_UpdateCameraUI;
_cam attachTo [_vehicle, [0,0,0],_turret_select # 0,!(_turret_select # 2)];
player setVariable ["TGP_View_Selected_Optic",[_turret_select,_vehicle],true];
//UI
_gunner = [name _turret_Unit,"--"] select ((_turret_Unit isEqualTo objNull) || (name (driver _vehicle) == name _turret_Unit));
((uiNameSpace getVariable "BCE_TGP") displayCtrl 1029) ctrlSetText (format ["Gunner: %1", _gunner]);
};
},
"",
[0xCD, [false, false, false]],
true
] call cba_fnc_addKeybind;
//Optional
[
"Better CAS Environment (TGP)","Unit_Tracker_Box",
SetTitle("STR_BCE_Toggle","STR_BCE_Tracker_Box"),
{
if (IsTGP_CAM_ON || IsPilot_CAM_ON) then {
SwitchSound;
if (player getVariable ["TGP_view_Unit_Tracker_Box",true]) then {
player setVariable ["TGP_view_Unit_Tracker_Box",false];
} else {
player setVariable ["TGP_view_Unit_Tracker_Box",true];
};
};
},
"",
[0x16, [false, false, false]]
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","Unit_Tracker",
SetTitle("STR_BCE_Toggle","STR_BCE_Unit_Tracker"),
{
if (IsTGP_CAM_ON || IsPilot_CAM_ON) then {
SwitchSound;
if (player getVariable ["TGP_view_Unit_Tracker",true]) then {
player setVariable ["TGP_view_Unit_Tracker",false];
} else {
player setVariable ["TGP_view_Unit_Tracker",true];
};
};
},
"",
[0x24, [false, false, false]]
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","Compass",
SetTitle("STR_BCE_Toggle","STR_BCE_3D_Compass"),
{
if (IsTGP_CAM_ON || IsPilot_CAM_ON) then {
SwitchSound;
if (player getVariable ["TGP_view_3D_Compass",true]) then {
player setVariable ["TGP_view_3D_Compass",false];
} else {
player setVariable ["TGP_view_3D_Compass",true];
};
};
},
"",
[0x25, [false, false, false]]
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","Unit_MapIcon",
SetTitle("STR_BCE_Toggle","STR_BCE_Map_Icon"),
{
if (IsTGP_CAM_ON) then {
SwitchSound;
if (player getVariable ["TGP_view_Map_Icon",true]) then {
player setVariable ["TGP_view_Map_Icon",false];
} else {
player setVariable ["TGP_view_Map_Icon",true];
};
};
},
"",
[0x26, [false, false, false]]
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","Unit_MapIcon_Aircraft",
format ["%1 (%2)",SetTitle("STR_BCE_Toggle","STR_BCE_Map_Icon"),localize "str_dn_aircrafts"],
{
if (IsPilot_CAM_ON && ((player getVariable ["TGP_View_MapIcons_last",-1]) == -1)) then {
_end = time + 3;
[{
params ["_end","_unit"];
_last_time = _end - time;
_unit setVariable ["TGP_View_MapIcons_last",_last_time];
(time >= _end)
}, {
params ["_end","_unit"];
if (time >= _end) then {
_unit setVariable ["TGP_View_MapIcons",[]];
_unit setVariable ["TGP_View_MapIcons_last",-1];
};
}, [_end,player]
] call CBA_fnc_waitUntilAndExecute;
};
},
"",
[0x26, [false, false, false]]
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","LandMark_Icon",
SetTitle("STR_BCE_Toggle","STR_BCE_LandMark_Icon"),
{
if (IsTGP_CAM_ON || IsPilot_CAM_ON) then {
SwitchSound;
if (player getVariable ["TGP_view_LandMark_Icon",true]) then {
player setVariable ["TGP_view_LandMark_Icon",false];
} else {
player setVariable ["TGP_view_LandMark_Icon",true];
};
};
},
"",
[0x27, [false, false, false]]
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","NextWeapon",
localize "STR_BCE_Next_Weapon_Setup",
{
if !(IsTGP_CAM_ON) exitWith {};
_vehicle = (player getVariable "TGP_View_Selected_Optic") # 1;
_current_turret = ((player getVariable "TGP_View_Selected_Optic") # 0) # 1;
_turret_Unit = _vehicle turretUnit _current_turret;
if !((_turret_Unit getVariable ["TGP_View_Turret_Control",[]]) isEqualTo []) then {
SwitchSound;
//Switch Weapon Setup
_weapon_info = weaponState [_vehicle,_current_turret];
_selectWeapon = _weapon_info # 0;
_selectMuzzle = _weapon_info # 1;
_selectmode = _weapon_info # 2;
//-Modes
_modes = (getarray (configFile >> "CfgWeapons" >> _selectWeapon >> "modes")) select {
(getNumber (configFile >> "CfgWeapons" >> _selectWeapon >> _x >> "showToPlayer")) == 1
};
_mode_Index = _modes find (_weapon_info # 2);
_Muzzles = getarray (configFile >> "CfgWeapons" >> _selectWeapon >> "muzzles");
_Muzzle_Index = _Muzzles find _selectMuzzle;
if (_mode_Index >= ((count _modes) - 1)) then {
//Get Weapons
_weapons = _vehicle weaponsTurret _current_turret;
_Weapon_Index = _weapons find _selectWeapon;
//Dont Have other muzzle
if ((_selectMuzzle == "this") || (_selectMuzzle == _selectWeapon)) then {
//-Select Weapon
if (_Weapon_Index >= ((count _weapons) - 1)) then {
_selectWeapon = _weapons # 0;
} else {
_selectWeapon = _weapons # (_Weapon_Index + 1);
};
//-Set Muzzle
_Muzzles = getarray (configFile >> "CfgWeapons" >> _selectWeapon >> "muzzles");
if ((count _Muzzles) == 1) then {
_selectMuzzle = _selectWeapon;
} else {
_selectMuzzle = _Muzzles # 0;
};
} else {
if (_Muzzle_Index >= ((count _Muzzles) - 1)) then {
//-Select Weapon
if (_Weapon_Index >= ((count _weapons) - 1)) then {
_selectWeapon = _weapons # 0;
} else {
_selectWeapon = _weapons # (_Weapon_Index + 1);
};
_Muzzles = getarray (configFile >> "CfgWeapons" >> _selectWeapon >> "muzzles");
_selectMuzzle = _Muzzles # 0;
} else {
_selectMuzzle = _Muzzles # (_Muzzle_Index + 1);
};
};
_modes = (getarray (configFile >> "CfgWeapons" >> _selectWeapon >> "modes")) select {
(getNumber (configFile >> "CfgWeapons" >> _selectWeapon >> _x >> "showToPlayer")) == 1
};
_selectMode = _modes # 0;
} else {
_selectMode = _modes # (_mode_Index + 1);
};
// - Debug
_Muzzles = getarray (configFile >> "CfgWeapons" >> _selectWeapon >> "muzzles");
if ((_selectMuzzle == "this") || (_selectMuzzle == _selectWeapon)) then {
_selectMuzzle = _selectWeapon;
};
if (isnil{_selectMode}) then {
_selectMode = _selectWeapon;
};
_vehicle selectWeaponTurret [_selectWeapon,_current_turret,_selectMuzzle,_selectMode];
};
},
"",
[0x21, [false, false, false]]
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","TouchMark",
localize "STR_BCE_Set_Touch_Marker",
{
if (!(IsTGP_CAM_ON) || (isNull findDisplay 1022553)) exitWith {};
_list = allUnits select {
((_x getVariable ["AHUD_Actived",-1]) != -1) || ((_x getVariable ["TGP_View_EHs",-1]) != -1)
};
[selectRandom ["TacticalPing2","TacticalPing3","TacticalPing4"]] remoteExecCall ["playSound",_list,true];
_vehicle = (player getVariable "TGP_View_Selected_Optic") # 1;
_current_turret = ((player getVariable "TGP_View_Selected_Optic") # 0) # 1;
if (_current_turret isEqualTo []) then {_current_turret = [-1]};
_turret_Unit = _vehicle turretUnit _current_turret;
if ((_turret_Unit getVariable ["TGP_View_Turret_Control",[]]) isEqualTo []) then {
player setVariable ["TGP_View_Mark", (screenToWorld getMousePosition),true];
_pos_old = player getVariable ["TGP_View_Mark",[]];
_end = time + 3;
[{
params ["_end","_pos_old","_unit"];
_last_time = _end - time;
_unit setVariable ["TGP_View_Marker_last",_last_time,true];
((time >= _end) || !(_pos_old isEqualTo (_unit getVariable "TGP_View_Mark")))
}, {
params ["_end","_pos_old","_unit"];
/* if (time >= _end) then {
_unit setVariable ["TGP_View_Marker_last",-1,true];
}; */
}, [_end,_pos_old,player]
] call CBA_fnc_waitUntilAndExecute;
};
},
"",
[0xF0, [false, false, false]]
] call cba_fnc_addKeybind;
[
"Better CAS Environment (TGP)","ToggleCursor",
SetTitle("STR_BCE_Toggle","STR_BCE_Mouse_Cursor"),
{
if !(IsTGP_CAM_ON) exitWith {};
_vehicle = (player getVariable "TGP_View_Selected_Optic") # 1;
_current_turret = ((player getVariable "TGP_View_Selected_Optic") # 0) # 1;
_turret_Unit = _vehicle turretUnit _current_turret;
if (((_turret_Unit getVariable ["TGP_View_Turret_Control",[]]) isEqualTo []) && (isNull findDisplay 1022553)) then {
createdialog "RscDisplayEmpty_BCE";
setMousePosition [0.5, 0.5];
player setVariable ["TGP_view_Mouse_Cursor",true];
SwitchSound;
} else {
if !(isNull findDisplay 1022553) then {
closedialog 1022553;
player setVariable ["TGP_view_Mouse_Cursor",false];
SwitchSound;
};
};
},
"",
[0x32, [false, false, false]]
] call cba_fnc_addKeybind;