author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 12 Feb 2018 19:38:07 +0100 | |
changeset 12990 | add647b0036e |
parent 12989 | 353603f5cec3 |
child 12991 | 1c38d4370943 |
permissions | -rwxr-xr-x |
12417 | 1 |
--[[ |
2 |
######################################################################## |
|
3 |
Name: Battalion |
|
4 |
Made by: Anachron |
|
5 |
######################################################################## |
|
6 |
]]-- |
|
7 |
||
8 |
--[[ |
|
9 |
||
10 |
Readme: |
|
12424
6944a9161cdb
Update readme link in Battalion script
Wuzzy <almikes@aol.com>
parents:
12423
diff
changeset
|
11 |
https://hedgewars.org/wiki/Battalion |
12417 | 12 |
|
13 |
######################################################################## |
|
14 |
]]-- |
|
15 |
||
16 |
--[[ |
|
17 |
######################################################################## |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
18 |
TODO / ideas list |
12417 | 19 |
######################################################################## |
20 |
||
21 |
- Make Hogs sorted by rareness for teams with less hogs (more fair) |
|
22 |
- Keep first picked up unused crate utitlity until next round |
|
23 |
- Ship default scheme but let user overwrite it |
|
24 |
- Make SuddenDeathWaterRise dynamic |
|
25 |
- Make SuddenDeathTurns dynamic |
|
26 |
- Add Hog Variants like Crazy Scientist or Astronaut |
|
27 |
||
28 |
######################################################################## |
|
29 |
]]-- |
|
30 |
||
31 |
--[[ |
|
32 |
############################################################################## |
|
33 |
### GENERAL SCRIPT LOADING AND VARIABLE INITIALISATION ### |
|
34 |
############################################################################## |
|
35 |
]]-- |
|
36 |
||
37 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
38 |
HedgewarsScriptLoad("/Scripts/Tracker.lua") |
|
39 |
HedgewarsScriptLoad("/Scripts/Params.lua") |
|
40 |
||
41 |
-- List of all hog variants with belonging weapons, |
|
42 |
-- hitpoints, chances and more |
|
43 |
local variants = {} |
|
44 |
local varName = "" |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
45 |
local newLine = "" |
12417 | 46 |
local gmAny = 0xFFFFFFFF |
47 |
||
48 |
--[[ |
|
49 |
############################################################################## |
|
50 |
### VARIANT SETUP ### |
|
51 |
############################################################################## |
|
52 |
]]-- |
|
53 |
||
54 |
varName = "Pyromancer" |
|
55 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
56 |
variants[varName]["name"] = loc("Pyromancer") |
12417 | 57 |
variants[varName]["chance"] = 7 |
58 |
variants[varName]["hat"] = "Gasmask" |
|
59 |
variants[varName]["hp"] = 70 |
|
60 |
variants[varName]["hogLimit"] = 2 |
|
61 |
variants[varName]["weaponLimit"] = 1 |
|
62 |
variants[varName]["weapons"] = {amFlamethrower, amMolotov, amWhip} |
|
63 |
variants[varName]["helperLimit"] = 1 |
|
64 |
variants[varName]["helpers"] = {amRope, amParachute} |
|
65 |
variants[varName]["special"] = false |
|
66 |
||
67 |
varName = "Builder" |
|
68 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
69 |
variants[varName]["name"] = loc("Builder") |
12417 | 70 |
variants[varName]["chance"] = 10 |
71 |
variants[varName]["hat"] = "constructor" |
|
72 |
variants[varName]["hp"] = 100 |
|
73 |
variants[varName]["hogLimit"] = 1 |
|
74 |
variants[varName]["weaponLimit"] = 1 |
|
75 |
variants[varName]["weapons"] = {amDynamite, amWhip, amHammer} |
|
76 |
variants[varName]["helperLimit"] = 1 |
|
77 |
variants[varName]["helpers"] = {amGirder, amBlowTorch} |
|
78 |
variants[varName]["special"] = false |
|
79 |
||
80 |
varName = "Rifleman" |
|
81 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
82 |
variants[varName]["name"] = loc("Rifleman") |
12417 | 83 |
variants[varName]["chance"] = 7 |
84 |
variants[varName]["hat"] = "Sniper" |
|
85 |
variants[varName]["hp"] = 70 |
|
86 |
variants[varName]["hogLimit"] = 2 |
|
87 |
variants[varName]["weaponLimit"] = 1 |
|
88 |
variants[varName]["weapons"] = {amRCPlane, amShotgun, amSniperRifle} |
|
89 |
variants[varName]["helperLimit"] = 1 |
|
90 |
variants[varName]["helpers"] = {amLowGravity, amParachute} |
|
91 |
variants[varName]["special"] = false |
|
92 |
||
93 |
varName = "Warrior" |
|
94 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
95 |
variants[varName]["name"] = loc("Warrior") |
12417 | 96 |
variants[varName]["chance"] = 12 |
97 |
variants[varName]["hat"] = "spartan" |
|
98 |
variants[varName]["hp"] = 120 |
|
99 |
variants[varName]["hogLimit"] = 2 |
|
100 |
variants[varName]["weaponLimit"] = 1 |
|
101 |
variants[varName]["weapons"] = {amClusterBomb, amGrenade, amBazooka} |
|
102 |
variants[varName]["helperLimit"] = 1 |
|
103 |
variants[varName]["helpers"] = {amParachute, amRope} |
|
104 |
variants[varName]["special"] = false |
|
105 |
||
106 |
varName = "Chef" |
|
107 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
108 |
variants[varName]["name"] = loc("Chef") |
12417 | 109 |
variants[varName]["chance"] = 7 |
110 |
variants[varName]["hat"] = "chef" |
|
111 |
variants[varName]["hp"] = 70 |
|
112 |
variants[varName]["hogLimit"] = 1 |
|
113 |
variants[varName]["weaponLimit"] = 1 |
|
114 |
variants[varName]["weapons"] = {amCake, amKnife, amWhip} |
|
115 |
variants[varName]["helperLimit"] = 1 |
|
116 |
variants[varName]["helpers"] = {amRubber, amParachute} |
|
117 |
variants[varName]["special"] = false |
|
118 |
||
119 |
varName = "Medic" |
|
120 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
121 |
variants[varName]["name"] = loc("Medic") |
12417 | 122 |
variants[varName]["chance"] = 12 |
123 |
variants[varName]["hat"] = "war_desertmedic" |
|
124 |
variants[varName]["hp"] = 120 |
|
125 |
variants[varName]["hogLimit"] = 1 |
|
126 |
variants[varName]["weaponLimit"] = 1 |
|
127 |
variants[varName]["weapons"] = {amResurrector, amMine, amGasBomb} |
|
128 |
variants[varName]["helperLimit"] = 1 |
|
129 |
variants[varName]["helpers"] = {amTeleport, amParachute} |
|
130 |
variants[varName]["special"] = false |
|
131 |
||
132 |
varName = "Ninja" |
|
133 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
134 |
variants[varName]["name"] = loc("Ninja") |
12417 | 135 |
variants[varName]["chance"] = 8 |
136 |
variants[varName]["hat"] = "NinjaTriangle" |
|
137 |
variants[varName]["hp"] = 80 |
|
138 |
variants[varName]["hogLimit"] = 2 |
|
139 |
variants[varName]["weaponLimit"] = 1 |
|
140 |
variants[varName]["weapons"] = {amSMine, amMine, amFirePunch} |
|
141 |
variants[varName]["helperLimit"] = 1 |
|
142 |
variants[varName]["helpers"] = {amRope, amParachute} |
|
143 |
variants[varName]["special"] = false |
|
144 |
||
145 |
varName = "Athlete" |
|
146 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
147 |
variants[varName]["name"] = loc("Athlete") |
12417 | 148 |
variants[varName]["chance"] = 8 |
149 |
variants[varName]["hat"] = "footballhelmet" |
|
150 |
variants[varName]["hp"] = 80 |
|
151 |
variants[varName]["hogLimit"] = 1 |
|
152 |
variants[varName]["weaponLimit"] = 1 |
|
153 |
variants[varName]["weapons"] = {amBaseballBat, amFirePunch, amSeduction} |
|
154 |
variants[varName]["helperLimit"] = 1 |
|
155 |
variants[varName]["helpers"] = {amRope, amPickHammer} |
|
156 |
variants[varName]["special"] = false |
|
157 |
||
158 |
varName = "Scientist" |
|
159 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
160 |
variants[varName]["name"] = loc("Scientist") |
12417 | 161 |
variants[varName]["chance"] = 7 |
162 |
variants[varName]["hat"] = "doctor" |
|
163 |
variants[varName]["hp"] = 80 |
|
164 |
variants[varName]["hogLimit"] = 1 |
|
165 |
variants[varName]["weaponLimit"] = 1 |
|
166 |
variants[varName]["weapons"] = {amPortalGun, amSineGun, amIceGun} |
|
167 |
variants[varName]["helperLimit"] = 1 |
|
168 |
variants[varName]["helpers"] = {amTeleport, amJetpack} |
|
169 |
variants[varName]["special"] = false |
|
170 |
||
12422
f6fc84c55bfa
Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents:
12421
diff
changeset
|
171 |
varName = "Air General" |
12417 | 172 |
variants[varName] = {} |
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
173 |
variants[varName]["name"] = loc("Air General") |
12417 | 174 |
variants[varName]["chance"] = 5 |
175 |
variants[varName]["hat"] = "war_desertofficer" |
|
176 |
variants[varName]["hp"] = 50 |
|
177 |
variants[varName]["hogLimit"] = 1 |
|
178 |
variants[varName]["weaponLimit"] = 1 |
|
179 |
variants[varName]["weapons"] = {amMineStrike, amNapalm, amAirAttack} |
|
180 |
variants[varName]["helperLimit"] = 1 |
|
181 |
variants[varName]["helpers"] = {amRope, amParachute} |
|
182 |
variants[varName]["special"] = true |
|
183 |
||
184 |
varName = "Hunter" |
|
185 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
186 |
variants[varName]["name"] = loc("Hunter") |
12417 | 187 |
variants[varName]["chance"] = 10 |
188 |
variants[varName]["hat"] = "Skull" |
|
189 |
variants[varName]["hp"] = 100 |
|
190 |
variants[varName]["hogLimit"] = 1 |
|
191 |
variants[varName]["weaponLimit"] = 1 |
|
192 |
variants[varName]["weapons"] = {amBee, amMortar, amDrill} |
|
193 |
variants[varName]["helperLimit"] = 1 |
|
194 |
variants[varName]["helpers"] = {amRope, amParachute} |
|
195 |
variants[varName]["special"] = false |
|
196 |
||
197 |
varName = "King" |
|
198 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
199 |
variants[varName]["name"] = loc("King") |
12417 | 200 |
variants[varName]["chance"] = 3 |
201 |
variants[varName]["hat"] = "crown" |
|
202 |
variants[varName]["hp"] = 60 |
|
203 |
variants[varName]["hogLimit"] = 1 |
|
204 |
variants[varName]["weaponLimit"] = 1 |
|
205 |
variants[varName]["weapons"] = {amWatermelon, amHellishBomb, amBallgun} |
|
206 |
variants[varName]["helperLimit"] = 1 |
|
207 |
variants[varName]["helpers"] = {amRope, amParachute} |
|
208 |
variants[varName]["special"] = true |
|
209 |
||
210 |
varName = "Knight" |
|
211 |
variants[varName] = {} |
|
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
212 |
variants[varName]["name"] = loc("Knight") |
12417 | 213 |
variants[varName]["chance"] = 0 |
214 |
variants[varName]["hat"] = "knight" |
|
215 |
variants[varName]["hp"] = 80 |
|
216 |
variants[varName]["hogLimit"] = 1 |
|
217 |
variants[varName]["weaponLimit"] = 1 |
|
218 |
variants[varName]["weapons"] = {amShotgun, amBazooka, amMine} |
|
219 |
variants[varName]["helperLimit"] = 1 |
|
220 |
variants[varName]["helpers"] = {amParachute, amRope} |
|
221 |
variants[varName]["special"] = true |
|
222 |
||
223 |
--[[ |
|
224 |
############################################################################## |
|
225 |
### GENERAL VARIABLES USED FOR GAMEPLAY ### |
|
226 |
############################################################################## |
|
227 |
]]-- |
|
228 |
||
229 |
local unused = {amSnowball, amDrillStrike, amTardis} |
|
230 |
local lowWeaps = {amKamikaze} |
|
231 |
local lowTresh = 25 |
|
232 |
||
233 |
local counter = {} -- Saves how many hogs of a variant a team has |
|
234 |
local group = {} -- Saves randomized variants for all teams |
|
235 |
local teamIndex = {} -- Temporary counter for amount of mutated hogs in team |
|
236 |
local teamHogs = {} -- Saves a list of all hogs belonging to a team |
|
237 |
local hogCount = {} -- Saves how many hogs a team has |
|
238 |
local teamNames = {} -- Saves all teams and names |
|
239 |
local hogInfo = {} -- Saves all hogs with their original values |
|
240 |
||
241 |
local LastHog = nil -- Last Hedgehog |
|
242 |
local CurHog = nil -- Current Hedgehog |
|
243 |
local LastTeam = nil -- Last Team |
|
244 |
local CurTeam = nil -- Current Team |
|
245 |
||
246 |
local mode = 'default' -- Which game type to play |
|
12989
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
247 |
local modeExplicit = false -- Whether the mode was set in script param |
12417 | 248 |
local luck = 100 -- Multiplier for bonuses like crates |
249 |
local strength = 1 -- Multiplier for more weapons |
|
250 |
local mutate = false -- Whether or not to mutate the hogs |
|
251 |
||
252 |
local highHasBonusWeps = false -- whether or not a hog got bonus weapons on current turn |
|
253 |
local highHasBonusHelp = false -- whether or not a hog got bonus helpers on current turn |
|
254 |
local highPickupCount = 1 |
|
255 |
local highPickupSDCount = 2 |
|
256 |
local highHelperCount = 1 |
|
257 |
local highHelperSDCount = 1 |
|
258 |
local highEnemyKillHPBonus = 10 |
|
259 |
local highFriendlyKillHPBonus = 15 |
|
260 |
local highWeapons = {} -- Saves the weapons from kills |
|
261 |
local highHelpers = {} -- Saves the helpers from kills |
|
262 |
local highSpecialBonus = {amTeleport, amJetpack} |
|
263 |
local highSpecialPool = {amExtraDamage, amVampiric} |
|
264 |
||
265 |
local kingLinkPerc = 50 -- Percentage of life to share from the team |
|
266 |
||
267 |
local pointsWepBase = 5 -- Game start points weapons |
|
268 |
local pointsHlpBase = 2 -- Game start points helpers |
|
269 |
local pointsKeepPerc = 80 -- Percentage of points to take to next round |
|
270 |
local pointsWepTurn = 5 -- Round bonus points weapons |
|
271 |
local pointsHlpTurn = 2 -- Round bonus points helpers |
|
272 |
local pointsWepMax = 25 -- Maximum points for weapons |
|
273 |
local pointsHlpMax = 10 -- Maximum points for helpers |
|
274 |
local pointsKeepSDPerc = 60 -- Percentage of points to take to next round on SD |
|
275 |
local pointsWepSDTurn = 7 -- Round bonus points weapons on SD |
|
276 |
local pointsHlpSDTurn = 3 -- Round bonus points helpers on SD |
|
277 |
local pointsWepSDMax = 35 -- Maximum points for weapons on SD |
|
278 |
local pointsHlpSDMax = 15 -- Maximum points for helpers on SD |
|
279 |
||
280 |
local pointsWeaponVal = {} |
|
281 |
pointsWeaponVal[amBazooka] = 5 |
|
282 |
pointsWeaponVal[amShotgun] = 4 |
|
283 |
pointsWeaponVal[amFirePunch] = 3 |
|
284 |
pointsWeaponVal[amMine] = 5 |
|
285 |
--pointsWeaponVal[amAirAttack] = 10 |
|
286 |
pointsWeaponVal[amBee] = 6 |
|
287 |
pointsWeaponVal[amClusterBomb] = 7 |
|
288 |
pointsWeaponVal[amGrenade] = 5 |
|
289 |
pointsWeaponVal[amDEagle] = 3 |
|
290 |
pointsWeaponVal[amWhip] = 3 |
|
291 |
pointsWeaponVal[amDynamite] = 7 |
|
292 |
--pointsWeaponVal[amMineStrike] = 14 |
|
293 |
pointsWeaponVal[amMortar] = 4 |
|
294 |
pointsWeaponVal[amWatermelon] = 30 |
|
295 |
pointsWeaponVal[amSniperRifle] = 3 |
|
296 |
pointsWeaponVal[amBaseballBat] = 3 |
|
297 |
pointsWeaponVal[amCake] = 7 |
|
298 |
--pointsWeaponVal[amNapalm] = 11 |
|
299 |
pointsWeaponVal[amDrill] = 6 |
|
300 |
pointsWeaponVal[amHellishBomb] = 20 |
|
301 |
pointsWeaponVal[amSineGun] = 4 |
|
302 |
--pointsWeaponVal[amKamikaze] = 3 |
|
303 |
--pointsWeaponVal[amBallgun] = 12 |
|
304 |
--pointsWeaponVal[amPianoStrike] = 15 |
|
305 |
pointsWeaponVal[amSnowball] = 2 |
|
306 |
pointsWeaponVal[amMolotov] = 3 |
|
307 |
pointsWeaponVal[amFlamethrower] = 4 |
|
308 |
pointsWeaponVal[amRCPlane] = 7 |
|
309 |
--pointsWeaponVal[amDrillStrike] = 12 |
|
310 |
pointsWeaponVal[amGasBomb] = 2 |
|
311 |
pointsWeaponVal[amHammer] = 3 |
|
312 |
pointsWeaponVal[amSMine] = 4 |
|
313 |
pointsWeaponVal[amAirMine] = 3 |
|
314 |
pointsWeaponVal[amKnife] = 3 |
|
315 |
pointsWeaponVal[amPortalGun] = 5 |
|
316 |
--pointsWeaponVal[amIceGun] = 6 |
|
317 |
pointsWeaponVal[amSeduction] = 2 |
|
318 |
||
319 |
local pointsHelperVal = {} |
|
320 |
pointsHelperVal[amRope] = 5 |
|
321 |
pointsHelperVal[amParachute] = 2 |
|
322 |
--pointsHelperVal[amGirder] = 3 |
|
323 |
pointsHelperVal[amBlowTorch] = 2 |
|
324 |
pointsHelperVal[amLowGravity] = 3 |
|
325 |
--pointsHelperVal[amRubber] = 4 |
|
326 |
pointsHelperVal[amPickHammer] = 2 |
|
327 |
pointsHelperVal[amTeleport] = 10 |
|
328 |
pointsHelperVal[amJetpack] = 8 |
|
329 |
||
330 |
local pointsPerTeam = {} |
|
331 |
local pointsToWep = {} -- List of [points] = {ammo1, ammo2} |
|
332 |
local pointsToHlp = {} -- List of [points] = {ammo1, ammo2} |
|
333 |
local wepPoints = {} |
|
334 |
local hlpPoints = {} |
|
335 |
||
12990
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
336 |
local firstTurnOver = false |
12417 | 337 |
local suddenDeath = false |
338 |
||
339 |
local healthCrateChance = 7 |
|
340 |
local utilCrateChance = 9 |
|
341 |
local weaponCrateChance = 12 |
|
342 |
||
343 |
local healthCrateChanceSD = 12 |
|
344 |
local utilCrateChanceSD = 16 |
|
345 |
local weaponCrateChanceSD = 21 |
|
346 |
||
347 |
local emptyCrateChance = 7 |
|
348 |
local bonusCrateChance = 5 |
|
349 |
local cratePickupGap = 35 |
|
350 |
||
351 |
local utilities = {amInvulnerable, amVampiric, amExtraTime, amExtraDamage, amRope, amLandGun} |
|
352 |
local autoSelectHelpers = {amRope, amParachute} |
|
353 |
||
354 |
local LastWaterLine = 0 -- Saves WaterLine to make sure a water rise wont trigger highland kill |
|
355 |
||
356 |
local helpers = {} |
|
357 |
helpers[amSkip] = true |
|
358 |
helpers[amRope] = true |
|
359 |
helpers[amParachute] = true |
|
360 |
helpers[amBlowTorch] = true |
|
361 |
helpers[amGirder] = true |
|
362 |
helpers[amTeleport] = true |
|
363 |
helpers[amSwitch] = true |
|
364 |
helpers[amJetpack] = true |
|
365 |
helpers[amBirdy] = true |
|
366 |
helpers[amPortalGun] = true |
|
367 |
helpers[amResurrector] = true |
|
368 |
helpers[amTardis] = true |
|
369 |
helpers[amLandGun] = true |
|
370 |
helpers[amRubber] = true |
|
371 |
--helpers[amKamikaze] = true |
|
372 |
||
373 |
local posCaseAmmo = 1 |
|
374 |
local posCaseHealth = 2 |
|
375 |
local posCaseUtility = 4 |
|
376 |
local posCaseDummy = 8 |
|
377 |
||
378 |
--[[ |
|
379 |
############################################################################## |
|
380 |
### GENERAL BONUS LUA FUNCTIONS ### |
|
381 |
############################################################################## |
|
382 |
]]-- |
|
383 |
||
384 |
function swap(array, index1, index2) |
|
385 |
array[index1], array[index2] = array[index2], array[index1] |
|
386 |
end |
|
387 |
||
388 |
function shuffle(array) |
|
389 |
local cnt = #array |
|
390 |
while cnt > 1 do |
|
391 |
local index = GetRandom(cnt) +1 |
|
392 |
swap(array, index, cnt) |
|
393 |
cnt = cnt - 1 |
|
394 |
end |
|
395 |
end |
|
396 |
||
397 |
function table.clone(org) |
|
398 |
local copy = {} |
|
399 |
for orig_key, orig_value in pairs(org) do |
|
400 |
copy[orig_key] = orig_value |
|
401 |
end |
|
402 |
return copy |
|
403 |
end |
|
404 |
||
405 |
--[[ |
|
406 |
############################################################################## |
|
407 |
### WEAPON, UTILITY AND AMMO FUNCTIONS ### |
|
408 |
############################################################################## |
|
409 |
]]-- |
|
410 |
||
411 |
function clearHogAmmo(hog) |
|
412 |
local lastNum = amRubber |
|
413 |
||
414 |
if amAirMine ~= nil then |
|
415 |
lastNum = amAirMine |
|
416 |
end |
|
417 |
||
418 |
for val=0,lastNum do |
|
419 |
AddAmmo(hog, val, 0) |
|
420 |
end |
|
421 |
end |
|
422 |
||
423 |
function autoSelectAmmo(hog, var) |
|
424 |
-- Check if hog has any "useful" helper, select helper, if yes |
|
425 |
for key, val in pairs(autoSelectHelpers) do |
|
426 |
if GetAmmoCount(hog, val) > 0 then |
|
427 |
SetWeapon(val) |
|
428 |
return |
|
429 |
end |
|
430 |
end |
|
431 |
end |
|
432 |
||
433 |
function AddHogAmmo(hog, ammo) |
|
434 |
-- Add weapons of variant |
|
435 |
for key, val in pairs(ammo) do |
|
436 |
AddAmmo(hog, val, GetAmmoCount(hog, val) +1) |
|
437 |
end |
|
438 |
end |
|
439 |
||
440 |
function GetRandomAmmo(hog, sourceType) |
|
441 |
local var = getHogInfo(hog, 'variant') |
|
442 |
ammo = {} |
|
443 |
local source = '' |
|
444 |
||
445 |
if variants[var] == nil then |
|
446 |
return ammo |
|
447 |
end |
|
448 |
||
449 |
if sourceType == "weapons" then |
|
450 |
source = variants[var][sourceType] |
|
451 |
sourceLimit = variants[var]["weaponLimit"] |
|
452 |
elseif sourceType == "helpers" then |
|
453 |
source = variants[var][sourceType] |
|
454 |
sourceLimit = variants[var]["helperLimit"] |
|
455 |
elseif sourceType == 'poolWeapons' then |
|
456 |
if highWeapons[hog] == nil then |
|
457 |
highWeapons[hog] = {} |
|
458 |
end |
|
459 |
source = highWeapons[hog] |
|
460 |
if suddenDeath == false then |
|
461 |
sourceLimit = highPickupCount |
|
462 |
else |
|
463 |
sourceLimit = highPickupSDCount |
|
464 |
end |
|
465 |
elseif sourceType == 'poolHelpers' then |
|
466 |
if highHelpers[hog] == nil then |
|
467 |
highHelpers[hog] = {} |
|
468 |
end |
|
469 |
source = highHelpers[hog] |
|
470 |
if suddenDeath == false then |
|
471 |
sourceLimit = highHelperCount |
|
472 |
else |
|
473 |
sourceLimit = highHelperSDCount |
|
474 |
end |
|
475 |
else |
|
476 |
return ammo |
|
477 |
end |
|
478 |
||
479 |
local varAmmo = {} |
|
480 |
for key, val in pairs(source) do |
|
481 |
varAmmo[key] = val |
|
482 |
end |
|
483 |
||
484 |
-- If the amount of random weapons is equally to the amount of weapons possible |
|
485 |
-- We don't need to randomize |
|
486 |
if sourceLimit >= table.getn(source) then |
|
487 |
return varAmmo |
|
488 |
end |
|
489 |
||
490 |
local randIndex = 0 |
|
491 |
local i = 0 |
|
492 |
while i < sourceLimit and #varAmmo > 0 do |
|
493 |
randIndex = GetRandom(#varAmmo) +1 |
|
494 |
ammo[i] = varAmmo[randIndex] |
|
495 |
||
496 |
-- Shift last value to the current index |
|
497 |
varAmmo[randIndex] = varAmmo[#varAmmo] |
|
498 |
-- And remove the last index from the array |
|
499 |
varAmmo[#varAmmo] = nil |
|
500 |
i = i +1 |
|
501 |
end |
|
502 |
||
503 |
return ammo |
|
504 |
end |
|
505 |
||
506 |
function addTurnAmmo(hog) |
|
507 |
-- Check if hog is valid |
|
508 |
if hog == nil then |
|
509 |
return |
|
510 |
end |
|
511 |
||
512 |
-- Check if hog is alive |
|
513 |
local hp = GetHealth(hog) |
|
514 |
if hp == nil or hp <= 0 then |
|
515 |
return |
|
516 |
end |
|
517 |
||
518 |
-- Unless its points mode, get weapons normally by variant |
|
519 |
if mode ~= "points" then |
|
520 |
local maxHp = getHogInfo(hog, 'maxHp') |
|
521 |
local hpPer = div(hp * 100, maxHp) |
|
522 |
||
523 |
local wep = getHogInfo(hog, 'weapons') |
|
524 |
local hlp = getHogInfo(hog, 'helpers') |
|
525 |
||
526 |
if wep == nil or table.getn(wep) == 0 then |
|
527 |
hogInfo[hog]['weapons'] = GetRandomAmmo(hog, "weapons") |
|
528 |
wep = getHogInfo(hog, 'weapons') |
|
529 |
end |
|
530 |
||
531 |
if hlp == nil or table.getn(hlp) == 0 then |
|
532 |
hogInfo[hog]['helpers'] = GetRandomAmmo(hog, "helpers") |
|
533 |
hlp = getHogInfo(hog, 'helpers') |
|
534 |
end |
|
535 |
||
536 |
AddHogAmmo(hog, wep) |
|
537 |
AddHogAmmo(hog, hlp) |
|
538 |
||
539 |
if mode == 'highland' then |
|
540 |
local poolWeapons = GetRandomAmmo(hog, 'poolWeapons') |
|
541 |
local poolHelpers = GetRandomAmmo(hog, 'poolHelpers') |
|
542 |
||
543 |
AddHogAmmo(hog, poolWeapons) |
|
544 |
AddHogAmmo(hog, poolHelpers) |
|
545 |
end |
|
546 |
||
547 |
if hpPer < lowTresh or suddenDeath == true then |
|
548 |
AddHogAmmo(hog, lowWeaps) |
|
549 |
end |
|
550 |
-- We are on points mode, so we need to generate weapons based on points |
|
551 |
else |
|
552 |
setupPointsAmmo(hog) |
|
553 |
end |
|
554 |
||
555 |
AddAmmo(hog, amSkip, -1) |
|
556 |
end |
|
557 |
||
558 |
function setupPointsAmmo(hog) |
|
559 |
local teamName = getHogInfo(hog, 'team') |
|
560 |
local turnWepPoints = pointsPerTeam[teamName]['weapons'] |
|
561 |
local turnHlpPoints = pointsPerTeam[teamName]['helpers'] |
|
562 |
local weps = {} |
|
563 |
local help = {} |
|
564 |
||
565 |
local wepPointsTmp = table.clone(wepPoints) |
|
566 |
local wepMinPnt = wepPointsTmp[1] |
|
567 |
local wepMaxPnt = wepPointsTmp[#wepPointsTmp] |
|
568 |
||
569 |
--AddCaption("Hog: " .. hog .. " Wep: " .. turnWepPoints .. " - Hlp: " .. turnHlpPoints, GetClanColor(GetHogClan(CurHog)), capgrpGameState) |
|
570 |
--WriteLnToConsole("BEFORE ## Team: " .. teamName .. " Wep: " .. pointsPerTeam[teamName]['weapons'] .. " - Hlp: " .. pointsPerTeam[teamName]['helpers']) |
|
571 |
||
572 |
while true do |
|
573 |
if turnWepPoints < wepMinPnt then |
|
574 |
break |
|
575 |
end |
|
576 |
||
577 |
if wepPointsTmp[#wepPointsTmp] > turnWepPoints then |
|
578 |
while wepPointsTmp[#wepPointsTmp] > turnWepPoints do |
|
579 |
table.remove(wepPointsTmp) |
|
580 |
end |
|
581 |
wepMaxPnt = turnWepPoints |
|
582 |
end |
|
583 |
||
584 |
local randPoint = wepPointsTmp[GetRandom(#wepPointsTmp) +1] |
|
585 |
local randWepList = pointsToWep[randPoint] |
|
586 |
local randWep = randWepList[GetRandom(#randWepList) +1] |
|
587 |
||
588 |
table.insert(weps, randWep) |
|
589 |
turnWepPoints = turnWepPoints -randPoint |
|
590 |
end |
|
591 |
||
592 |
local hlpPointsTmp = table.clone(hlpPoints) |
|
593 |
local hlpMinPnt = hlpPointsTmp[1] |
|
594 |
local hlpMaxPnt = hlpPointsTmp[#hlpPointsTmp] |
|
595 |
||
596 |
while true do |
|
597 |
if turnHlpPoints < hlpMinPnt then |
|
598 |
break |
|
599 |
end |
|
600 |
||
601 |
if hlpPointsTmp[#hlpPointsTmp] > turnHlpPoints then |
|
602 |
while hlpPointsTmp[#hlpPointsTmp] > turnHlpPoints do |
|
603 |
table.remove(hlpPointsTmp) |
|
604 |
end |
|
605 |
hlpMaxPnt = turnHlpPoints |
|
606 |
end |
|
607 |
||
608 |
local randPoint = hlpPointsTmp[GetRandom(#hlpPointsTmp) +1] |
|
609 |
local randHlpList = pointsToHlp[randPoint] |
|
610 |
local randHlp = randHlpList[GetRandom(#randHlpList) +1] |
|
611 |
||
612 |
table.insert(help, randHlp) |
|
613 |
turnHlpPoints = turnHlpPoints -randPoint |
|
614 |
end |
|
615 |
||
616 |
AddHogAmmo(hog, weps) |
|
617 |
AddHogAmmo(hog, help) |
|
618 |
||
619 |
-- Save remaining points |
|
620 |
pointsPerTeam[teamName]['weaponsRem'] = turnWepPoints |
|
621 |
pointsPerTeam[teamName]['helpersRem'] = turnHlpPoints |
|
622 |
||
623 |
-- Save already collected points so that they wont be "taxed" |
|
624 |
pointsPerTeam[teamName]['weaponsFix'] = pointsPerTeam[teamName]['weapons'] |
|
625 |
pointsPerTeam[teamName]['helpersFix'] = pointsPerTeam[teamName]['helpers'] |
|
626 |
||
627 |
--WriteLnToConsole("AFTER ## Team: " .. teamName .. " Wep: " .. pointsPerTeam[teamName]['weapons'] .. " - Hlp: " .. pointsPerTeam[teamName]['helpers']) |
|
628 |
end |
|
629 |
||
630 |
--[[ |
|
631 |
############################################################################## |
|
632 |
### HOG SETUP FUNCTIONS ### |
|
633 |
############################################################################## |
|
634 |
]]-- |
|
635 |
||
636 |
function MutateHog(hog) |
|
637 |
local var = getHogInfo(hog, 'variant') |
|
638 |
||
12425
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
639 |
SetHogName(hog, variants[var]["name"]) |
12417 | 640 |
SetHogHat(hog, variants[var]["hat"]) |
641 |
end |
|
642 |
||
643 |
function GetRandomVariant() |
|
644 |
local maxNum = 0 |
|
645 |
||
646 |
for key, val in pairs(variants) do |
|
647 |
maxNum = maxNum + variants[key]["chance"] |
|
648 |
end |
|
649 |
||
650 |
local rand = GetRandom(maxNum) |
|
651 |
local lowBound = 0 |
|
652 |
local highBound = 0 |
|
653 |
local var = nil |
|
654 |
||
655 |
for key, val in pairs(variants) do |
|
656 |
highBound = lowBound + variants[key]["chance"] |
|
657 |
if rand <= highBound then |
|
658 |
var = key |
|
659 |
break |
|
660 |
end |
|
661 |
lowBound = highBound |
|
662 |
end |
|
663 |
||
664 |
return var |
|
665 |
end |
|
666 |
||
667 |
function addRandomVariantToTeam(team) |
|
668 |
if counter[team] == nil then |
|
669 |
counter[team] = {} |
|
670 |
end |
|
671 |
||
672 |
while true do |
|
673 |
local var = GetRandomVariant() |
|
674 |
if counter[team][var] == nil and variants[var]["hogLimit"] > 0 then |
|
675 |
counter[team][var] = 1 |
|
676 |
break |
|
677 |
elseif counter[team][var] ~= nil and counter[team][var] < variants[var]["hogLimit"] then |
|
678 |
counter[team][var] = counter[team][var] +1 |
|
679 |
break |
|
680 |
end |
|
681 |
end |
|
682 |
||
683 |
return var |
|
684 |
end |
|
685 |
||
686 |
function setTeamHogs(team) |
|
687 |
local maxHog = hogCount[team] |
|
688 |
||
689 |
group[team] = {} |
|
690 |
counter[team] = {} |
|
691 |
||
692 |
if mode == 'king' then |
|
693 |
maxHog = maxHog -1 |
|
694 |
end |
|
695 |
||
696 |
for i=1,maxHog do |
|
697 |
table.insert(group[team], group['all'][i]) |
|
698 |
end |
|
699 |
||
700 |
if mode == 'king' then |
|
701 |
counter[team]['King'] = 1 |
|
702 |
table.insert(group[team], 'King') |
|
703 |
end |
|
704 |
end |
|
705 |
||
706 |
function countTeamHogs(hog) |
|
707 |
local team = GetHogTeamName(hog) |
|
708 |
||
709 |
if hogCount[team] == nil then |
|
710 |
hogCount[team] = 1 |
|
711 |
teamHogs[team] = {} |
|
712 |
else |
|
713 |
hogCount[team] = hogCount[team] +1 |
|
714 |
end |
|
715 |
||
716 |
teamHogs[team][hogCount[team]] = hog |
|
717 |
||
718 |
teamNames[team] = 1 |
|
719 |
end |
|
720 |
||
721 |
function setHogVariant(hog) |
|
722 |
local team = getHogInfo(hog, 'team') |
|
723 |
||
724 |
if teamIndex[team] == nil then |
|
725 |
teamIndex[team] = 1 |
|
726 |
else |
|
727 |
teamIndex[team] = teamIndex[team] +1 |
|
728 |
end |
|
729 |
||
730 |
local hogNum = teamIndex[team] |
|
731 |
local hogVar = group[team][hogNum] |
|
732 |
||
733 |
hogInfo[hog]['variant'] = hogVar |
|
734 |
SetHealth(hog, variants[hogVar]["hp"]) |
|
735 |
end |
|
736 |
||
737 |
function getHogInfo(hog, info) |
|
738 |
if hog == nil then |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
739 |
WriteLnToChat("ERROR [getHogInfo]: hog is nil!") |
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
740 |
WriteLnToConsole("ERROR [getHogInfo]: hog is nil!") |
12417 | 741 |
return |
742 |
end |
|
743 |
||
744 |
if hogInfo[hog] == nil then |
|
745 |
return nil |
|
746 |
end |
|
747 |
||
748 |
return hogInfo[hog][info] |
|
749 |
end |
|
750 |
||
751 |
function setHogInfo(hog) |
|
752 |
if hog == nil then |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
753 |
WriteLnToChat("ERROR [setHogInfo]: hog is nil!") |
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
754 |
WriteLnToConsole("ERROR [setHogInfo]: hog is nil!") |
12417 | 755 |
return |
756 |
end |
|
757 |
||
758 |
hogInfo[hog] = {} |
|
759 |
hogInfo[hog]['maxHp'] = GetHealth(hog) |
|
760 |
hogInfo[hog]['name'] = GetHogName(hog) |
|
761 |
hogInfo[hog]['hat'] = GetHogHat(hog) |
|
762 |
hogInfo[hog]['team'] = GetHogTeamName(hog) |
|
763 |
hogInfo[hog]['clan'] = GetHogClan(hog) |
|
764 |
hogInfo[hog]['clanColor'] = GetClanColor(hogInfo[hog]['clan']) |
|
765 |
end |
|
766 |
||
767 |
--[[ |
|
768 |
############################################################################## |
|
769 |
### CRATE SPAWN AND PICKUP FUNCTIONS ### |
|
770 |
############################################################################## |
|
771 |
]]-- |
|
772 |
||
773 |
--[[ |
|
774 |
: Heals either 10 (95% chance) or 15 (5% chance) hitpoints |
|
775 |
: Plus 10% of the hogs base hitpoints. |
|
776 |
: |
|
777 |
: Has a 7% chance to be empty. |
|
778 |
]]-- |
|
779 |
function onHealthCratePickup() |
|
780 |
local factor = 2 |
|
781 |
local msgColor = getHogInfo(CurHog, 'clanColor') |
|
782 |
local healHp = 0 |
|
783 |
PlaySound(sndShotgunReload) |
|
784 |
||
785 |
if GetRandom(100) < emptyCrateChance then |
|
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
786 |
AddCaption(loc("It's empty!"), msgColor, capgrpMessage) |
12417 | 787 |
return |
788 |
elseif GetRandom(100) < bonusCrateChance then |
|
789 |
factor = 3 |
|
790 |
end |
|
791 |
||
792 |
local var = getHogInfo(CurHog, 'variant') |
|
793 |
local hogHealth = GetHealth(CurHog) |
|
794 |
healHp = 5 * factor |
|
795 |
||
796 |
-- Add extra 10% of hogs base hp to heal |
|
797 |
healHp = healHp + div(getHogInfo(CurHog, 'maxHp'), 10) |
|
798 |
||
12984
b6d67e975b51
Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
799 |
HealHog(CurHog, healHp) |
12417 | 800 |
|
801 |
SetEffect(CurHog, hePoisoned, 0) |
|
802 |
end |
|
803 |
||
804 |
--[[ |
|
805 |
: Adds either 1 (95% chance) or 2 (5% chance) random weapon(s) based on the hog variant. |
|
806 |
: |
|
807 |
: Has a 7% chance to be empty. |
|
808 |
]]-- |
|
12988
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
809 |
function onWeaponCratePickup(crate) |
12417 | 810 |
local factor = 1 * strength |
811 |
local msgColor = GetClanColor(GetHogClan(CurHog)) |
|
812 |
PlaySound(sndShotgunReload) |
|
813 |
||
814 |
if GetRandom(100) < emptyCrateChance then |
|
12633
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
815 |
if IsHogLocal(CurHog) then |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
816 |
AddCaption(loc("It's empty!"), msgColor, capgrpMessage) |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
817 |
end |
12417 | 818 |
return |
819 |
elseif GetRandom(100) < bonusCrateChance then |
|
820 |
factor = 2 * strength |
|
821 |
end |
|
822 |
||
823 |
local randIndex |
|
824 |
local randAmmo |
|
825 |
||
826 |
if mode ~= 'points' then |
|
827 |
local var = getHogInfo(CurHog, 'variant') |
|
828 |
randIndex = GetRandom(table.getn(variants[var]["weapons"])) +1 |
|
829 |
randAmmo = variants[var]["weapons"][randIndex] |
|
830 |
else |
|
831 |
local possibleWeapons = {} |
|
832 |
||
833 |
for key, val in pairs(pointsWeaponVal) do |
|
834 |
if val > 2 and val < 8 then |
|
835 |
table.insert(possibleWeapons, key) |
|
836 |
end |
|
837 |
end |
|
838 |
||
839 |
randIndex = GetRandom(table.getn(possibleWeapons)) +1 |
|
840 |
randAmmo = possibleWeapons[randIndex] |
|
841 |
end |
|
842 |
||
843 |
AddAmmo(CurHog, randAmmo, GetAmmoCount(CurHog, randAmmo) +factor) |
|
12633
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
844 |
if IsHogLocal(CurHog) then |
12984
b6d67e975b51
Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
845 |
AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randAmmo), factor), msgColor, capgrpMessage) |
12988
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
846 |
local effect = AddVisualGear(GetX(crate), GetY(crate) +cratePickupGap, vgtAmmo, 0, true) |
12633
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
847 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmo, nil, nil, nil, msgColor) |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
848 |
end |
12417 | 849 |
end |
850 |
--[[ |
|
851 |
: Adds either 1 (95% chance) or 2 (5% chance) random helper(s) based on the hog variant. |
|
852 |
: |
|
853 |
: Has a 7% chance to be empty. |
|
854 |
]]-- |
|
12988
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
855 |
function onUtilityCratePickup(crate) |
12417 | 856 |
local factor = 1 * strength |
857 |
local msgColor = GetClanColor(GetHogClan(CurHog)) |
|
858 |
PlaySound(sndShotgunReload) |
|
859 |
||
860 |
if GetRandom(100) < emptyCrateChance then |
|
12633
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
861 |
if IsHogLocal(CurHog) then |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
862 |
AddCaption(loc("It's empty!"), msgColor, capgrpMessage) |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
863 |
end |
12417 | 864 |
return |
865 |
elseif GetRandom(100) < bonusCrateChance then |
|
866 |
factor = 2 * strength |
|
867 |
end |
|
868 |
||
869 |
local randIndex |
|
870 |
local randUtility |
|
871 |
||
872 |
if mode ~= 'points' then |
|
873 |
randIndex = GetRandom(table.getn(utilities)) +1 |
|
874 |
randUtility = utilities[randIndex] |
|
875 |
else |
|
876 |
local possibleHelpers = {} |
|
877 |
||
878 |
for key, val in pairs(pointsHelperVal) do |
|
879 |
table.insert(possibleHelpers, key) |
|
880 |
end |
|
881 |
||
882 |
randIndex = GetRandom(table.getn(possibleHelpers)) +1 |
|
883 |
randUtility = possibleHelpers[randIndex] |
|
884 |
end |
|
885 |
||
886 |
AddAmmo(CurHog, randUtility, GetAmmoCount(CurHog, randUtility) +factor) |
|
12633
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
887 |
if IsHogLocal(CurHog) then |
12984
b6d67e975b51
Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
888 |
AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randUtility), factor), msgColor, capgrpMessage) |
12988
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
889 |
local effect = AddVisualGear(GetX(crate), GetY(crate) +cratePickupGap, vgtAmmo, 0, true) |
12633
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
890 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, randUtility, nil, nil, nil, msgColor) |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
891 |
end |
12417 | 892 |
end |
893 |
||
894 |
function onPickupCrate(crate) |
|
895 |
local pos = GetGearPos(crate) |
|
896 |
||
897 |
-- Check if the crate is fake |
|
898 |
if pos % posCaseDummy >= 1 then |
|
899 |
if pos % posCaseDummy == posCaseAmmo then |
|
12988
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
900 |
onWeaponCratePickup(crate) |
12417 | 901 |
elseif pos % posCaseDummy == posCaseHealth then |
902 |
onHealthCratePickup() |
|
903 |
elseif pos % posCaseDummy == posCaseUtility then |
|
12988
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
904 |
onUtilityCratePickup(crate) |
12417 | 905 |
end |
906 |
end |
|
907 |
end |
|
908 |
||
909 |
function RandomTurnEvents() |
|
910 |
if GetRandom(100) < weaponCrateChance then |
|
911 |
SpawnFakeAmmoCrate(0, 0, false, false) |
|
912 |
return 5000 |
|
913 |
elseif GetRandom(100) < utilCrateChance then |
|
914 |
SpawnFakeUtilityCrate(0, 0, false, false) |
|
915 |
return 5000 |
|
916 |
elseif GetRandom(100) < healthCrateChance then |
|
917 |
SpawnFakeHealthCrate(0, 0, false, false) |
|
918 |
return 5000 |
|
919 |
end |
|
920 |
return 0 |
|
921 |
end |
|
922 |
||
923 |
--[[ |
|
924 |
############################################################################## |
|
925 |
### SUDDEN DEATH FUNCTIONS ### |
|
926 |
############################################################################## |
|
927 |
]]-- |
|
928 |
||
929 |
function onSuddenDeathDamage(hog) |
|
930 |
local hp = GetHealth(hog) |
|
931 |
local maxHp = getHogInfo(hog, 'maxHp') |
|
932 |
local newHp = 0 |
|
933 |
local hpDec = 0 |
|
934 |
local hpPer = div(hp * 100, maxHp) |
|
935 |
||
936 |
if hp > 1 then |
|
937 |
local msgColor = GetClanColor(GetHogClan(hog)) |
|
938 |
if hpPer <= 25 then |
|
939 |
newHp = hp -2 |
|
940 |
elseif hpPer <= 50 then |
|
941 |
newHp = hp -3 |
|
942 |
elseif hpPer <= 75 then |
|
943 |
newHp = hp -4 |
|
944 |
elseif hpPer <= 100 then |
|
945 |
newHp = hp -5 |
|
946 |
elseif hpPer <= 125 then |
|
947 |
newHp = hp -6 |
|
948 |
elseif hpPer <= 150 then |
|
949 |
newHp = hp -7 |
|
950 |
else |
|
951 |
newHp = div(hp * 93, 100) |
|
952 |
end |
|
953 |
||
954 |
if newHp <= 0 then |
|
955 |
newHp = 1 |
|
956 |
end |
|
957 |
||
958 |
hpDec = hp - newHp |
|
959 |
||
960 |
SetHealth(hog, newHp) |
|
961 |
local effect = AddVisualGear(GetX(hog), GetY(hog) +cratePickupGap, vgtHealthTag, hpDec, false) |
|
962 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, msgColor) |
|
963 |
end |
|
964 |
end |
|
965 |
||
966 |
function onSuddenDeathTurn() |
|
967 |
runOnGears(onSuddenDeathDamage) |
|
968 |
end |
|
969 |
||
970 |
function onSuddenDeath() |
|
971 |
suddenDeath = true |
|
972 |
||
973 |
healthCrateChance = healthCrateChanceSD |
|
974 |
utilCrateChance = utilCrateChanceSD |
|
975 |
weaponCrateChance = weaponCrateChanceSD |
|
976 |
||
977 |
if mode == 'highland' then |
|
978 |
highEnemyKillHPBonus = highEnemyKillHPBonus +5 |
|
979 |
highFriendlyKillHPBonus = highFriendlyKillHPBonus +10 |
|
980 |
end |
|
981 |
||
982 |
if mode ~= 'points' then |
|
983 |
for key, val in pairs(variants) do |
|
984 |
if not variants[key]["special"] then |
|
985 |
variants[key]["weaponLimit"] = variants[key]["weaponLimit"] +1 |
|
986 |
end |
|
987 |
end |
|
988 |
end |
|
989 |
||
990 |
if mode ~= 'points' then |
|
991 |
for hog, val in pairs(hogInfo) do |
|
992 |
hogInfo[hog]['weapons'] = {} |
|
993 |
hogInfo[hog]['helpers'] = {} |
|
994 |
end |
|
995 |
||
996 |
runOnGears(setupHogTurn) |
|
997 |
end |
|
998 |
end |
|
999 |
||
1000 |
--[[ |
|
1001 |
############################################################################## |
|
1002 |
### GEAR TRACKING FUNCTIONS ### |
|
1003 |
############################################################################## |
|
1004 |
]]-- |
|
1005 |
||
1006 |
function onGearAdd(gear) |
|
1007 |
local gearType = GetGearType(gear) |
|
1008 |
||
1009 |
if gearType == gtHedgehog then |
|
1010 |
trackGear(gear) |
|
1011 |
elseif gearType == gtRCPlane then |
|
12427
959d1f4dff25
Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents:
12426
diff
changeset
|
1012 |
SetHealth(gear, 2) |
12417 | 1013 |
elseif gearType == gtAirBomb then |
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1014 |
-- Set Boom |
12427
959d1f4dff25
Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents:
12426
diff
changeset
|
1015 |
SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 20) |
12417 | 1016 |
elseif gearType == gtCake then |
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1017 |
-- Set Boom |
12417 | 1018 |
SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 50) |
1019 |
elseif gearType == gtDEagleShot then |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1020 |
-- Set Boom |
12417 | 1021 |
SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 12) |
1022 |
end |
|
1023 |
end |
|
1024 |
||
1025 |
function onHighlandKill(gear) |
|
1026 |
local deathVar = getHogInfo(gear, 'variant') |
|
1027 |
local killVar = getHogInfo(CurHog, 'variant') |
|
1028 |
local bonAmmo = {} |
|
1029 |
local deathMaxHP = getHogInfo(gear, 'maxHp') |
|
1030 |
local curHP = GetHealth(CurHog) |
|
1031 |
local newHP = 0 |
|
1032 |
local hpDiff = 0 |
|
1033 |
local addAmmo = false |
|
1034 |
||
1035 |
-- Killer hog is dead! Don't do anything |
|
1036 |
if curHP == nil or curHP <= 0 then |
|
1037 |
return |
|
1038 |
end |
|
1039 |
||
1040 |
-- Killer and victim is equal! Don't do anything |
|
1041 |
if CurHog == gear then |
|
1042 |
return |
|
1043 |
end |
|
1044 |
||
1045 |
-- Hog drowned because of water, not enemy |
|
1046 |
if LastWaterLine ~= WaterLine then |
|
1047 |
return |
|
1048 |
end |
|
1049 |
||
1050 |
-- Enemy kill! Add weapons to pool and to hog |
|
1051 |
if getHogInfo(gear, 'clan') ~= getHogInfo(CurHog, 'clan') then |
|
1052 |
||
1053 |
-- Initialize weapons if required |
|
1054 |
if highWeapons[CurHog] == nil then |
|
1055 |
highWeapons[CurHog] = {} |
|
1056 |
end |
|
1057 |
||
1058 |
if highHelpers[CurHog] == nil then |
|
1059 |
highHelpers[CurHog] = {} |
|
1060 |
end |
|
1061 |
||
1062 |
-- If not a special hog, use the victims weapons |
|
1063 |
if variants[deathVar]['special'] == false then |
|
1064 |
bonAmmo = variants[deathVar]['weapons'] |
|
1065 |
||
1066 |
if suddenDeath == true then |
|
1067 |
ammoCount = highPickupSDCount |
|
1068 |
else |
|
1069 |
ammoCount = highPickupCount |
|
1070 |
end |
|
1071 |
||
1072 |
-- Check if hog already got bonus weapons |
|
1073 |
if table.getn(highWeapons[CurHog]) == 0 and highHasBonusWeps == false then |
|
1074 |
highHasBonusWeps = true |
|
1075 |
addAmmo = true |
|
1076 |
end |
|
1077 |
||
1078 |
-- Pass turn bonus weapons to hog pool |
|
1079 |
for key, val in pairs(bonAmmo) do |
|
1080 |
local idx = table.getn(highWeapons[CurHog]) +1 |
|
1081 |
highWeapons[CurHog][idx] = val |
|
1082 |
end |
|
1083 |
-- It's a special hog, use special pool |
|
1084 |
else |
|
1085 |
bonAmmo = highSpecialBonus |
|
1086 |
||
1087 |
ammoCount = 1 |
|
1088 |
||
1089 |
-- Check if hog already got bonus helpers |
|
1090 |
if table.getn(highWeapons[CurHog]) == 0 and highHasBonusHelp == false then |
|
1091 |
highHasBonusHelp = true |
|
1092 |
addAmmo = true |
|
1093 |
end |
|
1094 |
||
1095 |
-- Pass turn bonus weapons to hog pool |
|
1096 |
for key, val in pairs(highSpecialPool) do |
|
1097 |
local idx = table.getn(highHelpers[CurHog]) +1 |
|
1098 |
highHelpers[CurHog][idx] = val |
|
1099 |
end |
|
1100 |
end |
|
1101 |
||
1102 |
if addAmmo then |
|
1103 |
local i = 1 |
|
1104 |
while i <= ammoCount and #bonAmmo > 0 do |
|
1105 |
local randAmmo = GetRandom(#bonAmmo) +1 |
|
1106 |
local randAmmoType = bonAmmo[randAmmo] |
|
1107 |
||
1108 |
-- Remove the randomized weapon so it cannot be picked up twice |
|
1109 |
table.remove(bonAmmo, randAmmo) |
|
1110 |
||
1111 |
AddAmmo(CurHog, randAmmoType, GetAmmoCount(CurHog, randAmmoType) +1) |
|
1112 |
||
12633
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
1113 |
if IsHogLocal(CurHog) then |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
1114 |
local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) + (cratePickupGap * i), vgtAmmo, 0, true) |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
1115 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmoType, nil, nil, nil, nil) |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12427
diff
changeset
|
1116 |
end |
12417 | 1117 |
|
1118 |
i = i +1 |
|
1119 |
end |
|
1120 |
end |
|
1121 |
||
1122 |
hpDiff = div(deathMaxHP * highEnemyKillHPBonus, 100) |
|
1123 |
newHP = curHP + hpDiff |
|
12986
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1124 |
HealHog(CurHog, newHP) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1125 |
-- Friendly fire! Punish hog by removing weapons and helpers from pool |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1126 |
-- and reduce health |
12417 | 1127 |
else |
1128 |
highWeapons[CurHog] = {} |
|
1129 |
highHelpers[CurHog] = {} |
|
1130 |
||
1131 |
hpDiff = div(deathMaxHP * highFriendlyKillHPBonus, 100) |
|
1132 |
newHP = curHP - hpDiff |
|
1133 |
if newHP > 0 then |
|
1134 |
SetHealth(CurHog, newHP) |
|
1135 |
else |
|
1136 |
SetHealth(CurHog, 0) |
|
1137 |
end |
|
1138 |
||
1139 |
local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) - cratePickupGap, vgtHealthTag, hpDiff, false) |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1140 |
-- Set Tint |
12417 | 1141 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(CurHog))) |
1142 |
end |
|
1143 |
end |
|
1144 |
||
1145 |
function onKingDeath(KingHog) |
|
1146 |
local team = getHogInfo(KingHog, 'team') |
|
1147 |
local msgColor = getHogInfo(KingHog, 'clanColor') |
|
1148 |
||
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1149 |
AddCaption(string.format(loc("The king of %s has died!"), team), 0xFFFFFFFF, capgrpGameState) |
12417 | 1150 |
PlaySound(sndByeBye) |
1151 |
DismissTeam(team) |
|
1152 |
||
1153 |
-- for hog, val in pairs(hogInfo) do |
|
1154 |
-- if getHogInfo(hog, 'team') == team then |
|
1155 |
-- hp = GetHealth(hog) |
|
1156 |
-- if hp ~= nil and hp > 0 then |
|
1157 |
-- SetState(KingHog, gstHHDeath) |
|
1158 |
-- SetHealth(hog, 0) |
|
1159 |
-- SetGearValues(hog, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0) |
|
1160 |
-- end |
|
1161 |
-- end |
|
1162 |
-- end |
|
1163 |
end |
|
1164 |
||
1165 |
function onPointsKill(gear) |
|
1166 |
local deathVar = getHogInfo(gear, 'variant') |
|
1167 |
local killVar = getHogInfo(CurHog, 'variant') |
|
1168 |
local deathClan = getHogInfo(gear, 'clan') |
|
1169 |
local killClan = getHogInfo(CurHog, 'clan') |
|
1170 |
local team = getHogInfo(CurHog, 'team') |
|
1171 |
||
1172 |
local curHP = GetHealth(CurHog) |
|
1173 |
||
1174 |
-- Killer hog is dead! Don't do anything |
|
1175 |
if curHP == nil or curHP <= 0 then |
|
1176 |
return |
|
1177 |
end |
|
1178 |
||
1179 |
-- Hog drowned because of water, not enemy |
|
1180 |
if LastWaterLine ~= WaterLine then |
|
1181 |
return |
|
1182 |
end |
|
1183 |
||
1184 |
-- Same clan, friendly kill, skip |
|
1185 |
if killClan == deathClan then |
|
1186 |
return |
|
1187 |
end |
|
1188 |
||
1189 |
pointsPerTeam[team]['weapons'] = pointsPerTeam[team]['weapons'] + 2 |
|
1190 |
pointsPerTeam[team]['helpers'] = pointsPerTeam[team]['helpers'] + 1 |
|
1191 |
||
1192 |
local effect = AddVisualGear(GetX(CurHog) - (cratePickupGap / 2), GetY(CurHog), vgtHealthTag, 2, false) |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1193 |
-- Set Tint |
12417 | 1194 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFFFFFFFF) |
1195 |
||
1196 |
local effect = AddVisualGear(GetX(CurHog) + (cratePickupGap / 2), GetY(CurHog), vgtHealthTag, 1, false) |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1197 |
-- Set Tint |
12417 | 1198 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x444444FF) |
1199 |
end |
|
1200 |
||
1201 |
function onGearDelete(gear) |
|
1202 |
trackDeletion(gear) |
|
1203 |
||
1204 |
if GetGearType(gear) == gtCase and band(GetGearMessage(gear), gmDestroy) ~= 0 then |
|
1205 |
onPickupCrate(gear) |
|
1206 |
end |
|
1207 |
||
1208 |
if GetGearType(gear) == gtHedgehog then |
|
1209 |
if mode ~= 'points' then |
|
1210 |
hogInfo[gear]['weapons'] = {} |
|
1211 |
hogInfo[gear]['helpers'] = {} |
|
1212 |
end |
|
1213 |
||
1214 |
-- If dying gear is a hog and mode is highland, check for kills |
|
1215 |
if mode == 'highland' then |
|
1216 |
onHighlandKill(gear) |
|
1217 |
-- If current hog is dying and we are on points mode, we need to save the unused weapons/helpers |
|
1218 |
elseif mode == 'points' and CurHog == gear then |
|
1219 |
savePoints(gear) |
|
1220 |
elseif mode == 'points' and CurHog ~= gear then |
|
1221 |
onPointsKill(gear) |
|
1222 |
end |
|
1223 |
||
1224 |
if mode == 'king' and getHogInfo(gear, 'variant') == 'King' then |
|
1225 |
onKingDeath(gear) |
|
1226 |
end |
|
1227 |
end |
|
1228 |
end |
|
1229 |
||
1230 |
--[[ |
|
1231 |
############################################################################## |
|
1232 |
### TURN BASED FUNCTIONS ### |
|
1233 |
############################################################################## |
|
1234 |
]]-- |
|
1235 |
||
12986
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1236 |
function calcKingHP(doEffects) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1237 |
if doEffects == nil then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1238 |
doEffects = true |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1239 |
end |
12417 | 1240 |
local teamKings = {} |
1241 |
local teamHealth = {} |
|
1242 |
||
1243 |
for hog, val in pairs(hogInfo) do |
|
1244 |
local hp = GetHealth(hog) |
|
1245 |
||
1246 |
if hp ~= nil and hp > 0 then |
|
1247 |
local team = getHogInfo(hog, 'team') |
|
1248 |
||
1249 |
if teamHealth[team] == nil then |
|
1250 |
teamHealth[team] = 0 |
|
1251 |
end |
|
1252 |
||
1253 |
if getHogInfo(hog, 'variant') == 'King' then |
|
1254 |
teamKings[team] = hog |
|
1255 |
else |
|
1256 |
teamHealth[team] = teamHealth[team] + hp |
|
1257 |
end |
|
1258 |
end |
|
1259 |
end |
|
1260 |
||
1261 |
for team, hog in pairs(teamKings) do |
|
1262 |
local hp = GetHealth(hog) |
|
1263 |
local newHP = div(teamHealth[team] * kingLinkPerc, 100) |
|
1264 |
||
1265 |
-- Set hitpoints to 1 if no other hog is alive or only has 1 hitpoint |
|
1266 |
if newHP <= 0 then |
|
1267 |
newHP = 1 |
|
1268 |
end |
|
1269 |
||
12986
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1270 |
local diff = math.abs(newHP - hp) |
12417 | 1271 |
|
12986
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1272 |
-- Change HP and do some nice effects |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1273 |
if newHP ~= hp then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1274 |
if not doEffects then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1275 |
SetHealth(hog, newHP) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1276 |
else |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1277 |
if newHP > hp then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1278 |
HealHog(hog, diff, false) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1279 |
elseif newHP < hp then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1280 |
SetHealth(hog, newHP) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1281 |
if doEffects then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1282 |
local effect = AddVisualGear(GetX(hog), GetY(hog) - cratePickupGap, vgtHealthTag, diff, false) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1283 |
-- Set Tint |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1284 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(hog))) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1285 |
end |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1286 |
end |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1287 |
end |
12417 | 1288 |
end |
1289 |
end |
|
1290 |
end |
|
1291 |
||
1292 |
function setupHogTurn(hog) |
|
1293 |
clearHogAmmo(hog) |
|
1294 |
addTurnAmmo(hog) |
|
1295 |
end |
|
1296 |
||
12987
ba577e0b8c27
Battalion: Use official onEndTurn callback
Wuzzy <Wuzzy2@mail.ru>
parents:
12986
diff
changeset
|
1297 |
function onEndTurn() |
12990
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1298 |
if not firstTurnOver then |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1299 |
firstTurnOver = true |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1300 |
end |
12417 | 1301 |
local anyHog = nil |
1302 |
for team, val in pairs(teamNames) do |
|
1303 |
-- Count amount of alive hogs in team |
|
1304 |
local c = 0 |
|
1305 |
for idx, hog in pairs(teamHogs[team]) do |
|
1306 |
if GetHealth(hog) ~= nil then |
|
1307 |
anyHog = hog |
|
1308 |
c = c + 1 |
|
1309 |
end |
|
1310 |
end |
|
1311 |
||
1312 |
-- Only one hog left, unfreeze the hog |
|
1313 |
if c == 1 then |
|
1314 |
if GetHealth(anyHog) ~= nil then |
|
1315 |
SetEffect(anyHog, heFrozen, 0) |
|
1316 |
end |
|
1317 |
end |
|
1318 |
end |
|
1319 |
||
1320 |
-- When we are on points mode count remaining weapon/helper points |
|
1321 |
if mode == 'points' and GetHealth(CurHog) ~= nil then |
|
1322 |
savePoints(CurHog) |
|
1323 |
end |
|
1324 |
||
1325 |
-- Run random turn events |
|
1326 |
RandomTurnEvents() |
|
1327 |
end |
|
1328 |
||
1329 |
function savePoints(hog) |
|
1330 |
local team = getHogInfo(hog, 'team') |
|
1331 |
local hogWepPoints = 0 |
|
1332 |
local hogHlpPoints = 0 |
|
1333 |
||
1334 |
for ammoType=0,amAirMine do |
|
1335 |
local ammoCount = GetAmmoCount(hog, ammoType) |
|
1336 |
||
1337 |
if pointsWeaponVal[ammoType] ~= nil then |
|
1338 |
hogWepPoints = hogWepPoints + (pointsWeaponVal[ammoType] * ammoCount) |
|
1339 |
elseif pointsHelperVal[ammoType] ~= nil then |
|
1340 |
hogHlpPoints = hogHlpPoints + (pointsHelperVal[ammoType] * ammoCount) |
|
1341 |
end |
|
1342 |
end |
|
1343 |
||
1344 |
local wepWoTax = pointsPerTeam[team]['weaponsFix'] |
|
1345 |
local hlpWoTax = pointsPerTeam[team]['helpersFix'] |
|
1346 |
local wepToTax = 0 |
|
1347 |
local hlpToTax = 0 |
|
1348 |
||
1349 |
if hogWepPoints <= wepWoTax then |
|
1350 |
wepWoTax = hogWepPoints |
|
1351 |
else |
|
1352 |
wepToTax = hogWepPoints - wepWoTax |
|
1353 |
end |
|
1354 |
||
1355 |
if hogHlpPoints <= hlpWoTax then |
|
1356 |
hlpWoTax = hogHlpPoints |
|
1357 |
else |
|
1358 |
hlpToTax = hogHlpPoints - hlpWoTax |
|
1359 |
end |
|
1360 |
||
1361 |
if suddenDeath == false then |
|
1362 |
pointsPerTeam[team]['weapons'] = pointsPerTeam[team]['weaponsRem'] + wepWoTax + div(wepToTax * pointsKeepPerc, 100) |
|
1363 |
pointsPerTeam[team]['helpers'] = pointsPerTeam[team]['helpersRem'] + hlpWoTax + div(hlpToTax * pointsKeepPerc, 100) |
|
1364 |
else |
|
1365 |
pointsPerTeam[team]['weapons'] = pointsPerTeam[team]['weaponsRem'] + wepWoTax + div(wepToTax * pointsKeepSDPerc, 100) |
|
1366 |
pointsPerTeam[team]['helpers'] = pointsPerTeam[team]['helpersRem'] + hlpWoTax + div(hlpToTax * pointsKeepSDPerc, 100) |
|
1367 |
end |
|
1368 |
||
1369 |
local effect = AddVisualGear(GetX(hog) - (cratePickupGap / 2), GetY(hog), vgtHealthTag, pointsPerTeam[team]['weapons'], false) |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1370 |
-- Set Tint |
12417 | 1371 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFFFFFFFF) |
1372 |
||
1373 |
local effect = AddVisualGear(GetX(hog) + (cratePickupGap / 2), GetY(hog), vgtHealthTag, pointsPerTeam[team]['helpers'], false) |
|
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1374 |
-- Set Tint |
12417 | 1375 |
SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x444444FF) |
1376 |
end |
|
1377 |
||
1378 |
function onPointsTurn() |
|
1379 |
local hogWepPoints = 0 |
|
1380 |
local hogHlpPoints = 0 |
|
1381 |
||
1382 |
if suddenDeath == false then |
|
1383 |
pointsPerTeam[LastTeam]['weapons'] = pointsPerTeam[LastTeam]['weapons'] + pointsWepTurn |
|
1384 |
pointsPerTeam[LastTeam]['helpers'] = pointsPerTeam[LastTeam]['helpers'] + pointsHlpTurn |
|
1385 |
||
1386 |
if pointsPerTeam[LastTeam]['weapons'] > pointsWepMax then |
|
1387 |
pointsPerTeam[LastTeam]['weapons'] = pointsWepMax |
|
1388 |
end |
|
1389 |
||
1390 |
if pointsPerTeam[LastTeam]['helpers'] > pointsHlpMax then |
|
1391 |
pointsPerTeam[LastTeam]['helpers'] = pointsHlpMax |
|
1392 |
end |
|
1393 |
else |
|
1394 |
pointsPerTeam[LastTeam]['weapons'] = pointsPerTeam[LastTeam]['weapons'] + pointsWepSDTurn |
|
1395 |
pointsPerTeam[LastTeam]['helpers'] = pointsPerTeam[LastTeam]['helpers'] + pointsHlpSDTurn |
|
1396 |
||
1397 |
if pointsPerTeam[LastTeam]['weapons'] > pointsWepSDMax then |
|
1398 |
pointsPerTeam[LastTeam]['weapons'] = pointsWepSDMax |
|
1399 |
end |
|
1400 |
||
1401 |
if pointsPerTeam[LastTeam]['helpers'] > pointsHlpSDMax then |
|
1402 |
pointsPerTeam[LastTeam]['helpers'] = pointsHlpSDMax |
|
1403 |
end |
|
1404 |
end |
|
1405 |
||
1406 |
-- Take the first alive hog from LastTeam and setup new weapons and helpers |
|
1407 |
-- Since the weapons and helpers are shared the whole team, this is sufficent |
|
1408 |
for idx, teamHog in pairs(teamHogs[LastTeam]) do |
|
1409 |
if GetHealth(teamHog) ~= nil then |
|
1410 |
clearHogAmmo(teamHog) |
|
1411 |
addTurnAmmo(teamHog) |
|
1412 |
break |
|
1413 |
end |
|
1414 |
end |
|
1415 |
end |
|
1416 |
||
1417 |
function onNewTurn() |
|
1418 |
LastHog = CurHog |
|
1419 |
LastTeam = CurTeam |
|
1420 |
CurHog = CurrentHedgehog |
|
1421 |
CurTeam = getHogInfo(CurHog, 'team') |
|
1422 |
||
1423 |
if suddenDeath == true then |
|
1424 |
onSuddenDeathTurn() |
|
12990
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1425 |
else |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1426 |
local RoundsTillSD = (SuddenDeathTurns+2) - (TotalRounds+1) |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1427 |
-- Show SD reminder every couple of turns, and in the first turn |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1428 |
if (not firstTurnOver) or (RoundsTillSD <= 6) or (RoundsTillSD <= 25 and RoundsTillSD % 5 == 0) or (RoundsTillSD % 10 == 0) then |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1429 |
AddCaption(string.format(loc("Rounds until Sudden Death: %d"), RoundsTillSD), 0xFFFFFFFF, capgrpGameState) |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12989
diff
changeset
|
1430 |
end |
12417 | 1431 |
end |
1432 |
||
1433 |
-- Generate new weapons for last hog if it's still alive |
|
1434 |
if LastHog ~= nil and LastHog ~= CurHog then |
|
1435 |
if mode == 'points' then |
|
1436 |
onPointsTurn() |
|
1437 |
else |
|
1438 |
hogInfo[LastHog]['weapons'] = {} |
|
1439 |
hogInfo[LastHog]['helpers'] = {} |
|
1440 |
setupHogTurn(LastHog) |
|
1441 |
end |
|
1442 |
end |
|
1443 |
||
1444 |
-- Recalculate the kings hp if required |
|
1445 |
if mode == 'king' then |
|
1446 |
calcKingHP() |
|
1447 |
end |
|
1448 |
||
1449 |
if mode == 'highland' then |
|
1450 |
highHasBonusWeps = false |
|
1451 |
highHasBonusHelp = false |
|
1452 |
end |
|
1453 |
||
1454 |
-- Set LastWaterLine to the current water line |
|
1455 |
LastWaterLine = WaterLine |
|
1456 |
end |
|
1457 |
||
1458 |
--[[ |
|
1459 |
############################################################################## |
|
1460 |
### GAME START FUNCTIONS ### |
|
1461 |
############################################################################## |
|
1462 |
]]-- |
|
1463 |
||
1464 |
function onAmmoStoreInit() |
|
1465 |
local lastNum = amAirMine |
|
1466 |
||
1467 |
for val=0,lastNum do |
|
1468 |
SetAmmo(val, 0, 0, 0, 0) |
|
1469 |
end |
|
1470 |
end |
|
1471 |
||
1472 |
function onParameters() |
|
1473 |
parseParams() |
|
1474 |
||
1475 |
if params['mode'] ~= nil then |
|
1476 |
mode = params['mode'] |
|
12989
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1477 |
if mode == "default" or mode == "king" or mode == "points" or mode == "highland" then |
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1478 |
modeExplicit = true |
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1479 |
end |
12417 | 1480 |
end |
1481 |
||
1482 |
if params['mutate'] ~= nil then |
|
1483 |
mutate = params['mutate'] |
|
1484 |
end |
|
1485 |
||
1486 |
if params['strength'] ~= nil and tonumber(params['strength']) > 0 then |
|
1487 |
strength = tonumber(params['strength']) |
|
1488 |
-- Highland |
|
1489 |
if mode == 'highland' then |
|
1490 |
highPickupCount = highPickupCount * strength |
|
1491 |
highPickupSDCount = highPickupSDCount * strength |
|
1492 |
highHelperCount = highHelperCount * strength |
|
1493 |
highHelperSDCount = highHelperSDCount * strength |
|
1494 |
-- Points |
|
1495 |
elseif mode == 'points' then |
|
1496 |
pointsWepBase = pointsWepBase * strength |
|
1497 |
pointsHlpBase = pointsHlpBase * strength |
|
1498 |
pointsWepTurn = pointsWepTurn * strength |
|
1499 |
pointsHlpTurn = pointsHlpTurn * strength |
|
1500 |
pointsWepMax = pointsWepMax * strength |
|
1501 |
pointsHlpMax = pointsHlpMax * strength |
|
1502 |
pointsWepSDTurn = pointsWepSDTurn * strength |
|
1503 |
pointsHlpSDTurn = pointsHlpSDTurn * strength |
|
1504 |
pointsWepSDMax = pointsWepSDMax * strength |
|
1505 |
pointsHlpSDMax = pointsHlpSDMax * strength |
|
1506 |
-- Either king or normal mode, change variants |
|
1507 |
else |
|
1508 |
for name, data in pairs(variants) do |
|
1509 |
variants[name]["weaponLimit"] = variants[name]["weaponLimit"] * strength |
|
1510 |
variants[name]["helperLimit"] = variants[name]["helperLimit"] * strength |
|
1511 |
end |
|
1512 |
end |
|
1513 |
end |
|
1514 |
||
1515 |
if params['luck'] ~= nil and tonumber(params['luck']) > 0 then |
|
1516 |
luck = tonumber(params['luck']) |
|
1517 |
||
1518 |
healthCrateChance = div(healthCrateChance * luck, 100) |
|
1519 |
utilCrateChance = div(utilCrateChance * luck, 100) |
|
1520 |
weaponCrateChance = div(weaponCrateChance * luck, 100) |
|
1521 |
||
1522 |
healthCrateChanceSD = div(healthCrateChanceSD * luck, 100) |
|
1523 |
utilCrateChanceSD = div(utilCrateChanceSD * luck, 100) |
|
1524 |
weaponCrateChanceSD = div(weaponCrateChanceSD * luck, 100) |
|
1525 |
||
1526 |
emptyCrateChance = div(emptyCrateChance * 100, luck) |
|
1527 |
bonusCrateChance = div(bonusCrateChance * luck, 100) |
|
1528 |
end |
|
1529 |
end |
|
1530 |
||
1531 |
function onGameStart() |
|
1532 |
-- If we are not on points mode, we start randomizing everything |
|
1533 |
if mode ~= 'points' then |
|
1534 |
if GetGameFlag(gfBorder) or MapHasBorder() then |
|
12422
f6fc84c55bfa
Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents:
12421
diff
changeset
|
1535 |
variants["Air General"] = nil |
12417 | 1536 |
variants['Athlete'] = nil |
1537 |
end |
|
1538 |
||
1539 |
if mode == 'king' then |
|
1540 |
variants['King']['chance'] = 0 |
|
1541 |
end |
|
1542 |
||
1543 |
for i=1,8 do |
|
1544 |
addRandomVariantToTeam("all") |
|
1545 |
end |
|
1546 |
||
1547 |
-- Translate randomized team to a flat group |
|
1548 |
group['all'] = {} |
|
1549 |
for key, val in pairs(counter["all"]) do |
|
1550 |
for i=1, counter["all"][key] do |
|
1551 |
table.insert(group['all'], key) |
|
1552 |
end |
|
1553 |
end |
|
1554 |
||
1555 |
-- Shuffle group for more randomness |
|
1556 |
shuffle(group['all']) |
|
1557 |
-- We are in points mode, setup other weapons |
|
1558 |
elseif mode == 'points' then |
|
1559 |
-- Translate [ammo] -> points to [points] -> {ammo1, ammo2} |
|
1560 |
for ammoType, ammoPoints in pairs(pointsWeaponVal) do |
|
1561 |
if pointsToWep[ammoPoints] == nil then |
|
1562 |
pointsToWep[ammoPoints] = {} |
|
1563 |
end |
|
1564 |
||
1565 |
table.insert(pointsToWep[ammoPoints], ammoType) |
|
1566 |
end |
|
1567 |
||
1568 |
for ammoType, ammoPoints in pairs(pointsHelperVal) do |
|
1569 |
if pointsToHlp[ammoPoints] == nil then |
|
1570 |
pointsToHlp[ammoPoints] = {} |
|
1571 |
end |
|
1572 |
||
1573 |
table.insert(pointsToHlp[ammoPoints], ammoType) |
|
1574 |
end |
|
1575 |
||
1576 |
for points, ammoList in pairs(pointsToWep) do |
|
1577 |
table.insert(wepPoints, points) |
|
1578 |
end |
|
1579 |
||
1580 |
for points, ammoList in pairs(pointsToHlp) do |
|
1581 |
table.insert(hlpPoints, points) |
|
1582 |
end |
|
1583 |
||
1584 |
table.sort(wepPoints) |
|
1585 |
table.sort(hlpPoints) |
|
1586 |
end |
|
1587 |
||
1588 |
-- Initial Hog Setup |
|
1589 |
runOnGears(countTeamHogs) |
|
1590 |
||
1591 |
for key, val in pairs(teamNames) do |
|
1592 |
if mode == 'points' then |
|
1593 |
pointsPerTeam[key] = {} |
|
1594 |
pointsPerTeam[key]['weapons'] = pointsWepBase |
|
1595 |
pointsPerTeam[key]['helpers'] = pointsHlpBase |
|
1596 |
else |
|
1597 |
setTeamHogs(key) |
|
1598 |
end |
|
1599 |
end |
|
1600 |
||
1601 |
runOnGears(setHogInfo) |
|
1602 |
||
1603 |
if mode ~= 'points' then |
|
1604 |
runOnGears(setHogVariant) |
|
1605 |
runOnGears(setupHogTurn) |
|
1606 |
if mutate ~= false and mutate ~= 'false' then |
|
1607 |
runOnGears(MutateHog) |
|
1608 |
end |
|
1609 |
end |
|
1610 |
||
1611 |
if mode == 'points' then |
|
1612 |
for key, val in pairs(teamNames) do |
|
1613 |
clearHogAmmo(teamHogs[key][1]) |
|
1614 |
addTurnAmmo(teamHogs[key][1]) |
|
1615 |
end |
|
1616 |
end |
|
1617 |
||
1618 |
if mode == 'king' then |
|
12986
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1619 |
calcKingHP(false) |
12417 | 1620 |
end |
1621 |
||
1622 |
local txt = '' |
|
1623 |
local icon = 0 |
|
1624 |
||
1625 |
if mode ~= 'points' then |
|
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1626 |
txt = txt .. loc("Variants: Hogs will be randomized from 12 different variants") .. "|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1627 |
txt = txt .. loc("Weapons: Hogs will get 1 out of 3 weapons randomly each turn") .. "|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1628 |
txt = txt .. loc("Helpers: Hogs will get 1 out of 2 helpers randomly each turn") .. "|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1629 |
txt = txt .. loc("Crates: Crates drop randomly with chance of being empty") .. "|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1630 |
txt = txt .. loc("Last Resort: Having less than 25% base health gives kamikaze") .. "|" |
12989
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1631 |
txt = txt .. loc("Modifiers: Unlimited attacks, per-hog ammo") .. "|" |
12417 | 1632 |
else |
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1633 |
txt = txt .. loc("Crates: Crates drop randomly and may be empty") .. "|" |
12989
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1634 |
txt = txt .. loc("Modifiers: Unlimited attacks, shared clan ammo") .. "|" |
12417 | 1635 |
end |
1636 |
||
1637 |
if luck ~= 100 then |
|
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1638 |
txt = txt .. string.format(loc("Luck: %d%% (modifier for crates)"), luck) .. "|" |
12417 | 1639 |
end |
1640 |
||
1641 |
if strength > 1 then |
|
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1642 |
txt = txt .. string.format(loc("Strength: %d (multiplier for ammo)"), strength) .. "|" |
12417 | 1643 |
end |
1644 |
||
1645 |
if mode == 'highland' then |
|
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1646 |
txt = txt .. " |" |
12989
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1647 |
txt = txt .. loc("--- Highland Mode ---").."|" |
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1648 |
txt = txt .. string.format(loc("Enemy kills: Collect victim's weapons and +%d%% of its base health"), highEnemyKillHPBonus).."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1649 |
txt = txt .. string.format(loc("Friendly kills: Clear killer's pool and -%d%% of its base health"), highFriendlyKillHPBonus).."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1650 |
txt = txt .. string.format(loc("Turns: Hogs get %d random weapon(s) from their pool"), highPickupCount).."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1651 |
txt = txt .. loc("Hint: Kills won't transfer a hog's pool to the killer's pool").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1652 |
txt = txt .. loc("Specials: Kings and air generals drop helpers, not weapons").."|" |
12417 | 1653 |
icon = 1 -- Target |
1654 |
elseif mode == 'king' then |
|
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1655 |
txt = txt .. " |" |
12989
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1656 |
txt = txt .. loc("--- King Mode ---").."|" |
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1657 |
txt = txt .. loc("Protect the King: When the king dies, the team is vaporized").."|" |
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1658 |
txt = txt .. string.format(loc("Turns: King's health is set to %d%% of the team health"), kingLinkPerc).."|" |
12985
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1659 |
icon = 0 -- Golden Crown |
12417 | 1660 |
elseif mode == 'points' then |
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1661 |
txt = txt .. " |" |
12989
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1662 |
txt = txt .. loc("--- Points Mode ---").."|" |
12422
f6fc84c55bfa
Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents:
12421
diff
changeset
|
1663 |
txt = txt .. loc("Variants: Kings and air generals are disabled").."|" |
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1664 |
txt = txt .. string.format(loc("Weapons: Each team starts with %d weapon points"), pointsWepBase).."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1665 |
txt = txt .. string.format(loc("Helpers: Each team starts with %d helper points"), pointsHlpBase).."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1666 |
txt = txt .. string.format(loc("Turns: Refill %d weapon and %d helper points|and randomize weapons and helpers based on team points"), pointsWepTurn, pointsHlpTurn).."|" |
12417 | 1667 |
icon = 4 -- Golden Star |
1668 |
else |
|
1669 |
icon = -amGrenade -- Grenade |
|
1670 |
end |
|
1671 |
||
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1672 |
txt = txt .. " |" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1673 |
txt = txt .. loc("--- Sudden Death ---").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1674 |
txt = txt .. loc("Weapons: Nearly every hog variant gets 1 kamikaze").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1675 |
txt = txt .. loc("Crates: Crates drop more often with a higher chance of bonus ammo").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1676 |
txt = txt .. loc("Water: Rises by 37 per turn").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1677 |
txt = txt .. loc("Health: Hogs lose up to 7% base health per turn").."|" |
12417 | 1678 |
|
12989
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1679 |
-- Add hint if mode was not set in script parameter, or set incorrectly |
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12988
diff
changeset
|
1680 |
if not modeExplicit then |
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1681 |
txt = txt .. " |" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1682 |
txt = txt .. loc("--- Hint ---").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1683 |
txt = txt .. loc("Modes: Activate “highland”, “king” or “points” mode by putting mode=<name>|into the script parameter").."|" |
12417 | 1684 |
end |
1685 |
||
1686 |
if mode == 'highland' then |
|
12420
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1687 |
txt = txt .. string.format(loc("Highland: Hogs get %d random weapons from their pool"), highPickupSDCount) .. "|" |
12417 | 1688 |
end |
1689 |
||
12427
959d1f4dff25
Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents:
12426
diff
changeset
|
1690 |
SetAmmoDescriptionAppendix(amRCPlane, loc("The RC plane only carries 2 weak bombs.")) |
12426
a0c655e38cc8
Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents:
12425
diff
changeset
|
1691 |
SetAmmoDescriptionAppendix(amAirAttack, loc("The air bombs are weaker than usual.")) |
a0c655e38cc8
Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents:
12425
diff
changeset
|
1692 |
SetAmmoDescriptionAppendix(amCake, loc("The explosion is weaker than usual.")) |
a0c655e38cc8
Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents:
12425
diff
changeset
|
1693 |
SetAmmoDescriptionAppendix(amDEagle, loc("Base damage has been modified to 12 per shot.")) |
a0c655e38cc8
Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents:
12425
diff
changeset
|
1694 |
|
12423
665317ace94e
Show Battalion mission panel for the default time
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
1695 |
ShowMission(loc("Battalion"), loc("Less tools, more fun"), txt, icon, 0) |
12417 | 1696 |
end |
1697 |
||
1698 |
function onGameInit() |
|
1699 |
--[[ CONFIGURATEABLE FOR PLAYERS ]]-- |
|
1700 |
--[[ ONCE IT HAS BEEN ADDED TO HW ]]-- |
|
1701 |
||
1702 |
--[[ REQUIRED CONFIGURATIONS ]]-- |
|
1703 |
||
1704 |
WaterRise = 37 -- Water rises by 37 |
|
1705 |
HealthDecrease = 0 -- No health decrease by game, script with 7% |
|
1706 |
CaseFreq = 0 -- don't spawn crates |
|
1707 |
||
1708 |
-- Removed gfResetWeps to see weapons next turn |
|
1709 |
EnableGameFlags(gfInfAttack) |
|
1710 |
DisableGameFlags(gfResetWeps) |
|
1711 |
||
1712 |
if mode ~= 'points' then |
|
1713 |
EnableGameFlags(gfPerHogAmmo) |
|
1714 |
else |
|
1715 |
DisableGameFlags(gfPerHogAmmo) |
|
1716 |
end |
|
1717 |
end |