117 |
117 |
118 local numTeams -- store the number of teams in the game |
118 local numTeams -- store the number of teams in the game |
119 local teamNameArr = {} -- store the list of teams |
119 local teamNameArr = {} -- store the list of teams |
120 local teamSize = {} -- store how many hogs per team |
120 local teamSize = {} -- store how many hogs per team |
121 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 |
|
122 local clanTeams = {} -- list of teams per clan |
122 |
123 |
123 ------------------- |
124 ------------------- |
124 -- flag variables |
125 -- flag variables |
125 ------------------- |
126 ------------------- |
126 |
127 |
226 |
227 |
227 function CheckScore(teamID) |
228 function CheckScore(teamID) |
228 |
229 |
229 if teamID == 0 then |
230 if teamID == 0 then |
230 alt = 1 |
231 alt = 1 |
231 winner = "Red" |
|
232 |
232 |
233 elseif teamID == 1 then |
233 elseif teamID == 1 then |
234 alt = 0 |
234 alt = 0 |
235 winner = "Blue" |
|
236 end |
235 end |
237 |
236 |
238 if fCaptures[teamID] == 3 then |
237 if fCaptures[teamID] == 3 then |
239 for i = 0, (numhhs-1) do |
238 for i = 0, (numhhs-1) do |
240 if GetHogClan(hhs[i]) == alt then |
239 if GetHogClan(hhs[i]) == alt then |
241 SetEffect(hhs[i], heResurrectable, 0) |
240 SetEffect(hhs[i], heResurrectable, 0) |
242 SetHealth(hhs[i],0) |
241 SetHealth(hhs[i],0) |
243 end |
242 end |
244 end |
243 end |
245 --ShowMission("GAME OVER!", "Victory for the " .. winner .. " Team!", "Hooray!", 0, 0) |
|
246 ShowMission(loc("GAME OVER!"), loc("Victory for the ") .. GetHogTeamName(CurrentHedgehog), loc("Hooray!"), 0, 0) |
244 ShowMission(loc("GAME OVER!"), loc("Victory for the ") .. GetHogTeamName(CurrentHedgehog), loc("Hooray!"), 0, 0) |
247 end |
245 end |
248 |
246 |
249 end |
247 end |
250 |
248 |
251 function HandleRespawns() |
249 function HandleRespawns() |
252 |
250 |
253 for i = 0, 1 do |
251 for i = 0, 1 do |
254 |
252 |
255 if fNeedsRespawn[i] == true then |
253 if fNeedsRespawn[i] == true then |
256 fGear[i] = SpawnAmmoCrate(fSpawnX[i],fSpawnY[i],amSkip) |
254 fGear[i] = SpawnFakeAmmoCrate(fSpawnX[i],fSpawnY[i],false,false) |
257 --fGear[i] = SpawnHealthCrate(fSpawnX[i],fSpawnY[i]) |
255 --fGear[i] = SpawnHealthCrate(fSpawnX[i],fSpawnY[i]) |
258 fNeedsRespawn[i] = false |
256 fNeedsRespawn[i] = false |
259 fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score |
257 fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score |
260 AddCaption(loc("Flag respawned!")) |
258 AddCaption(loc("Flag respawned!")) |
261 end |
259 end |
290 fNeedsRespawn[wtf] = true |
289 fNeedsRespawn[wtf] = true |
291 fIsMissing[bbq] = false |
290 fIsMissing[bbq] = false |
292 fNeedsRespawn[bbq] = true |
291 fNeedsRespawn[bbq] = true |
293 fCaptures[wtf] = fCaptures[wtf] +1 --fCaptures[wtf] |
292 fCaptures[wtf] = fCaptures[wtf] +1 --fCaptures[wtf] |
294 |
293 |
295 --ShowMission(LOC_NOT("You have SCORED!!"), "Red Team: " .. fCaptures[0], "Blue Team: " .. fCaptures[1], -amBazooka, 0) |
294 AddCaption(string.format(loc("%s has scored!"), GetHogTeamName(CurrentHedgehog)), 0xFFFFFFFF, capgrpGameState) |
296 ShowMission(loc("You have SCORED!!"), GetHogTeamName(CurrentHedgehog) .. ": " .. fCaptures[wtf], loc("Opposing Team: ") .. fCaptures[bbq], 0, 0) |
295 for i=1, #clanTeams[wtf] do |
297 |
296 SetTeamLabel(clanTeams[wtf][i], fCaptures[wtf]) |
298 PlaySound(sndVictory) |
297 end |
|
298 |
|
299 PlaySound(sndHomerun) |
299 --SetEffect(fThief[bbq], hePoisoned, false) |
300 --SetEffect(fThief[bbq], hePoisoned, false) |
300 fThief[bbq] = nil -- player no longer has the enemy flag |
301 fThief[bbq] = nil -- player no longer has the enemy flag |
301 CheckScore(wtf) |
302 CheckScore(wtf) |
302 |
303 |
303 --if the player is returning the flag |
304 --if the player is returning the flag |
374 end |
375 end |
375 |
376 |
376 if fThief[wtf] ~= nil then |
377 if fThief[wtf] ~= nil then |
377 |
378 |
378 if fThiefY[wtf] > 2040 then |
379 if fThiefY[wtf] > 2040 then |
379 fGear[wtf] = SpawnAmmoCrate(fThiefX[wtf],(fThiefY[wtf]+10),amSkip) |
380 fGear[wtf] = SpawnFakeAmmoCrate(fThiefX[wtf],(fThiefY[wtf]+10),false,false) |
380 else |
381 else |
381 fGear[wtf] = SpawnAmmoCrate(fThiefX[wtf],(fThiefY[wtf]-50),amSkip) |
382 fGear[wtf] = SpawnFakeAmmoCrate(fThiefX[wtf],(fThiefY[wtf]-50),false,false) |
382 end |
383 end |
383 |
384 |
384 AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false) |
385 AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false) |
385 fThief[wtf] = nil |
386 fThief[wtf] = nil |
386 end |
387 end |
475 function RebuildTeamInfo() |
476 function RebuildTeamInfo() |
476 |
477 |
477 |
478 |
478 -- make a list of individual team names |
479 -- make a list of individual team names |
479 for i = 0, (TeamsCount-1) do |
480 for i = 0, (TeamsCount-1) do |
480 teamNameArr[i] = i |
481 teamNameArr[i] = GetTeamName(i) |
481 teamSize[i] = 0 |
482 teamSize[i] = 0 |
482 teamIndex[i] = 0 |
483 teamIndex[i] = 0 |
483 end |
484 SetTeamLabel(teamNameArr[i], "0") |
484 numTeams = 0 |
485 end |
485 |
486 numTeams = TeamsCount |
486 for i = 0, (numhhs-1) do |
|
487 |
|
488 z = 0 |
|
489 unfinished = true |
|
490 while(unfinished == true) do |
|
491 |
|
492 newTeam = true |
|
493 tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name |
|
494 |
|
495 if tempHogTeamName == teamNameArr[z] then |
|
496 newTeam = false |
|
497 unfinished = false |
|
498 end |
|
499 |
|
500 z = z + 1 |
|
501 |
|
502 if z == TeamsCount then |
|
503 unfinished = false |
|
504 if newTeam == true then |
|
505 teamNameArr[numTeams] = tempHogTeamName |
|
506 numTeams = numTeams + 1 |
|
507 end |
|
508 end |
|
509 |
|
510 end |
|
511 |
|
512 end |
|
513 |
487 |
514 -- find out how many hogs per team, and the index of the first hog in hhs |
488 -- find out how many hogs per team, and the index of the first hog in hhs |
515 for i = 0, numTeams-1 do |
489 for i = 0, numTeams-1 do |
516 |
490 |
517 for z = 0, numhhs-1 do |
491 for z = 0, numhhs-1 do |
518 if GetHogTeamName(hhs[z]) == teamNameArr[i] then |
492 if GetHogTeamName(hhs[z]) == teamNameArr[i] then |
519 if teamSize[i] == 0 then |
493 if teamSize[i] == 0 then |
520 teamIndex[i] = z -- should give starting index |
494 teamIndex[i] = z -- should give starting index |
521 end |
495 end |
522 teamSize[i] = teamSize[i] + 1 |
496 teamSize[i] = teamSize[i] + 1 |
523 --add a pointer so this hog appears at i in hhs |
497 |
|
498 local clan = GetHogClan(hhs[z]) |
|
499 -- Also remember the clan to which the team belongs to |
|
500 if not clanTeams[clan] then |
|
501 clanTeams[clan] = {} |
|
502 end |
|
503 table.insert(clanTeams[clan], teamNameArr[i]) |
524 end |
504 end |
525 end |
505 end |
|
506 |
526 |
507 |
527 end |
508 end |
528 |
509 |
529 end |
510 end |
530 |
511 |
626 fSpawnY[0] = 1747 |
607 fSpawnY[0] = 1747 |
627 fSpawnX[1] = 3123 |
608 fSpawnX[1] = 3123 |
628 fSpawnY[1] = 1747 |
609 fSpawnY[1] = 1747 |
629 |
610 |
630 for i = 0, 1 do |
611 for i = 0, 1 do |
631 fGear[i] = SpawnAmmoCrate(fSpawnX[i],fSpawnY[i],amSkip) |
612 fGear[i] = SpawnFakeAmmoCrate(fSpawnX[i],fSpawnY[i],false,false) |
632 fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true) |
613 fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true) |
633 fCol[i] = GetClanColor(i) |
614 fCol[i] = GetClanColor(i) |
634 |
615 |
635 fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true) |
616 fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true) |
636 SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 10, 200, 1, 10, 0, 300, 5, fCol[i]) |
617 SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 10, 200, 1, 10, 0, 300, 5, fCol[i]) |