diff --git a/Content.Server/Damage/Components/DamageOnHitComponent.cs b/Content.Server/Damage/Components/DamageOnHitComponent.cs new file mode 100644 index 0000000000..c625168073 --- /dev/null +++ b/Content.Server/Damage/Components/DamageOnHitComponent.cs @@ -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!; +} + diff --git a/Content.Server/Damage/Systems/DamageOnHitSystem.cs b/Content.Server/Damage/Systems/DamageOnHitSystem.cs new file mode 100644 index 0000000000..63ef0f92e6 --- /dev/null +++ b/Content.Server/Damage/Systems/DamageOnHitSystem.cs @@ -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(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); + } +} diff --git a/Resources/Audio/Weapons/attributions.yml b/Resources/Audio/Weapons/attributions.yml index 00ee4e7790..b7b4022eee 100644 --- a/Resources/Audio/Weapons/attributions.yml +++ b/Resources/Audio/Weapons/attributions.yml @@ -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/" diff --git a/Resources/Audio/Weapons/guitarsmash.ogg b/Resources/Audio/Weapons/guitarsmash.ogg new file mode 100644 index 0000000000..dabbed8c2d Binary files /dev/null and b/Resources/Audio/Weapons/guitarsmash.ogg differ diff --git a/Resources/Prototypes/Entities/Objects/Fun/Instruments/instruments_string.yml b/Resources/Prototypes/Entities/Objects/Fun/Instruments/instruments_string.yml index a7f2b2d225..5f38bdca3e 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/Instruments/instruments_string.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/Instruments/instruments_string.yml @@ -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 diff --git a/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/meta.json b/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/meta.json index 8b247337ae..6813282372 100644 --- a/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/meta.json +++ b/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/meta.json @@ -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 diff --git a/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/wielded-inhand-left.png b/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/wielded-inhand-left.png new file mode 100644 index 0000000000..2da0a7ba1d Binary files /dev/null and b/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/wielded-inhand-left.png differ diff --git a/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/wielded-inhand-right.png b/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/wielded-inhand-right.png new file mode 100644 index 0000000000..5d0f4ec150 Binary files /dev/null and b/Resources/Textures/Objects/Fun/Instruments/guitar.rsi/wielded-inhand-right.png differ