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