]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Meat kudzu (from anomoly) more killable, telegraphs better (#16107)
authorTom Leys <tom@crump-leys.com>
Sat, 6 May 2023 05:08:50 +0000 (17:08 +1200)
committerGitHub <noreply@github.com>
Sat, 6 May 2023 05:08:50 +0000 (15:08 +1000)
14 files changed:
Content.Server/Spreader/GrowingKudzuComponent.cs
Content.Server/Spreader/KudzuComponent.cs
Content.Server/Spreader/KudzuSystem.cs
Resources/Prototypes/Entities/Objects/Misc/kudzu.yml
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_11.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_12.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_13.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_21.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_22.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_23.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_31.png [moved from Resources/Textures/Objects/Misc/fleshkudzu.rsi/base.png with 100% similarity]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_32.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_33.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/fleshkudzu.rsi/meta.json

index 52a122ef1932af09f541e792bc619f4c0b6912ca..b3f571dea84ae51bfd57e90631b3d7fe66e936ab 100644 (file)
@@ -11,9 +11,6 @@ public sealed class GrowingKudzuComponent : Component
     [DataField("growthLevel")]
     public int GrowthLevel = 1;
 
-    [DataField("growthTickChance")]
-    public float GrowthTickChance = 1f;
-
     /// <summary>
     /// The next time kudzu will try to tick its growth level.
     /// </summary>
index ae4aedf6503988beb47d9be13cb8f7dbd54287a4..8fcc56c5dd789a62d47eada489c0ada88d16b5e0 100644 (file)
@@ -1,3 +1,5 @@
+using Content.Shared.Damage;
+
 namespace Content.Server.Spreader;
 
 /// <summary>
@@ -11,4 +13,26 @@ public sealed class KudzuComponent : Component
     /// </summary>
     [DataField("spreadChance")]
     public float SpreadChance = 1f;
+
+    /// <summary>
+    /// How much damage is required to reduce growth level
+    /// </summary>
+    [DataField("growthHealth")]
+    public float GrowthHealth = 10.0f;
+
+    /// <summary>
+    /// How much damage is required to prevent growth
+    /// </summary>
+    [DataField("growthBlock")]
+    public float GrowthBlock = 20.0f;
+
+    /// <summary>
+    /// How much the kudzu heals each tick
+    /// </summary>
+    [DataField("damageRecovery")]
+    public DamageSpecifier? DamageRecovery = null;
+
+    [DataField("growthTickChance")]
+    public float GrowthTickChance = 1f;
+
 }
index 407d99e478c2c37fc43d054b1834d46226809fcb..fa197836530c74d0a81a1f063d3936fac27080a3 100644 (file)
@@ -1,3 +1,4 @@
+using Content.Shared.Damage;
 using Content.Shared.Spreader;
 using Robust.Shared.Random;
 using Robust.Shared.Timing;
@@ -9,6 +10,7 @@ public sealed class KudzuSystem : EntitySystem
     [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly IRobustRandom _robustRandom = default!;
     [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+    [Dependency] private readonly DamageableSystem _damageable = default!;
 
     private const string KudzuGroup = "kudzu";
 
@@ -19,6 +21,28 @@ public sealed class KudzuSystem : EntitySystem
         SubscribeLocalEvent<KudzuComponent, SpreadNeighborsEvent>(OnKudzuSpread);
         SubscribeLocalEvent<GrowingKudzuComponent, EntityUnpausedEvent>(OnKudzuUnpaused);
         SubscribeLocalEvent<SpreadGroupUpdateRate>(OnKudzuUpdateRate);
+        SubscribeLocalEvent<KudzuComponent, DamageChangedEvent>(OnDamageChanged);
+    }
+
+    private void OnDamageChanged(EntityUid uid, KudzuComponent component, DamageChangedEvent args)
+    {
+        // Every time we take any damage, we reduce growth depending on all damage over the growth impact
+        //   So the kudzu gets slower growing the more it is hurt.
+        int growthDamage = (int) (args.Damageable.TotalDamage / component.GrowthHealth);
+        if (growthDamage > 0)
+        {
+            GrowingKudzuComponent? growing;
+            if (!TryComp<GrowingKudzuComponent>(uid, out growing))
+            {
+                growing = AddComp<GrowingKudzuComponent>(uid);
+                growing.GrowthLevel = 3;
+            }
+            growing.GrowthLevel = Math.Max(1, growing.GrowthLevel - growthDamage);
+            if (EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance))
+            {
+                _appearance.SetData(uid, KudzuVisuals.GrowthLevel, growing.GrowthLevel, appearance);
+            }
+        }
     }
 
     private void OnKudzuSpread(EntityUid uid, KudzuComponent component, ref SpreadNeighborsEvent args)
