Selfdamage for melee (#85) (#342)

* Selfdamage for melee.

* Update base.yml

---------

Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
This commit is contained in:
Gagarinten-Noverdo
2024-07-22 12:18:08 +03:00
committed by GitHub
parent f91a642428
commit cb3c6b555a
11 changed files with 64 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server._CP14.MeleeWeapon;
using Content.Server._CP14.MeleeWeapon.Components;
using Content.Server.Administration.Logs;
using Content.Server.Damage.Components;
using Content.Server.Weapons.Ranged.Systems;

View File

@@ -0,0 +1,10 @@
using Content.Shared.Damage;
namespace Content.Server._CP14.MeleeWeapon.Components;
[RegisterComponent]
public sealed partial class CP14MeleeSelfDamageComponent : Component
{
[DataField(required: true)]
public DamageSpecifier DamageToSelf;
}

View File

@@ -1,5 +1,7 @@
namespace Content.Server._CP14.MeleeWeapon;
using Content.Server._CP14.MeleeWeapon.EntitySystems;
namespace Content.Server._CP14.MeleeWeapon.Components;
/// <summary>
/// allows the object to become blunt with use

View File

@@ -1,7 +1,8 @@
using Content.Shared.Damage;
using Content.Server._CP14.MeleeWeapon.EntitySystems;
using Content.Shared.Damage;
using Robust.Shared.Audio;
namespace Content.Server._CP14.MeleeWeapon;
namespace Content.Server._CP14.MeleeWeapon.Components;
/// <summary>
/// component allows you to sharpen objects by restoring their damage.

View File

@@ -0,0 +1,24 @@
using Content.Server._CP14.MeleeWeapon.Components;
using Content.Shared.Damage;
using Content.Shared.Weapons.Melee.Events;
namespace Content.Server._CP14.MeleeWeapon.EntitySystems;
public sealed class CP14MeleeSelfDamageSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageable = default!;
public override void Initialize()
{
SubscribeLocalEvent<CP14MeleeSelfDamageComponent, MeleeHitEvent>(OnMeleeHit);
}
private void OnMeleeHit(Entity<CP14MeleeSelfDamageComponent> ent, ref MeleeHitEvent args)
{
if (!args.IsHit)
return;
if (args.HitEntities.Count == 0)
return;
_damageable.TryChangeDamage(ent, ent.Comp.DamageToSelf);
}
}

View File

@@ -1,4 +1,5 @@
using System.Linq;
using Content.Server._CP14.MeleeWeapon.Components;
using Content.Shared.Damage;
using Content.Shared.Examine;
using Content.Shared.Interaction;
@@ -8,7 +9,7 @@ using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Wieldable;
using Robust.Shared.Audio.Systems;
namespace Content.Server._CP14.MeleeWeapon;
namespace Content.Server._CP14.MeleeWeapon.EntitySystems;
public sealed class CP14SharpeningSystem : EntitySystem
{

View File

@@ -1,6 +1,7 @@
using System.Numerics;
using Content.Server._CP14.Alchemy;
using Content.Server._CP14.MeleeWeapon;
using Content.Server._CP14.MeleeWeapon.EntitySystems;
using Content.Server.Popups;
using Content.Shared._CP14.Skills;
using Content.Shared._CP14.Skills.Components;

View File

@@ -21,7 +21,7 @@
- type: entity
id: CP14BaseWeaponThrowable
abstract: true
components:
components:
- type: LandAtCursor
- type: DamageOtherOnHit
damage:
@@ -56,7 +56,7 @@
- type: entity
id: CP14BaseWeaponShort
abstract: true
components:
components:
- type: MeleeWeapon
range: 1.0 # 1.5 standart
cPAnimationOffset: -0.75
@@ -88,4 +88,13 @@
sound:
collection: MetalBreak
- !type:DoActsBehavior
acts: ["Destruction"]
acts: ["Destruction"]
- type: entity
id: CP14BaseWeaponSelfDamage
abstract: true
components:
- type: CP14MeleeSelfDamage
damageToSelf:
types:
Blunt: 0.5 # 100 hits

View File

@@ -3,6 +3,7 @@
parent:
- BaseItem
- CP14BaseWeaponDestructible
- CP14BaseWeaponSelfDamage
name: battle hammer
description: A big heavy hammer! Bruh! #TODO
components:
@@ -55,4 +56,4 @@
path: /Audio/_CP14/Effects/thud.ogg
params:
variation: 0.03
volume: 2
volume: 2

View File

@@ -1,11 +1,12 @@
- type: entity
id: CP14BaseLightHammer
parent:
parent:
- BaseItem
- CP14BaseWeaponDestructible
- CP14BaseWeaponThrowable
- CP14BaseWeaponLight
- CP14BaseWeaponShort
- CP14BaseWeaponSelfDamage
name: light hammer
description: A small hammer. Good for carpentry work as well as for cracking skulls.
components:
@@ -40,4 +41,4 @@
collection: CP14Hammering
params:
variation: 0.03
volume: 2
volume: 2

View File

@@ -1,9 +1,10 @@
- type: entity
id: CP14BaseMace
parent:
parent:
- BaseItem
- CP14BaseWeaponDestructible
- CP14BaseWeaponThrowable
- CP14BaseWeaponSelfDamage
name: mace
description: A heavy piece of metal on a long stick. What could be simpler than that?
components:
@@ -32,4 +33,4 @@
- type: DamageOnLand
damage:
types:
Blunt: 10
Blunt: 10