From 3f5a5d46b6d52dfbadba2b962f3a83500a9cf1ff Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 8 Aug 2022 14:19:53 +1000 Subject: [PATCH] Dragon rift fixes (#10428) --- .../Dragon/Components/DragonRiftComponent.cs | 4 +-- Content.Server/Dragon/DragonSystem.cs | 29 +++++++++++++++++-- .../Locale/en-US/actions/actions/dragon.ftl | 1 + .../Prototypes/Entities/Mobs/NPCs/carp.yml | 2 +- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Content.Server/Dragon/Components/DragonRiftComponent.cs b/Content.Server/Dragon/Components/DragonRiftComponent.cs index 3a55709778..b60c8a2f87 100644 --- a/Content.Server/Dragon/Components/DragonRiftComponent.cs +++ b/Content.Server/Dragon/Components/DragonRiftComponent.cs @@ -27,13 +27,13 @@ public sealed class DragonRiftComponent : SharedDragonRiftComponent /// Accumulation of the spawn timer. /// [ViewVariables(VVAccess.ReadWrite), DataField("spawnAccumulator")] - public float SpawnAccumulator = 60f; + public float SpawnAccumulator = 30f; /// /// How long it takes for a new spawn to be added. /// [ViewVariables(VVAccess.ReadWrite), DataField("spawnCooldown")] - public float SpawnCooldown = 60f; + public float SpawnCooldown = 30f; [ViewVariables(VVAccess.ReadWrite), DataField("spawn", customTypeSerializer: typeof(PrototypeIdSerializer))] public string SpawnPrototype = "MobCarpDragon"; diff --git a/Content.Server/Dragon/DragonSystem.cs b/Content.Server/Dragon/DragonSystem.cs index 5adb70ec6c..06806ba93d 100644 --- a/Content.Server/Dragon/DragonSystem.cs +++ b/Content.Server/Dragon/DragonSystem.cs @@ -33,6 +33,13 @@ namespace Content.Server.Dragon [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedAudioSystem _audioSystem = default!; + /// + /// Minimum distance between 2 rifts allowed. + /// + private const int RiftRange = 15; + + private const int RiftsAllowed = 3; + public override void Initialize() { base.Initialize(); @@ -75,7 +82,7 @@ namespace Content.Server.Dragon } // At max rifts - if (comp.Rifts.Count >= 3) + if (comp.Rifts.Count >= RiftsAllowed) { continue; } @@ -121,7 +128,7 @@ namespace Content.Server.Dragon comp.SpawnAccumulator += frameTime; - if (comp.State < DragonRiftState.AlmostFinished && comp.SpawnAccumulator > comp.MaxAccumulator / 2f) + if (comp.State < DragonRiftState.AlmostFinished && comp.Accumulator > comp.MaxAccumulator / 2f) { comp.State = DragonRiftState.AlmostFinished; Dirty(comp); @@ -197,7 +204,7 @@ namespace Content.Server.Dragon return; } - if (component.Rifts.Count >= 3) + if (component.Rifts.Count >= RiftsAllowed) { _popupSystem.PopupEntity(Loc.GetString("carp-rift-max"), uid, Filter.Entities(uid)); return; @@ -218,6 +225,15 @@ namespace Content.Server.Dragon return; } + foreach (var (_, riftXform) in EntityQuery(true)) + { + if (riftXform.Coordinates.InRange(EntityManager, xform.Coordinates, RiftRange)) + { + _popupSystem.PopupEntity(Loc.GetString("carp-rift-proximity", ("proximity", RiftRange)), uid, Filter.Entities(uid)); + return; + } + } + var carpUid = Spawn(component.RiftPrototype, xform.MapPosition); component.Rifts.Add(carpUid); Comp(carpUid).Dragon = uid; @@ -244,6 +260,13 @@ namespace Content.Server.Dragon _audioSystem.PlayPvs(component.SoundDeath, uid, component.SoundDeath.Params); component.DragonStomach.EmptyContainer(); + + foreach (var rift in component.Rifts) + { + QueueDel(rift); + } + + component.Rifts.Clear(); } } diff --git a/Resources/Locale/en-US/actions/actions/dragon.ftl b/Resources/Locale/en-US/actions/actions/dragon.ftl index 09d75c6290..7860d4b046 100644 --- a/Resources/Locale/en-US/actions/actions/dragon.ftl +++ b/Resources/Locale/en-US/actions/actions/dragon.ftl @@ -17,6 +17,7 @@ carp-rift-duplicate = Cannot have 2 charging rifts at the same time! carp-rift-examine = It is [color=yellow]{$percentage}%[/color] charged! carp-rift-max = You have reached your maximum amount of rifts carp-rift-anchor = Rifts require a stable surface to spawn. +carp-rift-proximity = Too close to a nearby rift! Need to be at least {$proximity}m away. carp-rift-weakened = You are unable to summon more rifts in your weakened state. carp-rift-destroyed = A rift has been destroyed! You are now weakened temporarily. diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml b/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml index 1445bdb0c2..894cab4984 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml @@ -148,7 +148,7 @@ name: space carp id: MobCarpDragon suffix: DragonBrood - parent: MobCarp + parent: BaseMobCarp components: - type: GhostTakeoverAvailable makeSentient: true