mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-20 23:17:43 +03:00
# Description Adds traitors and hellshift to the list of gamemodes offered by the gamemode vote. Traitors just make sense. Hellshift is a new version of survival. It starts out roughly as slow as survival, but it slowly devolves into a torrent of station events as frequent as one every 10-30 seconds. Good for when there's no other ~~self-antaggers~~ players to spice up the shift, or when there's one too many security officers to deal with all the threats this brings. # Technical details Had to refactor a lot of RampingStationEventScheduler. Firstly, it was total shitcode, secondly, it had everything hardcoded, thirdly, it had a bug that made it possible for events to appear with little to no delay whatsoever. Now its component features four data fields that can be used to configure the scheduler and its system contains cleaner and more readable code. <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>   </p> </details> # Changelog 🆑 - tweak: Players can now vote on two more gamemodes: Traitors and Hellshift. --------- Signed-off-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
78 lines
3.0 KiB
C#
78 lines
3.0 KiB
C#
using Content.Server.GameTicking;
|
|
using Content.Server.GameTicking.Rules;
|
|
using Content.Server.GameTicking.Rules.Components;
|
|
using Content.Server.StationEvents.Components;
|
|
using Content.Server.StationEvents.Events;
|
|
using Content.Shared.CCVar;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.StationEvents;
|
|
|
|
public sealed class RampingStationEventSchedulerSystem : GameRuleSystem<RampingStationEventSchedulerComponent>
|
|
{
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly EventManagerSystem _event = default!;
|
|
[Dependency] private readonly GameTicker _gameTicker = default!;
|
|
|
|
public float GetChaosModifier(EntityUid uid, RampingStationEventSchedulerComponent component)
|
|
{
|
|
var roundTime = (float) _gameTicker.RoundDuration().TotalSeconds;
|
|
if (roundTime > component.EndTime)
|
|
return component.MaxChaos;
|
|
|
|
return component.MaxChaos / component.EndTime * roundTime + component.StartingChaos;
|
|
}
|
|
|
|
protected override void Started(EntityUid uid, RampingStationEventSchedulerComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
|
{
|
|
base.Started(uid, component, gameRule, args);
|
|
|
|
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 = avgChaos * _random.NextFloat(0.75f, 1.25f);
|
|
// This is in minutes, so *60 for seconds (for the chaos calc)
|
|
component.EndTime = avgTime * _random.NextFloat(0.75f, 1.25f) * 60f;
|
|
component.StartingChaos = component.MaxChaos * component.StartingChaosRatio;
|
|
|
|
PickNextEventTime(uid, component);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
if (!_event.EventsEnabled)
|
|
return;
|
|
|
|
var query = EntityQueryEnumerator<RampingStationEventSchedulerComponent, GameRuleComponent>();
|
|
while (query.MoveNext(out var uid, out var scheduler, out var gameRule))
|
|
{
|
|
if (!GameTicker.IsGameRuleActive(uid, gameRule))
|
|
return;
|
|
|
|
if (scheduler.TimeUntilNextEvent > 0f)
|
|
{
|
|
scheduler.TimeUntilNextEvent -= frameTime;
|
|
return;
|
|
}
|
|
|
|
PickNextEventTime(uid, scheduler);
|
|
_event.RunRandomEvent();
|
|
}
|
|
}
|
|
|
|
private void PickNextEventTime(EntityUid uid, RampingStationEventSchedulerComponent component)
|
|
{
|
|
component.TimeUntilNextEvent = _random.NextFloat(
|
|
_cfg.GetCVar(CCVars.GameEventsRampingMinimumTime),
|
|
_cfg.GetCVar(CCVars.GameEventsRampingMaximumTime));
|
|
|
|
component.TimeUntilNextEvent *= component.EventDelayModifier / GetChaosModifier(uid, component);
|
|
}
|
|
}
|