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