author | Wuzzy <almikes@aol.com> |
Wed, 26 Apr 2017 02:55:40 +0200 | |
changeset 12335 | 8f693d25be2f |
parent 12288 | a5a7d0c6d3f3 |
child 12341 | c73521104fac |
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 |
||
11909 | 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 |
|
11909 | 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 |
" |" .. |
|
11909 | 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 |
||
11909 | 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 |
|
11909 | 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() |
|
11909 | 154 |
SendHealthStatsOff() |
12335
8f693d25be2f
Show traditional winning animation in Mutant again
Wuzzy <almikes@aol.com>
parents:
12288
diff
changeset
|
155 |
SendRankingStatsOff() |
8f693d25be2f
Show traditional winning animation in Mutant again
Wuzzy <almikes@aol.com>
parents:
12288
diff
changeset
|
156 |
SendAchievementsStatsOff() |
11015 | 157 |
trackTeams() |
158 |
teamScan() |
|
159 |
runOnHogs(saveStuff) |
|
160 |
||
161 |
hogLimitHit = false |
|
162 |
for i=0 , TeamsCount - 1 do |
|
163 |
cnthhs = 0 |
|
164 |
runOnHogsInTeam(limitHogs, teams[i]) |
|
165 |
end |
|
166 |
if hogLimitHit then |
|
11909 | 167 |
AddCaption(loc("Only one hog per team allowed! Excess hogs will be removed"), 0xFFFFFFFF, capgrpGameState) |
11015 | 168 |
end |
169 |
showStartingInfo() |
|
170 |
end |
|
171 |
||
172 |
||
173 |
||
174 |
function giveWeapons(gear) |
|
175 |
if gear == mutant then |
|
176 |
AddAmmo(gear, amRope) |
|
177 |
for i=1, #mt_weapons do |
|
178 |
AddAmmo(gear, mt_weapons[i]) |
|
179 |
end |
|
180 |
||
181 |
else |
|
182 |
for i=1, #hh_weapons do |
|
183 |
AddAmmo(gear,hh_weapons[i]) |
|
184 |
end |
|
185 |
end |
|
186 |
end |
|
187 |
||
188 |
function onAmmoStoreInit() |
|
189 |
||
190 |
SetAmmo(amSkip, 9, 0, 0, 0) |
|
191 |
SetAmmo(amRope,0,1,0,5) |
|
192 |
SetAmmo(amSnowball,0,1,0,1) |
|
193 |
||
194 |
for i=1, #hh_weapons do |
|
195 |
SetAmmo(hh_weapons[i], 0, 0, 0, 1) |
|
196 |
end |
|
197 |
||
198 |
for i=1, #mt_weapons do |
|
199 |
SetAmmo(mt_weapons[i], 0, 3, 0, 1) |
|
200 |
end |
|
201 |
||
202 |
end |
|
203 |
||
204 |
function drawCircles() |
|
205 |
for i = 0, #hhs do |
|
206 |
if circles[hhs[i]] ~= nil then |
|
207 |
DeleteVisualGear(circles[hhs[i]]) |
|
208 |
circles[hhs[i]] = nil |
|
209 |
end |
|
210 |
||
211 |
if hhs[i] ~= CurrentHedgehog then |
|
212 |
if mutant == nil then |
|
213 |
circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) |
|
214 |
SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080) |
|
215 |
elseif CurrentHedgehog == mutant then |
|
216 |
circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) |
|
217 |
SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070) |
|
218 |
elseif getGearValue(CurrentHedgehog, "Feeder") and hhs[i] ~= mutant then |
|
219 |
circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) |
|
220 |
SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070) |
|
221 |
elseif hhs[i] == mutant then |
|
222 |
circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) |
|
223 |
SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080) |
|
224 |
end |
|
225 |
end |
|
226 |
end |
|
227 |
circleFrame = 0 |
|
228 |
end |
|
229 |
||
230 |
function onNewTurn() |
|
231 |
||
232 |
trackTeams() |
|
233 |
killsCounter = 0 |
|
234 |
||
235 |
if mutant == nil then |
|
11909 | 236 |
AddCaption( loc("First killer will mutate"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 237 |
end |
238 |
||
239 |
checkScore() |
|
11909 | 240 |
|
241 |
for i=0, TeamsCount-1 do |
|
242 |
SendStat(siClanHealth, getTeamValue(teams[i], "Score"), teams[i]) |
|
243 |
end |
|
244 |
||
11015 | 245 |
giveWeapons(CurrentHedgehog) |
246 |
drawCircles() |
|
247 |
setAIHints() |
|
248 |
kill_reward= numhhs*10 |
|
249 |
||
250 |
if CurrentHedgehog == mutant then |
|
251 |
mt_hurt=true |
|
252 |
disease= mutant_base_disease - numhhs |
|
253 |
else |
|
254 |
mt_hurt=false |
|
255 |
end |
|
256 |
||
257 |
setGearValue(CurrentHedgehog, "Alive", true) |
|
258 |
||
259 |
end |
|
260 |
||
261 |
function countBodies() |
|
262 |
if killsCounter == 2 then |
|
11909 | 263 |
AddCaption(loc("Double kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 264 |
elseif killsCounter == 3 then |
11909 | 265 |
AddCaption(loc("Mega kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 266 |
PlaySound(sndRegret) |
267 |
elseif killsCounter == 4 then |
|
11909 | 268 |
AddCaption(loc("Ultra kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 269 |
elseif killsCounter == 5 then |
11909 | 270 |
AddCaption(loc("Monster kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 271 |
PlaySound(sndIllGetYou) |
272 |
elseif killsCounter == 6 then |
|
11909 | 273 |
AddCaption(loc("Ludicrous kill!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 274 |
PlaySound(sndNutter) |
275 |
elseif killsCounter == 7 then |
|
11909 | 276 |
AddCaption(loc("Holy shit!"), 0xFFFFFFFF, capgrpGameState ) |
11015 | 277 |
PlaySound(sndLaugh) |
278 |
elseif killsCounter > 8 then |
|
11909 | 279 |
AddCaption(loc("Insanity!"), 0xFFFFFFFF, capgrpGameState ) |
280 |
end |
|
281 |
||
282 |
if killsCounter > recordKills then |
|
283 |
recordKills = killsCounter |
|
284 |
recordKillsHogName = getGearValue(CurrentHedgehog, "Name") |
|
285 |
recordKillsTeamName = GetHogTeamName(CurrentHedgehog) |
|
11015 | 286 |
end |
287 |
end |
|
288 |
||
289 |
function onGameTick() |
|
290 |
||
291 |
if circleFrame > -1 then |
|
292 |
for i = 0, #hhs do |
|
293 |
if circles[hhs[i]] ~= nil and hhs[i]~= nil then |
|
294 |
hhx, hhy = GetGearPosition(hhs[i]) |
|
295 |
X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint = GetVisualGearValues(circles[hhs[i]]) |
|
296 |
SetVisualGearValues(circles[hhs[i]], hhx + 1, hhy - 3, 0, 0, 0, 0, 0, 40 - (circleFrame % 25), Timer, Tint) |
|
297 |
end |
|
298 |
end |
|
299 |
||
300 |
circleFrame = circleFrame + 0.06 |
|
301 |
||
302 |
if circleFrame >= 25 then |
|
303 |
for i = 0, #hhs do |
|
304 |
if circles[hhs[i]] ~= nil then |
|
305 |
DeleteVisualGear(circles[hhs[i]]) |
|
306 |
circles[hhs[i]] = nil |
|
307 |
end |
|
308 |
end |
|
309 |
end |
|
310 |
end |
|
311 |
||
312 |
if TurnTimeLeft==0 and mt_hurt then |
|
313 |
mt_hurt = false |
|
314 |
end |
|
315 |
||
316 |
if mt_hurt and mutant~=nil then |
|
317 |
timer = timer + 1 |
|
318 |
if timer > disease_timer then |
|
319 |
timer = 0 |
|
320 |
SetHealth(mutant, GetHealth(mutant)-disease ) |
|
321 |
AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true) |
|
322 |
if GetHealth(mutant)<=0 then |
|
323 |
SetHealth(mutant,0) |
|
324 |
mt_hurt= false |
|
325 |
setGearValue(mutant,"SelfDestruct",true) |
|
326 |
TurnTimeLeft = 0 |
|
327 |
end |
|
328 |
end |
|
329 |
end |
|
330 |
||
331 |
end |
|
332 |
||
333 |
function saveStuff(gear) |
|
334 |
setGearValue(gear,"Name",GetHogName(gear)) |
|
335 |
setGearValue(gear,"Hat",GetHogHat(gear)) |
|
336 |
end |
|
337 |
||
338 |
function armageddon(gear) |
|
339 |
SetState(gear, gstLoser) |
|
340 |
SetEffect(gear, heResurrectable, false) |
|
341 |
SetHealth(gear, 0) |
|
342 |
end |
|
343 |
||
344 |
function updateScore() |
|
345 |
||
346 |
local showScore = "" |
|
347 |
||
348 |
for i=0, TeamsCount-1 do |
|
349 |
if teams[i]~= nil then |
|
350 |
||
351 |
local curr_score = getTeamValue(teams[i], "Score") |
|
11909 | 352 |
showScore = showScore .. string.format(loc("%s: %d (deaths: %d)"), teams[i], curr_score, getTeamValue(teams[i], "DeadHogs")) .. "|" |
11015 | 353 |
|
354 |
end |
|
355 |
end |
|
356 |
||
11909 | 357 |
ShowMission(loc("Mutant"), |
358 |
loc("Scores"), |
|
359 |
showScore, 4, 1) |
|
11015 | 360 |
|
361 |
HideMission() |
|
362 |
||
363 |
end |
|
364 |
||
365 |
function checkScore() |
|
366 |
local showScore = "" |
|
367 |
local lowest_score_team = nil |
|
368 |
local min_score=nil |
|
369 |
local winTeam = nil |
|
370 |
||
371 |
local only_low_score = true |
|
372 |
||
373 |
for i=0, TeamsCount-1 do |
|
374 |
if teams[i]~=nil then |
|
375 |
local curr_score = getTeamValue(teams[i], "Score") |
|
376 |
||
377 |
runOnHogsInTeam(removeFeeder, teams[i]) |
|
378 |
||
11909 | 379 |
showScore = showScore .. string.format(loc("%s: %d (deaths: %d)"), teams[i], curr_score, getTeamValue(teams[i], "DeadHogs")) .. "|" |
11015 | 380 |
|
381 |
if curr_score >= winScore then |
|
382 |
gameOver = true |
|
383 |
winTeam = teams[i] |
|
384 |
end |
|
385 |
||
386 |
if min_score==nil then |
|
387 |
min_score= curr_score |
|
388 |
lowest_score_team = teams[i] |
|
389 |
else |
|
390 |
if curr_score <= min_score then |
|
391 |
if curr_score == min_score then |
|
392 |
if getTeamValue(teams[i], "DeadHogs") == getTeamValue(lowest_score_team, "DeadHogs") then |
|
393 |
only_low_score = false |
|
394 |
else |
|
395 |
if getTeamValue(teams[i], "DeadHogs") > getTeamValue(lowest_score_team, "DeadHogs") then |
|
396 |
lowest_score_team = teams[i] |
|
397 |
end |
|
398 |
only_low_score = true |
|
399 |
end |
|
400 |
||
401 |
else |
|
402 |
min_score= curr_score |
|
403 |
lowest_score_team = teams[i] |
|
404 |
only_low_score = true |
|
405 |
end |
|
406 |
end |
|
407 |
end |
|
408 |
end |
|
409 |
end |
|
410 |
||
411 |
if gameOver then |
|
11909 | 412 |
SendStat(siGraphTitle, loc("Score graph")) |
413 |
||
11015 | 414 |
TurnTimeLeft = 0 |
11909 | 415 |
|
416 |
teamsSorted = {} |
|
417 |
||
418 |
for i=0, TeamsCount-1 do |
|
11015 | 419 |
if teams[i]~=winTeam then |
420 |
runOnHogsInTeam(armageddon, teams[i]) |
|
421 |
end |
|
11909 | 422 |
teamsSorted[i+1] = teams[i] |
11015 | 423 |
end |
424 |
||
11909 | 425 |
-- Achievements stuff |
426 |
local achievements = 0 |
|
427 |
--- Most kills per turn |
|
428 |
if recordKills >= 3 then |
|
429 |
SendStat(siMaxStepKills, string.format("%d %s (%s)", recordKills, recordKillsHogName, recordKillsTeamName)) |
|
430 |
achievements = achievements + 1 |
|
431 |
end |
|
432 |
--- Most crates collected |
|
433 |
if recordCrates >= 5 then |
|
434 |
SendStat(siCustomAchievement, string.format(loc("%s (%s) was the greediest hedgehog and collected %d crates."), recordCratesHogName, recordCratesTeamName, recordCrates)) |
|
435 |
achievements = achievements + 1 |
|
436 |
end |
|
437 |
--- Most suicides |
|
438 |
if recordSuicides >= 5 then |
|
439 |
SendStat(siCustomAchievement, string.format(loc("%s (%s) hate life and suicided %d times."), recordSuicidesHogName, recordSuicidesTeamName, recordSuicides)) |
|
440 |
achievements = achievements + 1 |
|
441 |
end |
|
442 |
--- Most deaths |
|
443 |
if recordDeaths >= 5 then |
|
444 |
SendStat(siCustomAchievement, string.format(loc("Poor %s (%s) died %d times."), recordDeathsHogName, recordDeathsTeamName, recordDeaths)) |
|
445 |
achievements = achievements + 1 |
|
446 |
end |
|
447 |
--- Most skips |
|
448 |
if recordSkips >= 3 then |
|
449 |
SendStat(siMaxTurnSkips, string.format("%d %s (%s)", recordSkips, recordSkipsHogName, recordSkipsTeamName)) |
|
450 |
achievements = achievements + 1 |
|
451 |
end |
|
452 |
--- Total damage |
|
453 |
if totalDamage >= 900 then |
|
454 |
SendStat(siCustomAchievement, string.format(loc("%d damage was dealt in this game."), totalDamage)) |
|
455 |
achievements = achievements + 1 |
|
456 |
end |
|
457 |
--- Total kills |
|
458 |
if totalKills >= 20 or achievements <= 0 then |
|
459 |
SendStat(siKilledHHs, tostring(totalKills)) |
|
460 |
achievements = achievements + 1 |
|
461 |
end |
|
462 |
||
463 |
-- Score and stats stuff |
|
464 |
table.sort(teamsSorted, function(team1, team2) return getTeamValue(team1, "Score") < getTeamValue(team2, "Score") end) |
|
465 |
for i=TeamsCount, 1, -1 do |
|
466 |
SendStat(siPointType, loc("point(s)")) |
|
467 |
SendStat(siPlayerKills, getTeamValue(teamsSorted[i], "Score"), teamsSorted[i]) |
|
468 |
end |
|
469 |
||
470 |
ShowMission( loc("Mutant"), |
|
471 |
loc("Final result"), |
|
472 |
string.format(loc("Winner: %s"), winTeam) .. "| |" .. loc("Scores:") .. " |" .. |
|
473 |
showScore, 0, 15000) |
|
11015 | 474 |
else |
475 |
||
476 |
if only_low_score then |
|
477 |
runOnHogsInTeam(setFeeder, lowest_score_team) |
|
478 |
end |
|
479 |
||
480 |
if meh == false then |
|
481 |
meh = true |
|
482 |
else |
|
11909 | 483 |
ShowMission( loc("Mutant"), |
484 |
loc("Scores"), |
|
485 |
showScore, 4, 1) |
|
486 |
HideMission() |
|
11015 | 487 |
end |
488 |
||
489 |
end |
|
490 |
end |
|
491 |
||
492 |
function backToNormal(gear) |
|
493 |
SetHogName(gear, getGearValue(gear,"Name")) |
|
494 |
SetHogHat(gear, 'NoHat') |
|
495 |
SetHogHat(gear, getGearValue(gear,"Hat")) |
|
496 |
setGearValue(mutant,"SelfDestruct",false) |
|
497 |
mt_hurt=false |
|
498 |
mutant=nil |
|
499 |
end |
|
500 |
||
501 |
function setAIHints() |
|
502 |
for i = 0, #hhs do |
|
503 |
if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant or getGearValue(CurrentHedgehog, "Feeder") then |
|
504 |
SetGearAIHints(hhs[i], aihUsual) |
|
505 |
else |
|
506 |
SetGearAIHints(hhs[i], aihDoesntMatter) |
|
507 |
end |
|
508 |
end |
|
509 |
end |
|
510 |
||
511 |
function removeFeeder(gear) |
|
512 |
if gear~=nil then |
|
513 |
setGearValue(gear,"Feeder",false) |
|
514 |
if gear~= mutant then |
|
515 |
SetHogName(gear, getGearValue(gear,"Name") ) |
|
516 |
SetHogHat(gear, 'NoHat') |
|
517 |
SetHogHat(gear, getGearValue(gear,"Hat")) |
|
518 |
end |
|
519 |
end |
|
520 |
end |
|
521 |
||
522 |
function setFeeder(gear) |
|
523 |
if gear~= mutant and gear~= nil then |
|
11909 | 524 |
SetHogName(gear, loc("Bottom Feeder")) |
11015 | 525 |
SetHogHat(gear, 'poke_slowpoke') |
526 |
setGearValue(gear,"Feeder", true) |
|
527 |
end |
|
528 |
end |
|
529 |
||
530 |
function setMutantStuff(gear) |
|
531 |
mutant = gear |
|
532 |
||
11909 | 533 |
SetHogName(gear, loc("Mutant")) |
11015 | 534 |
SetHogHat(gear,'WhySoSerious') |
535 |
SetHealth(gear, ( mutant_base_health + numhhs*25) ) |
|
536 |
SetEffect(gear, hePoisoned, 1) |
|
537 |
setGearValue(mutant,"SelfDestruct",false) |
|
538 |
setGearValue(gear, "Feeder", false) |
|
539 |
||
11909 | 540 |
AddCaption(string.format(loc("%s has mutated! +2 points"), getGearValue(gear, "Name")), GetClanColor(GetHogClan(gear)), capgrpMessage) |
11015 | 541 |
|
542 |
TurnTimeLeft=0 |
|
543 |
||
544 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) |
|
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 |
PlaySound(sndSuddenDeath) |
|
550 |
end |
|
551 |
||
552 |
function teamScan() |
|
553 |
||
554 |
for i=0, TeamsCount-1 do --nil filling |
|
555 |
teams[i]=nil |
|
556 |
end |
|
557 |
||
558 |
for i=0, #hhs do |
|
559 |
for j=0, TeamsCount-1 do |
|
560 |
if teams[j] ==nil and hhs[i]~=nil then |
|
561 |
teams[j] = GetHogTeamName(hhs[i]) |
|
11909 | 562 |
setTeamValue(teams[j], "Score",0) |
563 |
setTeamValue(teams[j], "Suicides",0) |
|
564 |
setTeamValue(teams[j], "Skips",0) |
|
565 |
setTeamValue(teams[j], "Crates",0) |
|
11015 | 566 |
setTeamValue(teams[j], "DeadHogs",0) |
567 |
break |
|
568 |
end |
|
569 |
||
570 |
if teams[j] == GetHogTeamName(hhs[i]) then |
|
571 |
break |
|
572 |
end |
|
573 |
end |
|
574 |
end |
|
575 |
||
576 |
---***--- |
|
577 |
end |
|
578 |
||
579 |
function set_Mutant_and_Score(gear) |
|
580 |
||
581 |
local curr_team = GetHogTeamName(CurrentHedgehog) |
|
582 |
||
583 |
if gear == CurrentHedgehog then |
|
584 |
if CurrentHedgehog == mutant then |
|
585 |
PlaySound(sndHomerun) |
|
586 |
if getGearValue(gear, "SelfDestruct")==false then |
|
587 |
decreaseTeamValue(curr_team,"Score") |
|
588 |
end |
|
589 |
backToNormal(gear) |
|
590 |
else |
|
591 |
decreaseTeamValue(curr_team,"Score") |
|
592 |
end |
|
593 |
||
594 |
else |
|
595 |
if gear == mutant then |
|
596 |
backToNormal(mutant) |
|
597 |
if curr_team ~=GetHogTeamName(gear) then |
|
598 |
if getGearValue(CurrentHedgehog, "Alive") then |
|
599 |
setMutantStuff(CurrentHedgehog) |
|
600 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward)) |
|
601 |
end |
|
602 |
else |
|
603 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) |
|
11909 | 604 |
increaseTeamValue(curr_team,"Suicides") |
605 |
if(getTeamValue(curr_team, "Suicides") > recordSuicides) then |
|
606 |
recordSuicides = getTeamValue(curr_team, "Suicides") |
|
607 |
recordSuicidesHogName = getGearValue(CurrentHedgehog, "Name") |
|
608 |
recordSuicidesTeamName = curr_team |
|
609 |
end |
|
610 |
AddCaption(loc("-1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
|
11015 | 611 |
end |
612 |
else |
|
613 |
if mutant==nil then |
|
614 |
if curr_team ~=GetHogTeamName(gear) then |
|
615 |
if getGearValue(CurrentHedgehog, "Alive") then |
|
616 |
setMutantStuff(CurrentHedgehog) |
|
617 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward)) |
|
618 |
else |
|
619 |
increaseTeamValue(curr_team,"Score") |
|
620 |
end |
|
621 |
else |
|
622 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) |
|
11909 | 623 |
increaseTeamValue(curr_team,"Suicides") |
624 |
if(getTeamValue(curr_team, "Suicides") > recordSuicides) then |
|
625 |
recordSuicides = getTeamValue(curr_team, "Suicides") |
|
626 |
recordSuicidesHogName = getGearValue(CurrentHedgehog, "Name") |
|
627 |
recordSuicidesTeamName = curr_team |
|
628 |
end |
|
629 |
AddCaption(loc("-1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
|
11015 | 630 |
end |
631 |
else |
|
632 |
if curr_team ~=GetHogTeamName(gear) then |
|
633 |
if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then |
|
634 |
SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog)+kill_reward) |
|
12288
a5a7d0c6d3f3
Fix incorrect Mutant score message color
Wuzzy <almikes@aol.com>
parents:
11909
diff
changeset
|
635 |
AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
a5a7d0c6d3f3
Fix incorrect Mutant score message color
Wuzzy <almikes@aol.com>
parents:
11909
diff
changeset
|
636 |
AddCaption(string.format(loc("+%d health"), kill_reward), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2) |
11015 | 637 |
increaseTeamValue(curr_team,"Score") |
638 |
end |
|
639 |
if getGearValue(CurrentHedgehog,"Feeder") then |
|
640 |
increaseTeamValue(curr_team,"Score") |
|
11909 | 641 |
AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
11015 | 642 |
end |
643 |
else |
|
644 |
setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) |
|
11909 | 645 |
AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) |
11015 | 646 |
end |
647 |
end |
|
648 |
end |
|
649 |
end |
|
650 |
end |
|
651 |
||
652 |
function onGearResurrect(gear) |
|
653 |
if not gameOver then |
|
654 |
if GetGearType(gear) == gtHedgehog then |
|
655 |
||
656 |
increaseTeamValue(GetHogTeamName(gear), "DeadHogs") |
|
11909 | 657 |
totalKills = totalKills + 1 |
658 |
if(getTeamValue(GetHogTeamName(gear), "DeadHogs") > recordDeaths) then |
|
659 |
recordDeaths = getTeamValue(GetHogTeamName(gear), "DeadHogs") |
|
660 |
recordDeathsHogName = getGearValue(gear, "Name") |
|
661 |
recordDeathsTeamName = GetHogTeamName(gear) |
|
662 |
end |
|
11015 | 663 |
|
664 |
if gear==CurrentHedgehog then |
|
665 |
setGearValue(CurrentHedgehog, "Alive", false) |
|
666 |
end |
|
667 |
set_Mutant_and_Score(gear) |
|
668 |
if gear~=CurrentHedgehog then |
|
669 |
killsCounter = killsCounter + 1 |
|
670 |
countBodies() |
|
671 |
end |
|
672 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) |
|
673 |
PlaySound(sndWhack) |
|
674 |
updateScore() |
|
675 |
end |
|
676 |
end |
|
677 |
end |
|
678 |
||
11909 | 679 |
function onGearDamage(gear, damage) |
680 |
if not gameOver and GetGearType(gear) == gtHedgehog then |
|
681 |
totalDamage = totalDamage + damage |
|
682 |
end |
|
683 |
end |
|
684 |
||
685 |
function onHogAttack(ammoType) |
|
686 |
-- Record skips for achievement |
|
687 |
if ammoType == amSkip then |
|
688 |
local team = GetHogTeamName(CurrentHedgehog) |
|
689 |
increaseTeamValue(team, "Skips") |
|
690 |
if(getTeamValue(team, "Skips") > recordSkips) then |
|
691 |
recordSkips = getTeamValue(team, "Skips") |
|
692 |
recordSkipsHogName = getGearValue(CurrentHedgehog, "Name") |
|
693 |
recordSkipsTeamName = team |
|
694 |
end |
|
695 |
end |
|
696 |
end |
|
697 |
||
11015 | 698 |
function onGearAdd(gear) |
699 |
||
700 |
-- Catch hedgehogs for the tracker |
|
701 |
if GetGearType(gear) == gtHedgehog then |
|
702 |
trackGear(gear) |
|
703 |
hhs[numhhs] = gear |
|
704 |
numhhs = numhhs + 1 |
|
705 |
SetEffect(gear, heResurrectable, 1) |
|
706 |
end |
|
707 |
end |
|
708 |
||
709 |
function checkEmptyTeam (teamName) |
|
710 |
for i=0 , #hhs do |
|
711 |
if hhs[i]~=nil then |
|
712 |
if teamName == GetHogTeamName(hhs[i]) then |
|
713 |
return false |
|
714 |
end |
|
715 |
end |
|
716 |
end |
|
717 |
return true |
|
718 |
end |
|
719 |
||
720 |
function onGearDelete(gear) |
|
721 |
-- Remove hogs that are gone |
|
722 |
if GetGearType(gear) == gtHedgehog then |
|
723 |
numhhs = numhhs - 1 |
|
724 |
||
725 |
local found |
|
726 |
for i=0, #hhs do |
|
727 |
if hhs[i] == gear then |
|
728 |
found = i |
|
729 |
break |
|
730 |
end |
|
731 |
end |
|
732 |
for i = found, #hhs - 1 do |
|
733 |
hhs[i] = hhs[i + 1] |
|
734 |
end |
|
735 |
hhs[#hhs] = nil |
|
736 |
||
737 |
local t_name = GetHogTeamName(gear) |
|
738 |
if checkEmptyTeam(t_name) then |
|
739 |
for i = 0, TeamsCount - 1 do |
|
740 |
if teams[i] == t_name then |
|
741 |
found = i |
|
742 |
break |
|
743 |
end |
|
744 |
end |
|
745 |
for i = found, TeamsCount - 2 do |
|
746 |
teams[i] = teams[i + 1] |
|
747 |
end |
|
748 |
teams[TeamsCount - 1] = nil |
|
749 |
TeamsCount = TeamsCount - 1 |
|
750 |
end |
|
751 |
AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
752 |
trackDeletion(gear) |
|
11909 | 753 |
elseif GetGearType(gear) == gtCase then |
754 |
-- Check if a crate has been collected |
|
755 |
if band(GetGearMessage(gear), gmDestroy) ~= 0 and CurrentHedgehog ~= nil then |
|
756 |
-- Update crate collection achievement |
|
757 |
increaseTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") |
|
758 |
if(getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") > recordCrates) then |
|
759 |
recordCrates = getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") |
|
760 |
recordCratesHogName = getGearValue(CurrentHedgehog, "Name") |
|
761 |
recordCratesTeamName = GetHogTeamName(CurrentHedgehog) |
|
762 |
end |
|
763 |
end |
|
11015 | 764 |
end |
765 |
end |
|
766 |
||
767 |
function onParameters() |
|
768 |
parseParams() |
|
769 |
winScore = tonumber(params["winscore"]) or winScore |
|
770 |
end |
|
771 |
||
772 |
--[[ |
|
773 |
S T A R R I N G |
|
774 |
prof - Coding, implementing and evangelism |
|
775 |
vos - Initial idea and script improvements |
|
776 |
mikade - Moving the `how to play` into the game so that people know `how to play`, and whitespace :D |
|
777 |
--]] |