Skip to content

Commit

Permalink
Merge pull request #872 from Darkmajia/lowpop-gamemodes
Browse files Browse the repository at this point in the history
lowpop gamemodes, plus a little extra
  • Loading branch information
starlighthowls authored Dec 2, 2024
2 parents 729ae08 + c4c3c49 commit 6f98690
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ private void OnRoundStartAttempt(RoundStartAttemptEvent args)
while (query.MoveNext(out _, out _, out var gameRule))
{
var minPlayers = gameRule.MinPlayers;
if (!gameRule.CancelPresetOnTooFewPlayers)
var maxPlayers = gameRule.MaxPlayers;
if (!gameRule.CancelPresetOnTooFewPlayers && !gameRule.CancelPresetOnTooManyPlayers)
continue;
if (args.Players.Length >= minPlayers)
if (args.Players.Length >= minPlayers && args.Players.Length <= maxPlayers)
continue;

args.Cancel();
Expand Down
13 changes: 11 additions & 2 deletions Content.Server/GameTicking/Rules/GameRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,26 @@ private void OnStartAttempt(RoundStartAttemptEvent args)
while (query.MoveNext(out var uid, out _, out var gameRule))
{
var minPlayers = gameRule.MinPlayers;
if (args.Players.Length >= minPlayers)
var maxPlayers = gameRule.MaxPlayers;
if (args.Players.Length >= minPlayers && args.Players.Length <= maxPlayers)
continue;

if (gameRule.CancelPresetOnTooFewPlayers)
if (args.Players.Length < minPlayers && gameRule.CancelPresetOnTooFewPlayers)
{
ChatManager.SendAdminAnnouncement(Loc.GetString("preset-not-enough-ready-players",
("readyPlayersCount", args.Players.Length),
("minimumPlayers", minPlayers),
("presetName", ToPrettyString(uid))));
args.Cancel();
}
else if (args.Players.Length > maxPlayers && gameRule.CancelPresetOnTooManyPlayers)
{
ChatManager.SendAdminAnnouncement(Loc.GetString("preset-too-many-ready-players",
("readyPlayersCount", args.Players.Length),
("maximumPlayers", maxPlayers),
("presetName", ToPrettyString(uid))));
args.Cancel();
}
else
{
ForceEndSelf(uid, gameRule);
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/GameTicking/Rules/SecretRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ private bool CanPick([NotNullWhen(true)] GamePresetPrototype? selected, int play

if (ruleComp.MinPlayers > players && ruleComp.CancelPresetOnTooFewPlayers)
return false;

if (ruleComp.MaxPlayers < players && ruleComp.CancelPresetOnTooManyPlayers)
return false;
}

if (_nextRoundAllowed.ContainsKey(selected.ID) && _nextRoundAllowed[selected.ID] > _ticker.RoundId)
Expand Down
13 changes: 13 additions & 0 deletions Content.Shared/GameTicking/Components/GameRuleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,26 @@ public sealed partial class GameRuleComponent : Component
[DataField]
public int MinPlayers;

/// <summary>
/// The maximum amount of players supported by this game rule.
/// </summary>
[DataField]
public int MaxPlayers = 9999; // cheap hack

/// <summary>
/// If true, this rule not having enough players will cancel the preset selection.
/// If false, it will simply not run silently.
/// </summary>
[DataField]
public bool CancelPresetOnTooFewPlayers = true;

/// <summary>
/// If true, this rule having too many players will cancel the preset selection.
/// If false, it will simply not run silently.
/// </summary>
[DataField]
public bool CancelPresetOnTooManyPlayers = false;

/// <summary>
/// A delay for when the rule the is started and when the starting logic actually runs.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extended-lowpop-title = Extended (Lowpop)
extended-lowpop-description = A calm experience.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
survival-lowpop-title = Survival (Lowpop)
survival-lowpop-description = No internal threats, but how long can the station survive increasingly chaotic and frequent events?
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
thief-lowpop-title = Thief (Lowpop)
thief-lowpop-description = Watch your pockets.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
traitor-lowpop-title = Traitor (Lowpop)
traitor-lowpop-description = There are traitors among us...
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preset-too-many-ready-players = Can't start {$presetName}. Requires at most {$maximumPlayers} players but we have {$readyPlayersCount}.
2 changes: 2 additions & 0 deletions Resources/Prototypes/GameRules/events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
id: SleeperlessAntagEventsTable
table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
children:
- !type:NestedSelector # DeltaV
tableId: BasicAntagEventsTableDeltaV
- id: ClosetSkeleton
- id: DragonSpawn
- id: KingRatMigration
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/_Goobstation/game_presets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- MidpopLimiter

- type: gamePreset
id: Secretling
Expand Down
14 changes: 14 additions & 0 deletions Resources/Prototypes/_Impstation/GameRules/events.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
- type: entityTable
id: LowpopAntagEventsTable
table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
children:
- !type:NestedSelector # DeltaV
tableId: BasicAntagEventsTableDeltaV
- id: ClosetSkeleton
- id: DragonSpawn
- id: KingRatMigration
- id: NinjaSpawn
- id: RevenantSpawn
- id: GoblinStowawaysEvent # imp
- id: GoblinCastawaysEvent # imp

- type: entity
id: ChangelingAwakening
parent: BaseGameRule
Expand Down
50 changes: 50 additions & 0 deletions Resources/Prototypes/_Impstation/GameRules/roundstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,53 @@
forceAllPossible: true
mindRoles:
- MindRoleTraitor

# population limiters

- type: entity
parent: BaseGameRule
id: MidpopLimiter
components:
- type: GameRule
minPlayers: 20

- type: entity
parent: BaseGameRule
id: LowpopLimiter
components:
- type: GameRule
maxPlayers: 19
cancelPresetOnTooManyPlayers: true

# event schedulers

- type: entityTable
id: LowpopGameRulesTable
table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
children:
- !type:NestedSelector
tableId: BasicCalmEventsTable
- !type:NestedSelector
tableId: LowpopAntagEventsTable
- !type:NestedSelector
tableId: CargoGiftsTable
- !type:NestedSelector
tableId: CalmPestEventsTable
- !type:NestedSelector
tableId: SpicyPestEventsTable

- type: entity
id: LowpopStationEventScheduler
parent: BaseGameRule
components:
- type: BasicStationEventScheduler
scheduledGameRules: !type:NestedSelector
tableId: LowpopGameRulesTable

- type: entity
id: LowpopRampingStationEventScheduler
parent: BaseGameRule
components:
- type: RampingStationEventScheduler
scheduledGameRules: !type:NestedSelector
tableId: LowpopGameRulesTable
62 changes: 62 additions & 0 deletions Resources/Prototypes/_Impstation/game_presets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,65 @@
- SpaceTrafficControlEventScheduler
- SpaceTrafficControlFriendlyEventScheduler
- BasicRoundstartVariation

- type: gamePreset
id: TraitorLowpop
alias:
- LowpopTraitor
name: traitor-lowpop-title
description: traitor-lowpop-description
showInVote: false
rules:
- Traitor
- SubGamemodesRule
- LowpopStationEventScheduler
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- LowpopLimiter

- type: gamePreset
id: ThiefLowpop
alias:
- LowpopThief
name: thief-lowpop-title
description: thief-lowpop-description
showInVote: false
rules:
- Thief
- LowpopStationEventScheduler
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- LowpopLimiter

- type: gamePreset
id: SurvivalLowpop
alias:
- LowpopSurvival
name: survival-lowpop-title
description: survival-lowpop-description
showInVote: false
cooldown: 2
rules:
- MeteorSwarmScheduler
- LowpopRampingStationEventScheduler
- SpaceTrafficControlEventScheduler
- SpaceTrafficControlFriendlyEventScheduler
- BasicRoundstartVariation
- LowpopLimiter

- type: gamePreset
id: ExtendedLowpop
alias:
- LowpopExtended
name: extended-lowpop-title
description: extended-lowpop-description
showInVote: false
cooldown: 1 # zzz
rules:
- LowpopStationEventScheduler
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- LowpopLimiter
8 changes: 8 additions & 0 deletions Resources/Prototypes/game_presets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- SpaceTrafficControlEventScheduler
- SpaceTrafficControlFriendlyEventScheduler
- BasicRoundstartVariation
- MidpopLimiter

- type: gamePreset
id: KesslerSyndrome
Expand All @@ -28,6 +29,7 @@
- RampingStationEventScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- MidpopLimiter

- type: gamePreset
id: AllAtOnce
Expand Down Expand Up @@ -159,6 +161,7 @@
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- MidpopLimiter

- type: gamePreset
id: SpyVsSpy
Expand All @@ -175,6 +178,7 @@
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- MidpopLimiter

- type: gamePreset
id: SpyVsSpy3TC
Expand Down Expand Up @@ -245,6 +249,7 @@
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- MidpopLimiter

- type: gamePreset
id: Revolutionary
Expand All @@ -262,6 +267,7 @@
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- MidpopLimiter

- type: gamePreset
id: Zombie
Expand All @@ -281,6 +287,7 @@
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- MidpopLimiter

- type: gamePreset
id: Zombieteors
Expand All @@ -298,3 +305,4 @@
- KesslerSyndromeScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- MidpopLimiter
7 changes: 7 additions & 0 deletions Resources/Prototypes/secret_weights.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- type: weightedRandom
id: Secret
weights:
# regular gamemodes, gamemodes with 20 population requirement or more
Nukeops: 0.15
Traitor: 0.50
SpyVsSpy: 0.03
Expand All @@ -10,3 +11,9 @@
Survival: 0.10
KesslerSyndrome: 0.01
Revolutionary: 0.03

# lowpop gamemodes, gamemodes with 19 population requirement or below
TraitorLowpop: 0.50
ThiefLowpop: 0.25
SurvivalLowpop: 0.20
ExtendedLowpop: 0.05

0 comments on commit 6f98690

Please sign in to comment.