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