· 7 years ago · Oct 09, 2018, 07:22 PM
1import("ScarUtil.scar")
2import("Fatalities/Fatalities.scar")
3import("Prototype/WorldEntityCollector.scar")
4import("Prototype/VPTickerWin-Annihilate_Functions.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
15function SGroup_CountSquadMembers(sgroup)
16 local t = 0;
17 for i=1, SGroup_Count(sgroup) do
18 local squad = SGroup_GetSpawnedSquadAt(sgroup, i);
19 t = t + Squad_Count(squad);
20 end
21 return t;
22end
23
24-- Creates a temporary SGroup from a squadID
25function SGroup_FromSquad(squad)
26 local sg_temp = SGroup_CreateIfNotFound("sg_temp_from_squad");
27 SGroup_Clear(sg_temp);
28 SGroup_Add(sg_temp, squad);
29 return sg_temp;
30end
31-- Fetches the first vehicle entity from a squad
32function Entity_VehicleFromSquad(squad)
33 for i = 0, Squad_Count(squad) - 1 do
34 local e = Squad_EntityAt(squad, i);
35 if Entity_IsVehicle(e) then
36 return e;
37 end
38 end
39 return nil;
40end
41
42-------------------------------------------------------------------------
43-- [[ SETUP ]]
44-------------------------------------------------------------------------
45function OnGameSetup()
46
47end
48
49
50local function PopCap_OnInit()
51 Camera_SetTuningValue(TV_DistMax, 100)
52 for i = 1, World_GetPlayerCount() do
53 local player = World_GetPlayerAt(i)
54 Player_SetPopCapOverride(player, 100)
55 Cmd_InstantUpgrade(player , BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:1944_bulge_mp"));
56
57 end
58end
59
60Scar_AddInit(PopCap_OnInit)
61
62-------------------------------------------------------------------------
63-- [[ ONINIT ]]
64-------------------------------------------------------------------------
65function OnInit_Delayed()
66
67 UI_TerritoryHide()
68
69 UI_OutOfBoundsLinesHide()
70
71 UI_UnrestrictBuildingPlacement()
72
73 VPTicker_OnInit()
74
75 UI_EnableGameEventCueType(GE_PlayerBeingAttacked , true)
76 UI_EnableGameEventCueType(GE_AbilityExecuted , false)
77 UI_EnableGameEventCueType(GE_UpgradeComplete , false)
78 UI_EnableGameEventCueType(GE_ConstructionComplete , false)
79 UI_EnableGameEventCueType(GE_BuildItemComplete , false)
80 UI_EnableGameEventCueType(GE_SpawnActionComplete , false)
81 UI_EnableGameEventCueType(GE_SquadKilled , false)
82 UI_EnableGameEventCueType(GE_SquadPinned , false)
83 UI_EnableGameEventCueType(GE_EntityKilled , false)
84
85
86
87end
88
89function OnInit()
90
91 UI_SetCPMeterVisibility(false)
92
93 UI_EnableUIEventCueType(UIE_EnemyReveal , false)
94 UI_EnableUIEventCueType(UIE_SquadCold , false)
95 UI_EnableUIEventCueType(UIE_SquadFreezing , false)
96 UI_EnableUIEventCueType(UIE_SquadVeterancy , false)
97 UI_EnableUIEventCueType(UIE_StrategicPointCaptured , false)
98 UI_EnableUIEventCueType(UIE_StrategicPointSecured , false)
99 UI_EnableUIEventCueType(UIE_StrategicPointReverting , false)
100 UI_EnableUIEventCueType(UIE_SquadFreezing , false)
101 UI_EnableUIEventCueType(UIE_SquadVeterancy , false)
102
103 SelectionSystem_Start(); -- starts the selection system
104
105GAME_ISINITIALIZED = true; -- Tell the Ammo_CreateEntity function we're ready to register entities.
106
107 Rule_AddGlobalEvent(Ammo_UpdateSquad, GE_SquadSizeChanged); -- Updates the squad incase it's resized
108
109 Ammo_RegisterPreSpawned(); -- Register the prespawned squads
110
111
112 Rule_AddOneShot(OnInit_Delayed, 0.5)
113end
114
115
116Scar_AddInit(OnInit)
117
118WinWarning_ShowLoseWarning = function () end
119WinWarning_PublishLoseReminder = function () end
120WinWarning_SetCritical = function () end
121VPTicker_VictoryBalanceReminder = function() end
122VPTicker_VictorySpeechReminder = function () end
123VPTicker_PointReminder = function () end
124
125---------------------------------------------------------------------------------------------------------------------------------------------
126-- Fuel system - Developed by CoDiEx
127---------------------------------------------------------------------------------------------------------------------------------------------
128fuel_profiles = {};
129-- USF Vehicles
130fuel_profiles["dodge_wc51_50cal_squad_mp"] = {fuel_max = 3860, fuel_burn = 10};
131fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:dodge_wc51_50cal_squadcommander_mp"] = {fuel_max = 3860, fuel_burn = 10};
132fuel_profiles["dodge_wc51_ambulance_squad_mp"] = {fuel_max = 3860, fuel_burn = 10};
133fuel_profiles["dodge_wc51_pathfinder_squad_mp"] = {fuel_max = 3860, fuel_burn = 10};
134fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:dodge_wc51_pathfinder_squadcommander_mp"] = {fuel_max = 3860, fuel_burn = 10};
135fuel_profiles["dodge_wc51_squad_mp"] = {fuel_max = 3860, fuel_burn = 10};
136fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad_assault_mp"] = {fuel_max = 2010, fuel_burn = 10};
137fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad_assault_ranger_mp"] = {fuel_max = 2010, fuel_burn = 10};
138fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad_assaultcommander_mp"] = {fuel_max = 2010, fuel_burn = 10};
139fuel_profiles["m3_halftrack_squad_mp"] = {fuel_max = 2010, fuel_burn = 10};
140fuel_profiles["m15a1_aa_halftrack_squad_mp"] = {fuel_max = 2820, fuel_burn = 10};
141fuel_profiles["m21_mortar_halftrack_squad_mp"] = {fuel_max = 2010, fuel_burn = 10};
142fuel_profiles["t34_calliope_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
143fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:crocodile_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
144fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_jumbo_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
145fuel_profiles["m4a3_76mm_sherman_bulldozer_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
146fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_sherman_bulldozercommander_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
147fuel_profiles["m4a3_76mm_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
148fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_shermancommander_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
149fuel_profiles["m4a3_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
150fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_sherman_squadcommander_mp"] = {fuel_max = 1900, fuel_burn = 10};
151fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_sherman_squad_dozzer_mp"] = {fuel_max = 1900, fuel_burn = 10};
152fuel_profiles["m4a3e8_sherman_easy_8_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
153fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3e8_sherman_easy_8_squadcommander_mp"] = {fuel_max = 1900, fuel_burn = 10};
154fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a4v_canadian_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
155fuel_profiles["m5a1_stuart_squad_mp"] = {fuel_max = 1600, fuel_burn = 10};
156fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5a1_stuart_squadcomm_mp"] = {fuel_max = 1600, fuel_burn = 10};
157fuel_profiles["m7b1_priest_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
158fuel_profiles["m8_greyhound_squad_mp"] = {fuel_max = 5400, fuel_burn = 10};
159fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m8_greyhound_squadcommander_mp"] = {fuel_max = 5400, fuel_burn = 10};
160fuel_profiles["m8a1_hmc_squad_mp"] = {fuel_max = 1600, fuel_burn = 10};
161fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m8a1_hmc_squadcomm_mp"] = {fuel_max = 1600, fuel_burn = 10};
162fuel_profiles["m10_tank_destroyer_squad_mp"] = {fuel_max = 2600, fuel_burn = 10};
163fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m10_tank_destroyercommander_squad_mp"] = {fuel_max = 2600, fuel_burn = 10};
164fuel_profiles["m20_utility_car_squad_mp"] = {fuel_max = 5400, fuel_burn = 10};
165fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m20_utility_car_squad_commander_mp"] = {fuel_max = 5400, fuel_burn = 10};
166fuel_profiles["m26_pershing_mp"] = {fuel_max = 1610, fuel_burn = 10};
167fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m26_pershing_ace_mp"] = {fuel_max = 1610, fuel_burn = 10};
168fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3a1_scout_car_squad_us_mp"] = {fuel_max = 4030, fuel_burn = 10};
169fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sherman_firefly_squad_grizzly_mp"] = {fuel_max = 1900, fuel_burn = 10};
170fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:aef_halftrack_squad_air_mp"] = {fuel_max = 2820, fuel_burn = 10};
171fuel_profiles["aef_halftrack_squad_mp"] = {fuel_max = 2820, fuel_burn = 10};
172-- OKW Vehicles
173fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:brummbar_squad2_mp"] = {fuel_max = 2100, fuel_burn = 10};
174fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:elefant_tank_destroyer_squad_two_mp"] = {fuel_max = 1500, fuel_burn = 10};
175fuel_profiles["goliath_mp"] = {fuel_max = 1500, fuel_burn = 10};
176fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mechanized_250_halftrack_grenadiers2_mp"] = {fuel_max = 3500, fuel_burn = 10};
177fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mortar_250_halftrack_squad_westgerman_mp"] = {fuel_max = 3500, fuel_burn = 10};
178fuel_profiles["sdkfz_251_17_flak_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
179fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_halftrack_squad_mp_falli"] = {fuel_max = 3200, fuel_burn = 10};
180fuel_profiles["sdkfz_251_20_ir_searchlight_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
181fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_2512_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
182fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_2513_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
183fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_halftrack_squad_mp_falli"] = {fuel_max = 3200, fuel_burn = 10};
184fuel_profiles["sdkfz_251_wurfrahmen_40_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
185fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:hetzer_jagdpanzer38_squad_mp"] = {fuel_max = 1800, fuel_burn = 10};
186fuel_profiles["hetzer_squad_mp"] = {fuel_max = 1800, fuel_burn = 10};
187fuel_profiles["jagdpanzer_tank_destroyer_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
188fuel_profiles["jagdtiger_td_squad_mp"] = {fuel_max = 1700, fuel_burn = 10};
189fuel_profiles["king_tiger_squad_mp"] = {fuel_max = 1700, fuel_burn = 10};
190fuel_profiles["kubelwagen_squad_mp"] = {fuel_max = 4500, fuel_burn = 10};
191fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:kubelwagen_squad_ss_mp"] = {fuel_max = 4500, fuel_burn = 10};
192fuel_profiles["ostwind_squad_westgerman_mp"] = {fuel_max = 2000, fuel_burn = 10};
193fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_ausf_g_command_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
194fuel_profiles["panther_ausf_g_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
195fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_ausf_g1_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
196fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_ausf_g2_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
197fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_commander_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
198fuel_profiles["panzer_ii_luchs_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
199fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_ii_luchs_squad2_mp"] = {fuel_max = 2000, fuel_burn = 10};
200fuel_profiles["panzer_iv_ausf_j_battle_group_mp"] = {fuel_max = 2000, fuel_burn = 10};
201fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_commander_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
202fuel_profiles["panzer_iv_stubbyokw_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
203fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_stubbyokw_squad2_mp"] = {fuel_max = 2000, fuel_burn = 10};
204fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_ivg_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
205fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzerwerfer1_squad_mp"] = {fuel_max = 1400, fuel_burn = 10};
206fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stuh_42_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
207fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stuh_42_squadss_mp"] = {fuel_max = 1550, fuel_burn = 10};
208fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:armored_car_sdkfz_234_squad_okw_mp"] = {fuel_max = 6000, fuel_burn = 10};
209fuel_profiles["armored_car_sdkfz_234_squad_mp"] = {fuel_max = 6000, fuel_burn = 10};
210fuel_profiles["sturmtiger_squad_mp"] = {fuel_max = 1200, fuel_burn = 10};
211fuel_profiles["sws_halftrack_squad_mp"] = {fuel_max = 3000, fuel_burn = 10};
212fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_beute_mp"] = {fuel_max = 4650, fuel_burn = 10};
213fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_ace_squad_wittmann_mp"] = {fuel_max = 1000, fuel_burn = 10};
214fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_squadss_mp"] = {fuel_max = 1000, fuel_burn = 10};
215fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_squadss1_mp"] = {fuel_max = 1000, fuel_burn = 10};
216fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_squadss2_mp"] = {fuel_max = 1000, fuel_burn = 10};
217fuel_profiles["scoutcar_223_squad"] = {fuel_max = 3000, fuel_burn = 10};
218fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:scoutcar_223_squadss"] = {fuel_max = 3000, fuel_burn = 10};
219-- UKF Vehicles
220fuel_profiles["aec_armoured_car_squad_mp"] = {fuel_max = 4000, fuel_burn = 10};
221fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:aec_armoured_car_squad2_mp"] = {fuel_max = 4000, fuel_burn = 10};
222fuel_profiles["centaur_aa_mk2_squad_mp"] = {fuel_max = 2800, fuel_burn = 10};
223fuel_profiles["churchill_avre_squad_mp"] = {fuel_max = 900, fuel_burn = 10};
224fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_avre_commander_squad_mp"] = {fuel_max = 900, fuel_burn = 10};
225fuel_profiles["churchill_crocodile_mp"] = {fuel_max = 900, fuel_burn = 10};
226fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_crocodile_commander_mp"] = {fuel_max = 900, fuel_burn = 10};
227fuel_profiles["churchill_default_squad_mp"] = {fuel_max = 900, fuel_burn = 10};
228fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_default_squad_95_mp"] = {fuel_max = 900, fuel_burn = 10};
229fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_default_squad_commander_mp"] = {fuel_max = 900, fuel_burn = 10};
230fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_default_squad_soviet_mp"] = {fuel_max = 900, fuel_burn = 10};
231fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:churchill_howitzer_squad_mp"] = {fuel_max = 900, fuel_burn = 10};
232fuel_profiles["comet_tank_squad_mp"] = {fuel_max = 1980, fuel_burn = 10};
233fuel_profiles["cromwell_mk4_75mm_squad_mp"] = {fuel_max = 2800, fuel_burn = 10};
234fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:cromwell_mk4_95mm_squad_mp"] = {fuel_max = 2800, fuel_burn = 10};
235fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:cromwell_mk4_75mm_squad_commander_mp"] = {fuel_max = 2800, fuel_burn = 10};
236fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad__resupply_mp"] = {fuel_max = 2010, fuel_burn = 10};
237fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad__resupply_no_requirement_mp"] = {fuel_max = 2010, fuel_burn = 10};
238fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m3_halftrack_squad_resupply_tommie_mp"] = {fuel_max = 2010, fuel_burn = 10};
239fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_sherman_2_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
240fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_76mm_sherman_3_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
241fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_sherman_1_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
242fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a3_sherman_british_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
243fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a4_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
244fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m4a4v_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
245fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:aef_halftrack_squad1_mp"] = {fuel_max = 2820, fuel_burn = 10};
246fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5a1_stuart_squad_british_mp"] = {fuel_max = 1600, fuel_burn = 10};
247fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5a1_stuart_squad_british2_mp"] = {fuel_max = 1600, fuel_burn = 10};
248fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m8a1_hmc_squad_british_mp"] = {fuel_max = 1600, fuel_burn = 10};
249fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m10_achilles_tank_destroyer_squad_mp"] = {fuel_max = 2600, fuel_burn = 10};
250fuel_profiles["sexton_spg_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
251fuel_profiles["sherman_firefly_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
252fuel_profiles["universal_carrier_squad_mp"] = {fuel_max = 2500, fuel_burn = 10};
253fuel_profiles["universal_carrier_resupply"] = {fuel_max = 2500, fuel_burn = 10};
254fuel_profiles["valentine_observation_mp"] = {fuel_max = 1400, fuel_burn = 10};
255fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:valentine_observation_russia_mp"] = {fuel_max = 1400, fuel_burn = 10};
256fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:valentine_russia_mp"] = {fuel_max = 1400, fuel_burn = 10};
257-- WEHR Vehicles
258fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_wurfrahmen_40_halftrack_squad_east_mp"] = {fuel_max = 3200, fuel_burn = 10};
259fuel_profiles["brummbar_squad_mp"] = {fuel_max = 2100, fuel_burn = 10};
260fuel_profiles["elefant_tank_destroyer_squad_mp"] = {fuel_max = 1500, fuel_burn = 10};
261fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:goliath_wehrmacht_mp"] = {fuel_max = 1500, fuel_burn = 10};
262fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mechanized_250_halftrack_fallis_mp"] = {fuel_max = 3500, fuel_burn = 10};
263fuel_profiles["mechanized_250_halftrack_grenadiers_mp"] = {fuel_max = 3500, fuel_burn = 10};
264fuel_profiles["mechanized_250_halftrack_mp"] = {fuel_max = 3500, fuel_burn = 10};
265fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mechanized_250_halftrackcommander_mp"] = {fuel_max = 3500, fuel_burn = 10};
266fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mortar_250_halftrack_squad_commander_mp"] = {fuel_max = 3500, fuel_burn = 10};
267fuel_profiles["mortar_250_halftrack_squad_mp"] = {fuel_max = 770, fuel_burn = 2.1};
268fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_halftrack_squad_flame_mp"] = {fuel_max = 3200, fuel_burn = 10};
269fuel_profiles["sdkfz_251_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
270fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_halftrack_squad_wehrmacht_mp"] = {fuel_max = 3200, fuel_burn = 10};
271fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_halftrack_squad_east_mp"] = {fuel_max = 3200, fuel_burn = 10};
272fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_halftrack_squad_east_romania_mp"] = {fuel_max = 3200, fuel_burn = 10};
273fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:sdkfz_251_17_flak_halftrack_squad_east_romania_mp"] = {fuel_max = 3200, fuel_burn = 10};
274fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:hetzer_jagdpanzer38_squadw_mp"] = {fuel_max = 1800, fuel_burn = 10};
275fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:jagdpanzerw_tank_destroyer_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
276fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:king_tiger_squadw_mp"] = {fuel_max = 1700, fuel_burn = 10};
277fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:marderm_mp"] = {fuel_max = 2100, fuel_burn = 10};
278fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mardermss_mp"] = {fuel_max = 2100, fuel_burn = 10};
279fuel_profiles["opel_blitz_supply_squad"] = {fuel_max = 3400, fuel_burn = 10};
280fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_squad_grenadiers"] = {fuel_max = 3400, fuel_burn = 10};
281fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_squad_obersoldaten"] = {fuel_max = 3400, fuel_burn = 10};
282fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_squad_ssgrenadiers"] = {fuel_max = 3400, fuel_burn = 10};
283fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_supply_squad"] = {fuel_max = 3400, fuel_burn = 10};
284fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_supplyss_squad"] = {fuel_max = 3400, fuel_burn = 10};
285fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:opel_blitz_supplyss_squad"] = {fuel_max = 3400, fuel_burn = 10};
286fuel_profiles["ostwind_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
287fuel_profiles["panther_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
288fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_squad1_mp"] = {fuel_max = 2000, fuel_burn = 10};
289fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panther_squad2_mp"] = {fuel_max = 2000, fuel_burn = 10};
290fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iii_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
291fuel_profiles["panzer_iv_command_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
292fuel_profiles["panzer_iv_squad_ausfj_mp"] = {fuel_max = 2000, fuel_burn = 10};
293fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_h_mp"] = {fuel_max = 2000, fuel_burn = 10};
294fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_h_okw_mp"] = {fuel_max = 2000, fuel_burn = 10};
295fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_h_wehr_mp"] = {fuel_max = 2000, fuel_burn = 10};
296fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_h2_mp"] = {fuel_max = 2000, fuel_burn = 10};
297fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squad_j_mp"] = {fuel_max = 2000, fuel_burn = 10};
298fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_squadausfh_mp"] = {fuel_max = 2000, fuel_burn = 10};
299fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:panzer_iv_stubby_squad2_mp"] = {fuel_max = 2000, fuel_burn = 10};
300fuel_profiles["panzer_iv_stubby_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
301fuel_profiles["panzerwerfer_squad_mp"] = {fuel_max = 1400, fuel_burn = 10};
302fuel_profiles["puma_east_german_mp"] = {fuel_max = 6000, fuel_burn = 10};
303fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:scoutcar_sdkfz221_mp"] = {fuel_max = 3000, fuel_burn = 10};
304fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:scoutcar_sdkfz221ss_mp"] = {fuel_max = 3000, fuel_burn = 10};
305fuel_profiles["scoutcar_sdkfz222_mp"] = {fuel_max = 3000, fuel_burn = 10};
306fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:scoutcar_sdkfz222ss_mp"] = {fuel_max = 3000, fuel_burn = 10};
307fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stug_4_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
308fuel_profiles["stug_iii_e_commander_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
309fuel_profiles["stug_iii_e_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
310fuel_profiles["stug_iii_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
311fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stug_iii_squad_neu_mp"] = {fuel_max = 1550, fuel_burn = 10};
312fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stug_iii_squad2_mp"] = {fuel_max = 1550, fuel_burn = 10};
313fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-3_squad_n_mp"] = {fuel_max = 1550, fuel_burn = 10};
314fuel_profiles["tiger_ace_squad_mp"] = {fuel_max = 1000, fuel_burn = 10};
315fuel_profiles["tiger_squad_mp"] = {fuel_max = 1000, fuel_burn = 10};
316fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tiger_squad2_mp"] = {fuel_max = 1000, fuel_burn = 10};
317-- USSR Vehicles
318fuel_profiles["is-2_mp"] = {fuel_max = 2400, fuel_burn = 10};
319fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:is-2_squad_mp"] = {fuel_max = 2400, fuel_burn = 10};
320fuel_profiles["isu-152_mp"] = {fuel_max = 3700, fuel_burn = 10};
321fuel_profiles["katyusha_bm-13n_squad_mp"] = {fuel_max = 2400, fuel_burn = 10};
322fuel_profiles["kv-1_mp"] = {fuel_max = 3350, fuel_burn = 10};
323fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:kv-1squad_mp"] = {fuel_max = 3350, fuel_burn = 10};
324fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:kv-l11_mp"] = {fuel_max = 3350, fuel_burn = 10};
325fuel_profiles["kv-2_mp"] = {fuel_max = 2500, fuel_burn = 10};
326fuel_profiles["kv-8_mp"] = {fuel_max = 3350, fuel_burn = 10};
327fuel_profiles["m3a1_scout_car_squad_mp"] = {fuel_max = 4030, fuel_burn = 10};
328fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5_halftrack__assault_squad_mp"] = {fuel_max = 2820, fuel_burn = 10};
329fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:m5_halftrack__assault_squad_rekruten_mp"] = {fuel_max = 2820, fuel_burn = 10};
330fuel_profiles["m5_halftrack_squad_mp"] = {fuel_max = 2820, fuel_burn = 10};
331fuel_profiles["soviet_76mm_sherman_mp"] = {fuel_max = 1900, fuel_burn = 10};
332fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:soviet_76mm_sherman_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
333fuel_profiles["su-76m_mp"] = {fuel_max = 4500, fuel_burn = 10};
334fuel_profiles["su-85_mp"] = {fuel_max = 2000, fuel_burn = 10};
335fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:su-85m_mp"] = {fuel_max = 2000, fuel_burn = 10};
336fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:su-85squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
337fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_e_squad_mp"] = {fuel_max = 4650, fuel_burn = 10};
338fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_dispatch_intervall_mp"] = {fuel_max = 4650, fuel_burn = 10};
339fuel_profiles["t_34_76_squad_mp"] = {fuel_max = 4650, fuel_burn = 10};
340fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_rider_dispatch_mp"] = {fuel_max = 4650, fuel_burn = 10};
341fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_test_mp"] = {fuel_max = 4650, fuel_burn = 10};
342fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squads_mp"] = {fuel_max = 4650, fuel_burn = 10};
343fuel_profiles["t_34_85_squad_mp"] = {fuel_max = 4650, fuel_burn = 10};
344fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-60m_mp"] = {fuel_max = 3600, fuel_burn = 10};
345fuel_profiles["t-70m_mp"] = {fuel_max = 3600, fuel_burn = 10};
346fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-70m2_mp"] = {fuel_max = 3600, fuel_burn = 10};
347fuel_profiles["zis_6_transport_truck_mp"] = {fuel_max = 2400, fuel_burn = 10};
348fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:zis_6_transport_truck_rekruts_mp"] = {fuel_max = 2400, fuel_burn = 10};
349fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:zis_6_transport_truck_supply_mp"] = {fuel_max = 2400, fuel_burn = 10};
350-- Finish Vehicles
351fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:mechanized_250_halftrack_finish_mp"] = {fuel_max = 3500, fuel_burn = 10};
352fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:kv-l11_captured_mp"] = {fuel_max = 3350, fuel_burn = 10};
353fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:stug_iii_g_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
354fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_finish_mp"] = {fuel_max = 4650, fuel_burn = 10};
355fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_85_squad_captured_mp"] = {fuel_max = 4650, fuel_burn = 10};
356fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:universal_carrier_squad_captured_mp"] = {fuel_max = 2500, fuel_burn = 10};
357-- Romanian Vehicles
358fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:251_halftrack_squad_mp"] = {fuel_max = 3200, fuel_burn = 10};
359fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:bm-13n_squad_mp"] = {fuel_max = 2400, fuel_burn = 10};
360fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_76_squad_1942_mp"] = {fuel_max = 4650, fuel_burn = 10};
361fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t_34_85_squad_1943_mp"] = {fuel_max = 4650, fuel_burn = 10};
362fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-3_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
363fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-4_g_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
364fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:t-5_a_squad_mp"] = {fuel_max = 2000, fuel_burn = 10};
365fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tas_iii_f_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
366fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tas_iii_squad_mp"] = {fuel_max = 1550, fuel_burn = 10};
367fuel_profiles["608c780e681d46b9a3f2b399b2a1d86a:tas_iv_70_tank_destroyer_squad_mp"] = {fuel_max = 1900, fuel_burn = 10};
368
369fuel_targets = {};
370
371-- Register a vehicle
372function Fuel_RegisterMe(...)
373
374 local entityVehicle = Entity_VehicleFromSquad(arg[1]); -- Get the vehicle entity in the squad
375
376 if entityVehicle == nil then -- Make sure the entity Vehicle is not Null/Nil
377 return; -- The target is not a vehicle, or atleast there's no entity in the squad that's marked as a vehicle
378 end
379
380 local entityID = Entity_GetGameID(entityVehicle); -- Get the entity ID of the vehicle entity
381 local squadbp = BP_GetName(Squad_GetBlueprint(arg[1])); -- Get the blueprint name of the squad
382 local player = Util_GetPlayerOwner(arg[1]); -- Get the player owner of the squad
383
384 if (fuel_targets[entityID] ~= nil) then -- Is the entity already registered in the system?
385 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
386 end
387
388 Cmd_InstantUpgrade(SGroup_FromSquad(arg[1]), BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:fuel_capable"), 1); -- Give the squad an upgrade, marking it as fuel capable
389 -- Replace the <ModID> with your mod ID, so for example, this mod would use ID 608c780e681d46b9a3f2b399b2a1d86a
390 -- and will therefore look like this: Cmd_InstantUpgrade(SGroup_FromSquad(arg[1]), BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:fuel_capable"), 1);
391 -- The SGroup_FromSquad function is currently undefined, as it's a custom function that we'll introduce later.
392
393 -- Here we actually register the entity in the system
394 fuel_targets[entityID] = { -- Create a new entry in the table with indexing key set to the unique game ID given to the entity
395 is_aiOwned = AI_IsAIPlayer(player), -- Is the AI an owner of this vehicle?
396
397 -- The following three variables are set using the fuel_profiles table. You'll be filling in these profiles later, dont worry.
398 -- 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)
399 maxf = fuel_profiles[squadbp].fuel_max;
400 current = fuel_profiles[squadbp].fuel_max;
401 burn = fuel_profiles[squadbp].fuel_burn;
402
403 warning50 = false; -- Variable used later, set it to false for now
404 out = false; -- Variable used to mark whether the vehicle is currently out of fuel
405 modifier = nil; -- A variable containing a speed modifier reference
406 position = Entity_GetPosition(entityVehicle); -- The current position of the vehicle
407 };
408
409 -- 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)
410 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
411
412 if (Rule_Exists(Fuel_Update) == false) then -- Check if there's already a rule calling the Fuel_Update function (defined soon)
413 Rule_AddInterval(Fuel_Update, 1); -- Add an interval to update the fuel system every second
414 end
415
416end
417
418-- Updates the state of the fuel targets
419function Fuel_Update()
420
421 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
422
423 if Entity_IsValid(k) then -- Make sure the entity exists/is valid
424
425 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
426
427 local e = Entity_FromWorldID(k); -- Get the actual entity from the entity ID
428
429 if Entity_IsMoving(e) then -- Check if the entity is moving
430
431 local s = Entity_GetSquad(e); -- Get the squad the entity is part of
432 local sg = SGroup_FromSquad(s); -- Make a temporary SquadGroup
433
434 v.current = v.current - v.burn; -- Subtract the burn rate from the current amount of fuel
435
436 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
437
438 Cmd_CriticalHit(Util_GetPlayerOwner(s), sg, BP_GetCriticalBlueprint("608c780e681d46b9a3f2b399b2a1d86a:vehicle_outfuel"), 0); -- Give a critical to the vehicle, disabling movement
439
440 if (Game_GetLocalPlayer() == Util_GetPlayerOwner(s)) then -- Is the vehicle owned by the local player?
441 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
442 end
443
444 v.out = true; -- Mark the vehicle as having run out of fuel
445
446 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
447
448 if (v.modifier ~= nil) then -- Incase the modifier is already in place (to make sure it's not stacked)
449 Modifier_Remove(v.modifier); -- Remove the modifier
450 end
451
452 v.modifier = Modify_UnitSpeed(sg, 0.75); -- Add a speed modifier (makes the unit move 25% slower)
453 v.warning50 = true; -- Mark this as having reached it's low point
454
455 end
456 end
457 end
458
459 else -- Not valid
460
461 fuel_targets[k] = nil; -- Make it be nil, so we no longer check this vehicle
462
463 end
464
465 end
466
467end
468
469-- Allows the executer to refuel the target
470function Fuel_RefuelTarget(executer, target)
471
472 if scartype(executer) == ST_SQUAD and scartype(target) == ST_SQUAD then -- Firtsly make sure both are squads
473
474 local __InfantryGroup = SGroup_CreateIfNotFound("__InfantryGroup"); -- Crate a Sgroup for the infantry squad that is going to refuel the vehicle
475 SGroup_Add(__InfantryGroup, executer); -- Add the ability executer to the Sgroup
476
477 local entityVehicle = Entity_VehicleFromSquad(target); -- Get the vehicle from the target squad
478 local entityID = Entity_GetGameID(entityVehicle); -- Get the entityID
479
480 if fuel_targets[entityID] ~= nil then -- Make sure the entity is registered in the fuel system
481
482 fuel_targets[entityID].current = fuel_targets[entityID].maxf; -- Set the vehicles current fuel to its max fuel
483
484 UI_CreateColouredSquadKickerMessage(Game_GetLocalPlayer(), target, "$608c780e681d46b9a3f2b399b2a1d86a:3067", 0, 255, 0, 0); -- Create a coloured kicker message that says 100% fuel (the last 4 numbers are RGBA numbers)
485 SGroup_RemoveUpgrade(SGroup_FromSquad(Entity_GetSquad(entityVehicle)), BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:fuel_out")); -- Remove the Fuel_Out upgrade from the entity
486
487 if Entity_HasCritical(entityVehicle, BP_GetCriticalBlueprint("608c780e681d46b9a3f2b399b2a1d86a:vehicle_outfuel")) == true then -- Make sure the target actually has this critical
488 Entity_RemoveCritical(entityVehicle, BP_GetCriticalBlueprint("608c780e681d46b9a3f2b399b2a1d86a:vehicle_outfuel")); -- Remove the critical
489 end
490
491 if (fuel_targets[entityID].modifier ~= nil) then -- Is the speed modifier valid?
492 Modifier_Remove(fuel_targets[entityID].modifier); -- Remove the speed modifier
493 end
494
495 fuel_targets[entityID].warning50 = false; -- Reset this variable
496 fuel_targets[entityID].out = false -- Reset the out variable
497
498 SGroup_RemoveUpgrade(__InfantryGroup, BP_GetUpgradeBlueprint("608c780e681d46b9a3f2b399b2a1d86a:fuel_equipped")); -- Remove the fuel_equippped upgrade from the infantry
499
500 end
501
502 SGroup_Clear(__InfantryGroup); -- Clear the infantry group
503
504 end -- You can add other combinations down here (like ST_SQUAD and ST_ENTITY)
505
506end