Skip to content

Commit

Permalink
Cult Yogg cultists count major trigger (#2634)
Browse files Browse the repository at this point in the history
* Cult Yogg cultists count major trigger

* Admin verb system fix
  • Loading branch information
stalengd authored Feb 26, 2025
1 parent 71d9e59 commit 9a3c612
Show file tree
Hide file tree
Showing 16 changed files with 294 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public sealed partial class AdminVerbSystem

//SS200 CultYogg start
[ValidatePrototypeId<EntityPrototype>]
private const string DefaultCultYoggRule = "CultYoggRule";
private const string DefaultCultYoggRule = "CultYoggRuleMidPop";
//SS220 CultYogg end

// All antag verbs have names so invokeverb works.
Expand Down
21 changes: 21 additions & 0 deletions Content.Server/GameTicking/Rules/SecretRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ private bool TryPickPreset(ProtoId<WeightedRandomPrototype> weights, [NotNullWhe
var options = _prototypeManager.Index(weights).Weights.ShallowClone();
var players = GameTicker.ReadyPlayerCount();

// SS220 Cult Yogg begin
var optionsToRemove = new HashSet<string>();
foreach ((var presetId, _) in options)
{
if (_prototypeManager.TryIndex<GamePresetPrototype>(presetId, out var presetToCheck)
&& players >= (presetToCheck.MinPlayers ?? 0)
&& players <= (presetToCheck.MaxPlayers ?? int.MaxValue))
{
// Passed
continue;
}

// Will be removed
optionsToRemove.Add(presetId);
}
foreach (var presetId in optionsToRemove)
{
options.Remove(presetId);
}
// SS220 Cult Yogg end

GamePresetPrototype? selectedPreset = null;
var sum = options.Values.Sum();
while (options.Count > 0)
Expand Down
12 changes: 0 additions & 12 deletions Content.Server/SS220/CultYogg/Altar/CultYoggAltarSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,11 @@ private void OnDoAfter(Entity<CultYoggAltarComponent> ent, ref MiGoSacrificeDoAf
RemComp<StrapComponent>(ent);
RemComp<DestructibleComponent>(ent);

int stage = 0;

var query = EntityQueryEnumerator<GameRuleComponent, CultYoggRuleComponent>();
while (query.MoveNext(out var uid, out _, out var cultRule))
{
var ev = new CultYoggSacrificedTargetEvent(ent);
RaiseLocalEvent(uid, ref ev, true);

stage = cultRule.AmountOfSacrifices;
}

//sending all cultists updating stage event
var queryCultists = EntityQueryEnumerator<CultYoggComponent>(); //ToDo ask if this code is ok
while (queryCultists.MoveNext(out var uid, out _))
{
var ev = new ChangeCultYoggStageEvent(stage);
RaiseLocalEvent(uid, ref ev, true);
}

//send cooldown to a MiGo sacrifice action
Expand Down
8 changes: 4 additions & 4 deletions Content.Server/SS220/CultYogg/Cultists/CultYoggSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ private void UpdateStage(Entity<CultYoggComponent> entity, ref ChangeCultYoggSta

switch (args.Stage)
{
case 0:
case CultYoggStage.Initial:
return;
case 1:
case CultYoggStage.Reveal:
entity.Comp.PreviousEyeColor = new Color(huAp.EyeColor.R, huAp.EyeColor.G, huAp.EyeColor.B, huAp.EyeColor.A);
huAp.EyeColor = Color.Green;
break;
case 2:
case CultYoggStage.Alarm:
if (_prototype.HasIndex<MarkingPrototype>(CultDefaultMarking))
{
if (!huAp.MarkingSet.Markings.ContainsKey(MarkingCategories.Special))
Expand Down Expand Up @@ -117,7 +117,7 @@ private void UpdateStage(Entity<CultYoggComponent> entity, ref ChangeCultYoggSta
//Log.Error($"{newMarkingId} marking doesn't exist");
}
break;
case 3:
case CultYoggStage.God:
if (!TryComp<MobStateComponent>(entity, out var mobstate))
return;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Shared.FixedPoint;
using Content.Shared.NPC.Prototypes;
using Content.Shared.SS220.CultYogg.Altar;
using Content.Shared.SS220.CultYogg.Cultists;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
Expand All @@ -11,17 +14,11 @@ namespace Content.Server.SS220.GameTicking.Rules.Components;
[RegisterComponent, Access(typeof(CultYoggRuleSystem))]
public sealed partial class CultYoggRuleComponent : Component
{
/// <summary>
/// General requirements
/// </summary>
[DataField]
public int AmountOfSacrificesToGodSummon = 3;

[DataField]
public int AmountOfSacrificesToWarningAnouncement = 2;
public int ReqAmountOfMiGo = 3;

[DataField]
public int ReqAmountOfMiGo = 3;
public Dictionary<CultYoggStage, CultYoggStageDefinition> Stages { get; private set; } = new();

/// <summary>
/// General requirements
Expand All @@ -33,6 +30,14 @@ public sealed partial class CultYoggRuleComponent : Component

public bool SacraficialsWerePicked = false;//buffer to prevent multiple generations

/// <summary>
/// Where previous sacrificial were performed
/// </summary>
public Entity<CultYoggAltarComponent>? LastSacrificialAltar = null;

public int InitialCrewCount;
public int TotalCultistsConverted;

/// <summary>
/// Storages for an endgame screen title
/// </summary>
Expand Down Expand Up @@ -90,6 +95,11 @@ public enum SelectionState
/// </summary>
public SelectionState SelectionStatus = SelectionState.WaitingForSpawn;

/// <summary>
/// Current cult gameplay stage
/// </summary>
public CultYoggStage Stage = CultYoggStage.Initial;

/// <summary>
/// When should cultists be selected and the announcement made
/// </summary>
Expand All @@ -102,3 +112,19 @@ public enum SelectionState
[DataField]
public SoundSpecifier GreetSoundNotification = new SoundPathSpecifier("/Audio/SS220/Ambience/Antag/cult_yogg_start.ogg");
}

[DataDefinition]
public sealed partial class CultYoggStageDefinition
{
/// <summary>
/// Amount of sacrifices that will progress cult to this stage.
/// </summary>
[DataField]
public int? SacrificesRequired;
/// <summary>
/// Fraction of total crew converted to cultists that will progress cult to this stage.
/// </summary>
[DataField]
public FixedPoint2? CultistsFractionRequired;
}

Loading

0 comments on commit 9a3c612

Please sign in to comment.