author | Wuzzy <almikes@aol.com> |
Sat, 22 Apr 2017 23:30:46 +0200 | |
changeset 12312 | cbc34bb96b1f |
parent 12293 | a5a7d0c6d3f3 |
child 12340 | 8f693d25be2f |
permissions | -rw-r--r-- |
11015 | 1 |
--[[ ___ ___ |
2 |
( ) ( ) |
|
3 |
___ .-. .-. ___ ___ | |_ .---. ___ .-. | |_ |
|
4 |
( ) ' ( )( ( __) / .-, ( ) ( __) |
|
5 |
| .-. .-. | | | | | | (__) ; || .-. .| | |
|
6 |
| | | | | | | | | | | ___ .'` || | | || | ___ |
|
7 |
| | | | | | | | | | |( / .'| || | | || |( ) |
|
8 |
| | | | | | | | | | | | | / | || | | || | | | |
|
9 |
| | | | | | | ; ' | ' | ; | ; || | | || ' | | |
|
10 |
| | | | | ' `-' / ' `-' ' `-' || | | |' `-' ; |
|
11 |
(___)(___)(___'.__.' `.__.`.__.'_(___)(___)`.__. |
|
12 |
||
13 |
||
14 |
---- Recommended settings: |
|
15 |
---- * one hedgehog per team |
|
16 |
---- * 'Small' one-island map |
|
17 |
||
18 |
--]] |
|
19 |
||
20 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
21 |
HedgewarsScriptLoad("/Scripts/Tracker.lua") |
|
22 |
HedgewarsScriptLoad("/Scripts/Params.lua") |
|
23 |
||
24 |
--[[ |
|
25 |
MUTANT SCRIPT |
|
26 |
||
27 |
To Do: -Clean-up this fucking piece of code |
|
28 |
-Debug |
|
29 |
-Find a girlfriend |
|
30 |
-Fix Sheepluva's hat +[p] |
|
31 |
-Cookies |
|
32 |
-----------------------]] |
|
33 |
||
34 |
local hhs = {} |
|
35 |
local numhhs = 0 |
|
36 |
local meh = false |
|
37 |
||
38 |
local gameOver=false |
|
39 |
||
40 |
local mutant = nil |
|
41 |
local mutant_base_health = 200 |
|
42 |
local mutant_base_disease = 25 |
|
43 |
local disease_timer = 2000 |
|
44 |
||
45 |
local kill_reward = nil |
|
46 |
local mt_hurt=false |
|
47 |
||
48 |
local killsCounter = 0 |
|
49 |
||
50 |
local team_fire_punishment = 3 |
|
51 |
local mutant_kill_reward = 2 |
|
52 |
||
53 |
local hh_weapons = { amBazooka, amGrenade, amShotgun, amMine} |
|
54 |
||
55 |
local mt_weapons = {amWatermelon, amHellishBomb, amBallgun, amRCPlane, amTeleport} |
|
56 |
||
57 |
local disease=0 |
|
58 |
local timer=0 |
|
59 |
||
60 |
local winScore = 15 |
|
61 |
local hogsLimit = 1 |
|
62 |
||
63 |
local teams = {} |
|
64 |
||
65 |
local circles = {} |
|
66 |
local circleFrame = -1 |
|
67 |
||
11914 | 68 |
-- Variables for custom achievements |
69 |
||
70 |
-- Most kills in 1 turn |
|
71 |
local recordKills = 0 |
|
72 |
local recordKillsHogName = nil |
|
73 |
local recordKillsTeamName = nil |
|
74 |
||
75 |
-- Most suicides |
|
76 |
local recordSuicides = 0 |
|
77 |
local recordSuicidesHogName = nil |
|
78 |
local recordSuicidesTeamName = nil |
|
79 |
||
80 |
-- Most skips |
|
81 |
local recordSkips = 0 |
|
82 |
local recordSkipsHogName = nil |
|
83 |
local recordSkipsTeamName = nil |
|
11015 | 84 |
|
11914 | 85 |
-- Most crates collected |
86 |
local recordCrates = 0 |
|
87 |
local recordCratesHogName = nil |
|
88 |
local recordCratesTeamName = nil |
|
89 |
||
90 |
-- Most deaths |
|
91 |
local recordDeaths = 0 |
|
92 |
local recordDeathsHogName = nil |
|
93 |
local recordDeathsTeamName = nil |
|
94 |
||
95 |
-- Total killed hedgehogs |
|
96 |
local totalKills = 0 |
|
97 |
||
98 |
-- Total damage |
|
99 |
local totalDamage = 0 |
|
100 |
||
101 |
function rules() |
|
102 |
||
103 |
local ruleSet = loc("Rules: ") .. "|" .. |
|
104 |
loc("Hedgehogs will be revived after their death.") .. "|" .. |
|
105 |
string.format(loc("Mines explode after %d s."), div(MinesTime, 1000)) .. "|" .. |
|
106 |
" |".. |
|
107 |
loc("The first hedgehog to kill someone becomes the Mutant.") .. "|" .. |
|
11015 | 108 |
loc("The Mutant has super-weapons and a lot of health.") .. "|" .. |
109 |
loc("The Mutant loses health quickly if he doesn't keep scoring kills.") .. "|" .. |
|
110 |
" |" .. |
|
11914 | 111 |
loc("Score points by killing other hedgehogs (see below).") .. "|" .. |
112 |
loc("The hedgehog with least points (or most deaths) becomes the Bottom Feeder.") .. "|" .. |
|
113 |
string.format(loc("The first hedgehog which scores %d or more wins the game."), winScore) .. "|" .. |
|
114 |
" |" .. |
|
115 |
loc("Scoring: ") .. "|" .. |
|
116 |
loc("+2 for becoming the Mutant") .. "|" .. |
|
117 |
loc("+1 to the Mutant for killing anyone") .. "|" .. |
|
118 |
loc("+1 to the Bottom Feeder for killing anyone") .. "|" .. |
|
11015 | 119 |
loc("-1 to anyone for a suicide") .. "|" .. |
120 |
loc("Other kills don't give you points.") |
|
121 |
||
11914 | 122 |
return ruleSet |
123 |
||
124 |
end |
|
125 |
||
126 |
function showStartingInfo() |
|
127 |
||
128 |
ShowMission(loc("Mutant"), loc("A Hedgewars tag game"), rules(), 1, 5000) |
|
11015 | 129 |
|
130 |
end |
|
131 |
||
132 |
function onGameInit() |
|
133 |
TurnTime = 20000 |
|
134 |
WaterRise = 0 |
|
11914 | 135 |
HealthDecrease = 0 |
11015 | 136 |
EnableGameFlags(gfResetWeps, gfPerHogAmmo) |
137 |
HealthCaseProb=0 |
|
138 |
HealthCaseAmount=0 |
|
139 |
MinesTime=1000 |
|
140 |
CaseFreq = 2 |
|
141 |
end |
|
142 |
||
143 |
||
144 |
function limitHogs(gear) |
|
145 |
cnthhs = cnthhs + 1 |
|
146 |
if cnthhs > 1 then |
|
147 |
hogLimitHit = true |
|
148 |
SetEffect(gear, heResurrectable, false) |
|
149 |
SetGearPosition(gear, -100,LAND_HEIGHT) |
|
150 |
end |
|
151 |
end |
|
152 |
||
153 |
function onGameStart() |
|
11914 | 154 |
SendHealthStatsOff() |
11015 | 155 |
trackTeams() |
156 |
teamScan() |
|
157 |
runOnHogs(saveStuff) |
|
158 |
||
159 |
hogLimitHit = false |
|
160 |
for i=0 , TeamsCount - 1 do |
|
161 |
cnthhs = 0 |
|
162 |
runOnHogsInTeam(limitHogs, teams[i]) |
|
163 |
end |
|
164 |
if hogLimitHit then |
|
11914 | 165 |
AddCaption(loc("Only one hog per team allowed! Excess hogs will be removed"), 0xFFFFFFFF, capgrpGameState) |
11015 | 166 |
end |
167 |
showStartingInfo() |
|
168 |
end |
|
169 |
||
170 |
||
171 |
||
172 |
function giveWeapons(gear) |
|
173 |
if gear == mutant then |
|
174 |
AddAmmo(gear, amRope) |
|
175 |
for i=1, #mt_weapons do |
|
176 |
AddAmmo(gear, mt_weapons[i]) |
|
177 |
end |
|
178 |
||
179 |
else |
|
180 |
for i=1, #hh_weapons do |
|
181 |
AddAmmo(gear,hh_weapons[i]) |
|
182 |
end |
|
183 |
end |
|
184 |
end |
|
185 |
||
186 |
function onAmmoStoreInit() |
|
187 |
||
188 |
SetAmmo(amSkip, 9, 0, 0, 0) |
|
189 |
SetAmmo(amRope,0,1,0,5) |
|
190 |
SetAmmo(amSnowball,0,1,0,1) |
|
191 |
||
192 |
for i=1, #hh_weapons do |
|
193 |
SetAmmo(hh_weapons[i], 0, 0, 0, 1) |
|
194 |
end |
|
195 |
||
196 |
for i=1, #mt_weapons do |
|
197 |
SetAmmo(mt_weapons[i], 0, 3, 0, 1) |
|
198 |
end |
|
199 |
||
200 |
end |
|
201 |
||
202 |
function drawCircles() |
|
203 |
for i = 0, #hhs do |
|
204 |
if circles[hhs[i]] ~= nil then |
|
205 |
DeleteVisualGear(circles[hhs[i]]) |
|
206 |
circles[hhs[i]] = nil |
|
207 |
end |
|
208 |
||
209 |
if hhs[i] ~= CurrentHedgehog then |
|
210 |
if mutant == nil then |
|
211 |
circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) |
|
212 |
SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080) |
|
213 |
elseif CurrentHedgehog == mutant then |
|
214 |
circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) |
|
215 |
SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070) |
|
216 |
elseif getGearValue(CurrentHedgehog, "Feeder") and hhs[i] ~= mutant then |
|
217 |
circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) |
|
218 |
SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070) |
|
219 |
elseif hhs[i] == mutant then |
|
220 |
circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) |
|
221 |
SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080) |
|
222 |
end |
|
223 |
end |
|
224 |
end |
|
225 |
circleFrame = 0 |
|
226 |
end |
|
227 |
||
228 |
function onNewTurn() |
|
229 |
||
230 |
trackTeams() |
|
231 |
killsCounter = 0 |
|
232 |
||
233 |
if mutant == nil then |
|
11914 | 234 |
AddCaption( loc("First killer will mutate"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 235 |
end |
236 |
||
237 |
checkScore() |
|
11914 | 238 |
|
239 |
for i=0, TeamsCount-1 do |
|
240 |
SendStat(siClanHealth, getTeamValue(teams[i], "Score"), teams[i]) |
|
241 |
end |
|
242 |
||
11015 | 243 |
giveWeapons(CurrentHedgehog) |
244 |
drawCircles() |
|
245 |
setAIHints() |
|
246 |
kill_reward= numhhs*10 |
|
247 |
||
248 |
if CurrentHedgehog == mutant then |
|
249 |
mt_hurt=true |
|
250 |
disease= mutant_base_disease - numhhs |
|
251 |
else |
|
252 |
mt_hurt=false |
|
253 |
end |
|
254 |
||
255 |
setGearValue(CurrentHedgehog, "Alive", true) |
|
256 |
||
257 |
end |
|
258 |
||
259 |
function countBodies() |
|
260 |
if killsCounter == 2 then |
|
11914 | 261 |
AddCaption(loc("Double kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 262 |
elseif killsCounter == 3 then |
11914 | 263 |
AddCaption(loc("Mega kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 264 |
PlaySound(sndRegret) |
265 |
elseif killsCounter == 4 then |
|
11914 | 266 |
AddCaption(loc("Ultra kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 267 |
elseif killsCounter == 5 then |
11914 | 268 |
AddCaption(loc("Monster kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 269 |
PlaySound(sndIllGetYou) |
270 |
elseif killsCounter == 6 then |
|
11914 | 271 |
AddCaption(loc("Ludicrous kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 272 |
PlaySound(sndNutter) |
273 |
elseif killsCounter == 7 then |
|
11914 | 274 |
AddCaption(loc("Holy shit!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 275 |
PlaySound(sndLaugh) |
276 |
elseif killsCounter > 8 then |
|
11914 | 277 |
AddCaption(loc("Insanity!"), 0xFFFFFFFF, capgrpGameState ) |
278 |
end |
|
279 |
||
280 |
if killsCounter > recordKills then |
|
281 |
recordKills = killsCounter |
|
282 |
recordKillsHogName = getGearValue(CurrentHedgehog, "Name") |
|
283 |
recordKillsTeamName = GetHogTeamName(CurrentHedgehog) |
|
11015 | 284 |
end |
285 |
end |
|
286 |
||
287 |
function onGameTick() |
|
288 |
||
289 |
if circleFrame > -1 then |
|
290 |
for i = 0, #hhs do |
|
291 |
if circles[hhs[i]] ~= nil and hhs[i]~= nil then |
|
292 |
hhx, hhy = GetGearPosition(hhs[i]) |
|
293 |
X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint = GetVisualGearValues(circles[hhs[i]]) |
|
294 |
SetVisualGearValues(circles[hhs[i]], hhx + 1, hhy - 3, 0, 0, 0, 0, 0, 40 - (circleFrame % 25), Timer, Tint) |
|
295 |
end |
|
296 |
end |
|
297 |
||
298 |
circleFrame = circleFrame + 0.06 |
|
299 |
||
300 |
if circleFrame >= 25 then |
|
301 |
for i = 0, #hhs do |
|
302 |
if circles[hhs[i]] ~= nil then |
|
303 |
DeleteVisualGear(circles[hhs[i]]) |
|
304 |
circles[hhs[i]] = nil |
|
305 |
end |
|
306 |
end |
|
307 |
end |
|
308 |
end |
|
309 |
||
310 |
if TurnTimeLeft==0 and mt_hurt then |
|
311 |
mt_hurt = false |
|
312 |
end |
|
313 |
||
314 |
if mt_hurt and mutant~=nil then |
|
315 |
timer = timer + 1 |
|
316 |
if timer > disease_timer then |
|
317 |
timer = 0 |
|
318 |
SetHealth(mutant, GetHealth(mutant)-disease ) |
|
319 |
AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true) |
|
320 |
if GetHealth(mutant)<=0 then |
|
321 |
SetHealth(mutant,0) |
|
322 |
mt_hurt= false |
|
323 |
setGearValue(mutant,"SelfDestruct",true) |
|
324 |
TurnTimeLeft = 0 |
|
325 |
end |
|
326 |
end |
|
327 |
end |
|
328 |
||
329 |
end |
|
330 |
||
331 |
function saveStuff(gear) |
|
332 |
setGearValue(gear,"Name",GetHogName(gear)) |
|
333 |
setGearValue(gear,"Hat",GetHogHat(gear)) |
|
334 |
end |
|
335 |
||
336 |
function armageddon(gear) |
|
337 |
SetState(gear, gstLoser) |
|
338 |
SetEffect(gear, heResurrectable, false) |
|
339 |
SetHealth(gear, 0) |
|
340 |
end |
|
341 |
||
342 |
function updateScore() |
|
343 |
||
344 |
local showScore = "" |
|
345 |
||
346 |
for i=0, TeamsCount-1 do |
|
347 |
if teams[i]~= nil then |
|
348 |
||
349 |
local curr_score = getTeamValue(teams[i], "Score") |
|
11914 | 350 |
showScore = showScore .. string.format(loc("%s: %d (deaths: %d)"), teams[i], curr_score, getTeamValue(teams[i], "DeadHogs")) .. "|" |
11015 | 351 |
|
352 |
end |
|
353 |
end |
|
354 |
||
11914 | 355 |
ShowMission(loc("Mutant"), |
356 |
loc("Scores"), |
|
357 |
showScore, 4, 1) |
|
11015 | 358 |
|
359 |
HideMission() |
|
360 |
||
361 |
end |
|
362 |
||
363 |
function checkScore() |
|
364 |
local showScore = "" |
|
365 |
local lowest_score_team = nil |
|
366 |
local min_score=nil |
|
367 |
local winTeam = nil |
|
368 |
||
369 |
local only_low_score = true |
|
370 |
||
371 |
for i=0, TeamsCount-1 do |
|
372 |
if teams[i]~=nil then |
|
373 |
local curr_score = getTeamValue(teams[i], "Score") |
|
374 |
||
375 |
runOnHogsInTeam(removeFeeder, teams[i]) |
|
376 |
||
11914 | 377 |
showScore = showScore .. string.format(loc("%s: %d (deaths: %d)"), teams[i], curr_score, getTeamValue(teams[i], "DeadHogs")) .. "|" |
11015 | 378 |
|
379 |
if curr_score >= winScore then |
|
380 |
gameOver = true |
|
381 |
winTeam = teams[i] |
|
382 |
end |
|
383 |
||
384 |
if min_score==nil then |
|
385 |
min_score= curr_score |
|
386 |
lowest_score_team = teams[i] |
|
387 |
else |
|
388 |
if curr_score <= min_score then |
|
389 |
if curr_score == min_score then |
|
390 |
if getTeamValue(teams[i], "DeadHogs") == getTeamValue(lowest_score_team, "DeadHogs") then |
|
391 |
only_low_score = false |
|
392 |
else |
|
393 |
if getTeamValue(teams[i], "DeadHogs") > getTeamValue(lowest_score_team, "DeadHogs") then |
|
394 |
lowest_score_team = teams[i] |
|
395 |
end |
|
396 |
only_low_score = true |
|
397 |
end |
|
398 |
||
399 |
else |
|
400 |
min_score= curr_score |
|
401 |
lowest_score_team = teams[i] |
|
402 |
only_low_score = true |
|
403 |
end |
|
404 |
end |
|
405 |
end |
|
406 |
end |
|
407 |
end |
|
408 |
||
409 |
if gameOver then |
|
11914 | 410 |
SendStat(siGraphTitle, loc("Score graph")) |
411 |
||
11015 | 412 |
TurnTimeLeft = 0 |
11914 | 413 |
|
414 |
teamsSorted = {} |
|
415 |
||
416 |
for i=0, TeamsCount-1 do |
|
11015 | 417 |
if teams[i]~=winTeam then |
418 |
runOnHogsInTeam(armageddon, teams[i]) |
|
419 |
end |
|
11914 | 420 |
teamsSorted[i+1] = teams[i] |
11015 | 421 |
end |
422 |
||
11914 | 423 |
-- Achievements stuff |
424 |
local achievements = 0 |
|
425 |
--- Most kills per turn |
|
426 |
if recordKills >= 3 then |
|
427 |
SendStat(siMaxStepKills, string.format("%d %s (%s)", recordKills, recordKillsHogName, recordKillsTeamName)) |
|
428 |
achievements = achievements + 1 |
|
429 |
end |
|
430 |
--- Most crates collected |
|
431 |
if recordCrates >= 5 then |
|
432 |
SendStat(siCustomAchievement, string.format(loc("%s (%s) was the greediest hedgehog and collected %d crates."), recordCratesHogName, recordCratesTeamName, recordCrates)) |
|
433 |
achievements = achievements + 1 |
|
434 |
end |
|
435 |
--- Most suicides |
|
436 |
if recordSuicides >= 5 then |
|
437 |
SendStat(siCustomAchievement, string.format(loc("%s (%s) hate life and suicided %d times."), recordSuicidesHogName, recordSuicidesTeamName, recordSuicides)) |
|
438 |
achievements = achievements + 1 |
|
439 |
end |
|
440 |
--- Most deaths |
|
441 |
if recordDeaths >= 5 then |
|
442 |
SendStat(siCustomAchievement, string.format(loc("Poor %s (%s) died %d times."), recordDeathsHogName, recordDeathsTeamName, recordDeaths)) |
|
443 |
achievements = achievements + 1 |
|
444 |
end |
|
445 |
--- Most skips |
|
446 |
if recordSkips >= 3 then |
|
447 |
SendStat(siMaxTurnSkips, string.format("%d %s (%s)", recordSkips, recordSkipsHogName, recordSkipsTeamName)) |
|
448 |
achievements = achievements + 1 |
|
449 |
end |
|
450 |
--- Total damage |
|
451 |
if totalDamage >= 900 then |
|
452 |
SendStat(siCustomAchievement, string.format(loc("%d damage was dealt in this game."), totalDamage)) |
|
453 |
achievements = achievements + 1 |
|
454 |
end |
|
455 |
--- Total kills |
|
456 |
if totalKills >= 20 or achievements <= 0 then |
|
457 |
SendStat(siKilledHHs, tostring(totalKills)) |
|
458 |
achievements = achievements + 1 |
|
459 |
end |
|
460 |
||
461 |
-- Score and stats stuff |
|
462 |
table.sort(teamsSorted, function(team1, team2) return getTeamValue(team1, "Score") < getTeamValue(team2, "Score") end) |
|
463 |
for i=TeamsCount, 1, -1 do |
|
464 |
SendStat(siPointType, loc("point(s)")) |
|
465 |
SendStat(siPlayerKills, getTeamValue(teamsSorted[i], "Score"), teamsSorted[i]) |
|
466 |
end |
|
467 |
||
468 |
AddCaption(string.format(loc("%s wins!"), winTeam), 0xFFFFFFFF, capgrpGameState ) |
|
469 |
SendStat(siGameResult, string.format("%s wins!", winTeam)) |
|
470 |
||
471 |
ShowMission( loc("Mutant"), |
|
472 |
loc("Final result"), |
|
473 |
string.format(loc("Winner: %s"), winTeam) .. "| |" .. loc("Scores:") .. " |" .. |
|
474 |
showScore, 0, 15000) |
|
11015 | 475 |
else |
476 |
||
477 |
if only_low_score then |
|
478 |
runOnHogsInTeam(setFeeder, lowest_score_team) |
|
479 |
end |
|
480 |
||
481 |
if meh == false then |
|
482 |
meh = true |
|
483 |
else |
|
11914 | 484 |
ShowMission( loc("Mutant"), |
485 |
loc("Scores"), |
|
486 |
showScore, 4, 1) |
|
487 |
HideMission() |
|
11015 | 488 |
end |
489 |
||
490 |
end |
|
491 |
end |
|
492 |
||
493 |
function backToNormal(gear) |
|
494 |
SetHogName(gear, getGearValue(gear,"Name")) |
|
495 |
SetHogHat(gear, 'NoHat') |
|
496 |
SetHogHat(gear, getGearValue(gear,"Hat")) |
|
497 |
setGearValue(mutant,"SelfDestruct",false) |
|
498 |
mt_hurt=false |
|
499 |
mutant=nil |
|
500 |
end |
|
501 |
||
502 |
function setAIHints() |
|
503 |
for i = 0, #hhs do |
|
504 |
if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant or getGearValue(CurrentHedgehog, "Feeder") then |
|
505 |
SetGearAIHints(hhs[i], aihUsual) |
|
506 |
else |
|
507 |
SetGearAIHints(hhs[i], aihDoesntMatter) |
|
508 |
end |
|
509 |
end |
|
510 |
end |
|
511 |
||
512 |
function removeFeeder(gear) |
|
513 |
if gear~=nil then |
|
514 |
setGearValue(gear,"Feeder",false) |
|
515 |
if gear~= mutant then |
|
516 |
SetHogName(gear, getGearValue(gear,"Name") ) |
|
517 |
SetHogHat(gear, 'NoHat') |
|
518 |
SetHogHat(gear, getGearValue(gear,"Hat")) |
|
519 |
end |
|
520 |
end |
|
521 |
end |
|
522 |
||
523 |
function setFeeder(gear) |
|
524 |
if gear~= mutant and gear~= nil then |
|
11914 | 525 |
SetHogName(gear, loc("Bottom Feeder")) |
11015 | 526 |
SetHogHat(gear, 'poke_slowpoke') |
527 |
setGearValue(gear,"Feeder", true) |
|
528 |
end |
|
529 |
end |
|
530 |
||
531 |
function setMutantStuff(gear) |
|
532 |
mutant = gear |
|
533 |
||
11914 | 534 |
SetHogName(gear, loc("Mutant")) |
11015 | 535 |
SetHogHat(gear,'WhySoSerious') |
536 |
SetHealth(gear, ( mutant_base_health + numhhs*25) ) |
|
537 |
SetEffect(gear, hePoisoned, 1) |
|
538 |
setGearValue(mutant,"SelfDestruct",false) |
|
539 |
setGearValue(gear, "Feeder", false) |
|
540 |
||
11914 | 541 |
AddCaption(string.format(loc("%s has mutated! +2 points"), getGearValue(gear, "Name")), GetClanColor(GetHogClan(gear)), capgrpMessage) |
11015 | 542 |
|
543 |
TurnTimeLeft=0 |
|
544 |
||
545 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) |
|
546 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) |
|
547 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) |
|
548 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) |
|
549 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) |
|
550 |
PlaySound(sndSuddenDeath) |
|
551 |
end |
|
552 |
||
553 |
function teamScan() |
|
554 |
||
555 |
for i=0, TeamsCount-1 do --nil filling |
|
556 |
teams[i]=nil |
|
557 |
end |
|
558 |
||
559 |
for i=0, #hhs do |
|
560 |
for j=0, TeamsCount-1 do |
|
561 |
if teams[j] ==nil and hhs[i]~=nil then |
|
562 |
teams[j] = GetHogTeamName(hhs[i]) |
|
11914 | 563 |
setTeamValue(teams[j], "Score",0) |
564 |
setTeamValue(teams[j], "Suicides",0) |
|
565 |
setTeamValue(teams[j], "Skips",0) |
|
566 |
setTeamValue(teams[j], "Crates",0) |
|
11015 | 567 |
setTeamValue(teams[j], "DeadHogs",0) |
568 |
break |
|
569 |
end |
|
570 |
||
571 |
if teams[j] == GetHogTeamName(hhs[i]) then |
|
572 |
break |
|
573 |
end |
|
574 |
end |
|
575 |
end |
|
576 |
||
577 |
---***--- |
|
578 |
end |
|
579 |
||
580 |
function set_Mutant_and_Score(gear) |
|
581 |
||
582 |
local curr_team = GetHogTeamName(CurrentHedgehog) |
|
583 |
||
584 |
if gear == CurrentHedgehog then |
|
585 |
if CurrentHedgehog == mutant then |
|
586 |
PlaySound(sndHomerun) |
|
587 |
if getGearValue(gear, "SelfDestruct")==false then |
|
588 |
decreaseTeamValue(curr_team,"Score") |
|
589 |
end |
|
590 |
backToNormal(gear) |
|
591 |
else |
|
592 |
decreaseTeamValue(curr_team,"Score") |
|
593 |
end |
|
594 |
||
595 |
else |
|
596 |
if gear == mutant then |
|
597 |
backToNormal(mutant) |
|
598 |
if curr_team ~=GetHogTeamName(gear) then |
|
599 |
if getGearValue(CurrentHedgehog, "Alive") then |
|
600 |
setMutantStuff(CurrentHedgehog) |
|
601 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward)) |
|
602 |
end |
|
603 |
else |
|
604 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) |
|
11914 | 605 |
increaseTeamValue(curr_team,"Suicides") |
606 |
if(getTeamValue(curr_team, "Suicides") > recordSuicides) then |
|
607 |
recordSuicides = getTeamValue(curr_team, "Suicides") |
|
608 |
recordSuicidesHogName = getGearValue(CurrentHedgehog, "Name") |
|
609 |
recordSuicidesTeamName = curr_team |
|
610 |
end |
|
611 |
AddCaption(loc("-1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
|
11015 | 612 |
end |
613 |
else |
|
614 |
if mutant==nil then |
|
615 |
if curr_team ~=GetHogTeamName(gear) then |
|
616 |
if getGearValue(CurrentHedgehog, "Alive") then |
|
617 |
setMutantStuff(CurrentHedgehog) |
|
618 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward)) |
|
619 |
else |
|
620 |
increaseTeamValue(curr_team,"Score") |
|
621 |
end |
|
622 |
else |
|
623 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) |
|
11914 | 624 |
increaseTeamValue(curr_team,"Suicides") |
625 |
if(getTeamValue(curr_team, "Suicides") > recordSuicides) then |
|
626 |
recordSuicides = getTeamValue(curr_team, "Suicides") |
|
627 |
recordSuicidesHogName = getGearValue(CurrentHedgehog, "Name") |
|
628 |
recordSuicidesTeamName = curr_team |
|
629 |
end |
|
630 |
AddCaption(loc("-1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
|
11015 | 631 |
end |
632 |
else |
|
633 |
if curr_team ~=GetHogTeamName(gear) then |
|
634 |
if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then |
|
635 |
SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog)+kill_reward) |
|
12293
a5a7d0c6d3f3
Fix incorrect Mutant score message color
Wuzzy <almikes@aol.com>
parents:
11914
diff
changeset
|
636 |
AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
a5a7d0c6d3f3
Fix incorrect Mutant score message color
Wuzzy <almikes@aol.com>
parents:
11914
diff
changeset
|
637 |
AddCaption(string.format(loc("+%d health"), kill_reward), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2) |
11015 | 638 |
increaseTeamValue(curr_team,"Score") |
639 |
end |
|
640 |
if getGearValue(CurrentHedgehog,"Feeder") then |
|
641 |
increaseTeamValue(curr_team,"Score") |
|
11914 | 642 |
AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
11015 | 643 |
end |
644 |
else |
|
645 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) |
|
11914 | 646 |
AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
11015 | 647 |
end |
648 |
end |
|
649 |
end |
|
650 |
end |
|
651 |
end |
|
652 |
||
653 |
function onGearResurrect(gear) |
|
654 |
if not gameOver then |
|
655 |
if GetGearType(gear) == gtHedgehog then |
|
656 |
||
657 |
increaseTeamValue(GetHogTeamName(gear), "DeadHogs") |
|
11914 | 658 |
totalKills = totalKills + 1 |
659 |
if(getTeamValue(GetHogTeamName(gear), "DeadHogs") > recordDeaths) then |
|
660 |
recordDeaths = getTeamValue(GetHogTeamName(gear), "DeadHogs") |
|
661 |
recordDeathsHogName = getGearValue(gear, "Name") |
|
662 |
recordDeathsTeamName = GetHogTeamName(gear) |
|
663 |
end |
|
11015 | 664 |
|
665 |
if gear==CurrentHedgehog then |
|
666 |
setGearValue(CurrentHedgehog, "Alive", false) |
|
667 |
end |
|
668 |
set_Mutant_and_Score(gear) |
|
669 |
if gear~=CurrentHedgehog then |
|
670 |
killsCounter = killsCounter + 1 |
|
671 |
countBodies() |
|
672 |
end |
|
673 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) |
|
674 |
PlaySound(sndWhack) |
|
675 |
updateScore() |
|
676 |
end |
|
677 |
end |
|
678 |
end |
|
679 |
||
11914 | 680 |
function onGearDamage(gear, damage) |
681 |
if not gameOver and GetGearType(gear) == gtHedgehog then |
|
682 |
totalDamage = totalDamage + damage |
|
683 |
end |
|
684 |
end |
|
685 |
||
686 |
function onHogAttack(ammoType) |
|
687 |
-- Record skips for achievement |
|
688 |
if ammoType == amSkip then |
|
689 |
local team = GetHogTeamName(CurrentHedgehog) |
|
690 |
increaseTeamValue(team, "Skips") |
|
691 |
if(getTeamValue(team, "Skips") > recordSkips) then |
|
692 |
recordSkips = getTeamValue(team, "Skips") |
|
693 |
recordSkipsHogName = getGearValue(CurrentHedgehog, "Name") |
|
694 |
recordSkipsTeamName = team |
|
695 |
end |
|
696 |
end |
|
697 |
end |
|
698 |
||
11015 | 699 |
function onGearAdd(gear) |
700 |
||
701 |
-- Catch hedgehogs for the tracker |
|
702 |
if GetGearType(gear) == gtHedgehog then |
|
703 |
trackGear(gear) |
|
704 |
hhs[numhhs] = gear |
|
705 |
numhhs = numhhs + 1 |
|
706 |
SetEffect(gear, heResurrectable, 1) |
|
707 |
end |
|
708 |
end |
|
709 |
||
710 |
function checkEmptyTeam (teamName) |
|
711 |
for i=0 , #hhs do |
|
712 |
if hhs[i]~=nil then |
|
713 |
if teamName == GetHogTeamName(hhs[i]) then |
|
714 |
return false |
|
715 |
end |
|
716 |
end |
|
717 |
end |
|
718 |
return true |
|
719 |
end |
|
720 |
||
721 |
function onGearDelete(gear) |
|
722 |
-- Remove hogs that are gone |
|
723 |
if GetGearType(gear) == gtHedgehog then |
|
724 |
numhhs = numhhs - 1 |
|
725 |
||
726 |
local found |
|
727 |
for i=0, #hhs do |
|
728 |
if hhs[i] == gear then |
|
729 |
found = i |
|
730 |
break |
|
731 |
end |
|
732 |
end |
|
733 |
for i = found, #hhs - 1 do |
|
734 |
hhs[i] = hhs[i + 1] |
|
735 |
end |
|
736 |
hhs[#hhs] = nil |
|
737 |
||
738 |
local t_name = GetHogTeamName(gear) |
|
739 |
if checkEmptyTeam(t_name) then |
|
740 |
for i = 0, TeamsCount - 1 do |
|
741 |
if teams[i] == t_name then |
|
742 |
found = i |
|
743 |
break |
|
744 |
end |
|
745 |
end |
|
746 |
for i = found, TeamsCount - 2 do |
|
747 |
teams[i] = teams[i + 1] |
|
748 |
end |
|
749 |
teams[TeamsCount - 1] = nil |
|
750 |
TeamsCount = TeamsCount - 1 |
|
751 |
end |
|
752 |
AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
753 |
trackDeletion(gear) |
|
11914 | 754 |
|
755 |
-- End game properly when only the winner remains |
|
756 |
if gameOver and numhhs == 1 then |
|
757 |
EndGame() |
|
758 |
end |
|
759 |
elseif GetGearType(gear) == gtCase then |
|
760 |
-- Check if a crate has been collected |
|
761 |
if band(GetGearMessage(gear), gmDestroy) ~= 0 and CurrentHedgehog ~= nil then |
|
762 |
-- Update crate collection achievement |
|
763 |
increaseTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") |
|
764 |
if(getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") > recordCrates) then |
|
765 |
recordCrates = getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") |
|
766 |
recordCratesHogName = getGearValue(CurrentHedgehog, "Name") |
|
767 |
recordCratesTeamName = GetHogTeamName(CurrentHedgehog) |
|
768 |
end |
|
769 |
end |
|
11015 | 770 |
end |
771 |
end |
|
772 |
||
773 |
function onParameters() |
|
774 |
parseParams() |
|
775 |
winScore = tonumber(params["winscore"]) or winScore |
|
776 |
end |
|
777 |
||
778 |
--[[ |
|
779 |
S T A R R I N G |
|
780 |
prof - Coding, implementing and evangelism |
|
781 |
vos - Initial idea and script improvements |
|
782 |
mikade - Moving the `how to play` into the game so that people know `how to play`, and whitespace :D |
|
783 |
--]] |