Meat kudzu (from anomoly) more killable, telegraphs better (#16107)

This commit is contained in:
Tom Leys
2023-05-06 17:08:50 +12:00
committed by GitHub
parent 7d31c1daf2
commit eef3c6a5c7
14 changed files with 145 additions and 17 deletions

View 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>

View 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;
}

View 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);
}
}
}
}

View 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
@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View 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"
}
]
}