diff options
| author | Jan <> | 2015-07-10 18:11:22 +0200 |
|---|---|---|
| committer | Jan <_> | 2015-07-10 18:47:01 +0200 |
| commit | f1ece16c08d8c01e1d49a25f0314a96c021e73cb (patch) | |
| tree | 9bc9f547f2524dee8e62f168f317df465a6cbcdd /TemplePushing.c4s/Script.c | |
| parent | 80b15646d73587f4e15a2897314692b58aa1a47f (diff) | |
| download | tempelschubsen-f1ece16c08d8c01e1d49a25f0314a96c021e73cb.tar.gz tempelschubsen-f1ece16c08d8c01e1d49a25f0314a96c021e73cb.zip | |
r0.921
Diffstat (limited to 'TemplePushing.c4s/Script.c')
| -rw-r--r-- | TemplePushing.c4s/Script.c | 149 |
1 files changed, 129 insertions, 20 deletions
diff --git a/TemplePushing.c4s/Script.c b/TemplePushing.c4s/Script.c index 488b606..9c39a8d 100644 --- a/TemplePushing.c4s/Script.c +++ b/TemplePushing.c4s/Script.c @@ -5,10 +5,10 @@ static const MODE_Classic = 0, MODE_Magic = 1, MODE_Festive = 2, MODE_Apocalyptic = 3, MODE_Knightly = 4; static const SBRD_FirstRow = 0; -static const SBRD_NameCol = 0, SBRD_RelaunchesCol = 1, SBRD_ScoreCol = 2; -static const SORT_NAMECOL_Title = 0, SORT_NAMECOL_Team = 1, SORT_NAMECOL_Player = 2, SORT_NAMECOL_Leaver = 3; +static const SBRD_TeamSortCol = -3, SBRD_SortCol = -2, SBRD_NameCol = -1, SBRD_RelaunchesCol = 0, SBRD_ScoreCol = 1; +static const SORT_SORTCOL_Team = 0, SORT_SORTCOL_Player = 1, SORT_SORTCOL_Leaver = 2; -static const MaxTeamCount = 2; +static const MaxTeamCount = 3; static section, mode; static numRelaunches; @@ -17,11 +17,13 @@ static playerDeaths, playerScore, teamScore; static ambienceEnabled; static suddendeathEnabled; static loadingSection; +static eliminatedPlayers; static gameStartMessage, countdown, gameStarted, gameOver; func Initialize() { ShowLobby(); + eliminatedPlayers = []; // Create Thrones for recreational purposes CreateObject(THRN, 590, 420, NO_OWNER); @@ -39,8 +41,14 @@ func Initialize() menu->LocalN("extinguisherEnabled") = true; menu->LocalN("rotateInJumpEnabled") = true; menu->LocalN("numRelaunches") = 10; - menu->LocalN("deathmatchWinScore") = 20; - menu->LocalN("ambienceEnabled") = true; + menu->LocalN("deathmatchWinScore") = 15; + menu->LocalN("ambienceEnabled") = !GetLeague(); + + // Modulate endscreen + SetNextMission("TemplePushing.c4s", "Rematch", "$Rematch$"); + + // Set possible spells + SetScrollSpells([ABLA, MBOT, MFRB, MDBT, GVTY, MLGT, CFAL, MSSH, MINV, MARK, MFWV, MGFL, LAVS, MGPL, ICNL, MDFL, AFST, MGCY, MATT]); ScriptGo(true); } @@ -62,10 +70,13 @@ func InitializePlayer(int player) var team = GetPlayerTeam(player); if (team) { - SetScoreboardData(TeamRow(team), SBRD_NameCol, Format("<c %x>Team %s</c>", GetTeamColor(team), GetTeamName(team)), SORT_NAMECOL_Team); + SetScoreboardData(TeamRow(team), SBRD_NameCol, Format("<c %x>Team %s</c>", GetTeamColor(team), GetTeamName(team))); + SetScoreboardData(TeamRow(team), SBRD_SortCol, " ", SORT_SORTCOL_Team); } } - SetScoreboardData(PlayerRow(player), SBRD_NameCol, GetTaggedPlayerName(player), SORT_NAMECOL_Player); + SetScoreboardData(PlayerRow(player), SBRD_NameCol, GetTaggedPlayerName(player)); + SetScoreboardData(PlayerRow(player), SBRD_SortCol, " ", SORT_SORTCOL_Player); + SetScoreboardData(PlayerRow(player), SBRD_TeamSortCol, " ", GetPlayerTeam(player)); UpdateScoreboard(player); LaunchClonk(player, GetCrew(player)); } @@ -78,6 +89,8 @@ func RemovePlayer(int player) if (!LobbyActive() && (!deathmatchEnabled && GetRelaunchesLeft(player) >= 0 || deathmatchEnabled && !gameOver)) { UpdateScoreboard(player, true); + eliminatedPlayers[GetPlayerID(player)] = true; + CheckGameOver(); } } @@ -123,7 +136,8 @@ func UpdateScoreboard(int player, bool leaver) { text = "{{SLVR}}"; // Move leaver to the bottom of the list - SetScoreboardData(PlayerRow(player), SBRD_NameCol, GetTaggedPlayerName(player), SORT_NAMECOL_Leaver); + SetScoreboardData(PlayerRow(player), SBRD_NameCol, GetTaggedPlayerName(player)); + SetScoreboardData(PlayerRow(player), SBRD_SortCol, " ", SORT_SORTCOL_Leaver); } else text = Format("%d", playerScore[playerID]); @@ -131,9 +145,10 @@ func UpdateScoreboard(int player, bool leaver) SetScoreboardData(PlayerRow(player), SBRD_ScoreCol, text, playerScore[playerID]); // Sort rows + SortScoreboard(SBRD_TeamSortCol); SortScoreboard(SBRD_ScoreCol, true); if (!deathmatchEnabled) SortScoreboard(SBRD_RelaunchesCol, true); - SortScoreboard(SBRD_NameCol); + SortScoreboard(SBRD_SortCol); } func ShowLobby() @@ -162,6 +177,15 @@ func StartGame(object menu, string message) Log("After LoadScenarioSection()"); loadingSection = false; section = CreateObject(sectionID, 0, 0, NO_OWNER); + + // Play ambience sounds + if (ambienceEnabled) + { + for(var sound in section->SectionAmbienceSounds()) + { + SoundLevel(sound[0], sound[1]); + } + } // Create spawnpoints if (mode != MODE_Apocalyptic) @@ -173,22 +197,23 @@ func StartGame(object menu, string message) if (mode == MODE_Classic) { - spawnPointSpawner->SetDefinitions([[ROCK, 7], [SCRL, 5], [FLNT, 7], [SFLN, 9], [STFN, 3], [EFLN, 5], [FBMP, 4], [ARWP, 4]]); - spawnPointSpawner->SetSpawnInterval(900); + spawnPointSpawner->SetDefinitions([[ROCK, 5], [SCRL, 5], [FLNT, 4], [SFLN, 9], [STFN, 3], [EFLN, 5], [FBMP, 4]]); + spawnPointSpawner->SetSpawnInterval(800); } if (mode == MODE_Festive) { - spawnPointSpawner->SetDefinitions([[TSWB, 10], [SCRL, 5]]); + spawnPointSpawner->SetDefinitions([[TSWB, 7], [SCRL, 5], [ICE1, 3]]); spawnPointSpawner->SetSpawnInterval(600); } if (mode == MODE_Knightly) { spawnPointSpawner->SetDefinitions([[SFLN, 3], [EFLN,3], [SWOR, 5], [AXE1, 5], [SPER, 2], [ARWP, 5], [SCRL, 5], [FARP, 3]]); - spawnPointSpawner->SetSpawnInterval(1000); + spawnPointSpawner->SetSpawnInterval(800); } if (mode == MODE_Magic) { - spawnPointSpawner->SetDefinitions([[SCRL, 14], [GBLT, 1]]); + if (suddendeathEnabled) spawnPointSpawner->SetDefinitions([[SCRL, 19]]); + else spawnPointSpawner->SetDefinitions([[SCRL, 19], [GBLT, 1]]); spawnPointSpawner->SetSpawnInterval(750); spawnPointSpawner->SetSpawnpointGamma(RGB(5, 5, 10), RGB(80, 80, 150), RGB(200, 200, 255)); } @@ -210,6 +235,7 @@ func StartGame(object menu, string message) if (ambienceEnabled) CreateObject(SNOR, 0, 0, NO_OWNER); SetSkyAdjust(RGB(189, 189, 255)); SetGamma(RGB(0, 0, 50), RGB(100, 100, 128), RGB(200, 200, 255)); + SetScrollSpells([MICS, ABLA, MFWV, MLGT, MGPL, ICNL, AFST, MDFL, MGCY, MATT]); } // Create melee goal @@ -243,14 +269,15 @@ func StartGame(object menu, string message) CreateObject(APCE, 0, 0, NO_OWNER); } - SetScoreboardData(SBRD_Caption, SBRD_NameCol, " ", SORT_NAMECOL_Title); // Make sure the name column gets created first + SetScoreboardData(SBRD_Caption, SBRD_NameCol, " "); // Make sure the name column gets created first // Deathmatch? if (deathmatchEnabled) { Log("Creating deathmatch rule"); CreateObject(DTHM, 0, 0, NO_OWNER); - SetScoreboardData(SBRD_FirstRow, SBRD_NameCol, "$WinScore$", SORT_NAMECOL_Title); + SetScoreboardData(SBRD_FirstRow, SBRD_NameCol, "$WinScore$"); + SetScoreboardData(SBRD_FirstRow, SBRD_SortCol, " "); SetScoreboardData(SBRD_FirstRow, SBRD_ScoreCol, Format("%d $Kills$", deathmatchWinScore)); } else @@ -317,8 +344,49 @@ func ShowCountdown() func LobbyActive() { return !section; } +global func GetActiveTeamCount() +{ + var teams = []; + for(var i = 0; i < GetPlayerCount(); i++) + { + if(!eliminatedPlayers[GetPlayerID(GetPlayerByIndex(i))]) + { + ++teams[GetPlayerTeam(GetPlayerByIndex(i))]; + } + } + + teams[-1] = 0; + var count = 0; + for(var teamCount in teams) + { + if(teamCount > 0) + { + ++count; + } + } + return count; +} + +global func EliminatePlayer(int iPlr, bool fQuiet) +{ + var ret = _inherited(iPlr, fQuiet); + eliminatedPlayers[GetPlayerID(iPlr)] = true; + + // Check if the game is over + CheckGameOver(); + return ret; +} + +global func CheckGameOver() +{ + if (GetActiveTeamCount() <= 1) StartGameOverEffect(); +} + func HandleKill(int killed, int killer) { + // Check if the game is over + if (GetEffectCount("GameOver")) return 0; + // Assume suicide if killer cannot be determined if (killer == NO_OWNER) killer = killed; @@ -409,6 +477,45 @@ func HandleKill(int killed, int killer) return killedEliminated; } +func OnGoalsFulfilled() +{ + // Safety only, GameOver-Effect should have already started + CheckGameOver(); + return 1; +} + +global func StartGameOverEffect() +{ + if (!GetEffect("GameOver")) AddEffect("GameOver", 0, 1, 1); +} + +global func FxGameOverStart(object pTarget, int iEffectNumber) +{ + EffectVar(0, pTarget, iEffectNumber) = section->SectionAmbienceSounds(); +} + +global func FxGameOverTimer(object pTarget, int iEffectNumber, int iEffectTime) +{ + var sounds = EffectVar(0, pTarget, iEffectNumber); + if (iEffectTime <= 100 && ambienceEnabled) + { + for(var sound in sounds) + { + SoundLevel(sound[0], sound[1]*(100 - iEffectTime)/100); + } + } + else if((iEffectTime > 200) || (iEffectTime > 100 && !ambienceEnabled)) + { + return -1; + } +} + +global func FxGameOverStop(object pTarget, int iEffectNumber) +{ + Sound("Trumpet", 1); + GameOver(); +} + func GetPlayers() { var players = CreateArray(GetPlayerCount()); @@ -455,7 +562,7 @@ func LaunchClonk(int player, object clonk, bool relaunch) // Move clonk to random position - var NumCheckPos = 10; + var NumCheckPos = 25; var positions = CreateArray(NumCheckPos); for (var i = 0; i < NumCheckPos; ++i) @@ -488,7 +595,7 @@ func LaunchClonk(int player, object clonk, bool relaunch) clonk->SetCrewEnabled(false); } - // No corpses in apocalopyse mode + // No corpses in apocalypse mode if (mode == MODE_Apocalyptic) clonk->LocalN("removeOnDeath") = true; // Enable rotation in jump for the clonk if allowed by rule @@ -502,12 +609,14 @@ func LaunchClonk(int player, object clonk, bool relaunch) clonk->Schedule("SelectCrew(GetOwner(), this, true)", 20); } + // Respawn effects PlayerMessage(player, "{{SREL}}", clonk); DrawParticleLine("PSpark", GetX(clonk), 0, GetX(clonk), GetY(clonk), 10, 150, RGBa(Random(255), Random(255), Random(255),50), RGBa(Random(255), Random(255), Random(255),50), 0); DrawParticleLine("PSpark", GetX(clonk) + RandomX(5, 60), 0, GetX(clonk), GetY(clonk), 10, 150, RGBa(Random(255), Random(255), Random(255),50), RGBa(Random(255), Random(255), Random(255),50), 0); DrawParticleLine("PSpark", GetX(clonk) - RandomX(5, 60), 0, GetX(clonk), GetY(clonk), 10, 150, RGBa(Random(255), Random(255), Random(255),50), RGBa(Random(255), Random(255), Random(255),50), 0); Sound("PlayerJoin", 0, clonk, 100); CastParticles("MSpark", 50, 20, GetX(clonk), GetY(clonk), 50, 75, RGBa(128,128,255,0), RGBa(255,255,255,127)); + SetPlrView(player, clonk); ResetHealth(clonk); } @@ -524,7 +633,7 @@ func ResetHealth(object clonk) } } -func CheckDeathmatchKillCount() +func CheckGameStatus() { if (GetTeamCount() == 0) { @@ -577,4 +686,4 @@ func CheckDeathmatchKillCount() } } } -}
\ No newline at end of file +} |
