103 |
103 |
104 local roundsCounter = 0 -- used to determine when to spawn more crates |
104 local roundsCounter = 0 -- used to determine when to spawn more crates |
105 -- currently every 6 TURNS, should this work |
105 -- currently every 6 TURNS, should this work |
106 -- on ROUNDS instead? |
106 -- on ROUNDS instead? |
107 local effectTimer = 0 |
107 local effectTimer = 0 |
|
108 local gameEnded = false |
108 |
109 |
109 local ropeGear = nil |
110 local ropeGear = nil |
110 |
111 |
111 -------------------------- |
112 -------------------------- |
112 -- hog and team tracking variales |
113 -- hog and team tracking variales |
117 |
118 |
118 local teamNameArr = {} -- store the list of teams |
119 local teamNameArr = {} -- store the list of teams |
119 local teamSize = {} -- store how many hogs per team |
120 local teamSize = {} -- store how many hogs per team |
120 local teamIndex = {} -- at what point in the hhs{} does each team begin |
121 local teamIndex = {} -- at what point in the hhs{} does each team begin |
121 local clanTeams = {} -- list of teams per clan |
122 local clanTeams = {} -- list of teams per clan |
|
123 |
|
124 local mostCapturesHogName = nil -- name of hog who holds the record of most flags captured |
|
125 local mostCapturesHogTeam = nil -- name of team who holds the record of most flags captured |
|
126 local mostCaptures = 0 -- number of most per-hog captures |
|
127 local capturesPerHog = {} |
122 |
128 |
123 ------------------- |
129 ------------------- |
124 -- flag variables |
130 -- flag variables |
125 ------------------- |
131 ------------------- |
126 |
132 |
228 |
234 |
229 elseif teamID == 1 then |
235 elseif teamID == 1 then |
230 alt = 0 |
236 alt = 0 |
231 end |
237 end |
232 |
238 |
233 if fCaptures[teamID] == 3 then |
239 if fCaptures[teamID] == 3 and not gameEnded then |
|
240 gameEnded = true |
234 for i = 0, (numhhs-1) do |
241 for i = 0, (numhhs-1) do |
235 if GetHogClan(hhs[i]) == alt then |
242 if GetHogClan(hhs[i]) == alt then |
236 SetEffect(hhs[i], heResurrectable, 0) |
243 SetEffect(hhs[i], heResurrectable, 0) |
237 SetHealth(hhs[i],0) |
244 SetHealth(hhs[i],0) |
238 end |
245 end |
239 end |
246 end |
240 local victoryMsg = string.format(loc("Victory for %s!"), GetHogTeamName(CurrentHedgehog)) |
247 local victoryMsg = string.format(loc("Victory for %s!"), GetHogTeamName(CurrentHedgehog)) |
241 AddCaption(victoryMsg, capcolDefault, capgrpGameState) |
248 AddCaption(victoryMsg, capcolDefault, capgrpGameState) |
|
249 |
|
250 -- Calculate team rankings |
|
251 local teamList = {} |
|
252 for i=0, TeamsCount-1 do |
|
253 local name = GetTeamName(i) |
|
254 local clan = GetTeamClan(name) |
|
255 if fCaptures[clan] ~= nil then |
|
256 table.insert(teamList, { score = fCaptures[clan], name = name, clan = clan }) |
|
257 end |
|
258 end |
|
259 local teamRank = function(a, b) |
|
260 return a.score > b.score |
|
261 end |
|
262 table.sort(teamList, teamRank) |
|
263 |
|
264 for i=1, #teamList do |
|
265 SendStat(siPointType, "!POINTS") |
|
266 SendStat(siPlayerKills, tostring(teamList[i].score), teamList[i].name) |
|
267 end |
|
268 if mostCaptures >= 2 then |
|
269 SendStat(siCustomAchievement, string.format(loc("%s (%s) has captured the flag %d times."), mostCapturesHogName, mostCapturesHogTeam, mostCaptures)) |
|
270 end |
242 end |
271 end |
243 |
272 |
244 end |
273 end |
245 |
274 |
246 function HandleRespawns() |
275 function HandleRespawns() |
286 fCaptures[wtf] = fCaptures[wtf] +1 |
315 fCaptures[wtf] = fCaptures[wtf] +1 |
287 |
316 |
288 AddCaption(string.format(loc("%s has scored!"), GetHogTeamName(CurrentHedgehog)), capcolDefault, capgrpGameState) |
317 AddCaption(string.format(loc("%s has scored!"), GetHogTeamName(CurrentHedgehog)), capcolDefault, capgrpGameState) |
289 for i=1, #clanTeams[wtf] do |
318 for i=1, #clanTeams[wtf] do |
290 SetTeamLabel(clanTeams[wtf][i], fCaptures[wtf]) |
319 SetTeamLabel(clanTeams[wtf][i], fCaptures[wtf]) |
|
320 end |
|
321 |
|
322 capturesPerHog[CurrentHedgehog] = capturesPerHog[CurrentHedgehog] + 1 |
|
323 if capturesPerHog[CurrentHedgehog] > mostCaptures then |
|
324 mostCaptures = capturesPerHog[CurrentHedgehog] |
|
325 mostCapturesHogName = GetHogName(CurrentHedgehog) |
|
326 mostCapturesHogTeam = GetHogTeamName(CurrentHedgehog) |
291 end |
327 end |
292 |
328 |
293 PlaySound(sndHomerun) |
329 PlaySound(sndHomerun) |
294 fThief[bbq] = nil -- player no longer has the enemy flag |
330 fThief[bbq] = nil -- player no longer has the enemy flag |
295 CheckScore(wtf) |
331 CheckScore(wtf) |
711 |
750 |
712 function onGearAdd(gear) |
751 function onGearAdd(gear) |
713 |
752 |
714 if GetGearType(gear) == gtHedgehog then |
753 if GetGearType(gear) == gtHedgehog then |
715 |
754 |
|
755 capturesPerHog[gear] = 0 |
716 if GetHogClan(gear) > 1 then |
756 if GetHogClan(gear) > 1 then |
717 DeleteGear(gear) |
757 DeleteGear(gear) |
718 if not excessHogsWarning then |
758 if not excessHogsWarning then |
719 WriteLnToChat(loc("Only two clans allowed! Excess hedgehogs will be removed.")) |
759 WriteLnToChat(loc("Only two clans allowed! Excess hedgehogs will be removed.")) |
720 excessHogsWarning = true |
760 excessHogsWarning = true |