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