182 fNeedsRespawn[wtf] = true |
182 fNeedsRespawn[wtf] = true |
183 fIsMissing[bbq] = false |
183 fIsMissing[bbq] = false |
184 fNeedsRespawn[bbq] = true |
184 fNeedsRespawn[bbq] = true |
185 fCaptures[wtf] = fCaptures[wtf] +1 |
185 fCaptures[wtf] = fCaptures[wtf] +1 |
186 AddCaption(string.format(loc("%s has scored!"), GetHogName(CurrentHedgehog))) |
186 AddCaption(string.format(loc("%s has scored!"), GetHogName(CurrentHedgehog))) |
187 showMissionAndScorebar() |
187 updateScores() |
188 PlaySound(sndHomerun) |
188 PlaySound(sndHomerun) |
189 fThief[bbq] = nil -- player no longer has the enemy flag |
189 fThief[bbq] = nil -- player no longer has the enemy flag |
190 CheckScore(wtf) |
190 CheckScore(wtf) |
191 |
191 |
192 --if the player is returning the flag |
192 --if the player is returning the flag |
470 |
470 |
471 Delay = 10 |
471 Delay = 10 |
472 |
472 |
473 end |
473 end |
474 |
474 |
475 function showMissionAndScorebar(instaHide) |
475 function showCTFMission() |
476 local captures |
476 local captures |
477 if captureLimit == 1 then |
477 if captureLimit == 1 then |
478 captures = string.format(loc("- First team to capture the flag wins"), captureLimit) |
478 captures = string.format(loc("- First team to capture the flag wins"), captureLimit) |
479 else |
479 else |
480 captures = string.format(loc("- First team to score %d captures wins"), captureLimit) |
480 captures = string.format(loc("- First team to score %d captures wins"), captureLimit) |
487 loc("- You may only score when your flag is in your base") .."|".. |
487 loc("- You may only score when your flag is in your base") .."|".. |
488 loc("- Hogs will drop the flag when killed") .."|".. |
488 loc("- Hogs will drop the flag when killed") .."|".. |
489 loc("- Dropped flags may be returned or recaptured").."|".. |
489 loc("- Dropped flags may be returned or recaptured").."|".. |
490 loc("- Hogs will be revived") |
490 loc("- Hogs will be revived") |
491 |
491 |
492 local scoreboard = "" |
492 ShowMission(loc("Capture The Flag"), loc("A Hedgewars minigame"), rules, 0, 0) |
493 |
493 end |
494 if gameStarted then |
494 |
495 scoreboard = "|" .. loc("Scores: ") .. "|" |
495 function updateScores() |
496 for i=0, 1 do |
496 for i=0, 1 do |
497 scoreboard = scoreboard .. string.format(loc("%s: %d"), teamNameArr[i], fCaptures[i]) |
497 SetTeamLabel(teamNameArr[i], tostring(fCaptures[i])) |
498 if i~=1 then scoreboard = scoreboard .. "|" end |
|
499 end |
|
500 end |
|
501 local mission = rules .. scoreboard |
|
502 |
|
503 ShowMission(loc("Capture The Flag"), loc("A Hedgewars minigame"), mission, 0, 0) |
|
504 if instaHide then |
|
505 HideMission() |
|
506 end |
498 end |
507 end |
499 end |
508 |
500 |
509 function onGameStart() |
501 function onGameStart() |
510 |
502 |
511 showMissionAndScorebar() |
503 showCTFMission() |
512 |
504 |
513 RebuildTeamInfo() |
505 RebuildTeamInfo() |
514 |
506 |
515 -- should gfDivideTeams do this automatically? |
507 -- should gfDivideTeams do this automatically? |
516 --[[for i = 0, (TeamsCount-1) do |
508 --[[for i = 0, (TeamsCount-1) do |
545 --AddCaption("Handling respawns") |
537 --AddCaption("Handling respawns") |
546 if gameStarted == true then |
538 if gameStarted == true then |
547 HandleRespawns() |
539 HandleRespawns() |
548 --new method of placing starting flags |
540 --new method of placing starting flags |
549 elseif gameTurns == 1 then |
541 elseif gameTurns == 1 then |
550 showMissionAndScorebar() |
542 showCTFMission() |
551 elseif gameTurns == 2 then |
543 elseif gameTurns == 2 then |
552 fPlaced[0] = true |
544 fPlaced[0] = true |
553 elseif gameTurns == 3 then |
545 elseif gameTurns == 3 then |
554 fPlaced[1] = true |
546 fPlaced[1] = true |
555 StartTheGame() |
547 StartTheGame() |