forked from Quantx/CC2-UI-Enhancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary_vehicle.lua
More file actions
executable file
·475 lines (428 loc) · 21.8 KB
/
library_vehicle.lua
File metadata and controls
executable file
·475 lines (428 loc) · 21.8 KB
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
function get_carrier_bay_name(index)
bay_name = update_get_loc(e_loc.upp_acronym_surface).."1";
if(index >= 8)
then
bay_name = update_get_loc(e_loc.upp_acronym_air)..(index - 7)
else
bay_name = update_get_loc(e_loc.upp_acronym_surface)..(index + 1)
end
return bay_name
end
function get_icon_data_by_definition_index(index)
region_vehicle_icon = atlas_icons.map_icon_air
icon_offset = 4
if index == e_game_object_type.chassis_land_wheel_light or index == e_game_object_type.chassis_land_wheel_medium or index == e_game_object_type.chassis_land_wheel_heavy then
region_vehicle_icon = atlas_icons.map_icon_surface
icon_offset = 4
elseif index == e_game_object_type.chassis_carrier then
region_vehicle_icon = atlas_icons.map_icon_carrier
icon_offset = 8
elseif index == e_game_object_type.chassis_sea_barge then
region_vehicle_icon = atlas_icons.map_icon_barge
icon_offset = 4
elseif index == e_game_object_type.chassis_land_turret then
region_vehicle_icon = atlas_icons.map_icon_turret
icon_offset = 4
elseif index == e_game_object_type.chassis_land_robot_dog then
region_vehicle_icon = atlas_icons.map_icon_robot_dog
icon_offset = 4
elseif index == e_game_object_type.chassis_sea_ship_light or index == e_game_object_type.chassis_sea_ship_heavy then
region_vehicle_icon = atlas_icons.map_icon_ship
icon_offset = 5
end
return region_vehicle_icon, icon_offset
end
function get_chassis_data_by_definition_index(index)
if index == e_game_object_type.chassis_carrier then
return update_get_loc(e_loc.upp_carrier), atlas_icons.icon_chassis_16_carrier, update_get_loc(e_loc.upp_crr), update_get_loc(e_loc.upp_logistics_carrier)
elseif index == e_game_object_type.chassis_land_wheel_light then
return update_get_loc(e_loc.upp_seal), atlas_icons.icon_chassis_16_wheel_small, update_get_loc(e_loc.upp_sel), update_get_loc(e_loc.upp_light_scout_vehicle)
elseif index == e_game_object_type.chassis_land_wheel_medium then
return update_get_loc(e_loc.upp_walrus), atlas_icons.icon_chassis_16_wheel_medium, update_get_loc(e_loc.upp_wlr), update_get_loc(e_loc.upp_all_purpose_vehicle)
elseif index == e_game_object_type.chassis_land_wheel_heavy then
return update_get_loc(e_loc.upp_bear), atlas_icons.icon_chassis_16_wheel_large, update_get_loc(e_loc.upp_ber), update_get_loc(e_loc.upp_heavy_platform)
elseif index == e_game_object_type.chassis_air_wing_light then
return update_get_loc(e_loc.upp_albatross), atlas_icons.icon_chassis_16_wing_small, update_get_loc(e_loc.upp_alb), update_get_loc(e_loc.upp_scout_wing_aircraft)
elseif index == e_game_object_type.chassis_air_wing_heavy then
return update_get_loc(e_loc.upp_manta), atlas_icons.icon_chassis_16_wing_large, update_get_loc(e_loc.upp_mnt), update_get_loc(e_loc.upp_fast_jet_aircraft)
elseif index == e_game_object_type.chassis_air_rotor_light then
return update_get_loc(e_loc.upp_razorbill), atlas_icons.icon_chassis_16_rotor_small, update_get_loc(e_loc.upp_rzr), update_get_loc(e_loc.upp_light_rotor)
elseif index == e_game_object_type.chassis_air_rotor_heavy then
return update_get_loc(e_loc.upp_petrel), atlas_icons.icon_chassis_16_rotor_large, update_get_loc(e_loc.upp_ptr), update_get_loc(e_loc.upp_heavy_lift_rotor)
elseif index == e_game_object_type.chassis_sea_barge then
return update_get_loc(e_loc.upp_barge), atlas_icons.icon_chassis_16_barge, update_get_loc(e_loc.upp_brg), update_get_loc(e_loc.upp_support_barge)
elseif index == e_game_object_type.chassis_land_turret then
return update_get_loc(e_loc.upp_turret), atlas_icons.icon_chassis_16_land_turret, update_get_loc(e_loc.upp_trt), update_get_loc(e_loc.upp_stationary_turret)
elseif index == e_game_object_type.chassis_land_robot_dog then
return update_get_loc(e_loc.upp_control_bot), atlas_icons.icon_chassis_16_robot_dog, update_get_loc(e_loc.upp_bot), update_get_loc(e_loc.upp_control_bot)
elseif index == e_game_object_type.chassis_sea_ship_light then
return update_get_loc(e_loc.upp_needlefish), atlas_icons.icon_chassis_16_ship_light, update_get_loc(e_loc.upp_ndl), update_get_loc(e_loc.upp_light_patrol_ship)
elseif index == e_game_object_type.chassis_sea_ship_heavy then
return update_get_loc(e_loc.upp_swordfish), atlas_icons.icon_chassis_16_ship_heavy, update_get_loc(e_loc.upp_swd), update_get_loc(e_loc.upp_heavy_patrol_ship)
end
return update_get_loc(e_loc.upp_unknown), atlas_icons.icon_chassis_16_wheel_small, "---", ""
end
function get_attachment_data_by_definition_index(index)
local attachment_data = {
[-1] = {
name = update_get_loc(e_loc.upp_unknown),
icon16 = atlas_icons.icon_attachment_16_none,
},
[e_game_object_type.attachment_turret_15mm] = {
name = update_get_loc(e_loc.upp_15mm_cannon),
icon16 = atlas_icons.icon_attachment_16_turret_main_gun_light,
},
[e_game_object_type.attachment_turret_30mm] = {
name = update_get_loc(e_loc.upp_30mm_cannon),
icon16 = atlas_icons.icon_attachment_16_turret_main_gun,
},
[e_game_object_type.attachment_turret_40mm] = {
name = update_get_loc(e_loc.upp_40mm_cannon),
icon16 = atlas_icons.icon_attachment_16_turret_main_gun_2,
},
[e_game_object_type.attachment_turret_heavy_cannon] = {
name = update_get_loc(e_loc.upp_heavy_cannon),
icon16 = atlas_icons.icon_attachment_16_turret_main_heavy_cannon,
},
[e_game_object_type.attachment_turret_battle_cannon] = {
name = update_get_loc(e_loc.upp_100mm_cannon),
icon16 = atlas_icons.icon_attachment_16_turret_main_battle_cannon,
},
[e_game_object_type.attachment_turret_artillery] = {
name = update_get_loc(e_loc.upp_artillery_gun),
icon16 = atlas_icons.icon_attachment_16_turret_artillery,
},
[e_game_object_type.attachment_turret_carrier_main_gun] = {
name = update_get_loc(e_loc.upp_naval_gun),
icon16 = atlas_icons.icon_attachment_16_none,
},
[e_game_object_type.attachment_turret_plane_chaingun] = {
name = update_get_loc(e_loc.upp_20mm_auto_cannon),
icon16 = atlas_icons.icon_attachment_16_air_chaingun,
},
[e_game_object_type.attachment_turret_rocket_pod] = {
name = update_get_loc(e_loc.upp_rocket_pod),
icon16 = atlas_icons.icon_attachment_16_rocket_pod,
},
[e_game_object_type.attachment_turret_robot_dog_capsule] = {
name = update_get_loc(e_loc.upp_control_bots),
icon16 = atlas_icons.icon_attachment_16_turret_robots,
},
[e_game_object_type.attachment_turret_ciws] = {
name = update_get_loc(e_loc.upp_anti_air_cannon),
icon16 = atlas_icons.icon_attachment_16_turret_ciws,
},
[e_game_object_type.attachment_turret_missile] = {
name = update_get_loc(e_loc.upp_missile_array),
icon16 = atlas_icons.icon_attachment_16_turret_missile,
},
[e_game_object_type.attachment_turret_carrier_ciws] = {
name = update_get_loc(e_loc.upp_naval_anti_air_cannon),
icon16 = atlas_icons.icon_attachment_16_none,
},
[e_game_object_type.attachment_turret_carrier_missile] = {
name = update_get_loc(e_loc.upp_naval_missile_array),
icon16 = atlas_icons.icon_attachment_16_none,
},
[e_game_object_type.attachment_turret_carrier_missile_silo] = {
name = update_get_loc(e_loc.upp_naval_cruise_missile),
icon16 = atlas_icons.icon_attachment_16_none,
},
[e_game_object_type.attachment_turret_carrier_flare_launcher] = {
name = update_get_loc(e_loc.upp_naval_flare_launcher),
icon16 = atlas_icons.icon_attachment_16_none,
},
[e_game_object_type.attachment_turret_carrier_camera] = {
name = update_get_loc(e_loc.upp_naval_camera),
icon16 = atlas_icons.icon_attachment_16_none,
},
[e_game_object_type.attachment_hardpoint_bomb_1] = {
name = update_get_loc(e_loc.upp_bomb_1),
icon16 = atlas_icons.icon_attachment_16_air_bomb_1,
},
[e_game_object_type.attachment_hardpoint_bomb_2] = {
name = update_get_loc(e_loc.upp_bomb_2),
icon16 = atlas_icons.icon_attachment_16_air_bomb_2,
},
[e_game_object_type.attachment_hardpoint_bomb_3] = {
name = update_get_loc(e_loc.upp_bomb_3),
icon16 = atlas_icons.icon_attachment_16_air_bomb_3,
},
[e_game_object_type.attachment_hardpoint_torpedo] = {
name = update_get_loc(e_loc.upp_torpedo),
icon16 = atlas_icons.icon_attachment_16_air_torpedo,
},
[e_game_object_type.attachment_hardpoint_torpedo_noisemaker] = {
name = update_get_loc(e_loc.upp_torpedo_noisemaker),
icon16 = atlas_icons.icon_attachment_16_air_torpedo_noisemaker,
},
[e_game_object_type.attachment_hardpoint_torpedo_decoy] = {
name = update_get_loc(e_loc.upp_torpedo_decoy),
icon16 = atlas_icons.icon_attachment_16_air_torpedo_decoy,
},
[e_game_object_type.attachment_hardpoint_missile_ir] = {
name = update_get_loc(e_loc.upp_missile_1),
icon16 = atlas_icons.icon_attachment_16_air_missile_1,
},
[e_game_object_type.attachment_hardpoint_missile_laser] = {
name = update_get_loc(e_loc.upp_missile_2),
icon16 = atlas_icons.icon_attachment_16_air_missile_2,
},
[e_game_object_type.attachment_hardpoint_missile_aa] = {
name = update_get_loc(e_loc.upp_missile_4),
icon16 = atlas_icons.icon_attachment_16_air_missile_4,
},
[e_game_object_type.attachment_hardpoint_missile_tv] = {
name = update_get_loc(e_loc.upp_missile_tv),
icon16 = atlas_icons.icon_attachment_16_air_missile_tv,
},
[e_game_object_type.attachment_camera] = {
name = update_get_loc(e_loc.upp_actuated_camera),
icon16 = atlas_icons.icon_attachment_16_camera_large,
},
[e_game_object_type.attachment_camera_vehicle_control] = {
name = update_get_loc(e_loc.upp_fixed_camera),
icon16 = atlas_icons.icon_attachment_16_small_camera,
},
[e_game_object_type.attachment_camera_plane] = {
name = update_get_loc(e_loc.upp_gimbal_camera),
icon16 = atlas_icons.icon_attachment_16_camera_aircraft,
},
[e_game_object_type.attachment_camera_observation] = {
name = update_get_loc(e_loc.upp_observation_camera),
icon16 = atlas_icons.icon_attachment_16_small_camera_obs,
},
[e_game_object_type.attachment_radar_awacs] = {
name = update_get_loc(e_loc.upp_awacs_radar_system),
icon16 = atlas_icons.icon_attachment_16_air_radar,
},
[e_game_object_type.attachment_fuel_tank_plane] = {
name = update_get_loc(e_loc.upp_external_fuel_tank),
icon16 = atlas_icons.icon_attachment_16_air_fuel,
},
[e_game_object_type.attachment_flare_launcher] = {
name = update_get_loc(e_loc.upp_ir_countermeasures),
icon16 = atlas_icons.icon_attachment_16_small_flare,
},
[e_game_object_type.attachment_radar_golfball] = {
name = update_get_loc(e_loc.upp_radar_golfball),
icon16 = atlas_icons.icon_attachment_16_radar_golfball,
},
[e_game_object_type.attachment_sonic_pulse_generator] = {
name = update_get_loc(e_loc.upp_sonic_pulse_generator),
icon16 = atlas_icons.icon_attachment_16_sonic_pulse_generator,
},
[e_game_object_type.attachment_smoke_launcher_explosive] = {
name = update_get_loc(e_loc.upp_smoke_launcher_explosive),
icon16 = atlas_icons.icon_attachment_16_smoke_launcher_explosive,
},
[e_game_object_type.attachment_smoke_launcher_stream] = {
name = update_get_loc(e_loc.upp_smoke_launcher_stream),
icon16 = atlas_icons.icon_attachment_16_smoke_launcher_stream,
},
}
return attachment_data[index] or attachment_data[-1]
end
function get_chassis_image_by_definition_index(index)
if index == e_game_object_type.chassis_land_wheel_light then
return atlas_icons.icon_chassis_wheel_small
elseif index == e_game_object_type.chassis_land_wheel_medium then
return atlas_icons.icon_chassis_wheel_medium
elseif index == e_game_object_type.chassis_land_wheel_heavy then
return atlas_icons.icon_chassis_wheel_large
elseif index == e_game_object_type.chassis_air_wing_light then
return atlas_icons.icon_chassis_wing_small
elseif index == e_game_object_type.chassis_air_wing_heavy then
return atlas_icons.icon_chassis_wing_large
elseif index == e_game_object_type.chassis_air_rotor_light then
return atlas_icons.icon_chassis_rotor_small
elseif index == e_game_object_type.chassis_air_rotor_heavy then
return atlas_icons.icon_chassis_rotor_large
elseif index == e_game_object_type.chassis_land_turret then
return atlas_icons.icon_chassis_turret
end
return atlas_icons.icon_chassis_unknown
end
function get_is_vehicle_air(definition_index)
return definition_index == e_game_object_type.chassis_air_wing_light
or definition_index == e_game_object_type.chassis_air_wing_heavy
or definition_index == e_game_object_type.chassis_air_rotor_light
or definition_index == e_game_object_type.chassis_air_rotor_heavy
end
function get_is_vehicle_sea(definition_index)
return definition_index == e_game_object_type.chassis_carrier
or definition_index == e_game_object_type.chassis_sea_barge
or definition_index == e_game_object_type.chassis_sea_ship_light
or definition_index == e_game_object_type.chassis_sea_ship_heavy
end
function get_is_vehicle_land(definition_index)
return definition_index == e_game_object_type.chassis_land_wheel_heavy
or definition_index == e_game_object_type.chassis_land_wheel_medium
or definition_index == e_game_object_type.chassis_land_wheel_light
or definition_index == e_game_object_type.chassis_land_robot_dog
or definition_index == e_game_object_type.chassis_land_turret
end
function get_attack_type_icon(attack_type)
if attack_type == e_attack_type.none then
return atlas_icons.icon_attack_type_any
elseif attack_type == e_attack_type.any then
return atlas_icons.icon_attack_type_any
elseif attack_type == e_attack_type.bomb_single then
return atlas_icons.icon_attack_type_bomb_single
elseif attack_type == e_attack_type.bomb_double then
return atlas_icons.icon_attack_type_bomb_double
elseif attack_type == e_attack_type.missile_single then
return atlas_icons.icon_attack_type_missile_single
elseif attack_type == e_attack_type.missile_double then
return atlas_icons.icon_attack_type_missile_double
elseif attack_type == e_attack_type.torpedo_single then
return atlas_icons.icon_attack_type_torpedo_single
elseif attack_type == e_attack_type.gun then
return atlas_icons.icon_attack_type_gun
elseif attack_type == e_attack_type.rockets then
return atlas_icons.icon_attack_type_rockets
elseif attack_type == e_attack_type.airlift then
return atlas_icons.icon_attack_type_airlift
end
return atlas_icons.icon_attack_type_any
end
function render_ui_chassis_definition_description(x, y, vehicle, index)
update_ui_push_offset(x, y)
local cy = 0
vehicle_definition_name, region_vehicle_icon, vehicle_definition_abreviation, vehicle_definition_description = get_chassis_data_by_definition_index(index)
update_ui_text(0, cy, vehicle_definition_name, 120, 0, color_white, 0)
local inventory_count = vehicle:get_inventory_count_by_definition_index(index)
update_ui_text(0, cy, "x" .. inventory_count, 120, 2, iff(inventory_count > 0, color_status_ok, color_status_bad), 0)
cy = cy + 10
local text_h = update_ui_text(0, cy, vehicle_definition_description, 120, 0, color_grey_dark, 0)
cy = cy + text_h + 2
local hitpoints, armour, mass = update_get_definition_vehicle_stats(index)
local icon_col = color_white
local text_col = color_status_ok
update_ui_image(0, cy, atlas_icons.icon_health, icon_col, 0)
update_ui_text(10, cy, hitpoints, 64, 0, text_col, 0)
cy = cy + 10
update_ui_image(0, cy, atlas_icons.column_difficulty, icon_col, 0)
update_ui_text(10, cy, armour, 64, 0, text_col, 0)
cy = cy + 10
update_ui_image(0, cy, atlas_icons.column_weight, icon_col, 0)
update_ui_text(10, cy, mass .. update_get_loc(e_loc.upp_kg), 64, 0, text_col, 0)
cy = cy + 10
update_ui_pop_offset()
end
function get_is_vehicle_type_waypoint_capable(vehicle_definition_index)
if vehicle_definition_index == e_game_object_type.chassis_carrier then
return false
elseif vehicle_definition_index == e_game_object_type.chassis_land_wheel_light then
return true
elseif vehicle_definition_index == e_game_object_type.chassis_land_wheel_medium then
return true
elseif vehicle_definition_index == e_game_object_type.chassis_land_wheel_heavy then
return true
elseif vehicle_definition_index == e_game_object_type.chassis_air_wing_light then
return true
elseif vehicle_definition_index == e_game_object_type.chassis_air_wing_heavy then
return true
elseif vehicle_definition_index == e_game_object_type.chassis_air_rotor_light then
return true
elseif vehicle_definition_index == e_game_object_type.chassis_air_rotor_heavy then
return true
elseif vehicle_definition_index == e_game_object_type.chassis_sea_barge then
return false
elseif vehicle_definition_index == e_game_object_type.chassis_land_turret then
return false
elseif vehicle_definition_index == e_game_object_type.chassis_sea_ship_light then
return true
elseif vehicle_definition_index == e_game_object_type.chassis_sea_ship_heavy then
return true
end
return false
end
g_item_categories = {}
g_item_data = {}
g_item_count = 0
function begin_load_inventory_data()
for i = 0, update_get_resource_inventory_category_count() - 1 do
local category_index, category_name, icon_name = update_get_resource_inventory_category_data(i)
local category_object =
{
index = category_index,
name = category_name,
icon = atlas_icons[icon_name],
items = {},
item_count = 0,
}
g_item_categories[category_index] = category_object
if category_object.icon == nil then
MM_LOG("icon not found: "..icon_name)
end
end
for i = 0, update_get_resource_inventory_item_count() - 1 do
local item_type, item_category, item_mass, item_production_cost, item_production_time, item_name, item_desc, icon_name, transfer_duration = update_get_resource_inventory_item_data(i)
local item_object =
{
index = item_type,
category = item_category,
mass = item_mass,
cost = item_production_cost,
time = item_production_time,
name = item_name,
desc = item_desc,
icon = atlas_icons[icon_name],
transfer_duration = transfer_duration,
}
g_item_data[item_type] = item_object
g_item_count = g_item_count + 1
if item_object.icon == nil then
MM_LOG("icon not found: "..icon_name)
end
end
for k, v in pairs(g_item_data) do
local item_data = v
local category_data = g_item_categories[item_data.category]
if category_data ~= nil then
table.insert(category_data.items, item_data)
category_data.item_count = category_data.item_count + 1
end
end
end
function get_vehicle_capability(vehicle)
local attachment_count = vehicle:get_attachment_count()
local has_missiles = false
local has_ciws = false
local has_cannon = false
for i = 0, attachment_count - 1 do
local attachment = vehicle:get_attachment(i)
if attachment:get() then
local attachment_def = attachment:get_definition_index()
if attachment_def == e_game_object_type.attachment_turret_15mm
or attachment_def == e_game_object_type.attachment_turret_30mm
or attachment_def == e_game_object_type.attachment_turret_40mm
or attachment_def == e_game_object_type.attachment_turret_heavy_cannon
or attachment_def == e_game_object_type.attachment_turret_artillery
or attachment_def == e_game_object_type.attachment_turret_battle_cannon
then
has_cannon = true
elseif attachment_def == e_game_object_type.attachment_turret_missile then
has_missiles = true
elseif attachment_def == e_game_object_type.attachment_turret_ciws then
has_ciws = true
end
end
end
local capabilities = {}
if has_missiles then table.insert(capabilities, update_get_loc(e_loc.upp_msl)) end
if has_ciws then table.insert(capabilities, update_get_loc(e_loc.upp_aa)) end
if has_cannon then table.insert(capabilities, update_get_loc(e_loc.upp_gun)) end
return join_strings(capabilities, "/")
end
function join_strings(strings, delim)
local str = ""
for i = 1, #strings do
if i > 1 then
str = str .. (delim or ", ")
end
str = str .. strings[i]
end
return str
end