GameModeBase class
Base of all game modes.
Implements the optional parts of IGameMode with neutral defaults: the mode owns its round logic, nothing restricts damage, pushing or freezing, a kill counts as usual, the score is the kills, and there are no overtime, commands, team numbers, scoreboard column or roles of its own. A mode overrides only what differs.
Base classes
- class IGameMode
- Rules of a single multiplayer game mode.
Derived classes
- class BattleMode
- Battle game mode (free-for-all).
- class CaptureTheFlagMode
- Capture The Flag game mode.
- class CooperationMode
- Cooperation game mode.
- class CustomGameModeBase
- Common base of the game modes that score points of their own.
- class RaceMode
- Race game mode.
- class TreasureHuntMode
- Treasure Hunt game mode.
Public functions
- auto OwnsRoundLogic() const -> bool override
- Returns whether this mode computes its own win condition (CheckGameEnds).
-
void OnPlayerTeamChanged(IGameModeContext& ctx,
Actors::
Player* player) override - Called when a living player changed the team, right before the player respawns on the new team.
-
auto CanDamagePlayer(IGameModeContext& ctx,
Actors::
Player* victim, Actors:: Player* attacker) -> bool override - Returns whether
attackermay hurtvictim. -
auto CanPlayersPush(IGameModeContext& ctx,
Actors::
Player* a, Actors:: Player* b) -> bool override - Returns
trueif playersaandbpush each other when they touch. -
auto PreventsHazardDeath(IGameModeContext& ctx,
Actors::
Player* player) -> bool override - Called before a pit nobody caused roasts the player, returns
trueto keep it alive at 1 heart instead. -
auto CanFreezeActor(IGameModeContext& ctx,
Actors::
ActorBase* actor, Actors:: Player* shooter) -> bool override - Returns
trueif a shot ofshooter(may benullptr) can freezeactor, it's called also on clients. - auto HasDamageAmplifierInOvertime() const -> bool override
- Returns
trueif the damage amplifier turns on in the overtime of this mode. - auto ProcessCommand(IGameModeContext& ctx, StringView command) -> bool override
- Processes an admin command of the mode (without the leading slash), returns
trueif it was one. - void OnOvertimeStarted(IGameModeContext& ctx) override
- Called when the round goes into overtime.
-
auto GetDamage(IGameModeContext& ctx,
Actors::
Player* victim, Actors:: Player* attacker, std:: int32_t amount) -> std:: int32_t override - Returns the damage
attackerdeals tovictimby one hit ofamount. -
void OnPlayerHit(IGameModeContext& ctx,
Actors::
Player* victim, Actors:: Player* attacker) override - Called when
attackerhurtvictim, also when the hit roasted it (after OnPlayerKilled then). -
auto CountsAsKill(IGameModeContext& ctx,
Actors::
Player* victim, Actors:: Player* attacker) -> bool override - Returns whether a kill of
victimbyattackercounts as a kill of the attacker and of its team. -
auto IsEliminated(IGameModeContext& ctx,
Actors::
Player* player) -> bool override - Returns whether the specified player is out of the round for good.
-
auto TryGetTeamScore(IGameModeContext& ctx,
std::
uint8_t team, std:: uint32_t& score) -> bool override - Returns the score of the specified team if the mode keeps it on its own, otherwise
false. -
auto TryGetTeamExtra(IGameModeContext& ctx,
std::
uint8_t team, std:: uint32_t& value) -> bool override - Returns a second number of the specified team the HUD shows (synchronized), otherwise
false. - 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. -
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.
- auto GetScoreboardLabel() const -> StringView override
- Returns label of the mode-specific column of the scoreboard, which shows GetStateScore(), or empty.
-
auto GetForcedFurColor(std::
uint8_t modeFlags) const -> std:: uint32_t override - Returns fur color forced on the player by its role in the mode, or
0to keep it. -
auto GetRoleLabel(std::
uint8_t modeFlags) const -> StringView override - Returns a short label shown next to the name of a player with the specified role, or empty.
Function documentation
bool Jazz2:: Multiplayer:: GameModes:: GameModeBase:: OwnsRoundLogic() const override
Returns whether this mode computes its own win condition (CheckGameEnds).
Returns true once the mode owns its win-condition check. While false — used during the staged migration — the host runs its legacy win-condition logic for this mode instead. Level-exit (OnLevelExitReached), respawn (DecideRespawn) and the HUD (OnDrawHUD) are always driven by the mode regardless of this flag.
bool Jazz2:: Multiplayer:: GameModes:: GameModeBase:: CanDamagePlayer(IGameModeContext& ctx,
Actors:: Player* victim,
Actors:: Player* attacker) override
Returns whether attacker may hurt victim.
Called on top of the friendly-fire rule of the host, so a mode only restricts it further.