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