74 --SCRIPT BEGINS |
77 --SCRIPT BEGINS |
75 ----------------- |
78 ----------------- |
76 |
79 |
77 -- enable awesome translaction support so we can use loc() wherever we want |
80 -- enable awesome translaction support so we can use loc() wherever we want |
78 HedgewarsScriptLoad("/Scripts/Locale.lua") |
81 HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
82 HedgewarsScriptLoad("/Scripts/Params.lua") |
79 |
83 |
80 --------------------------------------------------------------- |
84 --------------------------------------------------------------- |
81 ----------lots of bad variables and things |
85 ----------lots of bad variables and things |
82 ----------because someone is too lazy |
86 ----------because someone is too lazy |
83 ----------to read about tables properly |
87 ----------to read about tables properly |
84 ------------------ "Oh well, they probably have the memory" |
88 ------------------ "Oh well, they probably have the memory" |
85 |
89 |
86 local gameStarted = false |
90 local gameStarted = false |
87 local gameTurns = 0 |
91 local gameTurns = 0 |
|
92 local captureLimit = 3 |
88 |
93 |
89 -------------------------- |
94 -------------------------- |
90 -- hog and team tracking variales |
95 -- hog and team tracking variales |
91 -------------------------- |
96 -------------------------- |
92 |
97 |
138 alt = 1 |
143 alt = 1 |
139 elseif teamID == 1 then |
144 elseif teamID == 1 then |
140 alt = 0 |
145 alt = 0 |
141 end |
146 end |
142 |
147 |
143 if fCaptures[teamID] == 3 then |
148 if fCaptures[teamID] == captureLimit then |
144 for i = 0, (numhhs-1) do |
149 for i = 0, (numhhs-1) do |
145 if hhs[i] ~= nil then |
150 if hhs[i] ~= nil then |
146 if GetHogClan(hhs[i]) == alt then |
151 if GetHogClan(hhs[i]) == alt then |
147 SetEffect(hhs[i], heResurrectable, 0) |
152 SetEffect(hhs[i], heResurrectable, 0) |
148 SetHealth(hhs[i],0) |
153 SetHealth(hhs[i],0) |
442 |
447 |
443 ------------------------ |
448 ------------------------ |
444 -- game methods |
449 -- game methods |
445 ------------------------ |
450 ------------------------ |
446 |
451 |
|
452 function onParameters() |
|
453 parseParams() |
|
454 if params["captures"] ~= nil then |
|
455 local s = string.match(params["captures"], "(%d*)") |
|
456 if s ~= nil then |
|
457 captureLimit = math.max(1, tonumber(s)) |
|
458 end |
|
459 end |
|
460 end |
|
461 |
447 function onGameInit() |
462 function onGameInit() |
448 |
463 |
449 DisableGameFlags(gfKing) |
464 DisableGameFlags(gfKing) |
450 EnableGameFlags(gfDivideTeams) |
465 EnableGameFlags(gfDivideTeams) |
451 |
466 |
454 Delay = 10 |
469 Delay = 10 |
455 |
470 |
456 end |
471 end |
457 |
472 |
458 function showMissionAndScorebar(instaHide) |
473 function showMissionAndScorebar(instaHide) |
459 local place = loc("Flag placement phase: Flags, and their home base will be placed|where each team ends their first turn.") |
474 local captures |
|
475 if captureLimit == 1 then |
|
476 captures = string.format(loc("- First team to capture the flag wins"), captureLimit) |
|
477 else |
|
478 captures = string.format(loc("- First team to score %d captures wins"), captureLimit) |
|
479 end |
460 |
480 |
461 local rules = loc("Rules:") .. " |" .. |
481 local rules = loc("Rules:") .. " |" .. |
|
482 loc("- Place your team flag at the end of your first turn") .. "|" .. |
462 loc("- Return the enemy flag to your base to score") .."|".. |
483 loc("- Return the enemy flag to your base to score") .."|".. |
463 loc("- First team to score 3 captures wins") .."|".. |
484 captures .. "|" .. |
464 loc("- You may only score when your flag is in your base") .."|".. |
485 loc("- You may only score when your flag is in your base") .."|".. |
465 loc("- Hogs will drop the flag when killed") .."|".. |
486 loc("- Hogs will drop the flag when killed") .."|".. |
466 loc("- Dropped flags may be returned or recaptured").."|".. |
487 loc("- Dropped flags may be returned or recaptured").."|".. |
467 loc("- Hogs respawn when killed") |
488 loc("- Hogs will be revived") |
468 |
489 |
469 local mission |
490 local scoreboard = "" |
470 |
491 |
471 if gameTurns <= 2 then |
492 if gameStarted then |
472 mission = place |
493 scoreboard = "|" .. loc("Scores: ") .. "|" |
473 else |
494 for i=0, 1 do |
474 local scoreboard = "" |
495 scoreboard = scoreboard .. string.format(loc("%s: %d"), teamNameArr[i], fCaptures[i]) |
475 |
496 if i~=1 then scoreboard = scoreboard .. "|" end |
476 if gameStarted then |
497 end |
477 scoreboard = "|" .. loc("Scores: ") .. "|" |
498 end |
478 for i=0, 1 do |
499 local mission = rules .. scoreboard |
479 scoreboard = scoreboard .. string.format(loc("%s: %d"), teamNameArr[i], fCaptures[i]) |
|
480 if i~=1 then scoreboard = scoreboard .. "|" end |
|
481 end |
|
482 end |
|
483 mission = rules .. scoreboard |
|
484 end |
|
485 |
500 |
486 ShowMission(loc("Capture The Flag"), loc("A Hedgewars minigame"), mission, 0, 0) |
501 ShowMission(loc("Capture The Flag"), loc("A Hedgewars minigame"), mission, 0, 0) |
487 if instaHide then |
502 if instaHide then |
488 HideMission() |
503 HideMission() |
489 end |
504 end |
531 --new method of placing starting flags |
546 --new method of placing starting flags |
532 elseif gameTurns == 1 then |
547 elseif gameTurns == 1 then |
533 showMissionAndScorebar() |
548 showMissionAndScorebar() |
534 elseif gameTurns == 2 then |
549 elseif gameTurns == 2 then |
535 fPlaced[0] = true |
550 fPlaced[0] = true |
536 showMissionAndScorebar() |
|
537 elseif gameTurns == 3 then |
551 elseif gameTurns == 3 then |
538 fPlaced[1] = true |
552 fPlaced[1] = true |
539 showMissionAndScorebar() |
|
540 StartTheGame() |
553 StartTheGame() |
541 end |
554 end |
542 |
555 |
543 end |
556 end |
544 |
557 |