Skip to content

Commit

Permalink
More gamemodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnemotechnician committed Jul 8, 2024
1 parent a6073ef commit a048c11
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
[RegisterComponent, Access(typeof(RampingStationEventSchedulerSystem))]
public sealed partial class RampingStationEventSchedulerComponent : Component
{
/// <summary>
/// The maximum number by which the event rate will be multiplied when shift time reaches the end time.
/// </summary>
[DataField]
public float ChaosModifier = 3f;

/// <summary>
/// The minimum number by which the event rate will be multiplied when the shift has just begun.
/// </summary>
[DataField]
public float StartingChaosRatio = 0.1f;

/// <summary>
/// The number by which all event delays will be multiplied. Unlike chaos, remains constant throughout the shift.
/// </summary>
[DataField]
public float EventDelayModifier = 1f;

/// <summary>
/// The number by which average expected shift length is multiplied. Higher values lead to slower chaos growth.
/// </summary>
public float ShiftLengthModifier = 1f;

// Everything below is overridden in the RampingStationEventSchedulerSystem based on CVars
[DataField("endTime"), ViewVariables(VVAccess.ReadWrite)]
public float EndTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ protected override void Started(EntityUid uid, RampingStationEventSchedulerCompo
{
base.Started(uid, component, gameRule, args);

var avgChaos = _cfg.GetCVar(CCVars.EventsRampingAverageChaos);
var avgTime = _cfg.GetCVar(CCVars.EventsRampingAverageEndTime);
var avgChaos = _cfg.GetCVar(CCVars.EventsRampingAverageChaos) * component.ChaosModifier;
var avgTime = _cfg.GetCVar(CCVars.EventsRampingAverageEndTime) * component.ShiftLengthModifier;

// Worlds shittiest probability distribution
// Got a complaint? Send them to
component.MaxChaos = _random.NextFloat(avgChaos - avgChaos / 4, avgChaos + avgChaos / 4);
component.MaxChaos = avgChaos * _random.NextFloat(0.75f, 1.25f);
// This is in minutes, so *60 for seconds (for the chaos calc)
component.EndTime = _random.NextFloat(avgTime - avgTime / 4, avgTime + avgTime / 4) * 60f;
component.StartingChaos = component.MaxChaos / 10;
component.EndTime = avgTime * _random.NextFloat(0.75f, 1.25f) * 60f;
component.StartingChaos = component.MaxChaos * component.StartingChaosRatio;

PickNextEventTime(uid, component);
}
Expand Down Expand Up @@ -68,9 +68,10 @@ public override void Update(float frameTime)

private void PickNextEventTime(EntityUid uid, RampingStationEventSchedulerComponent component)
{
var mod = GetChaosModifier(uid, component);
component.TimeUntilNextEvent = _random.NextFloat(
_cfg.GetCVar(CCVars.GameEventsRampingMinimumTime),
_cfg.GetCVar(CCVars.GameEventsRampingMaximumTime));

component.TimeUntilNextEvent = _random.NextFloat(_cfg.GetCVar(CCVars.GameEventsRampingMinimumTime) / mod,
_cfg.GetCVar(CCVars.GameEventsRampingMaximumTime)) / mod;
component.TimeUntilNextEvent *= component.EventDelayModifier / GetChaosModifier(uid, component);
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
survival-title = Survival
survival-description = No internal threats, but how long can the station survive increasingly chaotic and frequent events?
hellshift-title = Hellshift
hellshift-description = The station rolled a "one" in a luck check. Can the crew make it to the end?
10 changes: 10 additions & 0 deletions Resources/Prototypes/GameRules/roundstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@
components:
- type: RampingStationEventScheduler

- type: entity
id: HellshiftStationEventScheduler
parent: BaseGameRule
noSpawn: true
components:
- type: RampingStationEventScheduler
chaosModifier: 4 # By default, one event each 30-10 seconds after two hours. Changing CVars will cause this to deviate.
startingChaosRatio: 0.025 # Starts as slow as survival, but quickly ramps up
shiftLengthModifier: 2.5

# variation passes
- type: entity
id: BasicRoundstartVariation
Expand Down
13 changes: 12 additions & 1 deletion Resources/Prototypes/game_presets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
- RampingStationEventScheduler
- BasicRoundstartVariation

- type: gamePreset
id: SurvivalHellshift
alias:
- hellshift
showInVote: true
name: hellshift-title
description: hellshift-description
rules:
- HellshiftStationEventScheduler
- BasicRoundstartVariation

- type: gamePreset
id: AllAtOnce
name: all-at-once-title
Expand Down Expand Up @@ -90,7 +101,7 @@
- traitor
name: traitor-title
description: traitor-description
showInVote: false
showInVote: true # if people want to antag let it be traitors instead of self-antaggers
rules:
- Traitor
- SubGamemodesRule
Expand Down

0 comments on commit a048c11

Please sign in to comment.