· 8 years ago · Jul 11, 2018, 04:38 PM
1import("ScarUtil.scar");
2import("Fatalities/Fatalities.scar");
3import("Prototype/WorldEntityCollector.scar");
4import("Prototype/SpecialAEFunctions.scar");
5import("WinConditions/Annihilate.scar")
6import("Prototype/SpecialAEFunctions.scar")
7import("PrintOnScreen.scar")
8
9function Util_CreateLocString(text)
10 local tmpstr = LOC(text)
11 tmpstr[1] = text
12 return tmpstr
13end
14
15-- Creates a temporary SGroup from a squadID
16function SGroup_FromSquad(squad)
17 local sg_temp = SGroup_CreateIfNotFound("sg_temp_from_squad");
18 SGroup_Clear(sg_temp);
19 SGroup_Add(sg_temp, squad);
20 return sg_temp;
21end
22-- Fetches the first vehicle entity from a squad
23function Entity_VehicleFromSquad(squad)
24 for i = 0, Squad_Count(squad) - 1 do
25 local e = Squad_EntityAt(squad, i);
26 if Entity_IsVehicle(e) then
27 return e;
28 end
29 end
30 return nil;
31end
32-------------------------------------------------------------------------
33-- [[ SETUP ]]
34-------------------------------------------------------------------------
35function OnGameSetup()
36
37end
38
39
40local function PopCap_OnInit()
41 Camera_SetTuningValue(TV_DistMax, 75)
42 for i = 1, World_GetPlayerCount() do
43 local player = World_GetPlayerAt(i)
44 Player_SetPopCapOverride(player, 150)
45
46 end
47end
48
49Scar_AddInit(PopCap_OnInit)
50
51-------------------------------------------------------------------------
52-- [[ ONINIT ]]
53-------------------------------------------------------------------------
54function OnInit_Delayed()
55
56 UI_TerritoryHide()
57
58 UI_OutOfBoundsLinesHide()
59
60 UI_UnrestrictBuildingPlacement()
61
62 VPTicker_OnInit()
63
64 UI_EnableGameEventCueType(GE_PlayerBeingAttacked , true)
65 UI_EnableGameEventCueType(GE_AbilityExecuted , false)
66 UI_EnableGameEventCueType(GE_UpgradeComplete , false)
67 UI_EnableGameEventCueType(GE_ConstructionComplete , false)
68 UI_EnableGameEventCueType(GE_BuildItemComplete , false)
69 UI_EnableGameEventCueType(GE_SpawnActionComplete , false)
70 UI_EnableGameEventCueType(GE_SquadKilled , false)
71 UI_EnableGameEventCueType(GE_SquadPinned , false)
72 UI_EnableGameEventCueType(GE_EntityKilled , false)
73
74
75
76end
77
78function OnInit()
79
80 UI_SetCPMeterVisibility(false)
81
82 UI_EnableUIEventCueType(UIE_EnemyReveal , false)
83 UI_EnableUIEventCueType(UIE_SquadCold , false)
84 UI_EnableUIEventCueType(UIE_SquadFreezing , false)
85 UI_EnableUIEventCueType(UIE_SquadVeterancy , false)
86 UI_EnableUIEventCueType(UIE_StrategicPointCaptured , false)
87 UI_EnableUIEventCueType(UIE_StrategicPointSecured , false)
88 UI_EnableUIEventCueType(UIE_StrategicPointReverting , false)
89 UI_EnableUIEventCueType(UIE_SquadFreezing , false)
90 UI_EnableUIEventCueType(UIE_SquadVeterancy , false)
91
92 SelectionSystem_Start(); -- starts the selection system
93
94GAME_ISINITIALIZED = true; -- Tell the Ammo_CreateEntity function we're ready to register entities.
95
96 Rule_AddGlobalEvent(Ammo_UpdateSquad, GE_SquadSizeChanged); -- Updates the squad incase it's resized
97
98 Ammo_RegisterPreSpawned(); -- Register the prespawned squads
99
100
101 Rule_AddOneShot(OnInit_Delayed, 0.5)
102
103end
104
105
106Scar_AddInit(OnInit)
107
108WinWarning_ShowLoseWarning = function () end
109WinWarning_PublishLoseReminder = function () end
110WinWarning_SetCritical = function () end
111VPTicker_VictoryBalanceReminder = function() end
112VPTicker_VictorySpeechReminder = function () end
113VPTicker_PointReminder = function () end
114VPTicker_OnInit = function() end
115
116
117---------------------------------------------------------------------------------------------------------------------------------------------
118-- Fuel system - Developed by CoDiEx
119---------------------------------------------------------------------------------------------------------------------------------------------
120fuel_profiles = {};
121-- USF Vehicles
122fuel_profiles["dodge_wc51_50cal_squad_mp"] = {fuel_max = 3860, fuel_burn = 10};
123fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:dodge_wc51_50cal_squadcommander_mp"] = {fuel_max = 3860, fuel_burn = 10};
124fuel_profiles["dodge_wc51_ambulance_squad_mp"] = {fuel_max = 3860, fuel_burn = 10};
125fuel_profiles["dodge_wc51_pathfinder_squad_mp"] = {fuel_max = 3860, fuel_burn = 10};
126fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:dodge_wc51_pathfinder_squadcommander_mp"] = {fuel_max = 3860, fuel_burn = 10};
127fuel_profiles["dodge_wc51_squad_mp"] = {fuel_max = 3860, fuel_burn = 10};
128fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad_assault_mp"] = {fuel_max = 2010, fuel_burn = 10};
129fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad_assault_ranger_mp"] = {fuel_max = 2010, fuel_burn = 10};
130fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad_assaultcommander_mp"] = {fuel_max = 2010, fuel_burn = 10};
131fuel_profiles["m3_halftrack_squad_mp"] = {fuel_max = 2010, fuel_burn = 10};
132fuel_profiles["m15a1_aa_halftrack_squad_mp"] = {fuel_max = 2820, fuel_burn = 10};
133fuel_profiles["m21_mortar_halftrack_squad_mp"] = {fuel_max = 2010, fuel_burn = 10};
134fuel_profiles["t34_calliope_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
135fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:crocodile_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
136fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_jumbo_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
137fuel_profiles["m4a3_76mm_sherman_bulldozer_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
138fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_sherman_bulldozercommander_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
139fuel_profiles["m4a3_76mm_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
140fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_shermancommander_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
141fuel_profiles["m4a3_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
142fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_sherman_squadcommander_mp"] = {fuel_max = 1900, fuel_burn = 10};
143fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_sherman_squad_dozzer_mp"] = {fuel_max = 1900, fuel_burn = 10};
144fuel_profiles["m4a3e8_sherman_easy_8_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
145fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3e8_sherman_easy_8_squadcommander_mp"] = {fuel_max = 1900, fuel_burn = 10};
146fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a4v_canadian_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
147fuel_profiles["m5a1_stuart_squad_mp"] = {fuel_max = 1600, fuel_burn = 10};
148fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5a1_stuart_squadcomm_mp"] = {fuel_max = 1600, fuel_burn = 10};
149fuel_profiles["m7b1_priest_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
150fuel_profiles["m8_greyhound_squad_mp"] = {fuel_max = 5400, fuel_burn = 10};
151fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m8_greyhound_squadcommander_mp"] = {fuel_max = 5400, fuel_burn = 10};
152fuel_profiles["m8a1_hmc_squad_mp"] = {fuel_max = 1600, fuel_burn = 10};
153fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m8a1_hmc_squadcomm_mp"] = {fuel_max = 1600, fuel_burn = 10};
154fuel_profiles["m10_tank_destroyer_squad_mp"] = {fuel_max = 2600, fuel_burn = 10};
155fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m10_tank_destroyercommander_squad_mp"] = {fuel_max = 2600, fuel_burn = 10};
156fuel_profiles["m20_utility_car_squad_mp"] = {fuel_max = 5400, fuel_burn = 10};
157fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m20_utility_car_squad_commander_mp"] = {fuel_max = 5400, fuel_burn = 10};
158fuel_profiles["m26_pershing_mp"] = {fuel_max = 1610, fuel_burn = 10};
159fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m26_pershing_ace_mp"] = {fuel_max = 1610, fuel_burn = 10};
160fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3a1_scout_car_squad_us_mp"] = {fuel_max = 4030, fuel_burn = 10};
161fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sherman_firefly_squad_grizzly_mp"] = {fuel_max = 1900, fuel_burn = 10};
162fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:aef_halftrack_squad_air_mp"] = {fuel_max = 2820, fuel_burn = 10};
163fuel_profiles["aef_halftrack_squad_mp"] = {fuel_max = 2820, fuel_burn = 10};
164-- OKW Vehicles
165fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:brummbar_squad2_mp"] = {fuel_max = 2100, fuel_burn = 10};
166fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:elefant_tank_destroyer_squad_two_mp"] = {fuel_max = 1500, fuel_burn = 10};
167fuel_profiles["goliath_mp"] = {fuel_max = 1500, fuel_burn = 10};
168fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mechanized_250_halftrack_grenadiers2_mp"] = {fuel_max = 3500, fuel_burn = 10};
169fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mortar_250_halftrack_squad_westgerman_mp"] = {fuel_max = 3500, fuel_burn = 10};
170fuel_profiles["sdkfz_251_17_flak_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
171fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_halftrack_squad_mp_falli"] = {fuel_max = 3200, fuel_burn = 10};
172fuel_profiles["sdkfz_251_20_ir_searchlight_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
173fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_2512_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
174fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_2513_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
175fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_halftrack_squad_mp_falli"] = {fuel_max = 3200, fuel_burn = 10};
176fuel_profiles["sdkfz_251_wurfrahmen_40_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
177fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:hetzer_jagdpanzer38_squad_mp"] = {fuel_max = 1800, fuel_burn = 10};
178fuel_profiles["hetzer_squad_mp"] = {fuel_max = 1800, fuel_burn = 10};
179fuel_profiles["jagdpanzer_tank_destroyer_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
180fuel_profiles["jagdtiger_td_squad_mp"] = {fuel_max = 1700, fuel_burn = 10};
181fuel_profiles["king_tiger_squad_mp"] = {fuel_max = 1700, fuel_burn = 10};
182fuel_profiles["kubelwagen_squad_mp"] = {fuel_max = 4500, fuel_burn = 10};
183fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:kubelwagen_squad_ss_mp"] = {fuel_max = 4500, fuel_burn = 10};
184fuel_profiles["ostwind_squad_westgerman_mp"] = {fuel_max = 2000, fuel_burn = 10};
185fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_ausf_g_command_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
186fuel_profiles["panther_ausf_g_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
187fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_ausf_g1_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
188fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_ausf_g2_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
189fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_commander_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
190fuel_profiles["panzer_ii_luchs_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
191fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_ii_luchs_squad2_mp"] = {fuel_max = 2000, fuel_burn = 10};
192fuel_profiles["panzer_iv_ausf_j_battle_group_mp"] = {fuel_max = 2000, fuel_burn = 10};
193fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_commander_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
194fuel_profiles["panzer_iv_stubbyokw_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
195fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_stubbyokw_squad2_mp"] = {fuel_max = 2000, fuel_burn = 10};
196fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_ivg_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
197fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzerwerfer1_squad_mp"] = {fuel_max = 1400, fuel_burn = 10};
198fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stuh_42_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
199fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stuh_42_squadss_mp"] = {fuel_max = 1550, fuel_burn = 10};
200fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:armored_car_sdkfz_234_squad_okw_mp"] = {fuel_max = 6000, fuel_burn = 10};
201fuel_profiles["armored_car_sdkfz_234_squad_mp"] = {fuel_max = 6000, fuel_burn = 10};
202fuel_profiles["sturmtiger_squad_mp"] = {fuel_max = 1200, fuel_burn = 10};
203fuel_profiles["sws_halftrack_squad_mp"] = {fuel_max = 3000, fuel_burn = 10};
204fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_beute_mp"] = {fuel_max = 4650, fuel_burn = 10};
205fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_ace_squad_wittmann_mp"] = {fuel_max = 1000, fuel_burn = 10};
206fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_squadss_mp"] = {fuel_max = 1000, fuel_burn = 10};
207fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_squadss1_mp"] = {fuel_max = 1000, fuel_burn = 10};
208fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_squadss2_mp"] = {fuel_max = 1000, fuel_burn = 10};
209fuel_profiles["scoutcar_223_squad"] = {fuel_max = 3000, fuel_burn = 10};
210fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:scoutcar_223_squadss"] = {fuel_max = 3000, fuel_burn = 10};
211-- UKF Vehicles
212fuel_profiles["aec_armoured_car_squad_mp"] = {fuel_max = 4000, fuel_burn = 10};
213fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:aec_armoured_car_squad2_mp"] = {fuel_max = 4000, fuel_burn = 10};
214fuel_profiles["centaur_aa_mk2_squad_mp"] = {fuel_max = 2800, fuel_burn = 10};
215fuel_profiles["churchill_avre_squad_mp"] = {fuel_max = 900, fuel_burn = 10};
216fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_avre_commander_squad_mp"] = {fuel_max = 900, fuel_burn = 10};
217fuel_profiles["churchill_crocodile_mp"] = {fuel_max = 900, fuel_burn = 10};
218fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_crocodile_commander_mp"] = {fuel_max = 900, fuel_burn = 10};
219fuel_profiles["churchill_default_squad_mp"] = {fuel_max = 900, fuel_burn = 10};
220fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_default_squad_95_mp"] = {fuel_max = 900, fuel_burn = 10};
221fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_default_squad_commander_mp"] = {fuel_max = 900, fuel_burn = 10};
222fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_default_squad_soviet_mp"] = {fuel_max = 900, fuel_burn = 10};
223fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_howitzer_squad_mp"] = {fuel_max = 900, fuel_burn = 10};
224fuel_profiles["comet_tank_squad_mp"] = {fuel_max = 1980, fuel_burn = 10};
225fuel_profiles["cromwell_mk4_75mm_squad_mp"] = {fuel_max = 2800, fuel_burn = 10};
226fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:cromwell_mk4_95mm_squad_mp"] = {fuel_max = 2800, fuel_burn = 10};
227fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:cromwell_mk4_75mm_squad_commander_mp"] = {fuel_max = 2800, fuel_burn = 10};
228fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad__resupply_mp"] = {fuel_max = 2010, fuel_burn = 10};
229fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad__resupply_no_requirement_mp"] = {fuel_max = 2010, fuel_burn = 10};
230fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad_resupply_tommie_mp"] = {fuel_max = 2010, fuel_burn = 10};
231fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_sherman_2_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
232fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_sherman_3_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
233fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_sherman_1_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
234fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_sherman_british_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
235fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a4_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
236fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a4v_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
237fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:aef_halftrack_squad1_mp"] = {fuel_max = 2820, fuel_burn = 10};
238fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5a1_stuart_squad_british_mp"] = {fuel_max = 1600, fuel_burn = 10};
239fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5a1_stuart_squad_british2_mp"] = {fuel_max = 1600, fuel_burn = 10};
240fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m8a1_hmc_squad_british_mp"] = {fuel_max = 1600, fuel_burn = 10};
241fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m10_achilles_tank_destroyer_squad_mp"] = {fuel_max = 2600, fuel_burn = 10};
242fuel_profiles["sexton_spg_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
243fuel_profiles["sherman_firefly_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
244fuel_profiles["universal_carrier_squad_mp"] = {fuel_max = 2500, fuel_burn = 10};
245fuel_profiles["universal_carrier_resupply"] = {fuel_max = 2500, fuel_burn = 10};
246fuel_profiles["valentine_observation_mp"] = {fuel_max = 1400, fuel_burn = 10};
247fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:valentine_observation_russia_mp"] = {fuel_max = 1400, fuel_burn = 10};
248fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:valentine_russia_mp"] = {fuel_max = 1400, fuel_burn = 10};
249-- WEHR Vehicles
250fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_wurfrahmen_40_halftrack_squad_east_mp"] = {fuel_max = 3200, fuel_burn = 10};
251fuel_profiles["brummbar_squad_mp"] = {fuel_max = 2100, fuel_burn = 10};
252fuel_profiles["elefant_tank_destroyer_squad_mp"] = {fuel_max = 1500, fuel_burn = 10};
253fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:goliath_wehrmacht_mp"] = {fuel_max = 1500, fuel_burn = 10};
254fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mechanized_250_halftrack_fallis_mp"] = {fuel_max = 3500, fuel_burn = 10};
255fuel_profiles["mechanized_250_halftrack_grenadiers_mp"] = {fuel_max = 3500, fuel_burn = 10};
256fuel_profiles["mechanized_250_halftrack_mp"] = {fuel_max = 3500, fuel_burn = 10};
257fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mechanized_250_halftrackcommander_mp"] = {fuel_max = 3500, fuel_burn = 10};
258fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mortar_250_halftrack_squad_commander_mp"] = {fuel_max = 3500, fuel_burn = 10};
259fuel_profiles["mortar_250_halftrack_squad_mp"] = {fuel_max = 770, fuel_burn = 2.1};
260fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_halftrack_squad_flame_mp"] = {fuel_max = 3200, fuel_burn = 10};
261fuel_profiles["sdkfz_251_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
262fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_halftrack_squad_wehrmacht_mp"] = {fuel_max = 3200, fuel_burn = 10};
263fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_halftrack_squad_east_mp"] = {fuel_max = 3200, fuel_burn = 10};
264fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_halftrack_squad_east_romania_mp"] = {fuel_max = 3200, fuel_burn = 10};
265fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_halftrack_squad_east_romania_mp"] = {fuel_max = 3200, fuel_burn = 10};
266fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:hetzer_jagdpanzer38_squadw_mp"] = {fuel_max = 1800, fuel_burn = 10};
267fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:jagdpanzerw_tank_destroyer_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
268fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:king_tiger_squadw_mp"] = {fuel_max = 1700, fuel_burn = 10};
269fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:marderm_mp"] = {fuel_max = 2100, fuel_burn = 10};
270fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mardermss_mp"] = {fuel_max = 2100, fuel_burn = 10};
271fuel_profiles["opel_blitz_supply_squad"] = {fuel_max = 3400, fuel_burn = 10};
272fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_squad_grenadiers"] = {fuel_max = 3400, fuel_burn = 10};
273fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_squad_obersoldaten"] = {fuel_max = 3400, fuel_burn = 10};
274fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_squad_ssgrenadiers"] = {fuel_max = 3400, fuel_burn = 10};
275fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_supply_squad"] = {fuel_max = 3400, fuel_burn = 10};
276fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_supplyss_squad"] = {fuel_max = 3400, fuel_burn = 10};
277fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_supplyss_squad"] = {fuel_max = 3400, fuel_burn = 10};
278fuel_profiles["ostwind_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
279fuel_profiles["panther_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
280fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_squad1_mp"] = {fuel_max = 2000, fuel_burn = 10};
281fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_squad2_mp"] = {fuel_max = 2000, fuel_burn = 10};
282fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iii_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
283fuel_profiles["panzer_iv_command_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
284fuel_profiles["panzer_iv_squad_ausfj_mp"] = {fuel_max = 2000, fuel_burn = 10};
285fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_h_mp"] = {fuel_max = 2000, fuel_burn = 10};
286fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_h_okw_mp"] = {fuel_max = 2000, fuel_burn = 10};
287fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_h_wehr_mp"] = {fuel_max = 2000, fuel_burn = 10};
288fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_h2_mp"] = {fuel_max = 2000, fuel_burn = 10};
289fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_j_mp"] = {fuel_max = 2000, fuel_burn = 10};
290fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squadausfh_mp"] = {fuel_max = 2000, fuel_burn = 10};
291fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_stubby_squad2_mp"] = {fuel_max = 2000, fuel_burn = 10};
292fuel_profiles["panzer_iv_stubby_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
293fuel_profiles["panzerwerfer_squad_mp"] = {fuel_max = 1400, fuel_burn = 10};
294fuel_profiles["puma_east_german_mp"] = {fuel_max = 6000, fuel_burn = 10};
295fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:scoutcar_sdkfz221_mp"] = {fuel_max = 3000, fuel_burn = 10};
296fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:scoutcar_sdkfz221ss_mp"] = {fuel_max = 3000, fuel_burn = 10};
297fuel_profiles["scoutcar_sdkfz222_mp"] = {fuel_max = 3000, fuel_burn = 10};
298fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:scoutcar_sdkfz222ss_mp"] = {fuel_max = 3000, fuel_burn = 10};
299fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stug_4_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
300fuel_profiles["stug_iii_e_commander_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
301fuel_profiles["stug_iii_e_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
302fuel_profiles["stug_iii_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
303fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stug_iii_squad_neu_mp"] = {fuel_max = 1550, fuel_burn = 10};
304fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stug_iii_squad2_mp"] = {fuel_max = 1550, fuel_burn = 10};
305fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-3_squad_n_mp"] = {fuel_max = 1550, fuel_burn = 10};
306fuel_profiles["tiger_ace_squad_mp"] = {fuel_max = 1000, fuel_burn = 10};
307fuel_profiles["tiger_squad_mp"] = {fuel_max = 1000, fuel_burn = 10};
308fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_squad2_mp"] = {fuel_max = 1000, fuel_burn = 10};
309-- USSR Vehicles
310fuel_profiles["is-2_mp"] = {fuel_max = 2400, fuel_burn = 10};
311fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:is-2_squad_mp"] = {fuel_max = 2400, fuel_burn = 10};
312fuel_profiles["isu-152_mp"] = {fuel_max = 3700, fuel_burn = 10};
313fuel_profiles["katyusha_bm-13n_squad_mp"] = {fuel_max = 2400, fuel_burn = 10};
314fuel_profiles["kv-1_mp"] = {fuel_max = 3350, fuel_burn = 10};
315fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:kv-1squad_mp"] = {fuel_max = 3350, fuel_burn = 10};
316fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:kv-l11_mp"] = {fuel_max = 3350, fuel_burn = 10};
317fuel_profiles["kv-2_mp"] = {fuel_max = 2500, fuel_burn = 10};
318fuel_profiles["kv-8_mp"] = {fuel_max = 3350, fuel_burn = 10};
319fuel_profiles["m3a1_scout_car_squad_mp"] = {fuel_max = 4030, fuel_burn = 10};
320fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5_halftrack__assault_squad_mp"] = {fuel_max = 2820, fuel_burn = 10};
321fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5_halftrack__assault_squad_rekruten_mp"] = {fuel_max = 2820, fuel_burn = 10};
322fuel_profiles["m5_halftrack_squad_mp"] = {fuel_max = 2820, fuel_burn = 10};
323fuel_profiles["soviet_76mm_sherman_mp"] = {fuel_max = 1900, fuel_burn = 10};
324fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:soviet_76mm_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
325fuel_profiles["su-76m_mp"] = {fuel_max = 4500, fuel_burn = 10};
326fuel_profiles["su-85_mp"] = {fuel_max = 2000, fuel_burn = 10};
327fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:su-85m_mp"] = {fuel_max = 2000, fuel_burn = 10};
328fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:su-85squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
329fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_e_squad_mp"] = {fuel_max = 4650, fuel_burn = 10};
330fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_dispatch_intervall_mp"] = {fuel_max = 4650, fuel_burn = 10};
331fuel_profiles["t_34_76_squad_mp"] = {fuel_max = 4650, fuel_burn = 10};
332fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_rider_dispatch_mp"] = {fuel_max = 4650, fuel_burn = 10};
333fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_test_mp"] = {fuel_max = 4650, fuel_burn = 10};
334fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squads_mp"] = {fuel_max = 4650, fuel_burn = 10};
335fuel_profiles["t_34_85_squad_mp"] = {fuel_max = 4650, fuel_burn = 10};
336fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-60m_mp"] = {fuel_max = 3600, fuel_burn = 10};
337fuel_profiles["t-70m_mp"] = {fuel_max = 3600, fuel_burn = 10};
338fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-70m2_mp"] = {fuel_max = 3600, fuel_burn = 10};
339fuel_profiles["zis_6_transport_truck_mp"] = {fuel_max = 2400, fuel_burn = 10};
340fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:zis_6_transport_truck_rekruts_mp"] = {fuel_max = 2400, fuel_burn = 10};
341fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:zis_6_transport_truck_supply_mp"] = {fuel_max = 2400, fuel_burn = 10};
342-- Finish Vehicles
343fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mechanized_250_halftrack_finish_mp"] = {fuel_max = 3500, fuel_burn = 10};
344fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:kv-l11_captured_mp"] = {fuel_max = 3350, fuel_burn = 10};
345fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stug_iii_g_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
346fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_finish_mp"] = {fuel_max = 4650, fuel_burn = 10};
347fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_85_squad_captured_mp"] = {fuel_max = 4650, fuel_burn = 10};
348fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:universal_carrier_squad_captured_mp"] = {fuel_max = 2500, fuel_burn = 10};
349-- Romanian Vehicles
350fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:251_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
351fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:bm-13n_squad_mp"] = {fuel_max = 2400, fuel_burn = 10};
352fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_1942_mp"] = {fuel_max = 4650, fuel_burn = 10};
353fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_85_squad_1943_mp"] = {fuel_max = 4650, fuel_burn = 10};
354fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-3_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
355fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-4_g_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
356fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-5_a_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
357fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tas_iii_f_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
358fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tas_iii_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
359fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tas_iv_70_tank_destroyer_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
360
361fuel_targets = {};
362
363-- Register a vehicle
364function Fuel_RegisterMe(...)
365
366 local entityVehicle = Entity_VehicleFromSquad(arg[1]); -- Get the vehicle entity in the squad
367
368 if entityVehicle == nil then -- Make sure the entity Vehicle is not Null/Nil
369 return; -- The target is not a vehicle, or atleast there's no entity in the squad that's marked as a vehicle
370 end
371
372 local entityID = Entity_GetGameID(entityVehicle); -- Get the entity ID of the vehicle entity
373 local squadbp = BP_GetName(Squad_GetBlueprint(arg[1])); -- Get the blueprint name of the squad
374 local player = Util_GetPlayerOwner(arg[1]); -- Get the player owner of the squad
375
376 if (fuel_targets[entityID] ~= nil) then -- Is the entity already registered in the system?
377 return; -- The target already exists in the system, no need to re-add it. Likewise we'll also avoid a bug where American vehicles can re-crew to regain lost fuel
378 end
379
380 Cmd_InstantUpgrade(SGroup_FromSquad(arg[1]), BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:fuel_capable"), 1); -- Give the squad an upgrade, marking it as fuel capable
381 -- Replace the <ModID> with your mod ID, so for example, this mod would use ID 608c780e681d46b9a3f2b399b2a1d86a
382 -- and will therefore look like this: Cmd_InstantUpgrade(SGroup_FromSquad(arg[1]), BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:fuel_capable"), 1);
383 -- The SGroup_FromSquad function is currently undefined, as it's a custom function that we'll introduce later.
384
385 -- Here we actually register the entity in the system
386 fuel_targets[entityID] = { -- Create a new entry in the table with indexing key set to the unique game ID given to the entity
387 is_aiOwned = AI_IsAIPlayer(player), -- Is the AI an owner of this vehicle?
388
389 -- The following three variables are set using the fuel_profiles table. You'll be filling in these profiles later, dont worry.
390 -- But as you can probably already see, the blueprint name is being used as a key. (if you want to challenge yourself, set up the fuel_profiles yourself without reading the tutorial)
391 maxf = fuel_profiles[squadbp].fuel_max;
392 current = fuel_profiles[squadbp].fuel_max;
393 burn = fuel_profiles[squadbp].fuel_burn;
394
395 warning50 = false; -- Variable used later, set it to false for now
396 out = false; -- Variable used to mark whether the vehicle is currently out of fuel
397 modifier = nil; -- A variable containing a speed modifier reference
398 position = Entity_GetPosition(entityVehicle); -- The current position of the vehicle
399 };
400
401 -- Should the AI ignore fuel for this vehicle? (this is handy for vehicles like the SWS where the AI could be dumb and have it use up its fuel before it gets to set up)
402 fuel_targets[entityID].ignoreifai = fuel_profiles[squadbp].ai_ignore or false; -- Make the default value false. If the ai_ignore flag is set to true, it will make the AI ignore the vehicle
403
404 if (Rule_Exists(Fuel_Update) == false) then -- Check if there's already a rule calling the Fuel_Update function (defined soon)
405 Rule_AddInterval(Fuel_Update, 1); -- Add an interval to update the fuel system every second
406 end
407
408end
409
410-- Updates the state of the fuel targets
411function Fuel_Update()
412
413 for k,v in pairs(fuel_targets) do -- Go through each element in the fuel_targets table where k = entity ID and v = entity entry
414
415 if Entity_IsValid(k) then -- Make sure the entity exists/is valid
416
417 if not (v.ignoreifai == true and v.is_aiOwned) then -- Make sure, that if the owner is an AI player, we're allowed to update it
418
419 local e = Entity_FromWorldID(k); -- Get the actual entity from the entity ID
420
421 if Entity_IsMoving(e) then -- Check if the entity is moving
422
423 local s = Entity_GetSquad(e); -- Get the squad the entity is part of
424 local sg = SGroup_FromSquad(s); -- Make a temporary SquadGroup
425
426 v.current = v.current - v.burn; -- Subtract the burn rate from the current amount of fuel
427
428 if v.current <= 0 and v.out == false then -- Check if the fuel amount is less than or equal to 0 AND the vehicle is not marked as out yet
429
430 Cmd_CriticalHit(Util_GetPlayerOwner(s), sg, BP_GetCriticalBlueprint("608c780e681d46b9a3f2b399b2a1d86a:vehicle_outfuel"), 0); -- Give a critical to the vehicle, disabling movement
431
432 if (Game_GetLocalPlayer() == Util_GetPlayerOwner(s)) then -- Is the vehicle owned by the local player?
433 EventCue_Create(CUE.VEHICLE, "$608c780e681d46b9a3f2b399b2a1d86a:1", "$608c780e681d46b9a3f2b399b2a1d86a:1", sg, "$608c780e681d46b9a3f2b399b2a1d86a:1", nil, 7, true); -- Alert the local player of the vehicle running out of fuel
434 end
435
436 v.out = true; -- Mark the vehicle as having run out of fuel
437
438 elseif v.current < (v.maxf / 3.0) and v.warning50 == false then -- Is the amount less than a third of the max fuel and the warning50 is set to false
439
440 if (v.modifier ~= nil) then -- Incase the modifier is already in place (to make sure it's not stacked)
441 Modifier_Remove(v.modifier); -- Remove the modifier
442 end
443
444 v.modifier = Modify_UnitSpeed(sg, 0.75); -- Add a speed modifier (makes the unit move 25% slower)
445 v.warning50 = true; -- Mark this as having reached it's low point
446
447 end
448 end
449 end
450
451 else -- Not valid
452
453 fuel_targets[k] = nil; -- Make it be nil, so we no longer check this vehicle
454
455 end
456
457 end
458
459end
460
461-- Allows the executer to refuel the target
462function Fuel_RefuelTarget(executer, target)
463
464 if scartype(executer) == ST_SQUAD and scartype(target) == ST_SQUAD then -- Firtsly make sure both are squads
465
466 local __InfantryGroup = SGroup_CreateIfNotFound("__InfantryGroup"); -- Crate a Sgroup for the infantry squad that is going to refuel the vehicle
467 SGroup_Add(__InfantryGroup, executer); -- Add the ability executer to the Sgroup
468
469 local entityVehicle = Entity_VehicleFromSquad(target); -- Get the vehicle from the target squad
470 local entityID = Entity_GetGameID(entityVehicle); -- Get the entityID
471
472 if fuel_targets[entityID] ~= nil then -- Make sure the entity is registered in the fuel system
473
474 fuel_targets[entityID].current = fuel_targets[entityID].maxf; -- Set the vehicles current fuel to its max fuel
475
476 UI_CreateColouredSquadKickerMessage(Game_GetLocalPlayer(), target, "$608c780e681d46b9a3f2b399b2a1d86a:2", 0, 255, 0, 0); -- Create a coloured kicker message that says 100% fuel (the last 4 numbers are RGBA numbers)
477 SGroup_RemoveUpgrade(SGroup_FromSquad(Entity_GetSquad(entityVehicle)), BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:fuel_out")); -- Remove the Fuel_Out upgrade from the entity
478
479 if Entity_HasCritical(entityVehicle, BP_GetCriticalBlueprint("608c780e681d46b9a3f2b399b2a1d86a:vehicle_outfuel")) == true then -- Make sure the target actually has this critical
480 Entity_RemoveCritical(entityVehicle, BP_GetCriticalBlueprint("608c780e681d46b9a3f2b399b2a1d86a:vehicle_outfuel")); -- Remove the critical
481 end
482
483 if (fuel_targets[entityID].modifier ~= nil) then -- Is the speed modifier valid?
484 Modifier_Remove(fuel_targets[entityID].modifier); -- Remove the speed modifier
485 end
486
487 fuel_targets[entityID].warning50 = false; -- Reset this variable
488 fuel_targets[entityID].out = false -- Reset the out variable
489
490 SGroup_RemoveUpgrade(__InfantryGroup, BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:fuel_equipped")); -- Remove the fuel_equippped upgrade from the infantry
491
492 end
493
494 SGroup_Clear(__InfantryGroup); -- Clear the infantry group
495
496 end -- You can add other combinations down here (like ST_SQUAD and ST_ENTITY)
497
498end
499---------------------------------------------------------------------------------------------------------------------------------------------
500-- Ammo System - Developed by CoDiEx
501---------------------------------------------------------------------------------------------------------------------------------------------
502ammo_icons = {
503 [""] = "Icons_weapons_weapon_dp_28_lmg", -- The default icon
504 ["tank"] = "Icons_weapons_weapon_firefly_tulip_rocket", -- A tulip rocket. Hopefully it's acceptable as a temporary tank projectile
505};
506
507ammo_profile = {};
508
509-- Small Arms - Rifles
510ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:g43_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 10, icon = "" };
511ammo_profile["g43_sniper_sniper_mp"] = { carried_clips = 6, rounds_in_clip = 10, icon = "" };
512ammo_profile["jaeger_g43_rifle_mp"] = { carried_clips = 5, rounds_in_clip = 10, icon = "" };
513ammo_profile["jaeger_panzergren_g43_rifle_mp"] = { carried_clips = 5, rounds_in_clip = 10, icon = "" };
514ammo_profile["stormtrooper_g43"] = { carried_clips = 5, rounds_in_clip = 10, icon = "" };
515ammo_profile["jaeger_light_recon_g43"] = { carried_clips = 5, rounds_in_clip = 10, icon = "" };
516ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:jaeger_light_recon_sniper_g43"] = { carried_clips = 5, rounds_in_clip = 10, icon = "" };
517ammo_profile["panzerfusilier_g43"] = { carried_clips = 5, rounds_in_clip = 10, icon = "" };
518ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:sniper_g43"] = { carried_clips = 6, rounds_in_clip = 10, icon = "" };
519ammo_profile["panzerfusilier_kar_98k_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
520ammo_profile["volksgrenadier_kar_98k_rifle_mp"] = { carried_clips = 5, rounds_in_clip = 5, icon = "" };
521ammo_profile["waffen_wlite_kar_98k_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
522ammo_profile["grenadier_kar_98k_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
523ammo_profile["ostruppen_kar_98k_rifle_mp"] = { carried_clips = 5, rounds_in_clip = 5, icon = "" };
524ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:kar_98k_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
525ammo_profile["weapon_crew_kar_98k_rifle_mp"] = { carried_clips = 5, rounds_in_clip = 5, icon = "" };
526ammo_profile["commando_lee_enfield_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 10, icon = "" };
527ammo_profile["medic_lee_enfield_rifle_mp"] = { carried_clips = 3, rounds_in_clip = 10, icon = "" };
528ammo_profile["sniper_lee_enfield_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 10, icon = "" };
529ammo_profile["tommy_lee_enfield_rifle_mp"] = { carried_clips = 5, rounds_in_clip = 10, icon = "" };
530ammo_profile["tommy_scoped_lee_enfield_rifle_mp"] = { carried_clips = 4, rounds_in_clip = 10, icon = "" };
531ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:tommy_scoped_lee_enfield_rifle_sniper_mp"] = { carried_clips = 4, rounds_in_clip = 10, icon = "" };
532ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:tommy_scoped_lee_enfield_rifle2_mp"] = { carried_clips = 4, rounds_in_clip = 10, icon = "" };
533ammo_profile["weapon_crew_lee_enfield_rifle_mp"] = { carried_clips = 5, rounds_in_clip = 10, icon = "" };
534ammo_profile["m1_garand_rifle_mortar_crew_mp"] = { carried_clips = 6, rounds_in_clip = 8, icon = "" };
535ammo_profile["m1_garand_rifle_rear_echelon_mp"] = { carried_clips = 5, rounds_in_clip = 8, icon = "" };
536ammo_profile["m1_garand_rifle_rifleman_mp"] = { carried_clips = 7, rounds_in_clip = 8, icon = "" };
537ammo_profile["pathfinder_m1garand_scope_mp"] = { carried_clips = 7, rounds_in_clip = 8, icon = "" };
538ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:pathfindersmiper_m1garand_scope_mp"] = { carried_clips = 7, rounds_in_clip = 8, icon = "" };
539ammo_profile["m1_carbine_rear_echelon_mp"] = { carried_clips = 4, rounds_in_clip = 15, icon = "" };
540ammo_profile["m1_carbine_rear_echelon_volley_mp"] = { carried_clips = 4, rounds_in_clip = 15, icon = "" };
541ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:m1a1_carbine_cavalry_mp"] = { carried_clips = 5, rounds_in_clip = 15, icon = "" };
542ammo_profile["m1a1_carbine_paratrooper_mp"] = { carried_clips = 5, rounds_in_clip = 15, icon = "" };
543ammo_profile["m1a1_carbine_ranger_mp"] = { carried_clips = 5, rounds_in_clip = 15, icon = "" };
544ammo_profile["m1a1_carbine_rifleman_spec_mp"] = { carried_clips = 4, rounds_in_clip = 15, icon = "" };
545ammo_profile["commando_de_lisle_carbine_mp"] = { carried_clips = 5, rounds_in_clip = 15, icon = "" };
546ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:springfield_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
547ammo_profile["springfield_sniper_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
548ammo_profile["guards_troops_mosin_nagant_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
549ammo_profile["mosin_nagant_rifle_combat_engineer_mp"] = { carried_clips = 4, rounds_in_clip = 5, icon = "" };
550ammo_profile["mosin_nagant_rifle_conscript_dummy"] = { carried_clips = 5, rounds_in_clip = 5, icon = "" };
551ammo_profile["mosin_nagant_rifle_conscript_mp"] = { carried_clips = 5, rounds_in_clip = 5, icon = "" };
552ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:mosin_nagant_rifle_snipernew_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
553ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:mosin_nagant_rifle_soviet_recruits_mp"] = { carried_clips = 5, rounds_in_clip = 5, icon = "" };
554ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:mosin_nagant_sniper_rodina_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 5, icon = "" };
555ammo_profile["partisan_troops_mosin_nagant_rifle_mp"] = { carried_clips = 4, rounds_in_clip = 5, icon = "" };
556ammo_profile["penal_troops_svt_rifle_mp"] = { carried_clips = 3, rounds_in_clip = 10, icon = "" };
557
558-- Small Arms - Pistols
559ammo_profile["luger_p08_9mm_pistol_mp"] = { carried_clips = 3, rounds_in_clip = 8, icon = "" };
560ammo_profile["m1911_45cal_pistol_mp"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
561ammo_profile["medic_m1911_45cal_pistol_mp"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
562ammo_profile["brit_medic_pistol_mp"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
563ammo_profile["brit_officer_pistol_mp"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
564ammo_profile["isakovich_colt_m1911_45_pistol_l_mp"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
565ammo_profile["isakovich_colt_m1911_45_pistol_mp"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
566ammo_profile["isakovich_colt_m1911_45_pistol_mp"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
567ammo_profile["nagant_m1895_revolver_227"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
568ammo_profile["nagant_m1895_revolver_227_enemy"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
569ammo_profile["nagant_m1895_revolver_mp"] = { carried_clips = 3, rounds_in_clip = 7, icon = "" };
570
571-- Small Arms - Sub Machine Guns
572ammo_profile["captain_m1_thompson_mp"] = { carried_clips = 5, rounds_in_clip = 30, icon = "" };
573ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:cavalry_m1_thompson_mp"] = { carried_clips = 6, rounds_in_clip = 30, icon = "" };
574ammo_profile["paratrooper_m1_thompson_mp"] = { carried_clips = 7, rounds_in_clip = 30, icon = "" };
575ammo_profile["ranger_m1_thompson_mp"] = { carried_clips = 7, rounds_in_clip = 30, icon = "" };
576ammo_profile["commando_m1_thompson_mp"] = { carried_clips = 7, rounds_in_clip = 30, icon = "" };
577ammo_profile["engineer_m3_grease_gun_mp"] = { carried_clips = 6, rounds_in_clip = 30, icon = "" };
578ammo_profile["m3_grease_gun_vehicle_crew_mp"] = { carried_clips = 3, rounds_in_clip = 30, icon = "" };
579ammo_profile["assault_grenadier_mp40"] = { carried_clips = 6, rounds_in_clip = 32, icon = "" };
580ammo_profile["eg_pioneer_mp40_smg_mp"] = { carried_clips = 5, rounds_in_clip = 32, icon = "" };
581ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:newunit_mortar_mp40_smg_mp"] = { carried_clips = 4, rounds_in_clip = 32, icon = "" };
582ammo_profile["panzer_grenadier_mp40_smg_mp"] = { carried_clips = 6, rounds_in_clip = 32, icon = "" };
583ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:sturminf_mp"] = { carried_clips = 6, rounds_in_clip = 32, icon = "" };
584ammo_profile["urban_panzer_grenadier_mp40_smg_mp"] = { carried_clips = 6, rounds_in_clip = 32, icon = "" };
585ammo_profile["pioneer_mp40_smg_mp"] = { carried_clips = 5, rounds_in_clip = 32, icon = "" };
586ammo_profile["weapon_crew_mp40_smg_mp"] = { carried_clips = 4, rounds_in_clip = 32, icon = "" };
587ammo_profile["weapon_crew_&_pioneer_mp40_smg_mp"] = { carried_clips = 4, rounds_in_clip = 32, icon = "" };
588ammo_profile["assault_pioneer_mp44_smg_mp"] = { carried_clips = 5, rounds_in_clip = 30, icon = "" };
589ammo_profile["waffen_elite_grenadier_mp44_smg_mp"] = { carried_clips = 6, rounds_in_clip = 30, icon = "" };
590ammo_profile["panzer_grenadier_mp44_smg_mp"] = { carried_clips = 6, rounds_in_clip = 30, icon = "" };
591ammo_profile["waffen_elite_grenadier_mp44_vampir_smg_mp"] = { carried_clips = 6, rounds_in_clip = 30, icon = "" };
592ammo_profile["waffen_elite_grenadier_mp44_vampir_smg_mp"] = { carried_clips = 6, rounds_in_clip = 30, icon = "" };
593ammo_profile["waffen_mp44_infrared_mp"] = { carried_clips = 6, rounds_in_clip = 30, icon = "" };
594ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:penal_troops_avs36_rifle_mp"] = { carried_clips = 6, rounds_in_clip = 10, icon = "" };
595ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:strelkies_ppsh-41_sub_machine_gun_mp"] = { carried_clips = 4, rounds_in_clip = 71, icon = "" };
596ammo_profile["conscript_ppsh-41_sub_machine_gun_mp"] = { carried_clips = 4, rounds_in_clip = 71, icon = "" };
597ammo_profile["avre_crew_sten_9mm_smg_mp"] = { carried_clips = 5, rounds_in_clip = 32, icon = "" };
598ammo_profile["commando_sten_mk_vi_silenced_smg_mp"] = { carried_clips = 6, rounds_in_clip = 32, icon = "" };
599ammo_profile["engineer_sten_9mm_smg_mp"] = { carried_clips = 5, rounds_in_clip = 32, icon = "" };
600
601-- Small Arms - Light Machine Guns
602ammo_profile["riflemen_30cal_lmg_mp"] = { carried_clips = 2, rounds_in_clip = 250, fire_rate = 6, icon = "" };
603ammo_profile["paratrooper_m1919a6_lmg_moving_mp"] = { carried_clips = 2, rounds_in_clip = 250, fire_rate = 6, icon = "" };
604ammo_profile["paratrooper_m1919a6_lmg_moving_no_prone_mp"] = { carried_clips = 2, rounds_in_clip = 250, fire_rate = 6, icon = "" };
605ammo_profile["riflemen_bar_30_06_light_machine_gun_mp"] = { carried_clips = 5, rounds_in_clip = 20, fire_rate = 5, icon = "" };
606ammo_profile["bren_light_machine_gun_mp"] = { carried_clips = 4, rounds_in_clip = 30, icon = "" };
607ammo_profile["commando_bren_lmg_moving_mp"] = { carried_clips = 6, rounds_in_clip = 30, fire_rate = 5, icon = "" };
608ammo_profile["sapper_bren_light_machine_gun_mp"] = { carried_clips = 4, rounds_in_clip = 30, fire_rate = 5, icon = "" };
609ammo_profile["tommy_bren_light_machine_gun_mp"] = { carried_clips = 5, rounds_in_clip = 30, fire_rate = 5, icon = "" };
610ammo_profile["guard_troop_dp-28_light_machine_gun_moving_mp"] = { carried_clips = 5, rounds_in_clip = 47, fire_rate = 5, icon = "" };
611ammo_profile["guard_troop_dp-28_light_machine_gun_mp"] = { carried_clips = 5, rounds_in_clip = 47, fire_rate = 5, icon = "" };
612ammo_profile["partisan_dp-28_light_machine_gun_mp"] = { carried_clips = 4, rounds_in_clip = 47, fire_rate = 5, icon = "" };
613ammo_profile["fallschirmjager_gewehr_42_mp"] = { carried_clips = 6, rounds_in_clip = 20, fire_rate = 5, icon = "" };
614ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:m1919a6_lmg_mp"] = { carried_clips = 2, rounds_in_clip = 250, fire_rate = 6, icon = "" };
615ammo_profile["grenadier_mg42lmg_moving_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 10, icon = "" };
616ammo_profile["grenadier_mg42lmg_moving_no_prone_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 10, icon = "" };
617ammo_profile["grenadier_mg42lmg_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 10, icon = "" };
618ammo_profile["sapper_vickers_k_machine_gun_mp"] = { carried_clips = 5, rounds_in_clip = 60, fire_rate = 6, icon = "" };
619ammo_profile["scout_car_mg34_pintle_generic_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 6, icon = "" };
620ammo_profile["halftrack_mg42_vehicle_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 10, icon = "" };
621ammo_profile["scout_car_mg34_coaxial_generic_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 6, icon = "" };
622ammo_profile["scout_car_mg34_pintle_generic_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 6, icon = "" };
623ammo_profile["m3a1_scout_car_30cal_browning_m1919__machine_gun_mp"] = { carried_clips = 5, rounds_in_clip = 110, fire_rate = 5, icon = "" };
624ammo_profile["kubelwagen_mg34_pintle_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 6, icon = "" };
625ammo_profile["vickers_k_universal_carrier"] = { carried_clips = 5, rounds_in_clip = 100, fire_rate = 6, icon = "" };
626ammo_profile["obersoldaten_mg34_lmg_generic_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 6, icon = "" };
627ammo_profile["obersoldaten_mg34_lmg_moving_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 6, icon = "" };
628ammo_profile["obersoldaten_mg34_lmg_moving_no_prone_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 6, icon = "" };
629ammo_profile["sdkfz_251_mg42_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 10, icon = "" };
630ammo_profile["sdkfz_251_mg42_rear_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 10, icon = "" };
631ammo_profile["sdkfz_250_mg34_mp"] = { carried_clips = 5, rounds_in_clip = 50, fire_rate = 6, icon = "" };
632-- Small Arms - Heavy Machine Guns (fire_rate = how many bullets to subtract)
633ammo_profile["universal_carrier_bren_lmg_mp"] = { carried_clips = 8, rounds_in_clip = 30, fire_rate = 4, icon = "" };
634ammo_profile["dshk_38_sokolov_mp"] = { carried_clips = 8, rounds_in_clip = 50, fire_rate = 4, icon = "" };
635ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:hmg_team_mg34new_mp"] = { carried_clips = 8, rounds_in_clip = 50, fire_rate = 6, icon = "" };
636ammo_profile["hmg_team_mg42_mp"] = { carried_clips = 10, rounds_in_clip = 50, fire_rate = 10, icon = "" };
637ammo_profile["m2hb_50cal_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
638ammo_profile["maxim_m1910_hmg_mp"] = { carried_clips = 6, rounds_in_clip = 250, fire_rate = 4, icon = "" };
639ammo_profile["vickers_hmg_mp"] = { carried_clips = 6, rounds_in_clip = 250, fire_rate = 4, icon = "" };
640ammo_profile["m5_halftrack_m2hb_hmg_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
641ammo_profile["m5_halftrack_quad_50_cal_m2hb_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
642ammo_profile["m3_halftrack_m2hb_50cal_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
643ammo_profile["m20_utility_car_m2hb_50cal_mounted_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
644ammo_profile["dodge_wc51_m1917_30cal_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
645ammo_profile["dodge_wc51_m2hb_50cal_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
646ammo_profile["dodge_wc51_m1917_30cal_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
647ammo_profile["m2hb_50cal_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
648ammo_profile["m3_halftrack_m2hb_50cal_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
649ammo_profile["m3a1_scout_car_m2hb_hmg_mp"] = { carried_clips = 7, rounds_in_clip = 110, fire_rate = 4, icon = "" };
650ammo_profile["m15a1_aa_half_track_50cal_left_mp"] = { carried_clips = 10, rounds_in_clip = 110, fire_rate = 4, icon = "" };
651
652-- Small Arms - Mortars
653ammo_profile["grw34_81mm_mortar_mp"] = { carried_clips = 24, rounds_in_clip = 1, icon = "" };
654ammo_profile["m1_81mm_mortar_mp"] = { carried_clips = 26, rounds_in_clip = 1, icon = "" };
655ammo_profile["brit_3_inch_mortar_1_auto_light_he_mp"] = { carried_clips = 60, rounds_in_clip = 1, icon = "" };
656ammo_profile["brit_3_inch_mortar_2_auto_light_he_mp"] = { carried_clips = 60, rounds_in_clip = 1, icon = "" };
657ammo_profile["hm_38_120mm_mortar_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "" };
658ammo_profile["pm41_82mm_mortar_mp"] = { carried_clips = 24, rounds_in_clip = 1, icon = "" };
659ammo_profile["pack_howitzer_75mm_auto_attack_mp"] = { carried_clips = 42, rounds_in_clip = 1, icon = "" };
660ammo_profile["m2_60mm_mortar_mp"] = { carried_clips = 42, rounds_in_clip = 1, icon = "" };
661ammo_profile["le_ig_18_howitzer_75mm_mp"] = { carried_clips = 64, rounds_in_clip = 1, icon = "" };
662ammo_profile["m8a1_hmc_m3_75mm_direct_mp"] = { carried_clips = 42, rounds_in_clip = 1, icon = "" };
663
664-- Flamethrowers (Hand-held)
665ammo_profile["flamethrower_roks3_mp"] = { carried_clips = 24, rounds_in_clip = 80, icon = "" };
666ammo_profile["assault_engineer_flamethrower"] = { carried_clips = 24, rounds_in_clip = 80, icon = "" };
667ammo_profile["pioneer_flamethrower_mp"] = { carried_clips = 24, rounds_in_clip = 80, icon = "" };
668ammo_profile["tommy_flamethrower"] = { carried_clips = 24, rounds_in_clip = 80, icon = "" };
669ammo_profile["flamethrower_roks3_mp"] = { carried_clips = 24, rounds_in_clip = 80, icon = "" };
670ammo_profile["flamethrower_roks3_mp"] = { carried_clips = 24, rounds_in_clip = 80, icon = "" };
671
672-- Flamethrowers (Tank)
673ammo_profile["hetzer_keobe_flamethrower__mp"] = { carried_clips = 96, rounds_in_clip = 1, icon = "" };
674
675-- Anti Tank Guns (Stationary)
676ammo_profile["75mm_pak_40_mp"] = { carried_clips = 32, rounds_in_clip = 1, icon = "" };
677ammo_profile["75mm_pak_40_ap_mp"] = { carried_clips = 32, rounds_in_clip = 1, icon = "" };
678ammo_profile["53k_45mm_m1937_at_gun_mp"] = { carried_clips = 48, rounds_in_clip = 1, icon = "" };
679ammo_profile["pak43_88mm_atg_ap_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "" };
680ammo_profile["pak43_88mm_atg_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "" };
681ammo_profile["zis3__at_gun_mp"] = { carried_clips = 30, rounds_in_clip = 1, icon = "" };
682ammo_profile["m1_57mm_at_gun__mp"] = { carried_clips = 38, rounds_in_clip = 1, icon = "" };
683ammo_profile["raketenwerfer43_88mm_wg_mp"] = { carried_clips = 16, rounds_in_clip = 1, icon = "" };
684ammo_profile["brit_6_pounder_at_gun_mp"] = { carried_clips = 38, rounds_in_clip = 1, icon = "" };
685ammo_profile["17_pounder_atg_mp"] = { carried_clips = 30, rounds_in_clip = 1, icon = "" };
686
687-- Anti Tank Guns (Hand-held)
688ammo_profile["panzerbusche_39_mp"] = { carried_clips = 28, rounds_in_clip = 1, icon = "" };
689ammo_profile["panzerschreck_atw_mp"] = { carried_clips = 6, rounds_in_clip = 1, icon = "" };
690ammo_profile["panzerschreck_54_atw_mp"] = { carried_clips = 6, rounds_in_clip = 1, icon = "" };
691ammo_profile["guard_troop_ptrs_41_mp"] = { carried_clips = 22, rounds_in_clip = 1, icon = "" };
692ammo_profile["m9_bazooka_mp"] = { carried_clips = 6, rounds_in_clip = 1, icon = "" };
693ammo_profile["boys_at_rifle_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "" };
694ammo_profile["boys_at_rifle_sniper_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "" };
695ammo_profile["piat_launcher_mp"] = { carried_clips = 6, rounds_in_clip = 1, icon = "" };
696
697-- Artillery
698ammo_profile["sexton_dummy_mp"] = { carried_clips = 84, rounds_in_clip = 1, icon = "" };
699ammo_profile["m7b1_priest_m2a1_105mm_dummy_mp"] = { carried_clips = 84, rounds_in_clip = 1, icon = "" };
700
701-- Tank Guns (Wehrmacht)
702ammo_profile["brummbar_150mm_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "tank" };
703ammo_profile["elefant_88mm_gun_mp"] = { carried_clips = 25, rounds_in_clip = 1, icon = "tank" };
704ammo_profile["ostwind_flak_43_37mm_mp"] = { carried_clips = 52, rounds_in_clip = 8, icon = "tank" };
705ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:ostwind_flak_43_37mm_he_mp"] = { carried_clips = 52, rounds_in_clip = 8, icon = "tank" };
706ammo_profile["sdkfz_222_kwk38_20mm__mp"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
707ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_222_kwk38_20mm_he_mp"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
708ammo_profile["panther_75mm_mp"] = { carried_clips = 40, rounds_in_clip = 1, icon = "tank" };
709ammo_profile["panzer_4_75mm_mp"] = { carried_clips = 44, rounds_in_clip = 1, icon = "tank" };
710ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:panzer_4_75mmausfh_mp"] = { carried_clips = 44, rounds_in_clip = 1, icon = "tank" };
711ammo_profile["panzer_4_75mm_short_mp"] = { carried_clips = 40, rounds_in_clip = 1, icon = "tank" };
712ammo_profile["puma_50mm_mp"] = { carried_clips = 26, rounds_in_clip = 1, icon = "tank" };
713ammo_profile["stug_75mm_mp"] = { carried_clips = 26, rounds_in_clip = 1, icon = "tank" };
714ammo_profile["stug_75mm_short_mp"] = { carried_clips = 22, rounds_in_clip = 1, icon = "tank" };
715ammo_profile["tiger_kwk36_88mm_mp"] = { carried_clips = 46, rounds_in_clip = 1, icon = "tank" };
716ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:stuh_105mm_mp"] = { carried_clips = 18, rounds_in_clip = 1, icon = "tank" };
717
718-- Tank Guns (Soviet)
719ammo_profile["is2_d25t_122mm_mp"] = { carried_clips = 14, rounds_in_clip = 1, icon = "tank" };
720ammo_profile["isu152_ml-20s_152mm_armor_piercing_mp"] = { carried_clips = 10, rounds_in_clip = 1, icon = "tank" };
721ammo_profile["isu152_ml-20s_152mm_howitzer_gun_piercing_shot_mp"] = { carried_clips = 10, rounds_in_clip = 1, icon = "tank" };
722ammo_profile["kv2_m10_152mm"] = { carried_clips = 18, rounds_in_clip = 1, icon = "tank" };
723ammo_profile["kv-8_45mm_mp"] = { carried_clips = 64, rounds_in_clip = 1, icon = "tank" };
724ammo_profile["su76_76mm_zis-3sh_gun_mp"] = { carried_clips = 70, rounds_in_clip = 1, icon = "tank" };
725ammo_profile["su85_d5t_85mm__mp"] = { carried_clips = 74, rounds_in_clip = 1, icon = "tank" };
726ammo_profile["t34_76mm_mp"] = { carried_clips = 38, rounds_in_clip = 1, icon = "tank" };
727ammo_profile["t34_85_zis-s-53_85mm_t34_mp"] = { carried_clips = 30, rounds_in_clip = 1, icon = "tank" };
728ammo_profile["t34_kv1_m1940_f-34_76mm__mp"] = { carried_clips = 58, rounds_in_clip = 1, icon = "tank" };
729ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:t34_kv1_m1940_f-32_76mm__mp"] = { carried_clips = 55, rounds_in_clip = 1, icon = "tank" };
730ammo_profile["t70_m1938_45mm_mp"] = { carried_clips = 45, rounds_in_clip = 1, icon = "tank" };
731ammo_profile["sherman_76mm_gun"] = { carried_clips = 35, rounds_in_clip = 1, icon = "tank" };
732
733-- Tank Guns (USF)
734ammo_profile["m10_m5_3inch_gun_mp"] = { carried_clips = 27, rounds_in_clip = 1, icon = "tank" };
735ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:m10_achilles_m5_3inch_gun_mp"] = { carried_clips = 25, rounds_in_clip = 1, icon = "tank" };
736ammo_profile["m15a1_halftrack_37mm_mp"] = { carried_clips = 240, rounds_in_clip = 1, icon = "tank" };
737ammo_profile["m26_m3_90mm_gun_mp"] = { carried_clips = 35, rounds_in_clip = 1, icon = "tank" };
738ammo_profile["m36_m4_90mm_gun_mp"] = { carried_clips = 22, rounds_in_clip = 1, icon = "tank" };
739ammo_profile["m5a1_stuart_m6_37mm_mp"] = { carried_clips = 53, rounds_in_clip = 1, icon = "tank" };
740ammo_profile["m8_greyhound_m6_37mm_mp"] = { carried_clips = 44, rounds_in_clip = 1, icon = "tank" };
741ammo_profile["sherman_m1_76mm"] = { carried_clips = 35, rounds_in_clip = 1, icon = "tank" };
742ammo_profile["sherman_m1_76mm_easy8_mp"] = { carried_clips = 35, rounds_in_clip = 1, icon = "tank" };
743ammo_profile["sherman_m3_75mm_mp"] = { carried_clips = 48, rounds_in_clip = 1, icon = "tank" };
744ammo_profile["sherman_m3_105mm_he_shell_mp"] = { carried_clips = 33, rounds_in_clip = 1, icon = "tank" };
745ammo_profile["m8a1_hmc_m3_75mm_mp"] = { carried_clips = 23, rounds_in_clip = 1, icon = "tank" };
746
747-- Tank Guns (OKW) <- Need to set values here (They're currently all 96)
748ammo_profile["jagdpanzer_iv_pak_42_75mm_mp"] = { carried_clips = 28, rounds_in_clip = 1, icon = "tank" };
749ammo_profile["jagdtiger_pak_44_128mm_gun_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "tank" };
750ammo_profile["luchs_kwk38_20mm_mp"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
751ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:luchs_kwk38_20mm_he_mp"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
752ammo_profile["sdkfz_234_puma_kwk39_5cm_mp"] = { carried_clips = 26, rounds_in_clip = 1, icon = "tank" };
753ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_20mm_flak38_he"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
754ammo_profile["sdkfz_251_17_flak_20mm_flak38"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
755ammo_profile["sdkfz_222_kwk38_20mm__mp"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
756ammo_profile["tiger_kwk43_88mm_mp"] = { carried_clips = 35, rounds_in_clip = 1, icon = "tank" };
757ammo_profile["panther_kwk42_75mm_mp"] = { carried_clips = 40, rounds_in_clip = 1, icon = "tank" };
758ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:hetzer_pak_39_75mm_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "tank" };
759ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_kwk40_75mm_mp"] = { carried_clips = 44, rounds_in_clip = 1, icon = "tank" };
760
761-- Tank Guns (UKF)
762ammo_profile["aec_75mm_ap_mp"] = { carried_clips = 30, rounds_in_clip = 1, icon = "tank" };
763ammo_profile["centaur_aa_mk2_twin_pelsten_20mm_mp"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
764ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:centaur_aa_mk2_twin_pelsten_20mm_he_mp"] = { carried_clips = 26, rounds_in_clip = 20, icon = "tank" };
765ammo_profile["churchill_mk7_75mm_croc_mp"] = { carried_clips = 42, rounds_in_clip = 1, icon = "tank" };
766ammo_profile["churchill_mk7_75mm_mp"] = { carried_clips = 42, rounds_in_clip = 1, icon = "tank" };
767ammo_profile["comet_17p_77mm_hv_mp"] = { carried_clips = 30, rounds_in_clip = 1, icon = "tank" };
768ammo_profile["cromwell_75mm_mp"] = { carried_clips = 36, rounds_in_clip = 1, icon = "tank" };
769ammo_profile["sherman_firefly_76mm_mp"] = { carried_clips = 38, rounds_in_clip = 1, icon = "tank" };
770ammo_profile["valentine_75mm_mp"] = { carried_clips = 22, rounds_in_clip = 1, icon = "tank" };
771ammo_profile["608c780e681d46b9a3f2b399b2a1d86a:sv_95mm_he_shell_mp"] = { carried_clips = 20, rounds_in_clip = 1, icon = "tank" };
772
773ammo_preSpawned = {}; -- A table that holds all squads prespawned. This is neccessarry because of the way the game spawns and initialises a match
774ammo_watch = {}; -- The table containing the entities and how much ammunition they have
775
776-- The function that will register a squad
777function Ammo_RegisterMe(...)
778 local squad = arg[1]; -- The squad that's passed as the first argument
779 local isTeamWeapon = Squad_HasTeamWeapon(squad); -- A variable to check if the
780 for i = 0, Squad_Count(squad)-1 do -- Go through eact entity in the squad
781 local e = Squad_EntityAt(squad, i); -- Get the entity found at i. Note that this operation is zero-indexed unlike how it's normally done in Lua to retrieve the first element
782 if (isTeamWeapon == false or (isTeamWeapon == true and Entity_IsSyncWeapon(e))) then -- Make sure it's an entity or the entity being the team weapon in the squad
783 Ammo_CreateEntity(e); -- Create the entity
784 end
785 end
786end
787
788-- Function to register the squads that have been prespawned
789function Ammo_RegisterPreSpawned()
790
791 for i=1, #ammo_preSpawned do -- Go through each entity in the table
792 Ammo_CreateEntity(ammo_preSpawned[i]); -- Register them
793 end
794
795 ammo_preSpawned = nil; -- "Delete" the table, no longer used
796
797end
798
799-- Team weapons override the team members stats meaning team members have unlimited bullets until the main weapon runs out
800function Ammo_CreateEntity(e)
801
802 if (GAME_ISINITIALIZED ~= nil) then -- Make sure this is not nil (we'll declare it later)
803
804 local weaponBP = Entity_GetWeaponBlueprint(e, 0);
805
806 if weaponBP == nil then
807 return
808 end
809
810 local bName = BP_GetName(weaponBP); -- Get the name of the weapon blueprint fround at hardpoint 1 (the main gun)
811 local squad = Entity_GetSquad(e); -- Get the squad from the entity
812 local isTeamWeapon = Squad_HasTeamWeapon(squad); -- Check to see if the squad has a team weapon
813
814 local entityID = Entity_GetGameID(e); -- Get the entity ID of the entity we're adding to the system
815
816 if (ammo_watch[entityID] ~= nil) then -- Is it already registered in the system?
817 return; -- Jump out of the execution of this function
818 end
819
820 if (isTeamWeapon == false or (isTeamWeapon == true and Entity_IsSyncWeapon(e))) then -- if entity or a team weapon
821 local blueprint = ammo_profile[bName]; -- get the blueprint profile
822 if (blueprint ~= nil) then -- make sure the blueprint profile is valid
823 ammo_watch[Entity_GetGameID(e)] = { -- register the entity based on the profile
824 clips = blueprint.carried_clips,
825 clip_max = blueprint.rounds_in_clip,
826 current_rounds_in_clip = blueprint.rounds_in_clip,
827 current_clips = blueprint.carried_clips,
828 rounds_current = blueprint.rounds_in_clip * blueprint.carried_clips,
829 rounds_total = blueprint.rounds_in_clip * blueprint.carried_clips,
830 display_icon = ammo_icons[blueprint.icon or ""];
831 rate = blueprint.fire_rate,
832 weapon_name = bName,
833 };
834 if (Squad_HasCritical(squad, BP_GetCriticalBlueprint("608c780e681d46b9a3f2b399b2a1d86a:infantry_ammo_out"))) then -- if the squad has the critical ammo out
835 ammo_watch[Entity_GetGameID(e)].rounds_current = 0; -- remove the current bullet count from this entity
836 end
837 end
838 end
839
840 else
841 table.insert(ammo_preSpawned, e); -- Insert this entity into the prespawned table, we'll then register the entity later
842 end
843
844end
845
846-- Registers the entity but with no ammunition
847function Ammo_CreateEntityWithoutRefill(e)
848
849 local entityID = Entity_GetGameID(e); -- Get the entity ID of the entity we're adding to the system
850
851 if (ammo_watch[entityID] ~= nil) then -- Is it already registered in the system?
852 return; -- Jump out of the execution of this function
853 end
854
855 local bName = BP_GetName(Entity_GetWeaponBlueprint(e, 0));
856 local blueprint = ammo_profile[bName];
857 if (blueprint ~= nil) then
858 ammo_watch[entityID] = {
859 clips = blueprint.carried_clips,
860 clip_max = blueprint.rounds_in_clip,
861 current_rounds_in_clip = 0, -- NEW CODE
862 current_clips = 0, -- NEW CODE
863 rounds_current = 0, -- Notice how this entity will start without any bullets
864 rounds_total = blueprint.rounds_in_clip * blueprint.carried_clips,
865 display_icon = ammo_icons[blueprint.icon or ""]; -- NEW CODE
866 rate = blueprint.fire_rate,
867 weapon_name = bName,
868 };
869 end
870
871end
872
873-- The function to actually update the weapon stats for the entity
874function Ammo_UpdateMe(...)
875
876 local userentity = arg[2]; -- The entity using the fired weapon
877 local user = Entity_GetGameID(userentity); -- Get the game ID of the weapon
878
879 if (ammo_watch[user] ~= nil) then -- Make sure the entity exists in the system
880 Ammo_UpdateWeapon(userentity, user); -- Update the weapon (verify that we're using the same weapon as before. If we've been upgraded with a new weapon, our stats are reset)
881 ammo_watch[user].rounds_current = ammo_watch[user].rounds_current - (ammo_watch[user].rate or 1); -- Subtract the amount of fired bullets (if the fire rate is not defined, it will subtract 1)
882 ammo_watch[user].current_rounds_in_clip, ammo_watch[user].current_clips = Ammo_CalculateBulletsInClip(ammo_watch[user].rounds_current, ammo_watch[user].clip_max);
883 if (ammo_watch[user].rounds_current <= 0) then -- Have we cun out of bullets?
884 if (Ammo_CheckSquad(Entity_GetSquad(userentity), user) == false) then -- Is the entire squad out of bullets?
885 Cmd_InstantUpgrade(SGroup_FromSquad(Entity_GetSquad(userentity)), BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:upg_ammo_out")); -- Give them the upg_ammo_out upgrade to mark them as being out of bullets
886 else -- The rest of the squad is doing just fine
887 ammo_watch[user].rounds_current = 1; -- We "loan" a bullet from our squad members
888 end
889 end
890 else -- Not registered (so register it, but without any ammunition)
891 local isTeamWeapon = Squad_HasTeamWeapon(Entity_GetSquad(userentity));
892 if (isTeamWeapon == false or (isTeamWeapon == true and Entity_IsSyncWeapon(userentity))) then
893 Ammo_CreateEntityWithoutRefill(userentity); -- Call the registering function, but with no ammunition
894 end
895 end
896
897end
898
899-- Updates the entity stats incase the entity has received a new weapon
900function Ammo_UpdateWeapon(e, eID)
901 local bName = BP_GetName(Entity_GetWeaponBlueprint(e, 0));
902 if (bName ~= ammo_watch[eID].weapon_name) then
903 local bp = ammo_profile[bName];
904 if (bp ~= nil) then
905 ammo_watch[eID].weapon_name = bName;
906 ammo_watch[eID].rounds_total = bp.rounds_in_clip * bp.carried_clips;
907 ammo_watch[eID].clips = bp.carried_clips;
908 ammo_watch[eID].display_icon = ammo_icons[blueprint.icon or ""];
909 return bp;
910 else
911 return ammo_profile[ammo_watch[eID].weapon_name];
912 end
913 else
914 return ammo_profile[bName];
915 end
916end
917
918-- Check if the squad has any ammunition left
919function Ammo_CheckSquad(squad, caller)
920
921 local total = 0;
922
923 for i = 0, Squad_Count(squad)-1 do
924
925 local eID = Entity_GetGameID(Squad_EntityAt(squad, i));
926
927 if (eID ~= caller) then
928 if (ammo_watch[eID] ~= nil) then
929 if (Entity_IsAlive(Squad_EntityAt(squad, i))) then
930 total = total + ammo_watch[eID].rounds_current;
931 end
932 end
933 end
934
935 end
936
937 if (total == 0) then
938 return false;
939 else
940 if (Ammo_RemoveFirst(squad, caller)) then -- Remove a bullet from the first location where it's possible
941 return true;
942 else
943 Ammo_Nullify(squad); -- Nullify this squad => remove all bullets from the squad
944 return false; -- We cant borrow from squad, as there a no more bullets
945 end
946 end
947
948end
949
950-- Removes 1 bullet from the first entity that has a spare bullet
951function Ammo_RemoveFirst(squad, caller)
952
953 for i = 0, Squad_Count(squad)-1 do
954
955 local eID = Entity_GetGameID(Squad_EntityAt(squad, i));
956
957 if (eID ~= caller) then
958 if (ammo_watch[eID] ~= nil) then
959 if (Entity_IsAlive(Squad_EntityAt(squad, i))) then
960 if (ammo_watch[eID].rounds_current > 1) then
961 ammo_watch[eID].rounds_current = ammo_watch[eID].rounds_current - 1;
962 return true;
963 end
964 end
965 end
966 end
967
968 end
969
970 return false;
971
972end
973
974-- Removes all bullets from a squad
975function Ammo_Nullify(squad)
976
977 for i = 0, Squad_Count(squad)-1 do
978
979 local eID = Entity_GetGameID(Squad_EntityAt(squad, i));
980
981 if (eID ~= caller) then
982 if (ammo_watch[eID] ~= nil) then
983 ammo_watch[eID].rounds_current = 0;
984 ammo_watch[eID].current_rounds_in_clip = 0;
985 ammo_watch[eID].current_clips = 0;
986 end
987 end
988
989 end
990
991end
992
993-- Updates the squad. Handles resizing of squads (eg. when a squad is reinforced)
994function Ammo_UpdateSquad(...)
995
996 local squad = arg[1];
997 local isTeamWeapon = Squad_HasTeamWeapon(squad);
998 local new_registers = 0;
999
1000 for i = 0, Squad_Count(squad)-1 do
1001 local e = Squad_EntityAt(squad, i);
1002 local eID = Entity_GetGameID(e);
1003 if (ammo_watch[eID] == nil) then
1004 if (isTeamWeapon == false or (isTeamWeapon == true and Entity_IsSyncWeapon(e))) then
1005 Ammo_CreateEntity(e);
1006 new_registers = new_registers + 1;
1007 end
1008 end
1009 end
1010
1011 return new_registers;
1012
1013end
1014
1015-- Rearms a squad
1016function Ammo_ReArm(...)
1017
1018 local squad = arg[1];
1019 local isTeamWeapon = Squad_HasTeamWeapon(squad);
1020
1021 for i=0, Squad_Count(squad)-1 do -- We'll go through each entity in the squad
1022 local e = Squad_EntityAt(squad, i);
1023 local id = Entity_GetGameID(e);
1024 if (ammo_watch[id] ~= nil) then
1025 local blueprint = Ammo_UpdateWeapon(e, id);
1026 ammo_watch[id].rounds_current = blueprint.rounds_in_clip * blueprint.carried_clips; -- Here we reset the supply
1027 ammo_watch[id].current_rounds_in_clip = blueprint.rounds_in_clip; -- NEW CODE
1028 ammo_watch[id].current_clips = blueprint.carried_clips; -- NEW CODE
1029 else
1030 if (isTeamWeapon == false or (isTeamWeapon == true and Entity_IsSyncWeapon(e))) then
1031 Ammo_CreateEntity(e); -- The entity is not registered, so we simply register them (and with ammunition this time)
1032 end
1033 end
1034 end
1035
1036 Cmd_InstantUpgrade(SGroup_FromSquad(squad), BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:upg_ammo_refill")); -- Remember to update the ModID
1037
1038end
1039
1040-- Get the UI data we'll use when displaying
1041function Ammo_GetUIData(squad)
1042
1043 local ammo_ui = {}; -- Table to contain the data we've found
1044 local j = 1; -- The current valid index we're to add to the table
1045
1046 for i=0, Squad_Count(squad)-1 do -- Go through each squad member (0-based index, remember!)
1047 local eID = Entity_GetGameID(Squad_EntityAt(squad, i)); -- Get the entity at i
1048 if (ammo_watch[eID] ~= nil) then -- Registered in the system?
1049 ammo_ui[j] = {
1050 in_clip = ammo_watch[eID].current_rounds_in_clip,
1051 max_in_clip = ammo_profile[ammo_watch[eID].weapon_name].rounds_in_clip,
1052 clips = ammo_watch[eID].current_clips,
1053 icon = ammo_watch[eID].display_icon,
1054 };
1055 j = j + 1; -- Increase j by one
1056 else -- Not registered
1057 if not Squad_HasTeamWeapon(squad) then -- The squad is a team weapon, we're not supposed to see all team members ammunition, only the sync weapon.
1058 if Ammo_UpdateSquad(squad) > 0 then -- Update and see if there's any new registered
1059 return ammo_ui; -- Return this same function, but with the updates squad.
1060 else
1061 return nil; -- Return nothing
1062 end
1063 end
1064 end
1065 end
1066
1067 return ammo_ui; -- Return the data we've collected
1068
1069end
1070
1071-- Calculates the amount of bullets left in the clip, if you have a better method, please do suggest it!
1072function Ammo_CalculateBulletsInClip(r, rclip)
1073 if r > rclip then
1074 local cclip = math.ceil(r / rclip);
1075 return rclip - ((cclip * rclip) % r), cclip;
1076 else
1077 if r == 0 then
1078 return 0, 0;
1079 else
1080 return r, 1;
1081 end
1082 end
1083end
1084
1085-- Squad Selection UI:
1086
1087SelectionUIPlayers = {}; -- Table to contain UI players
1088SelectionUISettings = {
1089 fuel = {
1090 ["self_colour"] = { -- The colour to display when a player-owned vehicle is selected
1091 R = 0,
1092 G = 255,
1093 B = 0,
1094 A = 60,
1095 },
1096 ["allied_colour"] = { -- The colour to display when an allied vehicle is selected
1097 R = 255,
1098 G = 188,
1099 B = 0,
1100 A = 60,
1101 },
1102 ["hostile_colour"] = { -- The colour to display when a hostile vehicle is selected
1103 R = 255,
1104 G = 0,
1105 B = 0,
1106 A = 60,
1107 },
1108 },
1109};
1110
1111-- Creates the fuel UI for a player
1112function SelectionSystem_CreateFuelUI(player)
1113 return {
1114 controlType = "panel",
1115 name = "fuelindicator"..Player_GetID(player),
1116 x = 904.0,
1117 y = 840.0,
1118 width = 520.0,
1119 height = 90.0,
1120 margin = 0.0,
1121 children =
1122 {
1123 {
1124 controlType = "icon",
1125 icon = "ModIcons_ f3b36164a74c4e7080e9cbba9aaf41cd_fuel_ui",
1126 },
1127 {
1128 controlType = "statusIndicator",
1129 name = "statusIndicator",
1130 height = 23.0,
1131 width = 388.0,
1132 top = 45.0,
1133 left = 102.0,
1134 value = 1.0,
1135 },
1136 },
1137 };
1138end
1139
1140-- Creates the ammunition UI for a player and makes an offset bed on the index
1141function SelectionSystem_CreateAmmunitionUI(player, index)
1142 local hVariable = 35.0; -- The height of our control
1143 local hOffset = (index - 1) * hVariable; -- The height offset based on the index (the index is not 0-index based we'll have to subtract one)
1144 return {
1145 controlType = "panel",
1146 name = "ammoIndicator"..Player_GetID(player) ..index,
1147 x = 1300.0,
1148 y = 810.0 - hOffset,
1149 width = 230.0,
1150 height = hVariable,
1151 margin = 0.0,
1152 children =
1153 { -- The following took 2 hours of perfecting... fml
1154 {
1155 controlType = "icon",
1156 icon = "ModIcons_ f3b36164a74c4e7080e9cbba9aaf41cd_ammo_ui",
1157 },
1158 {
1159 controlType = "icon",
1160 name = "UI_weapon_icon",
1161 icon = "",
1162 width = 48.0,
1163 height = 16.0,
1164 top = 8.0,
1165 left = 38.0,
1166 },
1167 {
1168 controlType = "label",
1169 name = "UI_Ammo_InClip",
1170 height = 28.0,
1171 width = 144.0,
1172 top = 1.0,
1173 left = 24.0,
1174 text = Util_CreateLocString("1000/1000"),
1175 size = 16.0,
1176 bold = true,
1177 italic = false,
1178 alignHorizontal = LAH_Right,
1179 alignVertical = LAV_Center,
1180 },
1181 {
1182 controlType = "icon",
1183 icon = "ModIcons_ f3b36164a74c4e7080e9cbba9aaf41cd_bullets",
1184 name = "UI_bullets",
1185 width = 21.6,
1186 height = 23.625,
1187 top = 4.0,
1188 left = 166.0,
1189 },
1190 {
1191 controlType = "label",
1192 name = "UI_Ammo_ClipCount",
1193 height = 28.0,
1194 top = 1.0,
1195 left = 166.0,
1196 text = Util_CreateLocString("16"),
1197 size = 14.0,
1198 bold = true,
1199 italic = false,
1200 alignHorizontal = LAH_Center,
1201 alignVertical = LAV_Center,
1202 },
1203 {
1204 controlType = "icon",
1205 icon = "ModIcons_ f3b36164a74c4e7080e9cbba9aaf41cd_mag",
1206 name = "UI_magazine",
1207 width = 13.0,
1208 height = 24.3,
1209 top = 4.0,
1210 left = 208.0,
1211 },
1212 },
1213 };
1214end
1215
1216-- Start the selection system
1217function SelectionSystem_Start()
1218
1219 for i=1, World_GetPlayerCount() do -- Go through all players in the world
1220
1221 local player = World_GetPlayerAt(i); -- Get the player
1222 local pid = Player_GetID(player); -- Get their index
1223
1224 local temp = {}; -- A temproary table
1225 temp.player = player;
1226 temp.SelectionUI_Current = SGroup_CreateIfNotFound("SelectionUI_Current"..pid);
1227 temp.SelectionUI_Last = SGroup_CreateIfNotFound("SelectionUI_Last"..pid);
1228 temp.isdrawing = false;
1229 temp.lastsquadsize = 0;
1230 temp.mostdrawnentities = 0;
1231
1232 if (AI_IsAIPlayer(player) == false) then -- This is really only relevant for NON AI players
1233 temp.fuel = SelectionSystem_CreateFuelUI(player);
1234 temp.lastammosize = 0;
1235 end
1236
1237 SelectionUIPlayers[pid] = temp; -- Set the data with index of the players index
1238
1239 end
1240
1241 Rule_Add(SelectionSystem_Update); -- Add the update rule
1242
1243end
1244
1245-- Clears the screen from our UI based on player index
1246function SelectionSystem_ClearUI(pid)
1247 UI_ControlRemove("fuelindicator"..pid); -- Remove the fuel UI
1248 for j=1, SelectionUIPlayers[pid].mostdrawnentities do -- Go through all the ammunition UI
1249 UI_ControlRemove("ammoIndicator"..pid ..j); -- Remove the ammunition UI
1250 end
1251end
1252
1253-- Get the mode to display (is it us, allied or enemy?)
1254function SelectionSystem_GetShowMode(squad)
1255 local owner = Util_GetPlayerOwner(squad); -- The owner of the squad
1256 local isSelf = owner == Game_GetLocalPlayer(); -- Are WE the owner of the squad?
1257 local isAlly = Player_IsAllied(owner, Game_GetLocalPlayer()); -- Are we allied to the squad?
1258 if isSelf then
1259 return 0, "self_colour";
1260 elseif isAlly then
1261 return 0, "allied_colour";
1262 else
1263 return 1, "hostile_colour";
1264 end
1265end
1266
1267-- Check to see if we should redraw the UI
1268function SelectionSystem_ShouldRedraw(sg_before, sg_now, squadSize)
1269 local is_same_unit = SGroup_Compare( sg_before, sg_now ); -- If they're the same
1270 local is_same_size = SGroup_CountSquadMembers(sg_now) ~= squadSize; -- if they're the same size
1271 if is_same_unit or (not is_same_size and is_same_unit) then -- Are we the same or have our squad size changed?
1272 return is_same_size; -- Redraw if the squad size is not the same as before!
1273 else
1274 return true; -- Always redraw if not the same unit
1275 end
1276end
1277
1278-- Draw the Ammunition UI
1279function SelectionSystem_UpdateAmmunition(data, lastammosize, player, is_vehicle, shouldredraw)
1280
1281 for j = 1, lastammosize do -- Go through all the ammunition entities to draw
1282 local controlAmmoName = nil; -- The control name
1283 if shouldredraw then -- Are we going to redraw?
1284 local control = SelectionSystem_CreateAmmunitionUI(player, j); -- Create the control
1285 controlAmmoName = control.name; -- Get the control name
1286 UI_AddControl(control); -- Add the control
1287 UI_IconSetIcon(controlAmmoName ..".UI_weapon_icon", data[j].icon); -- Set the weapon icon
1288 if is_vehicle then -- is vehicle?
1289 UI_ControlSetPosition(controlAmmoName ..".UI_Ammo_InClip", -999.0, -999.0); -- "hide" the ammo in clip, not really relevant
1290 UI_ControlSetPosition(controlAmmoName ..".UI_bullets", -999.0, -999.0); -- "hide" the bullets as their corresponding data is not shown
1291 end
1292 else
1293 controlAmmoName = "ammoIndicator" ..Player_GetID(player) ..j; -- Set the control name
1294 end
1295 UI_LabelSetText(controlAmmoName ..".UI_Ammo_InClip", Util_CreateLocString(data[j].in_clip .."/" ..data[j].max_in_clip)); -- Set the ammo in clip data
1296 UI_LabelSetText(controlAmmoName ..".UI_Ammo_ClipCount", Util_CreateLocString(data[j].clips)); -- Set the clip data
1297 end
1298
1299end
1300
1301-- The function to update everything UI related
1302function SelectionSystem_Update()
1303
1304 for k,v in pairs(SelectionUIPlayers) do -- Go through all the players in the selection system
1305
1306 if v.player == Game_GetLocalPlayer() then -- We only execute the following code for the local player eg. YOU
1307
1308 Misc_GetSelectedSquads(v.SelectionUI_Current, true); -- Get the currently selected squads
1309 local redraw = SelectionSystem_ShouldRedraw( v.SelectionUI_Last, v.SelectionUI_Current, v.lastsquadsize ); -- If they're the same, then we dont redraw all the UI
1310
1311 if redraw then -- If we're going to redraw
1312 SGroup_Clear(v.SelectionUI_Last); -- Clear the last sgroup
1313 SGroup_AddGroup( v.SelectionUI_Last, v.SelectionUI_Current ); -- Update the last sgroup to be the new one
1314 SelectionSystem_ClearUI(k); -- Clear the UI
1315 end
1316
1317 if SGroup_Count(v.SelectionUI_Current) == 1 then
1318
1319 local squad = SGroup_GetSpawnedSquadAt(v.SelectionUI_Current, 1); -- Get the first squad in the sgroup (that only has one squad)
1320 local entity = Squad_EntityAt(squad, 0); -- Get the first entity in the squad
1321 local eID = Entity_GetGameID(entity); -- Get the game ID of the entity
1322 local isVehicle = Entity_IsVehicle(entity); -- Find out if the entity is a vehicle
1323
1324 local data_fuel = nil; -- Container for the fuel data
1325 local data_ammo = Ammo_GetUIData(squad); -- Worst case scenario this returns nil and we can just skip this altogether. Will fetch the ammunition data for the squad
1326
1327 if fuel_targets[eID] ~= nil then -- if entity is registered in the fuel system
1328 data_fuel = fuel_targets[eID]; -- Get the fuel data for the entity
1329 end
1330
1331 local showmode, showtype = SelectionSystem_GetShowMode(squad); -- Get the mode to show. 0 = friendly and 1 = hostile
1332 local fueldisplay = SelectionUISettings.fuel[showtype]; -- Get the fuel colour modes
1333
1334 if showmode == 0 then -- self or allied
1335 if data_fuel ~= nil then -- Do we have any fuel data?
1336 if redraw then -- Should we redraw?
1337 UI_AddControl(v.fuel); -- Add the fuel control
1338 end
1339 UI_StatusIndicatorSetValue(v.fuel.name ..".statusIndicator", data_fuel.current / data_fuel.maxf); -- Set the fuel value
1340 UI_ControlSetColour(v.fuel.name ..".statusIndicator", fueldisplay.R, fueldisplay.G, fueldisplay.B, fueldisplay.A); -- Set the colour of the control (it's RGBA)
1341 end
1342 if data_ammo ~= nil then -- Do we have any ammunition data?
1343 v.lastammosize = #data_ammo; -- Update the about of ammunition guys found
1344 SelectionSystem_UpdateAmmunition(data_ammo, v.lastammosize, v.player, isVehicle, redraw); -- Update the ammunition display
1345 end
1346 else -- enemy
1347 if data_fuel ~= nil then -- Do we have any fuel data on the enemy?
1348 if redraw then -- Should we redraw?
1349 UI_AddControl(v.fuel); -- Add the fuel control
1350 end
1351 UI_StatusIndicatorSetValue(v.fuel.name ..".statusIndicator", data_fuel.current / data_fuel.maxf); -- Set the fuel value
1352 UI_ControlSetColour(v.fuel.name ..".statusIndicator", fueldisplay.R, fueldisplay.G, fueldisplay.B, fueldisplay.A); -- Set the colour of the control (it's RGBA)
1353 end
1354 end
1355
1356 v.lastsquadsize = Squad_Count(squad); -- Update the size of the squad (used to see if we should redraw the UI)
1357
1358 if v.lastsquadsize > v.mostdrawnentities then -- Are we currently drawing more than we did before?
1359 v.mostdrawnentities = v.lastsquadsize; -- Update it to reflect the highest drawn value
1360 end
1361
1362 else
1363 if v.isdrawing then -- Are we currently drawing?
1364 SelectionSystem_ClearUI(k); -- Clear the UI
1365 end
1366 end
1367
1368 end
1369
1370 end
1371
1372end