author | Wuzzy <Wuzzy@disroot.org> |
Wed, 28 Jun 2023 12:46:04 +0200 | |
changeset 15995 | 634d017650dc |
parent 15450 | c0ad952894d9 |
child 16000 | a803428704fd |
permissions | -rwxr-xr-x |
12412 | 1 |
--[[ |
2 |
######################################################################## |
|
3 |
Name: Battalion |
|
4 |
Made by: Anachron |
|
5 |
######################################################################## |
|
6 |
]]-- |
|
7 |
||
8 |
--[[ |
|
9 |
||
10 |
Readme: |
|
12419
6944a9161cdb
Update readme link in Battalion script
Wuzzy <almikes@aol.com>
parents:
12418
diff
changeset
|
11 |
https://hedgewars.org/wiki/Battalion |
12412 | 12 |
|
13 |
######################################################################## |
|
14 |
]]-- |
|
15 |
||
16 |
--[[ |
|
17 |
######################################################################## |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
18 |
TODO / ideas list |
12412 | 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 = "" |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
45 |
local newLine = "" |
12412 | 46 |
local gmAny = 0xFFFFFFFF |
47 |
||
48 |
--[[ |
|
49 |
############################################################################## |
|
50 |
### VARIANT SETUP ### |
|
51 |
############################################################################## |
|
52 |
]]-- |
|
53 |
||
54 |
varName = "Pyromancer" |
|
55 |
variants[varName] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
56 |
variants[varName]["name"] = loc("Pyromancer") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
69 |
variants[varName]["name"] = loc("Builder") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
82 |
variants[varName]["name"] = loc("Rifleman") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
95 |
variants[varName]["name"] = loc("Warrior") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
108 |
variants[varName]["name"] = loc("Chef") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
121 |
variants[varName]["name"] = loc("Medic") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
134 |
variants[varName]["name"] = loc("Ninja") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
147 |
variants[varName]["name"] = loc("Athlete") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
160 |
variants[varName]["name"] = loc("Scientist") |
12412 | 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 |
||
12417
f6fc84c55bfa
Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents:
12416
diff
changeset
|
171 |
varName = "Air General" |
12412 | 172 |
variants[varName] = {} |
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
173 |
variants[varName]["name"] = loc("Air General") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
186 |
variants[varName]["name"] = loc("Hunter") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
199 |
variants[varName]["name"] = loc("King") |
12412 | 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] = {} |
|
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
212 |
variants[varName]["name"] = loc("Knight") |
12412 | 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 |
|
12984
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
247 |
local modeExplicit = false -- Whether the mode was set in script param |
12412 | 248 |
local luck = 100 -- Multiplier for bonuses like crates |
249 |
local strength = 1 -- Multiplier for more weapons |
|
12987
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:
12986
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:
12986
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:
12986
diff
changeset
|
252 |
local useVariantNames = false -- Whether to overwrite the hog names to those of their variants |
12412 | 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 |
||
15149
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
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:
15147
diff
changeset
|
270 |
|
12412 | 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 |
||
12985
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
340 |
local firstTurnOver = false |
12412 | 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) |
|
13029
905449169319
Battalion: Use AmmoTypeMax for ammo type iterations
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
416 |
for val=0, AmmoTypeMax do |
12412 | 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 |
||
13030
da691787fcd2
Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents:
13029
diff
changeset
|
504 |
function updatePointsLabel(team) |
da691787fcd2
Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents:
13029
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:
13029
diff
changeset
|
506 |
end |
da691787fcd2
Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents:
13029
diff
changeset
|
507 |
|
12412 | 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 |
||
12987
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:
12986
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:
12986
diff
changeset
|
639 |
function SetHogVariantHat(hog) |
12412 | 640 |
local var = getHogInfo(hog, 'variant') |
12987
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:
12986
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:
12986
diff
changeset
|
642 |
end |
12412 | 643 |
|
12987
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
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:
12986
diff
changeset
|
658 |
local var = getHogInfo(hog, 'variant') |
12420
bdf81e6c00eb
Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents:
12419
diff
changeset
|
659 |
SetHogName(hog, variants[var]["name"]) |
12412 | 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') |
|
15149
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
722 |
teamKingsAlive[team] = true |
12412 | 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"]) |
|
15449
c95efbab66e6
Battalion Highland: Fix incorrect health bonus (bug 788)
Wuzzy <Wuzzy2@mail.ru>
parents:
15149
diff
changeset
|
755 |
hogInfo[hog]['maxHp'] = variants[hogVar]["hp"] |
12412 | 756 |
end |
757 |
||
758 |
function getHogInfo(hog, info) |
|
759 |
if hog == nil then |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
760 |
WriteLnToChat("ERROR [getHogInfo]: hog is nil!") |
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
761 |
WriteLnToConsole("ERROR [getHogInfo]: hog is nil!") |
12412 | 762 |
return |
763 |
end |
|
764 |
||
765 |
if hogInfo[hog] == nil then |
|
766 |
return nil |
|
767 |
end |
|
768 |
||
769 |
return hogInfo[hog][info] |
|
770 |
end |
|
771 |
||
772 |
function setHogInfo(hog) |
|
773 |
if hog == nil then |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
774 |
WriteLnToChat("ERROR [setHogInfo]: hog is nil!") |
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
775 |
WriteLnToConsole("ERROR [setHogInfo]: hog is nil!") |
12412 | 776 |
return |
777 |
end |
|
778 |
||
779 |
hogInfo[hog] = {} |
|
780 |
hogInfo[hog]['maxHp'] = GetHealth(hog) |
|
781 |
hogInfo[hog]['name'] = GetHogName(hog) |
|
782 |
hogInfo[hog]['hat'] = GetHogHat(hog) |
|
783 |
hogInfo[hog]['team'] = GetHogTeamName(hog) |
|
784 |
hogInfo[hog]['clan'] = GetHogClan(hog) |
|
785 |
hogInfo[hog]['clanColor'] = GetClanColor(hogInfo[hog]['clan']) |
|
786 |
end |
|
787 |
||
788 |
--[[ |
|
789 |
############################################################################## |
|
790 |
### CRATE SPAWN AND PICKUP FUNCTIONS ### |
|
791 |
############################################################################## |
|
792 |
]]-- |
|
793 |
||
794 |
--[[ |
|
795 |
: Heals either 10 (95% chance) or 15 (5% chance) hitpoints |
|
796 |
: Plus 10% of the hogs base hitpoints. |
|
797 |
: |
|
798 |
: Has a 7% chance to be empty. |
|
799 |
]]-- |
|
800 |
function onHealthCratePickup() |
|
801 |
local factor = 2 |
|
802 |
local msgColor = getHogInfo(CurHog, 'clanColor') |
|
803 |
local healHp = 0 |
|
804 |
PlaySound(sndShotgunReload) |
|
805 |
||
806 |
if GetRandom(100) < emptyCrateChance then |
|
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
807 |
AddCaption(loc("It's empty!"), msgColor, capgrpMessage) |
12412 | 808 |
return |
809 |
elseif GetRandom(100) < bonusCrateChance then |
|
810 |
factor = 3 |
|
811 |
end |
|
812 |
||
813 |
local var = getHogInfo(CurHog, 'variant') |
|
814 |
local hogHealth = GetHealth(CurHog) |
|
815 |
healHp = 5 * factor |
|
816 |
||
817 |
-- Add extra 10% of hogs base hp to heal |
|
818 |
healHp = healHp + div(getHogInfo(CurHog, 'maxHp'), 10) |
|
819 |
||
12979
b6d67e975b51
Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents:
12978
diff
changeset
|
820 |
HealHog(CurHog, healHp) |
12412 | 821 |
|
822 |
SetEffect(CurHog, hePoisoned, 0) |
|
823 |
end |
|
824 |
||
825 |
--[[ |
|
826 |
: Adds either 1 (95% chance) or 2 (5% chance) random weapon(s) based on the hog variant. |
|
827 |
: |
|
828 |
: Has a 7% chance to be empty. |
|
829 |
]]-- |
|
12983
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12982
diff
changeset
|
830 |
function onWeaponCratePickup(crate) |
12412 | 831 |
local factor = 1 * strength |
832 |
local msgColor = GetClanColor(GetHogClan(CurHog)) |
|
833 |
PlaySound(sndShotgunReload) |
|
834 |
||
835 |
if GetRandom(100) < emptyCrateChance then |
|
12628
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
836 |
if IsHogLocal(CurHog) then |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
837 |
AddCaption(loc("It's empty!"), msgColor, capgrpMessage) |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
838 |
end |
12412 | 839 |
return |
840 |
elseif GetRandom(100) < bonusCrateChance then |
|
841 |
factor = 2 * strength |
|
842 |
end |
|
843 |
||
844 |
local randIndex |
|
845 |
local randAmmo |
|
846 |
||
847 |
if mode ~= 'points' then |
|
848 |
local var = getHogInfo(CurHog, 'variant') |
|
849 |
randIndex = GetRandom(table.getn(variants[var]["weapons"])) +1 |
|
850 |
randAmmo = variants[var]["weapons"][randIndex] |
|
851 |
else |
|
852 |
local possibleWeapons = {} |
|
853 |
||
854 |
for key, val in pairs(pointsWeaponVal) do |
|
855 |
if val > 2 and val < 8 then |
|
856 |
table.insert(possibleWeapons, key) |
|
857 |
end |
|
858 |
end |
|
859 |
||
860 |
randIndex = GetRandom(table.getn(possibleWeapons)) +1 |
|
861 |
randAmmo = possibleWeapons[randIndex] |
|
862 |
end |
|
863 |
||
864 |
AddAmmo(CurHog, randAmmo, GetAmmoCount(CurHog, randAmmo) +factor) |
|
12628
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
865 |
if IsHogLocal(CurHog) then |
12979
b6d67e975b51
Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents:
12978
diff
changeset
|
866 |
AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randAmmo), factor), msgColor, capgrpMessage) |
12983
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12982
diff
changeset
|
867 |
local effect = AddVisualGear(GetX(crate), GetY(crate) +cratePickupGap, vgtAmmo, 0, true) |
12628
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
868 |
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:
12422
diff
changeset
|
869 |
end |
12412 | 870 |
end |
871 |
--[[ |
|
872 |
: Adds either 1 (95% chance) or 2 (5% chance) random helper(s) based on the hog variant. |
|
873 |
: |
|
874 |
: Has a 7% chance to be empty. |
|
875 |
]]-- |
|
12983
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12982
diff
changeset
|
876 |
function onUtilityCratePickup(crate) |
12412 | 877 |
local factor = 1 * strength |
878 |
local msgColor = GetClanColor(GetHogClan(CurHog)) |
|
879 |
PlaySound(sndShotgunReload) |
|
880 |
||
881 |
if GetRandom(100) < emptyCrateChance then |
|
12628
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
882 |
if IsHogLocal(CurHog) then |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
883 |
AddCaption(loc("It's empty!"), msgColor, capgrpMessage) |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
884 |
end |
12412 | 885 |
return |
886 |
elseif GetRandom(100) < bonusCrateChance then |
|
887 |
factor = 2 * strength |
|
888 |
end |
|
889 |
||
890 |
local randIndex |
|
891 |
local randUtility |
|
892 |
||
893 |
if mode ~= 'points' then |
|
894 |
randIndex = GetRandom(table.getn(utilities)) +1 |
|
895 |
randUtility = utilities[randIndex] |
|
896 |
else |
|
897 |
local possibleHelpers = {} |
|
898 |
||
899 |
for key, val in pairs(pointsHelperVal) do |
|
900 |
table.insert(possibleHelpers, key) |
|
901 |
end |
|
902 |
||
903 |
randIndex = GetRandom(table.getn(possibleHelpers)) +1 |
|
904 |
randUtility = possibleHelpers[randIndex] |
|
905 |
end |
|
906 |
||
907 |
AddAmmo(CurHog, randUtility, GetAmmoCount(CurHog, randUtility) +factor) |
|
12628
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
908 |
if IsHogLocal(CurHog) then |
12979
b6d67e975b51
Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents:
12978
diff
changeset
|
909 |
AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randUtility), factor), msgColor, capgrpMessage) |
12983
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12982
diff
changeset
|
910 |
local effect = AddVisualGear(GetX(crate), GetY(crate) +cratePickupGap, vgtAmmo, 0, true) |
12628
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
911 |
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:
12422
diff
changeset
|
912 |
end |
12412 | 913 |
end |
914 |
||
915 |
function onPickupCrate(crate) |
|
916 |
local pos = GetGearPos(crate) |
|
917 |
||
918 |
-- Check if the crate is fake |
|
919 |
if pos % posCaseDummy >= 1 then |
|
920 |
if pos % posCaseDummy == posCaseAmmo then |
|
12983
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12982
diff
changeset
|
921 |
onWeaponCratePickup(crate) |
12412 | 922 |
elseif pos % posCaseDummy == posCaseHealth then |
923 |
onHealthCratePickup() |
|
924 |
elseif pos % posCaseDummy == posCaseUtility then |
|
12983
7c3454083489
Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents:
12982
diff
changeset
|
925 |
onUtilityCratePickup(crate) |
12412 | 926 |
end |
927 |
end |
|
928 |
end |
|
929 |
||
14790
dd4daa216398
Battalion: Properly spawn crate between turns
Wuzzy <Wuzzy2@mail.ru>
parents:
14788
diff
changeset
|
930 |
function onCaseDrop() |
12412 | 931 |
if GetRandom(100) < weaponCrateChance then |
932 |
SpawnFakeAmmoCrate(0, 0, false, false) |
|
14790
dd4daa216398
Battalion: Properly spawn crate between turns
Wuzzy <Wuzzy2@mail.ru>
parents:
14788
diff
changeset
|
933 |
PlaySound(sndReinforce, CurrentHedgehog) |
12412 | 934 |
elseif GetRandom(100) < utilCrateChance then |
935 |
SpawnFakeUtilityCrate(0, 0, false, false) |
|
14790
dd4daa216398
Battalion: Properly spawn crate between turns
Wuzzy <Wuzzy2@mail.ru>
parents:
14788
diff
changeset
|
936 |
PlaySound(sndReinforce, CurrentHedgehog) |
12412 | 937 |
elseif GetRandom(100) < healthCrateChance then |
938 |
SpawnFakeHealthCrate(0, 0, false, false) |
|
14790
dd4daa216398
Battalion: Properly spawn crate between turns
Wuzzy <Wuzzy2@mail.ru>
parents:
14788
diff
changeset
|
939 |
PlaySound(sndReinforce, CurrentHedgehog) |
12412 | 940 |
end |
941 |
end |
|
942 |
||
943 |
--[[ |
|
944 |
############################################################################## |
|
945 |
### SUDDEN DEATH FUNCTIONS ### |
|
946 |
############################################################################## |
|
947 |
]]-- |
|
948 |
||
949 |
function onSuddenDeathDamage(hog) |
|
14788
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
950 |
if GetEffect(hog, heInvulnerable) ~= 0 then |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
951 |
return |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
952 |
end |
12412 | 953 |
local hp = GetHealth(hog) |
954 |
local maxHp = getHogInfo(hog, 'maxHp') |
|
955 |
local newHp = 0 |
|
956 |
local hpDec = 0 |
|
957 |
local hpPer = div(hp * 100, maxHp) |
|
958 |
||
959 |
if hp > 1 then |
|
960 |
local msgColor = GetClanColor(GetHogClan(hog)) |
|
961 |
if hpPer <= 25 then |
|
962 |
newHp = hp -2 |
|
963 |
elseif hpPer <= 50 then |
|
964 |
newHp = hp -3 |
|
965 |
elseif hpPer <= 75 then |
|
966 |
newHp = hp -4 |
|
967 |
elseif hpPer <= 100 then |
|
968 |
newHp = hp -5 |
|
969 |
elseif hpPer <= 125 then |
|
970 |
newHp = hp -6 |
|
971 |
elseif hpPer <= 150 then |
|
972 |
newHp = hp -7 |
|
973 |
else |
|
974 |
newHp = div(hp * 93, 100) |
|
975 |
end |
|
976 |
||
977 |
if newHp <= 0 then |
|
978 |
newHp = 1 |
|
979 |
end |
|
980 |
||
981 |
hpDec = hp - newHp |
|
982 |
||
983 |
SetHealth(hog, newHp) |
|
14788
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
984 |
if hpDec > 0 then |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
985 |
local r = math.random(1, 2) |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
986 |
if r == 1 then |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
987 |
PlaySound(sndPoisonCough, hog, true) |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
988 |
else |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
989 |
PlaySound(sndPoisonMoan, hog, true) |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
990 |
end |
458a8c4e65ca
Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents:
13643
diff
changeset
|
991 |
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:
13643
diff
changeset
|
992 |
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:
13643
diff
changeset
|
993 |
end |
12412 | 994 |
end |
995 |
end |
|
996 |
||
997 |
function onSuddenDeathTurn() |
|
998 |
runOnGears(onSuddenDeathDamage) |
|
999 |
end |
|
1000 |
||
1001 |
function onSuddenDeath() |
|
1002 |
suddenDeath = true |
|
1003 |
||
1004 |
healthCrateChance = healthCrateChanceSD |
|
1005 |
utilCrateChance = utilCrateChanceSD |
|
1006 |
weaponCrateChance = weaponCrateChanceSD |
|
1007 |
||
1008 |
if mode == 'highland' then |
|
1009 |
highEnemyKillHPBonus = highEnemyKillHPBonus +5 |
|
1010 |
highFriendlyKillHPBonus = highFriendlyKillHPBonus +10 |
|
1011 |
end |
|
1012 |
||
1013 |
if mode ~= 'points' then |
|
1014 |
for key, val in pairs(variants) do |
|
1015 |
if not variants[key]["special"] then |
|
1016 |
variants[key]["weaponLimit"] = variants[key]["weaponLimit"] +1 |
|
1017 |
end |
|
1018 |
end |
|
1019 |
end |
|
1020 |
||
1021 |
if mode ~= 'points' then |
|
1022 |
for hog, val in pairs(hogInfo) do |
|
1023 |
hogInfo[hog]['weapons'] = {} |
|
1024 |
hogInfo[hog]['helpers'] = {} |
|
1025 |
end |
|
1026 |
||
1027 |
runOnGears(setupHogTurn) |
|
1028 |
end |
|
1029 |
end |
|
1030 |
||
1031 |
--[[ |
|
1032 |
############################################################################## |
|
1033 |
### GEAR TRACKING FUNCTIONS ### |
|
1034 |
############################################################################## |
|
1035 |
]]-- |
|
1036 |
||
1037 |
function onGearAdd(gear) |
|
1038 |
local gearType = GetGearType(gear) |
|
1039 |
||
1040 |
if gearType == gtHedgehog then |
|
1041 |
trackGear(gear) |
|
1042 |
elseif gearType == gtRCPlane then |
|
12422
959d1f4dff25
Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents:
12421
diff
changeset
|
1043 |
SetHealth(gear, 2) |
12412 | 1044 |
elseif gearType == gtAirBomb then |
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1045 |
-- Set Boom |
12422
959d1f4dff25
Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents:
12421
diff
changeset
|
1046 |
SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 20) |
12412 | 1047 |
elseif gearType == gtCake then |
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1048 |
-- Set Boom |
12412 | 1049 |
SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 50) |
1050 |
elseif gearType == gtDEagleShot then |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1051 |
-- Set Boom |
12412 | 1052 |
SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 12) |
1053 |
end |
|
1054 |
end |
|
1055 |
||
1056 |
function onHighlandKill(gear) |
|
1057 |
local deathVar = getHogInfo(gear, 'variant') |
|
1058 |
local killVar = getHogInfo(CurHog, 'variant') |
|
1059 |
local bonAmmo = {} |
|
1060 |
local deathMaxHP = getHogInfo(gear, 'maxHp') |
|
1061 |
local curHP = GetHealth(CurHog) |
|
1062 |
local newHP = 0 |
|
1063 |
local hpDiff = 0 |
|
1064 |
local addAmmo = false |
|
1065 |
||
1066 |
-- Killer hog is dead! Don't do anything |
|
1067 |
if curHP == nil or curHP <= 0 then |
|
1068 |
return |
|
1069 |
end |
|
1070 |
||
1071 |
-- Killer and victim is equal! Don't do anything |
|
1072 |
if CurHog == gear then |
|
1073 |
return |
|
1074 |
end |
|
1075 |
||
1076 |
-- Hog drowned because of water, not enemy |
|
1077 |
if LastWaterLine ~= WaterLine then |
|
1078 |
return |
|
1079 |
end |
|
1080 |
||
1081 |
-- Enemy kill! Add weapons to pool and to hog |
|
1082 |
if getHogInfo(gear, 'clan') ~= getHogInfo(CurHog, 'clan') then |
|
1083 |
||
1084 |
-- Initialize weapons if required |
|
1085 |
if highWeapons[CurHog] == nil then |
|
1086 |
highWeapons[CurHog] = {} |
|
1087 |
end |
|
1088 |
||
1089 |
if highHelpers[CurHog] == nil then |
|
1090 |
highHelpers[CurHog] = {} |
|
1091 |
end |
|
1092 |
||
1093 |
-- If not a special hog, use the victims weapons |
|
1094 |
if variants[deathVar]['special'] == false then |
|
1095 |
bonAmmo = variants[deathVar]['weapons'] |
|
1096 |
||
1097 |
if suddenDeath == true then |
|
1098 |
ammoCount = highPickupSDCount |
|
1099 |
else |
|
1100 |
ammoCount = highPickupCount |
|
1101 |
end |
|
1102 |
||
1103 |
-- Check if hog already got bonus weapons |
|
1104 |
if table.getn(highWeapons[CurHog]) == 0 and highHasBonusWeps == false then |
|
1105 |
highHasBonusWeps = true |
|
1106 |
addAmmo = true |
|
1107 |
end |
|
1108 |
||
1109 |
-- Pass turn bonus weapons to hog pool |
|
1110 |
for key, val in pairs(bonAmmo) do |
|
1111 |
local idx = table.getn(highWeapons[CurHog]) +1 |
|
1112 |
highWeapons[CurHog][idx] = val |
|
1113 |
end |
|
1114 |
-- It's a special hog, use special pool |
|
1115 |
else |
|
1116 |
bonAmmo = highSpecialBonus |
|
1117 |
||
1118 |
ammoCount = 1 |
|
1119 |
||
1120 |
-- Check if hog already got bonus helpers |
|
1121 |
if table.getn(highWeapons[CurHog]) == 0 and highHasBonusHelp == false then |
|
1122 |
highHasBonusHelp = true |
|
1123 |
addAmmo = true |
|
1124 |
end |
|
1125 |
||
1126 |
-- Pass turn bonus weapons to hog pool |
|
1127 |
for key, val in pairs(highSpecialPool) do |
|
1128 |
local idx = table.getn(highHelpers[CurHog]) +1 |
|
1129 |
highHelpers[CurHog][idx] = val |
|
1130 |
end |
|
1131 |
end |
|
1132 |
||
1133 |
if addAmmo then |
|
1134 |
local i = 1 |
|
1135 |
while i <= ammoCount and #bonAmmo > 0 do |
|
1136 |
local randAmmo = GetRandom(#bonAmmo) +1 |
|
1137 |
local randAmmoType = bonAmmo[randAmmo] |
|
1138 |
||
1139 |
-- Remove the randomized weapon so it cannot be picked up twice |
|
1140 |
table.remove(bonAmmo, randAmmo) |
|
1141 |
||
1142 |
AddAmmo(CurHog, randAmmoType, GetAmmoCount(CurHog, randAmmoType) +1) |
|
1143 |
||
12628
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
1144 |
if IsHogLocal(CurHog) then |
96e30c42c318
Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents:
12422
diff
changeset
|
1145 |
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:
12422
diff
changeset
|
1146 |
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:
12422
diff
changeset
|
1147 |
end |
12412 | 1148 |
|
1149 |
i = i +1 |
|
1150 |
end |
|
1151 |
end |
|
1152 |
||
1153 |
hpDiff = div(deathMaxHP * highEnemyKillHPBonus, 100) |
|
15449
c95efbab66e6
Battalion Highland: Fix incorrect health bonus (bug 788)
Wuzzy <Wuzzy2@mail.ru>
parents:
15149
diff
changeset
|
1154 |
HealHog(CurHog, hpDiff) |
12981
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
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:
12980
diff
changeset
|
1156 |
-- and reduce health |
12412 | 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) |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1170 |
-- Set Tint |
12412 | 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 |
||
13643 | 1179 |
AddCaption(string.format(loc("The king of %s has died!"), team), capcolDefault, capgrpGameState) |
15147
ab21cbb0e3a0
Battalion (King): Kill minions with default boom
Wuzzy <Wuzzy2@mail.ru>
parents:
15146
diff
changeset
|
1180 |
SetState(KingHog, gstHHDeath) |
12412 | 1181 |
|
12986
1c38d4370943
Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
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:
12985
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:
12985
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:
12985
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:
12985
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:
12985
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:
12985
diff
changeset
|
1188 |
end |
1c38d4370943
Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1189 |
end |
1c38d4370943
Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1190 |
end |
15149
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1191 |
teamKingsAlive[team] = false |
12986
1c38d4370943
Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1192 |
|
1c38d4370943
Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
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:
12985
diff
changeset
|
1194 |
|
12412 | 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 |
|
13030
da691787fcd2
Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents:
13029
diff
changeset
|
1223 |
updatePointsLabel(team) |
12412 | 1224 |
|
1225 |
local effect = AddVisualGear(GetX(CurHog) - (cratePickupGap / 2), GetY(CurHog), vgtHealthTag, 2, false) |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1226 |
-- Set Tint |
12412 | 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) |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1230 |
-- Set Tint |
12412 | 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 |
||
12981
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1269 |
function calcKingHP(doEffects) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1270 |
if doEffects == nil then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1271 |
doEffects = true |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1272 |
end |
12412 | 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 |
||
12981
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1303 |
local diff = math.abs(newHP - hp) |
12412 | 1304 |
|
12981
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1305 |
-- Change HP and do some nice effects |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1306 |
if newHP ~= hp then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1307 |
if not doEffects then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1308 |
SetHealth(hog, newHP) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1309 |
else |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1310 |
if newHP > hp then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1311 |
HealHog(hog, diff, false) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1312 |
elseif newHP < hp then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1313 |
SetHealth(hog, newHP) |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1314 |
if doEffects then |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
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:
12980
diff
changeset
|
1316 |
-- Set Tint |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
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:
12980
diff
changeset
|
1318 |
end |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1319 |
end |
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1320 |
end |
12412 | 1321 |
end |
1322 |
end |
|
1323 |
end |
|
1324 |
||
1325 |
function setupHogTurn(hog) |
|
1326 |
clearHogAmmo(hog) |
|
1327 |
addTurnAmmo(hog) |
|
1328 |
end |
|
1329 |
||
15149
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1330 |
function checkKingAlive(gear) |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
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:
15147
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:
15147
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:
15147
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:
15147
diff
changeset
|
1335 |
end |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1336 |
end |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1337 |
|
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1338 |
function killLonelyMinion(gear) |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
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:
15147
diff
changeset
|
1340 |
SetHealth(gear, 0) |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1341 |
end |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1342 |
end |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1343 |
|
12982
ba577e0b8c27
Battalion: Use official onEndTurn callback
Wuzzy <Wuzzy2@mail.ru>
parents:
12981
diff
changeset
|
1344 |
function onEndTurn() |
12985
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1345 |
if not firstTurnOver then |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1346 |
firstTurnOver = true |
add647b0036e
Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents:
12984
diff
changeset
|
1347 |
end |
12412 | 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 |
|
15149
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1371 |
|
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
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:
15147
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:
15147
diff
changeset
|
1374 |
runOnGears(checkKingAlive) |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1375 |
runOnGears(killLonelyMinion) |
40537955de63
Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents:
15147
diff
changeset
|
1376 |
end |
12412 | 1377 |
end |
1378 |
||
1379 |
function savePoints(hog) |
|
1380 |
local team = getHogInfo(hog, 'team') |
|
1381 |
local hogWepPoints = 0 |
|
1382 |
local hogHlpPoints = 0 |
|
1383 |
||
13029
905449169319
Battalion: Use AmmoTypeMax for ammo type iterations
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
1384 |
for ammoType=0, AmmoTypeMax do |
12412 | 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 |
||
13030
da691787fcd2
Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents:
13029
diff
changeset
|
1419 |
updatePointsLabel(team) |
da691787fcd2
Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents:
13029
diff
changeset
|
1420 |
|
12412 | 1421 |
local effect = AddVisualGear(GetX(hog) - (cratePickupGap / 2), GetY(hog), vgtHealthTag, pointsPerTeam[team]['weapons'], false) |
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1422 |
-- Set Tint |
12412 | 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) |
|
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1426 |
-- Set Tint |
12412 | 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 |
|
15450
c0ad952894d9
Battalion points: Update displayed LastTeam points each turn
Wuzzy <Wuzzy2@mail.ru>
parents:
15449
diff
changeset
|
1467 |
|
c0ad952894d9
Battalion points: Update displayed LastTeam points each turn
Wuzzy <Wuzzy2@mail.ru>
parents:
15449
diff
changeset
|
1468 |
updatePointsLabel(LastTeam) |
12412 | 1469 |
end |
1470 |
||
1471 |
function onNewTurn() |
|
1472 |
LastHog = CurHog |
|
1473 |
LastTeam = CurTeam |
|
1474 |
CurHog = CurrentHedgehog |
|
1475 |
CurTeam = getHogInfo(CurHog, 'team') |
|
1476 |
||
1477 |
if suddenDeath == true then |
|
1478 |
onSuddenDeathTurn() |
|
1479 |
end |
|
1480 |
||
1481 |
-- Generate new weapons for last hog if it's still alive |
|
1482 |
if LastHog ~= nil and LastHog ~= CurHog then |
|
1483 |
if mode == 'points' then |
|
1484 |
onPointsTurn() |
|
1485 |
else |
|
1486 |
hogInfo[LastHog]['weapons'] = {} |
|
1487 |
hogInfo[LastHog]['helpers'] = {} |
|
1488 |
setupHogTurn(LastHog) |
|
1489 |
end |
|
1490 |
end |
|
1491 |
||
1492 |
-- Recalculate the kings hp if required |
|
1493 |
if mode == 'king' then |
|
1494 |
calcKingHP() |
|
1495 |
end |
|
1496 |
||
1497 |
if mode == 'highland' then |
|
1498 |
highHasBonusWeps = false |
|
1499 |
highHasBonusHelp = false |
|
1500 |
end |
|
1501 |
||
1502 |
-- Set LastWaterLine to the current water line |
|
1503 |
LastWaterLine = WaterLine |
|
1504 |
end |
|
1505 |
||
1506 |
--[[ |
|
1507 |
############################################################################## |
|
1508 |
### GAME START FUNCTIONS ### |
|
1509 |
############################################################################## |
|
1510 |
]]-- |
|
1511 |
||
1512 |
function onAmmoStoreInit() |
|
13029
905449169319
Battalion: Use AmmoTypeMax for ammo type iterations
Wuzzy <Wuzzy2@mail.ru>
parents:
12987
diff
changeset
|
1513 |
for val=0, AmmoTypeMax do |
12412 | 1514 |
SetAmmo(val, 0, 0, 0, 0) |
1515 |
end |
|
1516 |
end |
|
1517 |
||
1518 |
function onParameters() |
|
1519 |
parseParams() |
|
1520 |
||
1521 |
if params['mode'] ~= nil then |
|
1522 |
mode = params['mode'] |
|
12984
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1523 |
if mode == "default" or mode == "king" or mode == "points" or mode == "highland" then |
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1524 |
modeExplicit = true |
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1525 |
end |
12412 | 1526 |
end |
1527 |
||
12987
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:
12986
diff
changeset
|
1528 |
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:
12986
diff
changeset
|
1529 |
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:
12986
diff
changeset
|
1530 |
end |
12412 | 1531 |
if params['mutate'] ~= nil then |
12987
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:
12986
diff
changeset
|
1532 |
useVariantHats = params['mutate'] |
12412 | 1533 |
end |
1534 |
||
15995
634d017650dc
Fix error if passing bad number script param to Battallion/Space Invasion
Wuzzy <Wuzzy@disroot.org>
parents:
15450
diff
changeset
|
1535 |
if params['strength'] ~= nil and tonumber(params['strength']) ~= nil and tonumber(params['strength']) > 0 then |
12412 | 1536 |
strength = tonumber(params['strength']) |
1537 |
-- Highland |
|
1538 |
if mode == 'highland' then |
|
1539 |
highPickupCount = highPickupCount * strength |
|
1540 |
highPickupSDCount = highPickupSDCount * strength |
|
1541 |
highHelperCount = highHelperCount * strength |
|
1542 |
highHelperSDCount = highHelperSDCount * strength |
|
1543 |
-- Points |
|
1544 |
elseif mode == 'points' then |
|
1545 |
pointsWepBase = pointsWepBase * strength |
|
1546 |
pointsHlpBase = pointsHlpBase * strength |
|
1547 |
pointsWepTurn = pointsWepTurn * strength |
|
1548 |
pointsHlpTurn = pointsHlpTurn * strength |
|
1549 |
pointsWepMax = pointsWepMax * strength |
|
1550 |
pointsHlpMax = pointsHlpMax * strength |
|
1551 |
pointsWepSDTurn = pointsWepSDTurn * strength |
|
1552 |
pointsHlpSDTurn = pointsHlpSDTurn * strength |
|
1553 |
pointsWepSDMax = pointsWepSDMax * strength |
|
1554 |
pointsHlpSDMax = pointsHlpSDMax * strength |
|
1555 |
-- Either king or normal mode, change variants |
|
1556 |
else |
|
1557 |
for name, data in pairs(variants) do |
|
1558 |
variants[name]["weaponLimit"] = variants[name]["weaponLimit"] * strength |
|
1559 |
variants[name]["helperLimit"] = variants[name]["helperLimit"] * strength |
|
1560 |
end |
|
1561 |
end |
|
1562 |
end |
|
1563 |
||
15995
634d017650dc
Fix error if passing bad number script param to Battallion/Space Invasion
Wuzzy <Wuzzy@disroot.org>
parents:
15450
diff
changeset
|
1564 |
if params['luck'] ~= nil and tonumber(params['luck']) and tonumber(params['luck']) > 0 then |
12412 | 1565 |
luck = tonumber(params['luck']) |
1566 |
||
1567 |
healthCrateChance = div(healthCrateChance * luck, 100) |
|
1568 |
utilCrateChance = div(utilCrateChance * luck, 100) |
|
1569 |
weaponCrateChance = div(weaponCrateChance * luck, 100) |
|
1570 |
||
1571 |
healthCrateChanceSD = div(healthCrateChanceSD * luck, 100) |
|
1572 |
utilCrateChanceSD = div(utilCrateChanceSD * luck, 100) |
|
1573 |
weaponCrateChanceSD = div(weaponCrateChanceSD * luck, 100) |
|
1574 |
||
1575 |
emptyCrateChance = div(emptyCrateChance * 100, luck) |
|
1576 |
bonusCrateChance = div(bonusCrateChance * luck, 100) |
|
1577 |
end |
|
1578 |
end |
|
1579 |
||
1580 |
function onGameStart() |
|
1581 |
-- If we are not on points mode, we start randomizing everything |
|
1582 |
if mode ~= 'points' then |
|
1583 |
if GetGameFlag(gfBorder) or MapHasBorder() then |
|
12417
f6fc84c55bfa
Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents:
12416
diff
changeset
|
1584 |
variants["Air General"] = nil |
12412 | 1585 |
variants['Athlete'] = nil |
1586 |
end |
|
1587 |
||
1588 |
if mode == 'king' then |
|
1589 |
variants['King']['chance'] = 0 |
|
1590 |
end |
|
1591 |
||
1592 |
for i=1,8 do |
|
1593 |
addRandomVariantToTeam("all") |
|
1594 |
end |
|
1595 |
||
1596 |
-- Translate randomized team to a flat group |
|
1597 |
group['all'] = {} |
|
1598 |
for key, val in pairs(counter["all"]) do |
|
1599 |
for i=1, counter["all"][key] do |
|
1600 |
table.insert(group['all'], key) |
|
1601 |
end |
|
1602 |
end |
|
1603 |
||
1604 |
-- Shuffle group for more randomness |
|
1605 |
shuffle(group['all']) |
|
1606 |
-- We are in points mode, setup other weapons |
|
1607 |
elseif mode == 'points' then |
|
1608 |
-- Translate [ammo] -> points to [points] -> {ammo1, ammo2} |
|
1609 |
for ammoType, ammoPoints in pairs(pointsWeaponVal) do |
|
1610 |
if pointsToWep[ammoPoints] == nil then |
|
1611 |
pointsToWep[ammoPoints] = {} |
|
1612 |
end |
|
1613 |
||
1614 |
table.insert(pointsToWep[ammoPoints], ammoType) |
|
1615 |
end |
|
1616 |
||
1617 |
for ammoType, ammoPoints in pairs(pointsHelperVal) do |
|
1618 |
if pointsToHlp[ammoPoints] == nil then |
|
1619 |
pointsToHlp[ammoPoints] = {} |
|
1620 |
end |
|
1621 |
||
1622 |
table.insert(pointsToHlp[ammoPoints], ammoType) |
|
1623 |
end |
|
1624 |
||
1625 |
for points, ammoList in pairs(pointsToWep) do |
|
1626 |
table.insert(wepPoints, points) |
|
1627 |
end |
|
1628 |
||
1629 |
for points, ammoList in pairs(pointsToHlp) do |
|
1630 |
table.insert(hlpPoints, points) |
|
1631 |
end |
|
1632 |
||
1633 |
table.sort(wepPoints) |
|
1634 |
table.sort(hlpPoints) |
|
1635 |
end |
|
1636 |
||
1637 |
-- Initial Hog Setup |
|
1638 |
runOnGears(countTeamHogs) |
|
1639 |
||
1640 |
for key, val in pairs(teamNames) do |
|
1641 |
if mode == 'points' then |
|
1642 |
pointsPerTeam[key] = {} |
|
1643 |
pointsPerTeam[key]['weapons'] = pointsWepBase |
|
1644 |
pointsPerTeam[key]['helpers'] = pointsHlpBase |
|
13030
da691787fcd2
Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents:
13029
diff
changeset
|
1645 |
updatePointsLabel(key) |
12412 | 1646 |
else |
1647 |
setTeamHogs(key) |
|
1648 |
end |
|
1649 |
end |
|
1650 |
||
1651 |
runOnGears(setHogInfo) |
|
1652 |
||
1653 |
if mode ~= 'points' then |
|
1654 |
runOnGears(setHogVariant) |
|
1655 |
runOnGears(setupHogTurn) |
|
12987
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:
12986
diff
changeset
|
1656 |
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:
12986
diff
changeset
|
1657 |
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:
12986
diff
changeset
|
1658 |
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:
12986
diff
changeset
|
1659 |
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:
12986
diff
changeset
|
1660 |
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:
12986
diff
changeset
|
1661 |
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:
12986
diff
changeset
|
1662 |
-- 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:
12986
diff
changeset
|
1663 |
-- 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:
12986
diff
changeset
|
1664 |
-- 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:
12986
diff
changeset
|
1665 |
runOnGears(SetHogVariantHatKingMode) |
12412 | 1666 |
end |
1667 |
end |
|
1668 |
||
1669 |
if mode == 'points' then |
|
1670 |
for key, val in pairs(teamNames) do |
|
1671 |
clearHogAmmo(teamHogs[key][1]) |
|
1672 |
addTurnAmmo(teamHogs[key][1]) |
|
1673 |
end |
|
1674 |
end |
|
1675 |
||
1676 |
if mode == 'king' then |
|
12981
4c7472d3d483
Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents:
12980
diff
changeset
|
1677 |
calcKingHP(false) |
12412 | 1678 |
end |
1679 |
||
1680 |
local txt = '' |
|
1681 |
local icon = 0 |
|
1682 |
||
1683 |
if mode ~= 'points' then |
|
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1684 |
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:
12412
diff
changeset
|
1685 |
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:
12412
diff
changeset
|
1686 |
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:
12412
diff
changeset
|
1687 |
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:
12412
diff
changeset
|
1688 |
txt = txt .. loc("Last Resort: Having less than 25% base health gives kamikaze") .. "|" |
12984
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1689 |
txt = txt .. loc("Modifiers: Unlimited attacks, per-hog ammo") .. "|" |
12412 | 1690 |
else |
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1691 |
txt = txt .. loc("Crates: Crates drop randomly and may be empty") .. "|" |
12984
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1692 |
txt = txt .. loc("Modifiers: Unlimited attacks, shared clan ammo") .. "|" |
12412 | 1693 |
end |
1694 |
||
1695 |
if luck ~= 100 then |
|
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1696 |
txt = txt .. string.format(loc("Luck: %d%% (modifier for crates)"), luck) .. "|" |
12412 | 1697 |
end |
1698 |
||
1699 |
if strength > 1 then |
|
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1700 |
txt = txt .. string.format(loc("Strength: %d (multiplier for ammo)"), strength) .. "|" |
12412 | 1701 |
end |
1702 |
||
1703 |
if mode == 'highland' then |
|
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1704 |
txt = txt .. " |" |
12984
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1705 |
txt = txt .. loc("--- Highland Mode ---").."|" |
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1706 |
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:
12412
diff
changeset
|
1707 |
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:
12412
diff
changeset
|
1708 |
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:
12412
diff
changeset
|
1709 |
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:
12412
diff
changeset
|
1710 |
txt = txt .. loc("Specials: Kings and air generals drop helpers, not weapons").."|" |
12412 | 1711 |
icon = 1 -- Target |
1712 |
elseif mode == 'king' then |
|
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1713 |
txt = txt .. " |" |
12984
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1714 |
txt = txt .. loc("--- King Mode ---").."|" |
12986
1c38d4370943
Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents:
12985
diff
changeset
|
1715 |
txt = txt .. loc("Protect the King: When the king dies, so does the team").."|" |
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1716 |
txt = txt .. string.format(loc("Turns: King's health is set to %d%% of the team health"), kingLinkPerc).."|" |
12980
263d006c56a9
Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents:
12979
diff
changeset
|
1717 |
icon = 0 -- Golden Crown |
12412 | 1718 |
elseif mode == 'points' then |
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1719 |
txt = txt .. " |" |
12984
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1720 |
txt = txt .. loc("--- Points Mode ---").."|" |
12417
f6fc84c55bfa
Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents:
12416
diff
changeset
|
1721 |
txt = txt .. loc("Variants: Kings and air generals are disabled").."|" |
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1722 |
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:
12412
diff
changeset
|
1723 |
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:
12412
diff
changeset
|
1724 |
txt = txt .. string.format(loc("Turns: Refill %d weapon and %d helper points|and randomize weapons and helpers based on team points"), pointsWepTurn, pointsHlpTurn).."|" |
12412 | 1725 |
icon = 4 -- Golden Star |
1726 |
else |
|
1727 |
icon = -amGrenade -- Grenade |
|
1728 |
end |
|
1729 |
||
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1730 |
txt = txt .. " |" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1731 |
txt = txt .. loc("--- Sudden Death ---").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1732 |
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:
12412
diff
changeset
|
1733 |
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:
12412
diff
changeset
|
1734 |
txt = txt .. loc("Water: Rises by 37 per turn").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1735 |
txt = txt .. loc("Health: Hogs lose up to 7% base health per turn").."|" |
12412 | 1736 |
|
12984
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1737 |
-- Add hint if mode was not set in script parameter, or set incorrectly |
353603f5cec3
Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents:
12983
diff
changeset
|
1738 |
if not modeExplicit then |
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1739 |
txt = txt .. " |" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1740 |
txt = txt .. loc("--- Hint ---").."|" |
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1741 |
txt = txt .. loc("Modes: Activate “highland”, “king” or “points” mode by putting mode=<name>|into the script parameter").."|" |
12412 | 1742 |
end |
1743 |
||
1744 |
if mode == 'highland' then |
|
12415
e11758f70cce
Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents:
12412
diff
changeset
|
1745 |
txt = txt .. string.format(loc("Highland: Hogs get %d random weapons from their pool"), highPickupSDCount) .. "|" |
12412 | 1746 |
end |
1747 |
||
12422
959d1f4dff25
Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents:
12421
diff
changeset
|
1748 |
SetAmmoDescriptionAppendix(amRCPlane, loc("The RC plane only carries 2 weak bombs.")) |
12421
a0c655e38cc8
Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents:
12420
diff
changeset
|
1749 |
SetAmmoDescriptionAppendix(amAirAttack, loc("The air bombs are weaker than usual.")) |
a0c655e38cc8
Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents:
12420
diff
changeset
|
1750 |
SetAmmoDescriptionAppendix(amCake, loc("The explosion is weaker than usual.")) |
a0c655e38cc8
Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents:
12420
diff
changeset
|
1751 |
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:
12420
diff
changeset
|
1752 |
|
12418
665317ace94e
Show Battalion mission panel for the default time
Wuzzy <almikes@aol.com>
parents:
12417
diff
changeset
|
1753 |
ShowMission(loc("Battalion"), loc("Less tools, more fun"), txt, icon, 0) |
12412 | 1754 |
end |
1755 |
||
1756 |
function onGameInit() |
|
1757 |
--[[ CONFIGURATEABLE FOR PLAYERS ]]-- |
|
1758 |
--[[ ONCE IT HAS BEEN ADDED TO HW ]]-- |
|
1759 |
||
1760 |
--[[ REQUIRED CONFIGURATIONS ]]-- |
|
1761 |
||
1762 |
WaterRise = 37 -- Water rises by 37 |
|
1763 |
HealthDecrease = 0 -- No health decrease by game, script with 7% |
|
1764 |
CaseFreq = 0 -- don't spawn crates |
|
1765 |
||
1766 |
-- Removed gfResetWeps to see weapons next turn |
|
1767 |
EnableGameFlags(gfInfAttack) |
|
1768 |
DisableGameFlags(gfResetWeps) |
|
1769 |
||
1770 |
if mode ~= 'points' then |
|
1771 |
EnableGameFlags(gfPerHogAmmo) |
|
1772 |
else |
|
1773 |
DisableGameFlags(gfPerHogAmmo) |
|
1774 |
end |
|
15146 | 1775 |
if mode ~= 'points' and mode ~= 'highland' and mode ~= 'king' then |
1776 |
if GetGameFlag(gfKing) then |
|
1777 |
mode = 'king' |
|
1778 |
modeExplicit = true |
|
1779 |
end |
|
1780 |
end |
|
1781 |
DisableGameFlags(gfKing) |
|
12412 | 1782 |
end |