Работа для кузнеца (#80)

* add content

* Update CPSharpenedComponent.cs

* Update twoHandedSword.yml

* update
This commit is contained in:
Ed
2024-04-12 21:09:54 +03:00
committed by GitHub
parent f33bc2bd7a
commit 485873839b
26 changed files with 379 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
using Content.Server._CP14.MeleeWeapon;
using Content.Server.Administration.Logs;
using Content.Server.Damage.Components;
using Content.Server.Weapons.Ranged.Systems;
@@ -32,7 +33,14 @@ namespace Content.Server.Damage.Systems
private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
{
var dmg = _damageable.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.Component.Thrower);
//CrystallPunk Melee upgrade
var damage = component.Damage;
if (TryComp<CPSharpenedComponent>(uid, out var sharp))
damage *= sharp.Sharpness;
var dmg = _damageable.TryChangeDamage(args.Target, damage, component.IgnoreResistances, origin: args.Component.Thrower);
//CrystallPunk Melee pgrade end
// Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
if (dmg != null && HasComp<MobStateComponent>(args.Target))
@@ -59,7 +67,12 @@ namespace Content.Server.Damage.Systems
private void OnDamageExamine(EntityUid uid, DamageOtherOnHitComponent component, ref DamageExamineEvent args)
{
_damageExamine.AddDamageExamine(args.Message, component.Damage, Loc.GetString("damage-throw"));
var damage = component.Damage;
if (TryComp<CPSharpenedComponent>(uid, out var sharp))
damage *= sharp.Sharpness;
_damageExamine.AddDamageExamine(args.Message, damage, Loc.GetString("damage-throw"));
}
}
}

View File

@@ -0,0 +1,15 @@
namespace Content.Server._CP14.MeleeWeapon;
/// <summary>
/// allows the object to become blunt with use
/// </summary>
[RegisterComponent, Access(typeof(CPSharpeningSystem))]
public sealed partial class CPSharpenedComponent : Component
{
[DataField]
public float Sharpness = 1f;
[DataField]
public float SharpnessDamageByHit = 0.01f;
}

View File

@@ -0,0 +1,51 @@
using Content.Shared.Damage;
using Robust.Shared.Audio;
namespace Content.Server._CP14.MeleeWeapon;
/// <summary>
/// component allows you to sharpen objects by restoring their damage.
/// </summary>
[RegisterComponent, Access(typeof(CPSharpeningSystem))]
public sealed partial class CPSharpeningStoneComponent : Component
{
/// <summary>
/// the amount of acuity recoverable per use
/// </summary>
[DataField]
public float SharpnessHeal = 0.05f;
/// <summary>
/// sound when used
/// </summary>
[DataField]
public SoundSpecifier SharpeningSound =
new SoundPathSpecifier("/Audio/_CP14/Items/sharpening_stone.ogg")
{
Params = AudioParams.Default.WithVariation(0.02f),
};
/// <summary>
/// the damage that the sharpening stone does to itself for use
/// </summary>
[DataField]
public DamageSpecifier SelfDamage = new()
{
DamageDict = new()
{
{ "Blunt", 1 }
}
};
/// <summary>
/// the damage the sharpening stone does to the target
/// </summary>
[DataField]
public DamageSpecifier TargetDamage = new()
{
DamageDict = new()
{
{ "Blunt", 1 }
}
};
}

View File

@@ -0,0 +1,112 @@
using System.Linq;
using Content.Shared.Damage;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Placeable;
using Content.Shared.Timing;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Wieldable;
using Robust.Shared.Audio.Systems;
namespace Content.Server._CP14.MeleeWeapon;
public sealed class CPSharpeningSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CPSharpenedComponent, GetMeleeDamageEvent>(OnGetMeleeDamage, after: new[] { typeof(WieldableSystem) });
SubscribeLocalEvent<CPSharpenedComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<CPSharpenedComponent, MeleeHitEvent>(OnMeleeHit);
SubscribeLocalEvent<CPSharpeningStoneComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<CPSharpeningStoneComponent, ActivateInWorldEvent>(OnInteract);
}
private void OnMeleeHit(Entity<CPSharpenedComponent> sharpened, ref MeleeHitEvent args)
{
if (!args.HitEntities.Any())
return;
sharpened.Comp.Sharpness = MathHelper.Clamp(sharpened.Comp.Sharpness - sharpened.Comp.SharpnessDamageByHit, 0.1f, 1f);
}
private void OnInteract(Entity<CPSharpeningStoneComponent> stone, ref ActivateInWorldEvent args)
{
if (args.Handled)
return;
if (!TryComp<ItemPlacerComponent>(stone, out var itemPlacer))
return;
if (itemPlacer.PlacedEntities.Count <= 0)
return;
foreach (var item in itemPlacer.PlacedEntities)
{
if (!TryComp<CPSharpenedComponent>(item, out var sharpened))
continue;
SharpThing(stone, item, sharpened);
return;
}
}
private void OnAfterInteract(Entity<CPSharpeningStoneComponent> stone, ref AfterInteractEvent args)
{
if (!args.CanReach || args.Target == null || !TryComp<CPSharpenedComponent>(args.Target, out var sharpened))
return;
if (TryComp<UseDelayComponent>(stone, out var useDelay) && _useDelay.IsDelayed( new Entity<UseDelayComponent>(stone, useDelay)))
return;
SharpThing(stone, args.Target.Value, sharpened);
}
private void SharpThing(Entity<CPSharpeningStoneComponent> stone, EntityUid target, CPSharpenedComponent component)
{
_audio.PlayPvs(stone.Comp.SharpeningSound, target);
Spawn("EffectSparks", Transform(target).Coordinates);
_damageableSystem.TryChangeDamage(stone, stone.Comp.SelfDamage);
_damageableSystem.TryChangeDamage(target, stone.Comp.TargetDamage);
component.Sharpness = MathHelper.Clamp01(component.Sharpness + stone.Comp.SharpnessHeal);
_useDelay.TryResetDelay(stone);
}
private void OnExamined(Entity<CPSharpenedComponent> sharpened, ref ExaminedEvent args)
{
if (sharpened.Comp.Sharpness > 0.95f)
{
args.PushMarkup(Loc.GetString("sharpening-examined-95"));
return;
}
if (sharpened.Comp.Sharpness > 0.75f)
{
args.PushMarkup(Loc.GetString("sharpening-examined-75"));
return;
}
if (sharpened.Comp.Sharpness > 0.5f)
{
args.PushMarkup(Loc.GetString("sharpening-examined-50"));
return;
}
args.PushMarkup(Loc.GetString("sharpening-examined-25"));
}
private void OnGetMeleeDamage(Entity<CPSharpenedComponent> sharpened, ref GetMeleeDamageEvent args)
{
args.Damage *= sharpened.Comp.Sharpness;
}
}

