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