diff options
Diffstat (limited to 'TemplePushing.c4s/Script.c')
| -rw-r--r-- | TemplePushing.c4s/Script.c | 135 |
1 files changed, 107 insertions, 28 deletions
diff --git a/TemplePushing.c4s/Script.c b/TemplePushing.c4s/Script.c index a3c12a3..a37985f 100644 --- a/TemplePushing.c4s/Script.c +++ b/TemplePushing.c4s/Script.c @@ -2,8 +2,14 @@ #strict 2 +static const MODE_Normal = 0, MODE_ScrollsOnly = 1, MODE_Cancer = 2; +static const MENU_Landscape = 0, MENU_Mode = 1, MENU_Settings = 2; + +static setupDone, setupPlayer; +static gameMode; +static landscape; +static deathmatchEnabled, deathmatchKillLimit; static relaunches, playerScore, teamScore; -static deathmatchKillLimit; static g_iSaveSectIndex,szSection; static pChooser,iDif; @@ -21,27 +27,114 @@ func Initialize() CreateObject(BRK2, 225, 150, NO_OWNER); CreateObject(BRK2, 985, 150, NO_OWNER); - // Create relaunch counter, player score and team score arrays + // Initial values + deathmatchKillLimit = 20; + setupDone = false; + setupPlayer = -1; relaunches = CreateArray(); playerScore = CreateArray(); teamScore = CreateArray(); - deathmatchKillLimit = 20; - // Initialize scoreboard SetScoreboardData(SBRD_Caption, 0, "{{MELE}}"); SetScoreboardData(SBRD_Caption, 1, "{{GBLT}}"); SetScoreboardData(SBRD_Caption, 2, "{{CXIV}}"); + DoScoreboardShow(1); + + ScriptGo(true); } -func InitializePlayer(int plr) +func InitializePlayer(int player) { - if (!iDif && GetCrew(GetPlayerCount() - 1)) InitializePlayer2(0); - if (!FindObject(DTHM)) relaunches[plr] = 10; - playerScore[plr] = 0; + if (!setupDone && setupPlayer == -1) + { + setupPlayer = player; + ShowSetup(); + } + + /*if (!iDif && GetCrew(GetPlayerCount() - 1)) InitializePlayer2(0); + if (!FindObject(DTHM)) relaunches[player] = 10;*/ + UpdateScoreboard(); - DoScoreboardShow(1); - ScriptGo(true); +} + +func RemovePlayer(int player, int team) +{ + playerScore[player] = 0; + UpdateScoreboard(); + + // Player leaves and is still in setup? + if (!setupDone && setupPlayer == player) + { + // Try to find any other player to continue setup + for (var i = 0; i < GetPlayerCount(); ++i) + { + setupPlayer = GetPlayerByIndex(i); + if (setupPlayer != player) + { + ShowSetup(); + return; + } + } + } + + // No other players? + setupPlayer = -1; +} + +func ShowSetup(int menuStage, int selection, bool back) +{ + var clonk = GetCrew(setupPlayer); + + // Clonk already in setup menu? + if (clonk->GetMenu()) return; + + //int CreateMenu (id idSymbol, object pMenuObject, object pCommandObject, int iExtra, string szCaption, int iExtraData, int iStyle, bool fPermanent, id idMenuID); + //int AddMenuItem (string szCaption, string szCommand, id idItem, object pMenuObject, int iCount, int iParameter, string szInfoCaption, int iExtra, any XPar1, any XPar2); + + CreateMenu(ROCK, clonk, 0, C4MN_Extra_None, 0, 0, C4MN_Style_Context); + + if (menuStage == MENU_Landscape) + { + clonk->AddMenuItem("Default landscape", "ShowSetup(MENU_Mode, 0)", ROCK); + } + else if (menuStage == MENU_Mode) + { + if (!back) landscape = selection; + + // List modes + + var modes = [ + ["Normal", MODE_Normal], + ["Scrolls only", MODE_ScrollsOnly], + ["Cancer", MODE_Cancer]]; + + var itemIndex = 0; + for (var mode in modes) + { + clonk->AddMenuItem(mode[0], Format("ShowSetup(MENU_Settings, %d)", mode[1]), ROCK); + if (mode[1] == gameMode) clonk->SelectMenuItem(itemIndex); + ++itemIndex; + } + + clonk->AddMenuItem("Back", "ShowSetup(MENU_Landscape, 0, true)", ROCK); + } + else if (menuStage == MENU_Settings) + { + if (!back) gameMode = selection; + clonk->AddMenuItem("Back", "ShowSetup(MENU_Mode, 0, true)", ROCK); + } +} + +func Script2() +{ + // Reopen setup menu if it was closed (by player or runtime join) + if (!setupDone && setupPlayer != -1) ShowSetup(); + + UpdateScoreboard(); + + goto(1); + return 1; } func OnClonkDeath(object clonk, int killedBy) @@ -59,7 +152,7 @@ func OnClonkDeath(object clonk, int killedBy) } else { - // Deathmatch: Decrement kill counter on suicide or team kill. + // Deathmatch: Decrement score on suicide or team kill. if (isDeathmatch) --playerScore[killedBy]; } @@ -77,15 +170,11 @@ func OnClonkDeath(object clonk, int killedBy) --relaunches[player]; } - // Show relaunch message. Warn player if he only has one/no relaunch(es) remaining. + // Show relaunch message. Warn player if it was his last relaunch. if (relaunches[player] == 0) { PlayerMessage(player, "$MsgLastRelaunch$"); } - if (relaunches[player] == 1) - { - PlayerMessage (player, "$MsgOneRelaunch$"); - } else { PlayerMessage(player, "$MsgRelaunch$", 0, relaunches[player]); @@ -181,11 +270,11 @@ func UpdateScoreboard() SetScoreboardData(plr, 2, Format("%d", playerScore[plr])); if (relaunches[plr] < 0) { - SetScoreboardData(plr, 1, WarningText("$Death$")); + SetScoreboardData(plr, 1, Format("<c c80000>%s</c>", "$Death$")); } else if (relaunches[plr] <= 1) { - SetScoreboardData(plr, 1, WarningInt(relaunches[plr])); + SetScoreboardData(plr, 1, Format("<c c80000>%d</c>", relaunches[plr])); } else { @@ -194,16 +283,6 @@ func UpdateScoreboard() } } -func Script2() -{ - UpdateScoreboard(); - goto(1); - return 1; -} - -global func WarningText(sText) { return(Format("<c %x>%s</c>",RGB(200,0,0),sText)); } -global func WarningInt(iText) { return(Format("<c %x>%d</c>",RGB(200,0,0),iText)); } - /*-----------------------Spielmodi-----------------------*/ //Auswahl |