View File

@@ -11,4 +11,9 @@
- files: ["lockpick_fail.ogg"]
license: "CC0-1.0"
copyright: 'by SinusPi of Freesound.org. Cropped and mixed from stereo to mono.'
source: "https://freesound.org/people/SinusPi/sounds/545044/"
source: "https://freesound.org/people/SinusPi/sounds/545044/"
- files: ["sharpening_stone.ogg"]
license: "CC-BY-4.0"
copyright: 'by tim.kahn of Freesound.org. Cropped and mixed from stereo to mono.'
source: "https://freesound.org/people/tim.kahn/sounds/35827/"

Binary file not shown.

View File

@@ -0,0 +1,9 @@
sharpening-examined-95 = Выглядит идеально заточенным
sharpening-examined-75 = Выглядит остро заточенным
sharpening-examined-50 = Выглядит затупившимся
sharpening-examined-25 = Выглядит крайне сильно затупившимся
damageable-weapon-1 = Выглядит полностью целым
damageable-weapon-2 = Покрыт парой царапин
damageable-weapon-3 = Выглядит изношенным
damageable-weapon-4 = Он вот-вот сломается

View File

@@ -0,0 +1,7 @@
- type: examinableDamage
id: CPWeaponMessages
messages:
- damageable-weapon-1
- damageable-weapon-2
- damageable-weapon-3
- damageable-weapon-4

View File

@@ -1,5 +1,18 @@
- type: entity
parent: ClothingOuterStorageBase
abstract: true
parent: Clothing
id: CPClothingCloakBase
components:
- type: Clothing
equipDelay: 1
unequipDelay: 1
slots:
- cloak
- type: Sprite
state: icon
- type: entity
parent: CPClothingCloakBase
id: CPClothingOuterArmoredCloak
name: бронированная накидка
description: Огромные металлические наплечники дают дополнительную защиту от отрубания головы.

View File

@@ -0,0 +1,27 @@
- type: entity
id: CPBaseSharpeningStone
name: точильный камень
description: Позволит заточить притупленное оружие. Если перестараться, вы вполне можете сточить оружие полностью.
parent: BaseItem
components:
- type: Item
size: Tiny
- type: Sprite
sprite: _CP14/Objects/sharpening_stone.rsi
state: base
- type: UseDelay
- type: Damageable
damageContainer: Inorganic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 10
behaviors:
- !type:PlaySoundBehavior
sound:
collection: GlassCrack
- !type:DoActsBehavior
acts: ["Destruction"]
- type: CPSharpeningStone
sharpnessHeal: 0.1

View File

@@ -60,3 +60,31 @@
range: 1.0 # 1.5 standart
cPAnimationOffset: -0.75
- type: entity
id: CPBaseWeaponSharp
abstract: true
components:
- type: Sharp
- type: CPSharpened
- type: CPSharpeningStone
- type: UseDelay
- type: entity
id: CPBaseWeaponDestructible
abstract: true
components:
- type: ExaminableDamage
messages: CPWeaponMessages
- type: Damageable
damageContainer: Inorganic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 50
behaviors:
- !type:PlaySoundBehavior
sound:
collection: MetalBreak
- !type:DoActsBehavior
acts: ["Destruction"]

View File

