Skip to content

Commit

Permalink
RegalRat personal gamerule
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiiwwwie committed Jan 21, 2025
1 parent a62f631 commit 77d58de
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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<EntitySpawnEntry> Entries = new();

/// <summary>
/// At least one special entry is guaranteed to spawn
/// </summary>
[DataField("specialEntries")]
public List<EntitySpawnEntry> SpecialEntries = new();
}
Original file line number Diff line number Diff line change
@@ -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
{

}
61 changes: 61 additions & 0 deletions Content.Server/SS220/StationEvents/Events/RegalRatRule.cs
Original file line number Diff line number Diff line change
@@ -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<RegalRatRuleComponent>
{
/*
* 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<RegalRatSpawnLocationComponent, TransformComponent>();
var validLocations = new List<EntityCoordinates>();
while (locations.MoveNext(out _, out _, out var transform))
{
if (CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == station &&
HasComp<BecomesStationComponent>(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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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<RegalRatSpawnLocationComponent>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
tags:
- FoodSnack
- type: SpawnItemsOnUse
handlessUsable: true
items:
- id: FoodPacketChocolateTrash
- id: FoodSnackChocolateBar
Expand Down
10 changes: 6 additions & 4 deletions Resources/Prototypes/GameRules/events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
suffix: Мусор, Хлам
components:
- type: RatKingRummageable
- type: RegalRatSpawnLocation
rummageLoot: RatKingLootTrashPiles
- type: InteractionOutline
- type: Sprite
Expand Down

0 comments on commit 77d58de

Please sign in to comment.