Guitar Smashing (#17724)

This commit is contained in:
LankLTE
2023-06-29 12:27:08 -07:00
committed by GitHub
parent d24c75ec71
commit b10a7da5d8
8 changed files with 84 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
using Content.Shared.Damage;
// Damages the held item by a set amount when it hits someone. Can be used to make melee items limited-use.
namespace Content.Server.Damage.Components;
[RegisterComponent]
public sealed class DamageOnHitComponent : Component
{
[DataField("ignoreResistances")]
[ViewVariables(VVAccess.ReadWrite)]
public bool IgnoreResistances = true;
[DataField("damage", required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier Damage = default!;
}

View File

@@ -0,0 +1,22 @@
using Content.Server.Damage.Components;
using Content.Shared.Damage;
using Robust.Shared.Player;
using Content.Shared.Weapons.Melee.Events;
namespace Content.Server.Damage.Systems;
public sealed class DamageOnHitSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DamageOnHitComponent, MeleeHitEvent>(DamageItem);
}
// Looks for a hit, then damages the held item an appropriate amount.
private void DamageItem(EntityUid uid, DamageOnHitComponent component, MeleeHitEvent args)
{
_damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances);
}
}

View File

@@ -7,3 +7,8 @@
license: "CC0-1.0"
copyright: "User tosha73 on freesound.org"
source: "https://freesound.org/people/tosha73/sounds/509902/"
- files: ["guitarsmash.ogg"]
license: "CC0-1.0"
copyright: "User Mystovski on freesound.org. Modified by LankLTE on github."
source: "https://freesound.org/people/Mystovski/sounds/201111/"

Binary file not shown.

View File

@@ -105,6 +105,37 @@
slots:
- back
sprite: Objects/Fun/Instruments/guitar.rsi
- type: Wieldable
- type: Damageable # Smash it! Does 20 damage a hit, but breaks after 1 hit.
damageContainer: Inorganic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 20
behaviors:
- !type:PlaySoundBehavior
sound:
path: /Audio/Weapons/guitarsmash.ogg
- !type:SpawnEntitiesBehavior
spawn:
MaterialWoodPlank:
min: 2
max: 4
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: DamageOnHit # This makes it destroy after one hit.
damage:
types:
Blunt: 20
- type: MeleeWeapon
damage:
types:
Blunt: 5
- type: IncreaseDamageOnWield
damage:
types:
Blunt: 15
- type: entity
parent: BaseHandheldInstrument

View File

@@ -18,6 +18,14 @@
"name": "inhand-right",
"directions": 4
},
{
"name": "wielded-inhand-left",
"directions": 4
},
{
"name": "wielded-inhand-right",
"directions": 4
},
{
"name": "equipped-BACKPACK",
"directions": 4

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB