Skip to content

Commit

Permalink
Mobs burn to ashes on excessive heat damage (space-wizards#26971)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
QuietlyWhisper authored Apr 15, 2024
1 parent 3d0fc10 commit 4a6cf48
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public sealed partial class SpawnEntitiesBehavior : IThresholdBehavior
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)
{
Expand All @@ -49,7 +52,9 @@ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause

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);
Expand All @@ -58,7 +63,9 @@ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause
{
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);
}
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/burning/bodyburn.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bodyburn-text-others = {$name}'s body burns to ash!
15 changes: 15 additions & 0 deletions Resources/Prototypes/Entities/Mobs/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@
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
Expand Down

0 comments on commit 4a6cf48

Please sign in to comment.