From 77d58de12245212cd53274ef787e25c4000c049a Mon Sep 17 00:00:00 2001 From: kekw Date: Tue, 21 Jan 2025 21:06:31 +0300 Subject: [PATCH] RegalRat personal gamerule --- .../Components/RegalRatRuleComponent.cs | 19 ++++++ .../RegalRatSpawnLocationComponent.cs | 11 ++++ .../StationEvents/Events/RegalRatRule.cs | 61 +++++++++++++++++++ .../Events/RegalRatSpawnLocation.cs | 9 +++ .../Objects/Consumable/Food/snacks.yml | 1 - Resources/Prototypes/GameRules/events.yml | 10 +-- .../Entities/Structures/Specific/trash.yml | 1 + 7 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 Content.Server/SS220/StationEvents/Components/RegalRatRuleComponent.cs create mode 100644 Content.Server/SS220/StationEvents/Components/RegalRatSpawnLocationComponent.cs create mode 100644 Content.Server/SS220/StationEvents/Events/RegalRatRule.cs create mode 100644 Content.Server/SS220/StationEvents/Events/RegalRatSpawnLocation.cs diff --git a/Content.Server/SS220/StationEvents/Components/RegalRatRuleComponent.cs b/Content.Server/SS220/StationEvents/Components/RegalRatRuleComponent.cs new file mode 100644 index 000000000000..666e0ca2eda3 --- /dev/null +++ b/Content.Server/SS220/StationEvents/Components/RegalRatRuleComponent.cs @@ -0,0 +1,19 @@ +using Content.Server.SS220.StationEvents.Events; +using Content.Server.SS220.StationEvents.Components; +using Content.Server.StationEvents.Events; +using Content.Shared.Storage; + +namespace Content.Server.SS220.StationEvents.Components; + +[RegisterComponent, Access(typeof(RegalRatRule))] +public sealed partial class RegalRatRuleComponent : Component +{ + [DataField("entries")] + public List Entries = new(); + + /// + /// At least one special entry is guaranteed to spawn + /// + [DataField("specialEntries")] + public List SpecialEntries = new(); +} diff --git a/Content.Server/SS220/StationEvents/Components/RegalRatSpawnLocationComponent.cs b/Content.Server/SS220/StationEvents/Components/RegalRatSpawnLocationComponent.cs new file mode 100644 index 000000000000..5a975f81f1d0 --- /dev/null +++ b/Content.Server/SS220/StationEvents/Components/RegalRatSpawnLocationComponent.cs @@ -0,0 +1,11 @@ +using Content.Server.SS220.StationEvents.Events; +using Content.Server.SS220.StationEvents.Components; +using Content.Server.StationEvents.Events; + +namespace Content.Server.SS220.StationEvents.Components; + +[RegisterComponent, Access(typeof(RegalRatSpawnLocation))] +public sealed partial class RegalRatSpawnLocationComponent : Component +{ + +} diff --git a/Content.Server/SS220/StationEvents/Events/RegalRatRule.cs b/Content.Server/SS220/StationEvents/Events/RegalRatRule.cs new file mode 100644 index 000000000000..f62bdb50742f --- /dev/null +++ b/Content.Server/SS220/StationEvents/Events/RegalRatRule.cs @@ -0,0 +1,61 @@ +using Content.Server.Station.Components; +using Content.Server.SS220.StationEvents.Events; +using Content.Server.StationEvents.Events; +using Content.Shared.GameTicking.Components; +using Content.Shared.Station.Components; +using Content.Shared.Storage; +using Robust.Shared.Map; +using Robust.Shared.Random; + +namespace Content.Server.SS220.StationEvents.Events; + +public sealed class RegalRatRule : StationEventSystem +{ + /* + * DO NOT COPY PASTE THIS TO MAKE YOUR MOB EVENT. + * USE THE PROTOTYPE. + */ + + protected override void Started(EntityUid uid, RegalRatRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) + { + base.Started(uid, component, gameRule, args); + + if (!TryGetRandomStation(out var station)) + { + return; + } + + var locations = EntityQueryEnumerator(); + var validLocations = new List(); + while (locations.MoveNext(out _, out _, out var transform)) + { + if (CompOrNull(transform.GridUid)?.Station == station && + HasComp(transform.GridUid)) + { + validLocations.Add(transform.Coordinates); + foreach (var spawn in EntitySpawnCollection.GetSpawns(component.Entries, RobustRandom)) + { + Spawn(spawn, transform.Coordinates); + } + } + } + + if (component.SpecialEntries.Count == 0 || validLocations.Count == 0) + { + return; + } + + // guaranteed spawn + var specialEntry = RobustRandom.Pick(component.SpecialEntries); + var specialSpawn = RobustRandom.Pick(validLocations); + Spawn(specialEntry.PrototypeId, specialSpawn); + + foreach (var location in validLocations) + { + foreach (var spawn in EntitySpawnCollection.GetSpawns(component.SpecialEntries, RobustRandom)) + { + Spawn(spawn, location); + } + } + } +} diff --git a/Content.Server/SS220/StationEvents/Events/RegalRatSpawnLocation.cs b/Content.Server/SS220/StationEvents/Events/RegalRatSpawnLocation.cs new file mode 100644 index 000000000000..735ee4983e61 --- /dev/null +++ b/Content.Server/SS220/StationEvents/Events/RegalRatSpawnLocation.cs @@ -0,0 +1,9 @@ +using Content.Server.SS220.StationEvents.Events; +using Content.Server.SS220.StationEvents.Components; +using Content.Server.StationEvents.Events; + +namespace Content.Server.SS220.StationEvents.Events; +public sealed partial class RegalRatSpawnLocation : StationEventSystem +{ + +} \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/snacks.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/snacks.yml index 3b78b0ab653c..f172aa39073d 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/snacks.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/snacks.yml @@ -107,7 +107,6 @@ tags: - FoodSnack - type: SpawnItemsOnUse - handlessUsable: true items: - id: FoodPacketChocolateTrash - id: FoodSnackChocolateBar diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index 70b8518f36c2..ed3156698064 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -278,14 +278,16 @@ parent: BaseStationEventShortDelay components: - type: StationEvent - startAnnouncement: station-event-vent-creatures-start-announcement - startAudio: - path: /Audio/Announcements/attention.ogg + #SS220 audio muted and no announcment, because Central command do not check piles of trash + #startAnnouncement: station-event-vent-creatures-start-announcement + #startAudio: + # path: /Audio/Announcements/attention.ogg + #SS220 changes end here earliestStart: 15 weight: 6 duration: 50 minimumPlayers: 30 # Hopefully this is enough for the Rat King's potential Army (it was not, raised from 15 -> 30) - - type: VentCrittersRule + - type: RegalRatRule #SS220 RegalRat GameRule entries: - id: MobMouse prob: 0.02 diff --git a/Resources/Prototypes/SS220/Entities/Structures/Specific/trash.yml b/Resources/Prototypes/SS220/Entities/Structures/Specific/trash.yml index fe5bd7351235..2e4294693cb0 100644 --- a/Resources/Prototypes/SS220/Entities/Structures/Specific/trash.yml +++ b/Resources/Prototypes/SS220/Entities/Structures/Specific/trash.yml @@ -6,6 +6,7 @@ suffix: Мусор, Хлам components: - type: RatKingRummageable + - type: RegalRatSpawnLocation rummageLoot: RatKingLootTrashPiles - type: InteractionOutline - type: Sprite