summaryrefslogtreecommitdiffstats
path: root/TemplePushing.c4s/Script.c
diff options
context:
space:
mode:
Diffstat (limited to 'TemplePushing.c4s/Script.c')
-rw-r--r--TemplePushing.c4s/Script.c188
1 files changed, 134 insertions, 54 deletions
diff --git a/TemplePushing.c4s/Script.c b/TemplePushing.c4s/Script.c
index 7c0b225..ea02517 100644
--- a/TemplePushing.c4s/Script.c
+++ b/TemplePushing.c4s/Script.c
@@ -1,80 +1,131 @@
-/*-- Klippenschubsen --*/
+/*-- Temple Pushing --*/
#strict 2
-static const MODE_Classic = 0, MODE_SuddenDeath = 1, MODE_Magic = 2, MODE_Apocalyptic = 3;
+static const MODE_Classic = 0, MODE_Magic = 1, MODE_Festive = 2, MODE_Apocalyptic = 3, MODE_Knightly = 4;
+static const SBRD_ScoreCol = 0, SBRD_RelaunchesCol = 1;
+static const MaxTeamCount = 2;
static section, mode;
static numRelaunches;
static deathmatchEnabled, deathmatchWinScore;
static playerDeaths, playerScore, teamScore;
static ambienceEnabled;
+static suddendeathEnabled;
static loadingSection;
static gameStartMessage, countdown, gameStarted, gameOver;
func Initialize()
{
ShowLobby();
+
+ // Create Thrones for recreational purposes...
+ CreateObject(THRN, 590, 420, NO_OWNER);
+ CreateObject(THRN, 470, 210, NO_OWNER);
// Initial values
deathmatchWinScore = 20;
playerDeaths = CreateArray();
playerScore = CreateArray();
teamScore = CreateArray();
- countdown = 5;
+ countdown = 3;
// Create setup menu
var menu = CreateObject(SPMU, 0, 0, NO_OWNER);
menu->LocalN("extinguisherEnabled") = false;
menu->LocalN("rotateInJumpEnabled") = true;
menu->LocalN("numRelaunches") = 10;
- menu->LocalN("deathmatchWinScore") = 25;
+ menu->LocalN("deathmatchWinScore") = 20;
menu->LocalN("ambienceEnabled") = true;
ScriptGo(true);
}
-func TeamRow(int team) { return 1 + team * 1000; }
-func PlayerRow(int player) { return TeamRow(GetPlayerTeam(player)) + GetPlayerID(player); }
+/*func TeamRow(int team) { return 1 + team * 1000; }
+func PlayerRow(int player) { return TeamRow(GetPlayerTeam(player)) + GetPlayerID(player); }*/
+func TeamRow(int team) { return team; }
+func PlayerRow(int player) { return MaxTeamCount + 1 + GetPlayerID(player); }
func InitializePlayer(int player)
{
- if (LobbyActive()) return;
+ SetFoW(false, player);
- var team = GetPlayerTeam(player);
+ if (LobbyActive()) return;
+
playerDeaths[GetPlayerID(player)] = 0;
- if (team) SetScoreboardData(TeamRow(team), SBRD_Caption, Format("<c %x>%s</c>", GetTeamColor(team), GetTeamName(team)), TeamRow(team));
- SetScoreboardData(PlayerRow(player), SBRD_Caption, GetTaggedPlayerName(player), PlayerRow(player));
+ if (deathmatchEnabled)
+ {
+ var team = GetPlayerTeam(player);
+ if (team)
+ {
+ SetScoreboardData(TeamRow(team), SBRD_Caption, Format("<c %x>Team %s</c>", GetTeamColor(team), GetTeamName(team)), 0);
+ }
+ }
+ SetScoreboardData(PlayerRow(player), SBRD_Caption, GetTaggedPlayerName(player), 1);
UpdateScoreboard(player);
- SortScoreboard(SBRD_Caption);
LaunchClonk(player, GetCrew(player));
}
+func GetRelaunchesLeft(int player) { return numRelaunches - playerDeaths[GetPlayerID(player)]; }
+
func RemovePlayer(int player)
{
- if (!LobbyActive())
+ // Leaver?
+ if (!LobbyActive() && (!deathmatchEnabled && GetRelaunchesLeft(player) >= 0 || deathmatchEnabled && !gameOver))
{
- // Leaver?
- var relaunchesLeft = numRelaunches - playerDeaths[GetPlayerID(player)];
- if (!deathmatchEnabled && relaunchesLeft >= 0 || deathmatchEnabled && !gameOver) SetScoreboardData(PlayerRow(player), 0, "{{SLVR}}");
+ UpdateScoreboard(player, true);
}
}
-func UpdateScoreboard(int player)
+func UpdateScoreboard(int player, bool leaver)
{
- if (!GetPlayerID(player)) return;
+ var playerID = GetPlayerID(player);
+ var text;
- if (!deathmatchEnabled)
+ // Ignore invalid player numbers
+ if (!playerID) return;
+
+ // Deathmatch only: Team rows
+ if (deathmatchEnabled)
{
- var relaunchesLeft = numRelaunches - playerDeaths[GetPlayerID(player)];
- SetScoreboardData(PlayerRow(player), 0, Format("%d", IIf(relaunchesLeft < 0, "{{SKUL}}", relaunchesLeft)));
+ var team = GetPlayerTeam(player);
+ if (team)
+ {
+ if (teamScore[team] == deathmatchWinScore)
+ text = "<c 00ff00>$Win$</c>";
+ else
+ text = Format("<c %x>%d</c>", GetTeamColor(team), teamScore[team]);
+
+ SetScoreboardData(TeamRow(team), SBRD_ScoreCol, text, teamScore[team]);
+ }
}
+
+ // Normal and deathmatch mode: Show score
+ if (leaver)
+ text = "{{SLVR}}";
else
+ text = Format("%d", playerScore[playerID]);
+
+ SetScoreboardData(PlayerRow(player), SBRD_ScoreCol, text, playerScore[playerID]);
+
+ // Normal mode only: Show remaining relaunches
+ if (!deathmatchEnabled)
{
- SetScoreboardData(PlayerRow(player), 0, Format("%d", playerScore[GetPlayerID(player)]));
- var team = GetPlayerTeam(player);
- if (team) SetScoreboardData(TeamRow(team), 0, Format("%d", teamScore[team]));
+ var relaunchesLeft = numRelaunches - playerDeaths[playerID];
+ if (relaunchesLeft < 0)
+ text = "$Death$";
+ else if (leaver)
+ text = "{{SLVR}}";
+ else
+ text = Format("%d", relaunchesLeft);
+
+ SetScoreboardData(PlayerRow(player), SBRD_RelaunchesCol, text, relaunchesLeft);
}
+
+ // Sort rows
+ SortScoreboard(SBRD_ScoreCol, true);
+ if (!deathmatchEnabled) SortScoreboard(SBRD_RelaunchesCol, true);
+ SortScoreboard(SBRD_Caption);
}
func ShowLobby()
@@ -88,7 +139,7 @@ func StartGame(object menu, string message)
var sectionID = menu->LocalN("section");
mode = menu->LocalN("mode");
var extinguisherEnabled = menu->LocalN("extinguisherEnabled");
- var friendlyPushingEnabled = menu->LocalN("friendlyPushingEnabled");
+ var suddendeathEnabled = menu->LocalN("suddendeathEnabled");
var rotateInJumpEnabled = menu->LocalN("rotateInJumpEnabled");
ambienceEnabled = menu->LocalN("ambienceEnabled");
numRelaunches = menu->LocalN("numRelaunches");
@@ -98,29 +149,39 @@ func StartGame(object menu, string message)
// Change scenario section
loadingSection = true;
- //Log("Before LoadScenarioSection()");
+ Log("Before LoadScenarioSection()");
LoadScenarioSection(DefinitionCall(sectionID, "SectionName"));
- //Log("After LoadScenarioSection()");
+ Log("After LoadScenarioSection()");
loadingSection = false;
section = CreateObject(sectionID, 0, 0, NO_OWNER);
// Create spawnpoints
if (mode != MODE_Apocalyptic)
{
- //Log("Creating spawnpoints");
+ Log("Creating spawnpoints");
var spawnPointSpawner = CreateObject(SPSR, 0, 0, NO_OWNER);
spawnPointSpawner->SetLocations(section->SpawnpointLocations());
- if (mode != MODE_Magic)
+ if (mode == MODE_Classic)
{
- spawnPointSpawner->SetDefinitions([[ROCK, 9], [SCRL, 9], [FLNT, 9], [SFLN, 9], [STFN, 4], [EFLN, 4], [FBMP, 4]]);
- spawnPointSpawner->SetSpawnInterval(750);
+ spawnPointSpawner->SetDefinitions([[ROCK, 7], [SCRL, 5], [FLNT, 7], [SFLN, 9], [STFN, 3], [EFLN, 5], [FBMP, 4], [ARWP, 4]]);
+ spawnPointSpawner->SetSpawnInterval(900);
}
- else
+ if (mode == MODE_Festive)
{
- spawnPointSpawner->SetDefinitions([[SCRL, 14], [GBLT, 1]]);
+ spawnPointSpawner->SetDefinitions([[TSWB,5], [SCRL, 5], [ROCK, 1]]);
+ 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);
+ }
+ if (mode == MODE_Magic)
+ {
+ spawnPointSpawner->SetDefinitions([[SCRL, 14], [GBLT, 1]]);
+ spawnPointSpawner->SetSpawnInterval(750);
spawnPointSpawner->SetSpawnpointGamma(RGB(5, 5, 10), RGB(80, 80, 150), RGB(200, 200, 255));
}
spawnPointSpawner->CreateSpawnPoints();
@@ -136,25 +197,32 @@ func StartGame(object menu, string message)
}
// Create melee goal
- //Log("Creating melee goal");
+ Log("Creating melee goal");
CreateObject(MELE, 0, 0, NO_OWNER);
// Create rules
- //Log("Creating rules");
+ Log("Creating rules");
if (extinguisherEnabled) CreateObject(_ETG, 0, 0, NO_OWNER);
- if (friendlyPushingEnabled) CreateObject(FYPG, 0, 0, NO_OWNER);
+ if (suddendeathEnabled) CreateObject(SDDT, 0, 0, NO_OWNER);
if (rotateInJumpEnabled) CreateObject(RIJP, 0, 0, NO_OWNER);
+ CreateObject(OFDR, 0, 0, NO_OWNER);
+
- //Log("Creating mode rules");
- if (mode == MODE_SuddenDeath)
+
+ // Create mode objects
+ if (mode == MODE_Magic)
{
- CreateObject(SDDT, 0, 0, NO_OWNER);
+ CreateObject(MLPG, 0, 0, NO_OWNER);
}
- else if (mode == MODE_Magic)
+ if (mode == MODE_Festive)
{
- CreateObject(MLPG, 0, 0, NO_OWNER);
+ CreateObject(FSTV, 0, 0, NO_OWNER);
}
- else if (mode == MODE_Apocalyptic)
+ if (mode == MODE_Knightly)
+ {
+ CreateObject(MKNI, 0, 0, NO_OWNER);
+ }
+ if (mode == MODE_Apocalyptic)
{
CreateObject(APCE, 0, 0, NO_OWNER);
}
@@ -162,29 +230,30 @@ func StartGame(object menu, string message)
// Deathmatch?
if (deathmatchEnabled)
{
- //Log("Creating deathmatch rule");
+ Log("Creating deathmatch rule");
CreateObject(DTHM, 0, 0, NO_OWNER);
- SetScoreboardData(SBRD_Caption, 0, "{{DTHM}}");
+ SetScoreboardData(SBRD_Caption, 0, "{{SKIL}}");
SetScoreboardData(0, SBRD_Caption, "$WinScore$");
- SetScoreboardData(0, 0, Format("%d", deathmatchWinScore));
+ SetScoreboardData(0, 0, Format("%d $Kills$", deathmatchWinScore));
}
else
{
- SetScoreboardData(SBRD_Caption, 0, "{{SKUL}}");
+ SetScoreboardData(SBRD_Caption, 0, "{{SREL}}");
+ SetScoreboardData(SBRD_Caption, 1, "{{SKIL}}");
}
// Initialize players
- //Log("Initializing players");
+ Log("Initializing players");
for (var i = 0; i < GetPlayerCount(); ++i)
{
InitializePlayer(GetPlayerByIndex(i));
}
- //Log("Starting countdown");
+ Log("Starting countdown");
gameStartMessage = message;
ShowCountdown();
- //Log("StartGame() done");
+ Log("StartGame() done");
}
func ShowCountdown()
@@ -238,7 +307,7 @@ func HandleKill(int killed, int killer)
var killedEliminated = false;
var killedID = GetPlayerID(killed), killerID = GetPlayerID(killer);
var killedTeam = GetPlayerTeam(killed), killerTeam = GetPlayerTeam(killer);
- var teamKill = killer == killed || killedTeam != 0 && killedTeam == killerTeam;
+ var teamKill = killedTeam != 0 && killedTeam == killerTeam;
++playerDeaths[killedID];
@@ -248,9 +317,9 @@ func HandleKill(int killed, int killer)
++playerScore[killerID];
if (killerTeam) ++teamScore[killerTeam];
}
- else // Decrement score on suicide or team kill
+ else if (teamKill && killed != killer) // Decrement score if it's a team kill but not a suicide
{
- if (playerScore[killerID] > 0)
+ if (playerScore[killerID] > 0) // Prevent negative scores
{
--playerScore[killerID];
if (killerTeam) --teamScore[killerTeam];
@@ -295,6 +364,7 @@ func HandleKill(int killed, int killer)
{
if (GetPlayerTeam(player) != killerTeam) EliminatePlayer(player);
}
+ Message(Format("$MsgDeathmatchWin$", GetTeamColor(killerTeam), GetTeamName(killerTeam)));
gameOver = true;
killedEliminated = true;
}
@@ -347,9 +417,9 @@ func OnClonkDeath(object clonk, int killedBy)
if (GetPlayerID(player)) LaunchClonk(player, clonk, true);
}
-func LaunchClonk(int player, object clonk, bool forceCreate)
+func LaunchClonk(int player, object clonk, bool relaunch)
{
- if (!clonk || forceCreate)
+ if (!clonk || relaunch)
{
var newClonk = CreateObject(CLNK, 0, 0, player);
if (clonk)
@@ -404,14 +474,24 @@ func LaunchClonk(int player, object clonk, bool forceCreate)
// No corpses in apocalopyse mode
if (mode == MODE_Apocalyptic) clonk->LocalN("removeOnDeath") = true;
+ // Enable rotation in jump for the clonk if allowed by rule
if (FindObject(RIJP)) clonk->LocalN("rotateInJump") = true;
+ // Do not immediately pass player control to the new clonk to prevent accidental jumps
+ if (relaunch)
+ {
+ clonk->SetCrewEnabled(false);
+ clonk->SetCrewEnabled(true);
+ clonk->Schedule("SelectCrew(GetOwner(), this, true)", 20);
+ }
+
+ PlayerMessage(player, "<c %x>{{FLAG}}</c>", clonk, GetPlrColorDw(player));
SetPlrView(player, clonk);
}
func ResetHealth(object clonk)
{
- if (mode == MODE_SuddenDeath)
+ if (suddendeathEnabled)
{
clonk->DoEnergy(1 - clonk->GetEnergy());
}