@@ -2,6 +2,8 @@
id: CPBaseDagger
parent:
- BaseItem
- CPBaseWeaponDestructible
- CPBaseWeaponSharp
- CPBaseWeaponChemical
- CPBaseWeaponThrowable
- CPBaseWeaponLight
@@ -15,7 +17,6 @@
sprite: _CP14/Objects/Weapons/Melee/Dagger/dagger.rsi
layers:
- state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 1.8
wideAnimationRotation: 225

View File

@@ -2,6 +2,8 @@
id: CPBaseHandheldAxe
parent:
- BaseItem
- CPBaseWeaponDestructible
- CPBaseWeaponSharp
- CPBaseWeaponChemical
- CPBaseWeaponThrowable
- CPBaseWeaponLight
@@ -14,7 +16,6 @@
sprite: _CP14/Objects/Weapons/Melee/HandheldAxe/handheldAxe.rsi
layers:
- state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 1.4
range: 1.2

View File

@@ -2,6 +2,7 @@
id: CPBaseLightHammer
parent:
- BaseItem
- CPBaseWeaponDestructible
- CPBaseWeaponChemical
- CPBaseWeaponThrowable
- CPBaseWeaponLight

View File

@@ -2,6 +2,7 @@
id: CPBaseMace
parent:
- BaseItem
- CPBaseWeaponDestructible
name: булава
description: Тяжелый кусок металла на длинной палке. Что может быть проще?
components:

View File

@@ -2,6 +2,8 @@
id: CPBaseSickle
parent:
- BaseItem
- CPBaseWeaponDestructible
- CPBaseWeaponSharp
- CPBaseWeaponChemical
- CPBaseWeaponLight
- CPBaseWeaponShort

View File

@@ -2,6 +2,8 @@
id: CPBaseThrowableSpear
parent:
- BaseItem
- CPBaseWeaponDestructible
- CPBaseWeaponSharp
- CPBaseWeaponChemical
- CPBaseWeaponThrowable
name: метательное копье
@@ -14,7 +16,6 @@
sprite: _CP14/Objects/Weapons/Melee/ThrowableSpear/throwableSpear.rsi
layers:
- state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 1
wideAnimationRotation: -115

View File

@@ -2,6 +2,8 @@
id: CPBaseTwoHandedSword
parent:
- BaseItem
- CPBaseWeaponDestructible
- CPBaseWeaponSharp
- CPBaseWeaponChemical
name: двуручный меч
description: Мощное оружие, требующее огромной силы и умения для эффективного использования.
@@ -17,7 +19,6 @@
- type: Icon
sprite: _CP14/Objects/Weapons/Melee/TwoHandedSword/twoHandedSword32.rsi
state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 0.5
wideAnimationRotation: 205
@@ -29,7 +30,7 @@
Structural: 5
soundHit:
collection: MetalThud
cPAnimationLength: 0.8
cPAnimationLength: 0.6
- type: Wieldable
- type: IncreaseDamageOnWield
damage:
@@ -42,4 +43,6 @@
- type: ClothingSpeedModifier
walkModifier: 0.9
sprintModifier: 0.8
- type: HeldSpeedModifier
- type: HeldSpeedModifier
- type: CPSharpened
sharpnessDamageByHit: 0.04

View File

@@ -0,0 +1,48 @@
- type: entity
id: CPBaseSharpeningStoneStructure
name: стационарный точильный камень
description: прочный, долговечный точильный камень, способный затачивать оружие без особого вреда для него.
parent: BaseStructure
components:
- type: Clickable
- type: UseDelay
- type: InteractionOutline
- type: Sprite
sprite: _CP14/Structures/Specific/sharpening_stone.rsi
state: base
- type: PlaceableSurface
- type: ItemPlacer
whitelist:
components:
- CPSharpened
- type: Fixtures
fixtures:
fix1:
shape:
!type:PhysShapeAabb
bounds: "-0.08,-0.35,0.15,0.25"
mask:
- TabletopMachineMask
layer:
- Impassable
- MidImpassable
- LowImpassable
hard: false
- type: Damageable
damageContainer: Inorganic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 100
behaviors:
- !type:PlaySoundBehavior
sound:
collection: GlassCrack
- !type:DoActsBehavior
acts: ["Destruction"]
- type: CPSharpeningStone
sharpnessHeal: 0.1
targetDamage:
types:
blunt: 0.5

View File

@@ -10,7 +10,7 @@
- type: startingGear
id: CPTestGear
equipment:
outerClothing: CPClothingOuterArmoredCloak
cloak: CPClothingOuterArmoredCloak
innerClothingSkirt: ClothingUniformJumpskirtCargo
satchel: ClothingBackpackSatchelCargoFilled
duffelbag: ClothingBackpackDuffelCargoFilled

View File

@@ -11,7 +11,7 @@
"name": "icon"
},
{
"name": "equipped-OUTERCLOTHING",
"name": "equipped-CLOAK",
"directions": 4
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

View File

@@ -0,0 +1,14 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CC-BY-SA-3.0",
"copyright": "Created by TheShuEd (Github) for CrystallPunk14",
"states": [
{
"name": "base"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,15 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Created by TheShuEd (Github) for CrystallPunk 14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "base",
"directions": 4
}
]
}