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