Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing Mini-Update 1 #1434

Merged
merged 9 commits into from
Jan 5, 2025
3 changes: 2 additions & 1 deletion Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.Popups;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee;
using Content.Server.Weapons.Melee;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Physics.Components;
Expand All @@ -31,7 +32,7 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<StaminaComponent, BeforeThrowEvent>(OnBeforeThrow);
SubscribeLocalEvent<DamageOtherOnHitComponent, DamageExamineEvent>(OnDamageExamine);
SubscribeLocalEvent<DamageOtherOnHitComponent, DamageExamineEvent>(OnDamageExamine, after: [typeof(MeleeWeaponSystem)]);
}

private void OnBeforeThrow(EntityUid uid, StaminaComponent component, ref BeforeThrowEvent args)
Expand Down
21 changes: 21 additions & 0 deletions Content.Server/Projectiles/ProjectileSystem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using Content.Server.Administration.Logs;
using Content.Server.Damage.Systems;
using Content.Server.Effects;
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Camera;
using Content.Shared.Damage;
using Content.Shared.Damage.Events;
using Content.Shared.Database;
using Content.Shared.Projectiles;
using Robust.Shared.Physics.Events;
using Robust.Shared.Player;
using Robust.Shared.Utility;

namespace Content.Server.Projectiles;

Expand All @@ -22,6 +25,7 @@ public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ProjectileComponent, StartCollideEvent>(OnStartCollide);
SubscribeLocalEvent<EmbeddableProjectileComponent, DamageExamineEvent>(OnDamageExamine, after: [typeof(DamageOtherOnHitSystem)]);
}

private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref StartCollideEvent args)
Expand Down Expand Up @@ -75,4 +79,21 @@ private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref St
if (component.ImpactEffect != null && TryComp(uid, out TransformComponent? xform))
RaiseNetworkEvent(new ImpactEffectEvent(component.ImpactEffect, GetNetCoordinates(xform.Coordinates)), Filter.Pvs(xform.Coordinates, entityMan: EntityManager));
}

private void OnDamageExamine(EntityUid uid, EmbeddableProjectileComponent component, ref DamageExamineEvent args)
{
if (!component.EmbedOnThrow)
return;

if (!args.Message.IsEmpty)
args.Message.PushNewline();

var isHarmful = TryComp<EmbedPassiveDamageComponent>(uid, out var passiveDamage) && passiveDamage.Damage.AnyPositive();
var loc = isHarmful
? "damage-examine-embeddable-harmful"
: "damage-examine-embeddable";

var staminaCostMarkup = FormattedMessage.FromMarkupOrThrow(Loc.GetString(loc));
args.Message.AddMessage(staminaCostMarkup);
}
}
3 changes: 2 additions & 1 deletion Content.Server/Weapons/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Chat.Systems;
using Content.Server.CombatMode.Disarm;
using Content.Server.Movement.Systems;
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Actions.Events;
using Content.Shared.Administration.Components;
using Content.Shared.CombatMode;
Expand Down Expand Up @@ -44,7 +45,7 @@ public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MeleeSpeechComponent, MeleeHitEvent>(OnSpeechHit);
SubscribeLocalEvent<MeleeWeaponComponent, DamageExamineEvent>(OnMeleeExamineDamage);
SubscribeLocalEvent<MeleeWeaponComponent, DamageExamineEvent>(OnMeleeExamineDamage, after: [typeof(GunSystem)]);
}

private void OnMeleeExamineDamage(EntityUid uid, MeleeWeaponComponent component, ref DamageExamineEvent args)
Expand Down
24 changes: 12 additions & 12 deletions Content.Shared/Damage/Systems/SharedDamageOtherOnHitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ public override void Initialize()
/// </summary>
private void OnMapInit(EntityUid uid, DamageOtherOnHitComponent component, MapInitEvent args)
{
if (!TryComp<MeleeWeaponComponent>(uid, out var melee))
return;

if (component.Damage.Empty)
component.Damage = melee.Damage * component.MeleeDamageMultiplier;
if (component.SoundHit == null)
component.SoundHit = melee.SoundHit;
if (component.SoundNoDamage == null)
if (TryComp<MeleeWeaponComponent>(uid, out var melee))
{
if (melee.SoundNoDamage != null)
component.SoundNoDamage = melee.SoundNoDamage;
else
component.SoundNoDamage = new SoundCollectionSpecifier("WeakHit");
if (component.Damage.Empty)
component.Damage = melee.Damage * component.MeleeDamageMultiplier;
if (component.SoundHit == null)
component.SoundHit = melee.SoundHit;
if (component.SoundNoDamage == null)
{
if (melee.SoundNoDamage != null)
component.SoundNoDamage = melee.SoundNoDamage;
else
component.SoundNoDamage = new SoundCollectionSpecifier("WeakHit");
}
}

RaiseLocalEvent(uid, new DamageOtherOnHitStartupEvent((uid, component)));
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Objects/Misc/tiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
- type: DamageOnLand
damage:
types:
Blunt: 5
Blunt: 2

- type: entity
name: steel tile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
damage:
types:
Piercing: 10
staminaCost: 6
- type: Item
size: Ginormous
- type: Clothing
Expand Down Expand Up @@ -112,10 +113,6 @@
max: 1
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: DamageOnLand
damage:
types:
Blunt: 5
- type: UseDelay
- type: Appearance
- type: SolutionContainerVisuals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
- type: DamageOtherOnHit
damage:
types:
Blunt: 8
Blunt: 9
staminaCost: 50
soundHit:
collection: MetalThud

- type: entity
# This means that it's not anchored on spawn.
Expand Down
Loading