diff --git a/Content.Server/Spreader/GrowingKudzuComponent.cs b/Content.Server/Spreader/GrowingKudzuComponent.cs index 52a122ef19..b3f571dea8 100644 --- a/Content.Server/Spreader/GrowingKudzuComponent.cs +++ b/Content.Server/Spreader/GrowingKudzuComponent.cs @@ -11,9 +11,6 @@ public sealed class GrowingKudzuComponent : Component [DataField("growthLevel")] public int GrowthLevel = 1; - [DataField("growthTickChance")] - public float GrowthTickChance = 1f; - /// /// The next time kudzu will try to tick its growth level. /// diff --git a/Content.Server/Spreader/KudzuComponent.cs b/Content.Server/Spreader/KudzuComponent.cs index ae4aedf650..8fcc56c5dd 100644 --- a/Content.Server/Spreader/KudzuComponent.cs +++ b/Content.Server/Spreader/KudzuComponent.cs @@ -1,3 +1,5 @@ +using Content.Shared.Damage; + namespace Content.Server.Spreader; /// @@ -11,4 +13,26 @@ public sealed class KudzuComponent : Component /// [DataField("spreadChance")] public float SpreadChance = 1f; + + /// + /// How much damage is required to reduce growth level + /// + [DataField("growthHealth")] + public float GrowthHealth = 10.0f; + + /// + /// How much damage is required to prevent growth + /// + [DataField("growthBlock")] + public float GrowthBlock = 20.0f; + + /// + /// How much the kudzu heals each tick + /// + [DataField("damageRecovery")] + public DamageSpecifier? DamageRecovery = null; + + [DataField("growthTickChance")] + public float GrowthTickChance = 1f; + } diff --git a/Content.Server/Spreader/KudzuSystem.cs b/Content.Server/Spreader/KudzuSystem.cs index 407d99e478..fa19783653 100644 --- a/Content.Server/Spreader/KudzuSystem.cs +++ b/Content.Server/Spreader/KudzuSystem.cs @@ -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(OnKudzuSpread); SubscribeLocalEvent(OnKudzuUnpaused); SubscribeLocalEvent(OnKudzuUpdateRate); + SubscribeLocalEvent(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(uid, out growing)) + { + growing = AddComp(uid); + growing.GrowthLevel = 3; + } + growing.GrowthLevel = Math.Max(1, growing.GrowthLevel - growthDamage); + if (EntityManager.TryGetComponent(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 /// public override void Update(float frameTime) { - var query = EntityQueryEnumerator(); + var query = EntityQueryEnumerator(); 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(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(uid); } - _appearance.SetData(uid, KudzuVisuals.GrowthLevel, kudzu.GrowthLevel, appearance); + if (EntityManager.TryGetComponent(uid, out var appearance)) + { + _appearance.SetData(uid, KudzuVisuals.GrowthLevel, grow.GrowthLevel, appearance); + } } } } diff --git a/Resources/Prototypes/Entities/Objects/Misc/kudzu.yml b/Resources/Prototypes/Entities/Objects/Misc/kudzu.yml index 79d4fc15f5..40fdcab8f8 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/kudzu.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/kudzu.yml @@ -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 @@ -119,10 +119,11 @@ "/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 @@ -141,7 +142,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 10 + damage: 40 behaviors: - !type:DoActsBehavior acts: [ "Destruction" ] @@ -154,6 +155,33 @@ 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: @@ -174,3 +202,11 @@ 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 index 0000000000..afc0e28c56 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 index 0000000000..afc0e28c56 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 index 0000000000..afc0e28c56 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 index 0000000000..8dcb373e1e 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 index 0000000000..8dcb373e1e 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 index 0000000000..8dcb373e1e 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/base.png b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_31.png similarity index 100% rename from Resources/Textures/Objects/Misc/fleshkudzu.rsi/base.png rename to Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_31.png 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 index 0000000000..659b2ea979 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 index 0000000000..659b2ea979 Binary files /dev/null and b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/kudzu_33.png differ diff --git a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/meta.json b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/meta.json index fc8bf10c30..66738c8e11 100644 --- a/Resources/Textures/Objects/Misc/fleshkudzu.rsi/meta.json +++ b/Resources/Textures/Objects/Misc/fleshkudzu.rsi/meta.json @@ -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" + } ] }