CustomGameModeBase class
Common base of the game modes that score points of their own.
Competitive defaults: no level-exit rule, respawn at a fresh spawn point with spawn invulnerability, the score is MpPlayerState::
Base classes
- class GameModeBase
- Base of all game modes.
Derived classes
- class DominationMode
- Domination game mode (team-based).
- class FlagRunMode
- Flag Run game mode (team-based).
- class HeadHuntersMode
- Head Hunters game mode (team-based).
- class JailbreakMode
- Jailbreak game mode (team-based).
- class LastRabbitStandingMode
- Last Rabbit Standing game mode (free-for-all).
- class PestilenceMode
- Pestilence game mode (free-for-all).
- class RoastTagMode
- Roast Tag game mode (free-for-all).
- class TeamLastRabbitStandingMode
- Team Last Rabbit Standing game mode (team-based).
Public functions
- auto SkipsPreGameCountdown() const -> bool override
- Returns whether the pre-game wait and countdown are skipped (Cooperation starts immediately).
- auto HasUnlimitedHealth() const -> bool override
- Returns whether players have unlimited health in this mode.
- auto LowerScoreWins() const -> bool override
- Returns whether a lower round score ranks higher (Race finishes first).
- void OnRoundStarted(IGameModeContext& ctx) override
- Called when the round starts (after the countdown) to reset/initialize mode state.
- void OnUpdate(IGameModeContext& ctx, float timeMult) override
- Called every host tick while the round is running.
-
void OnPlayerSpawned(IGameModeContext& ctx,
Actors::
Player* player) override - Called after a player (re)spawns.
-
void OnPlayerKilled(IGameModeContext& ctx,
Actors::
Player* victim, Actors:: Player* killer) override - Called when a player dies, for mode-specific reactions (e.g. dropping a carried flag); kill/death counts are maintained by the host.
killermay benullptr(environmental death). -
auto DecideRespawn(IGameModeContext& ctx,
Actors::
Player* player) -> RespawnDecision override - Decides whether and where the specified player should respawn.
-
void OnCoinsCollected(IGameModeContext& ctx,
Actors::
Player* player, std:: int32_t prevCount, std:: int32_t newCount) override - Called when a player's coin count changes.
-
void OnGemsCollected(IGameModeContext& ctx,
Actors::
Player* player, std:: uint8_t gemType, std:: int32_t prevCount, std:: int32_t newCount) override - Called when a player's gem count changes.
-
auto OnLevelExitReached(IGameModeContext& ctx,
Actors::
Player* player) -> LevelExitAction override - Decides what happens when the specified player reaches the level exit.
- auto CheckGameEnds(IGameModeContext& ctx) -> GameEndResult override
- Checks whether the round should end now, and who won.
- void AssignTeams(IGameModeContext& ctx) override
- (Re)assigns players to teams (free-for-all modes assign one team per player)
-
auto GetRoundScore(IGameModeContext& ctx,
Actors::
Player* player) -> std:: uint32_t override - Returns the ranking metric of the specified player (kills / laps / treasure / ...).
-
auto GetStateScore(const MpPlayerState& state) const -> std::
uint32_t override - Returns the ranking metric stored in the specified state, a player with more ranks higher.
-
void OnDrawHUD(IGameModeContext& ctx,
IGameModeHUD& hud,
Actors::
Player* player, const Rectf& view) override - Draws the mode-specific part of the HUD for the given player's split-screen view.
- auto OnTimeOut(IGameModeContext& ctx) -> GameEndResult override
- Decides the round when its time runs out, if GameEndResult::
ShouldEnd is false, the host decides by the score. - void OnOvertimeStarted(IGameModeContext& ctx) override
- Called when the round goes into overtime.
Protected types
- enum class OvertimeRule { None, ScoreCap, NextLead, TiedLeaders }
- How the overtime of a mode works.
Protected static functions
-
static auto HasFlag(IGameModeContext& ctx,
Actors::
Player* player, PlayerModeFlags flag) -> bool - Returns
trueif the player has the role. -
static auto SetFlag(IGameModeContext& ctx,
Actors::
Player* player, PlayerModeFlags flag, bool value) -> bool - Sets or clears the role of the player, returns
trueif it changed. -
static void ClearFlag(IGameModeContext& ctx,
std::
uint32_t playerIndex, PlayerModeFlags flag) - Clears the role of the player with the specified index (if any) and synchronizes it if it changed.
-
static void AddPoints(IGameModeContext& ctx,
Actors::
Player* player, std:: int32_t points) - Adds points to the player, never below zero.
- static void AddTeamBases(IGameModeContext& ctx, GameModeObjectType type, Vector2f* basePos)
- Adds a game mode object of the specified type for the base of every team.
-
static auto AddObject(IGameModeContext& ctx,
GameModeObjectType type,
std::
uint8_t team, Vector2f pos) -> GameModeObject& - Adds a game mode object with a new identifier, nobody capturing or carrying it.
Protected functions
- auto GetOvertimeRule() const -> OvertimeRule virtual
- Returns how the overtime works in the mode.
-
auto GetLeaderScore(IGameModeContext& ctx,
Actors::
Player* player) -> std:: uint32_t virtual - Returns the score the overtime looks at, the round score by default.
- auto ShouldStartOvertime(IGameModeContext& ctx) -> bool
- Returns
trueif the round should go into overtime when its time runs out. - auto DecideByScore(IGameModeContext& ctx) -> GameEndResult
- Ends the round in favor of the best player or team, a tie is a draw.
-
auto GetScoreTarget(IGameModeContext& ctx) -> std::
uint32_t - Returns the score that wins, the max score or the cap of the overtime.
-
auto GetBestScore(IGameModeContext& ctx,
bool& tied) -> std::
uint32_t - Returns the best score of a player or team, and whether more of them have it.
-
auto IsActive(IGameModeContext& ctx,
Actors::
Player* player) -> bool - Returns
trueif the player takes part in the round right now (not spectating, not out). -
auto FindPlayerAtTarget(IGameModeContext& ctx) -> Actors::
Player* - Returns the player that reached ServerConfiguration::
TotalKills first, or nullptr. -
auto FindTeamAtTarget(IGameModeContext& ctx) -> std::
int32_t - Returns the team that reached ServerConfiguration::
TotalKills first, or -1. -
auto FindBestPlayer(IGameModeContext& ctx) -> Actors::
Player* - Returns the player with the best score, or
nullptron a tie. -
auto FindBestTeam(IGameModeContext& ctx) -> std::
int32_t - Returns the team with the best score, or
-1on a tie. -
void DrawScoreLine(IGameModeContext& ctx,
IGameModeHUD& hud,
const Rectf& view,
StringView label,
std::
uint32_t value, bool withTarget) - Draws the score line of the HUD with the label.
- void DrawStatusLine(IGameModeHUD& hud, const Rectf& view, StringView text, const Colorf& color)
- Draws a status line below the score line.
-
void DrawUnderTeamScore(IGameModeContext& ctx,
IGameModeHUD& hud,
const Rectf& view,
std::
uint8_t team, StringView text) - Draws a short text under the score of the team in the team score header, as the flag state in Capture The Flag.
Enum documentation
enum class Jazz2:: Multiplayer:: GameModes:: CustomGameModeBase:: OvertimeRule protected
How the overtime of a mode works.
| Enumerators | |
|---|---|
| None |
No overtime |
| ScoreCap |
First to the best score + 2 (never above the max score) wins |
| NextLead |
First to the best score + 1 (never above the max score) wins |
| TiedLeaders |
Only if several are tied for the best score, the round then ends by its own rules |
Function documentation
static void Jazz2:: Multiplayer:: GameModes:: CustomGameModeBase:: AddTeamBases(IGameModeContext& ctx,
GameModeObjectType type,
Vector2f* basePos) protected
Adds a game mode object of the specified type for the base of every team.
The positions are stored to basePos, which must have room for MaxTeamCount items.