Guitar Smashing (#17724)
This commit is contained in:
18
Content.Server/Damage/Components/DamageOnHitComponent.cs
Normal file
18
Content.Server/Damage/Components/DamageOnHitComponent.cs
Normal 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!;
|
||||||
|
}
|
||||||
|
|
||||||
22
Content.Server/Damage/Systems/DamageOnHitSystem.cs
Normal file
22
Content.Server/Damage/Systems/DamageOnHitSystem.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,3 +7,8 @@
|
|||||||
license: "CC0-1.0"
|
license: "CC0-1.0"
|
||||||
copyright: "User tosha73 on freesound.org"
|
copyright: "User tosha73 on freesound.org"
|
||||||
source: "https://freesound.org/people/tosha73/sounds/509902/"
|
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/"
|
||||||
|
|||||||
BIN
Resources/Audio/Weapons/guitarsmash.ogg
Normal file
BIN
Resources/Audio/Weapons/guitarsmash.ogg
Normal file
Binary file not shown.
@@ -105,6 +105,37 @@
|
|||||||
slots:
|
slots:
|
||||||
- back
|
- back
|
||||||
sprite: Objects/Fun/Instruments/guitar.rsi
|
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
|
- type: entity
|
||||||
parent: BaseHandheldInstrument
|
parent: BaseHandheldInstrument
|
||||||
|
|||||||
@@ -18,6 +18,14 @@
|
|||||||
"name": "inhand-right",
|
"name": "inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-left",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-right",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-BACKPACK",
|
"name": "equipped-BACKPACK",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Reference in New Issue
Block a user