@@ -83,32 +107,55 @@ public sealed class KudzuSystem : EntitySystem
     /// <inheritdoc/>
     public override void Update(float frameTime)
     {
-        var query = EntityQueryEnumerator<GrowingKudzuComponent, AppearanceComponent>();
+        var query = EntityQueryEnumerator<GrowingKudzuComponent, KudzuComponent>();
         var curTime = _timing.CurTime;
 
-        while (query.MoveNext(out var uid, out var kudzu, out var appearance))
+        while (query.MoveNext(out var uid, out var grow, out var kudzu))
         {
-            if (kudzu.NextTick > curTime)
+            if (grow.NextTick > curTime)
             {
                 continue;
             }
 
-            kudzu.NextTick = curTime + TimeSpan.FromSeconds(0.5);
+            grow.NextTick = curTime + TimeSpan.FromSeconds(0.5);
 
             if (!_robustRandom.Prob(kudzu.GrowthTickChance))
             {
                 continue;
             }
 
-            kudzu.GrowthLevel += 1;
+            if (TryComp<DamageableComponent>(uid, out var damage))
+            {
+                if (damage.TotalDamage > 1.0)
+                {
+                    if (kudzu.DamageRecovery != null)
+                    {
+                        // This kudzu features healing, so Gradually heal
+                        _damageable.TryChangeDamage(uid, kudzu.DamageRecovery, true);
+                    }
+                    if (damage.TotalDamage >= kudzu.GrowthBlock)
+                    {
+                        // Don't grow when quite damaged
+                        if (_robustRandom.Prob(0.95f))
+                        {
+                            continue;
+                        }
+                    }
+                }
+            }
 
-            if (kudzu.GrowthLevel >= 3)
+            grow.GrowthLevel += 1;
+
+            if (grow.GrowthLevel >= 3)
             {
                 // why cache when you can simply cease to be? Also saves a bit of memory/time.
                 RemCompDeferred<GrowingKudzuComponent>(uid);
             }
 
-            _appearance.SetData(uid, KudzuVisuals.GrowthLevel, kudzu.GrowthLevel, appearance);
+            if (EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance))
+            {
+                _appearance.SetData(uid, KudzuVisuals.GrowthLevel, grow.GrowthLevel, appearance);
+            }
         }
     }
 }
index 79d4fc15f5723061137f7de8bd975acdefc6c359..40fdcab8f871edf850a666cb4d6230aeaa0c3eef 100644 (file)
@@ -70,8 +70,8 @@
               Heat: 10
     - type: AtmosExposed
     - type: Kudzu
-    - type: GrowingKudzu
       growthTickChance: 0.3
+    - type: GrowingKudzu
     - type: SlowContacts
       walkSpeedModifier: 0.2
       sprintSpeedModifier: 0.2
             "/Audio/Weapons/slash.ogg"
     - type: Sprite
       sprite: Objects/Misc/fleshkudzu.rsi
-      state: base
+      state: kudzu_11
       drawdepth: Overdoors
       netsync: false
     - type: Appearance
+    - type: KudzuVisuals
     - type: Clickable
     - type: Transform
       anchored: true
       thresholds:
       - trigger:
           !type:DamageTrigger
-          damage: 10
+          damage: 40
         behaviors:
         - !type:DoActsBehavior
           acts: [ "Destruction" ]
         tags:
         - Flesh
     - type: Kudzu
+      growthTickChance: 0.3
+      # Heals each time it manages to do a growth tick:
+      damageRecovery:
+        types:
+          Slash: -0.5
+          Heat: -1.0
+          Cold: -1.0
+          Blunt: -0.5 # Needs to be balanced (approx 3x) with vacuum damage to stall but not kill Kudzu
+    - type: Temperature
+      heatDamage:
+        types:
+          Heat: 10
+      coldDamage:
+        types:
+          Cold: 5 #per second, scales with temperature & other constants
+    - type: Barotrauma
+      damage:
+        types:
+          Blunt: 0.15 #per second, scales with pressure and other constants.
+    - type: Flammable
+      fireSpread: true
+      damage:
+       types:
+         Heat: 1
+    - type: GrowingKudzu
+      growthTickChance: 0.3
+    - type: AtmosExposed
     - type: EdgeSpreader
     - type: NodeContainer
       nodes:
           reagents:
           - ReagentId: Protein
             Quantity: 2
+    - type: Respirator
+      damage:
+        types:
+          Asphyxiation: 0.25
+      damageRecovery:
+        types:
+          Asphyxiation: -0.25
+
diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_11.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_11.png
new file mode 100644 (file)
index 0000000..afc0e28
Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_11.png differ
diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_12.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_12.png
new file mode 100644 (file)
index 0000000..afc0e28
Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_12.png differ
diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_13.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_13.png
new file mode 100644 (file)
index 0000000..afc0e28
Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_13.png differ
diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_21.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_21.png
new file mode 100644 (file)
index 0000000..8dcb373
Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_21.png differ
diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_22.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_22.png
new file mode 100644 (file)
index 0000000..8dcb373
Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_22.png differ
diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_23.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_23.png
new file mode 100644 (file)
index 0000000..8dcb373
Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_23.png differ
diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_32.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_32.png
new file mode 100644 (file)
index 0000000..659b2ea
Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_32.png differ
diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_33.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_33.png
new file mode 100644 (file)
index 0000000..659b2ea
Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_33.png differ
index fc8bf10c303e0c6237e56917270948aa732c552e..66738c8e1100e46edb892232863bb2b47bfe865f 100644 (file)
@@ -1,14 +1,38 @@
 {
   "version": 1,
   "license": "CC0-1.0",
-  "copyright": "Created by EmoGarbage404 (github) for space-station-14",
+  "copyright": "Created by EmoGarbage404 & tom-leys (github) for space-station-14",
   "size": {
     "x": 32,
     "y": 32
   },
   "states": [
-    {
-      "name": "base"
-    }
+      {
+          "name": "kudzu_33"
+      },
+      {
+          "name": "kudzu_32"
+      },
+      {
+          "name": "kudzu_31"
+      },
+      {
+          "name": "kudzu_23"
+      },
+      {
+          "name": "kudzu_22"
+      },
+      {
+          "name": "kudzu_21"
+      },
+      {
+          "name": "kudzu_13"
+      },
+      {
+          "name": "kudzu_12"
+      },
+      {
+          "name": "kudzu_11"
+      }
   ]
 }