]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Mobs burn to ashes on excessive heat damage (#26971)
authorWhisper <121047731+QuietlyWhisper@users.noreply.github.com>
Mon, 15 Apr 2024 05:04:15 +0000 (01:04 -0400)
committerGitHub <noreply@github.com>
Mon, 15 Apr 2024 05:04:15 +0000 (15:04 +1000)
* mobs burn to ashes on excessive heat damage

* remove comment, remove random lines I didn't mean to add

* combine code into behavior

* clean unused

* fix namespace

* drop next to

* fix spawn entities behavior spawning entities outside container

Content.Server/Destructible/Thresholds/Behaviors/BurnBodyBehavior.cs [new file with mode: 0644]
Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs
Resources/Locale/en-US/burning/bodyburn.ftl [new file with mode: 0644]
Resources/Prototypes/Entities/Mobs/base.yml

diff --git a/Content.Server/Destructible/Thresholds/Behaviors/BurnBodyBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/BurnBodyBehavior.cs
new file mode 100644 (file)
index 0000000..28c4b2e
--- /dev/null
@@ -0,0 +1,32 @@
+using Content.Shared.Body.Components;
+using Content.Shared.Inventory;
+using Content.Shared.Popups;
+using JetBrains.Annotations;
+using Robust.Server.GameObjects;
+
+namespace Content.Server.Destructible.Thresholds.Behaviors;
+
+[UsedImplicitly]
+[DataDefinition]
+public sealed partial class BurnBodyBehavior : IThresholdBehavior
+{
+
+    public void Execute(EntityUid bodyId, DestructibleSystem system, EntityUid? cause = null)
+    {
+        var transformSystem = system.EntityManager.System<TransformSystem>();
+        var inventorySystem = system.EntityManager.System<InventorySystem>();
+        var sharedPopupSystem = system.EntityManager.System<SharedPopupSystem>();
+
+        if (!system.EntityManager.TryGetComponent<InventoryComponent>(bodyId, out var comp))
+            return;
+
+        foreach (var item in inventorySystem.GetHandOrInventoryEntities(bodyId))
+        {
+            transformSystem.DropNextTo(item, bodyId);
+        }
+
+        sharedPopupSystem.PopupCoordinates(Loc.GetString("bodyburn-text-others", ("name", bodyId)), transformSystem.GetMoverCoordinates(bodyId), PopupType.LargeCaution);
+
+        system.EntityManager.QueueDeleteEntity(bodyId);
+    }
+}
index ed5777c42aa99632ec216f8d58550bf4bae11b69..0fa3c06c04b89a6ed976cd52dd98b8482c0a365d 100644 (file)
@@ -23,7 +23,10 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
         public float Offset { get; set; } = 0.5f;
 
         [DataField("transferForensics")]
-        public bool DoTransferForensics = false;
+        public bool DoTransferForensics;
+
+        [DataField]
+        public bool SpawnInContainer;
 
         public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
         {
@@ -49,7 +52,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
 
                     if (EntityPrototypeHelpers.HasComponent<StackComponent>(entityId, system.PrototypeManager, system.ComponentFactory))
                     {
-                        var spawned = system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector()));
+                        var spawned = SpawnInContainer
+                            ? system.EntityManager.SpawnNextToOrDrop(entityId, owner)
+                            : system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector()));
                         system.StackSystem.SetCount(spawned, count);
 
                         TransferForensics(spawned, system, owner);
@@ -58,7 +63,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
                     {
                         for (var i = 0; i < count; i++)
                         {
-                            var spawned = system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector()));
+                            var spawned = SpawnInContainer
+                                ? system.EntityManager.SpawnNextToOrDrop(entityId, owner)
+                                : system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector()));
 
                             TransferForensics(spawned, system, owner);
                         }
diff --git a/Resources/Locale/en-US/burning/bodyburn.ftl b/Resources/Locale/en-US/burning/bodyburn.ftl
new file mode 100644 (file)
index 0000000..896a0b6
--- /dev/null
@@ -0,0 +1 @@
+bodyburn-text-others = {$name}'s body burns to ash!
index ac9aabbeadbb5d57e703d0fb9a79248ce14df3f5..065d62c748d4e13ced811e0147e732ca8b1c2e0d 100644 (file)
         damage: 400
       behaviors:
       - !type:GibBehavior { }
+    - trigger:
+        !type:DamageTypeTrigger
+        damageType: Heat
+        damage: 1500
+      behaviors:
+      - !type:SpawnEntitiesBehavior
+        spawnInContainer: true
+        spawn:
+          Ash:
+            min: 1
+            max: 1
+      - !type:BurnBodyBehavior { }
+      - !type:PlaySoundBehavior
+        sound:
+          collection: MeatLaserImpact
   - type: RadiationReceiver
   - type: Stamina
   - type: MobState