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

Stamina Damage Specifiers and Stun Meta Changes #1672

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public sealed partial class MeleeWeaponComponent : Component
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool ResistanceBypass = false;

/// <summary>
/// Base damage for this weapon. Can be modified via heavy damage or other means.
/// </summary>
Expand All @@ -84,6 +84,10 @@ public sealed partial class MeleeWeaponComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 BluntStaminaDamageFactor = FixedPoint2.New(0.5f);

[DataField]
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public DamageSpecifier? Stamina = null;

/// <summary>
/// Multiplies damage by this amount for single-target attacks.
/// </summary>
Expand Down
39 changes: 32 additions & 7 deletions Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Toolshed.Commands.Generic;
using ItemToggleMeleeWeaponComponent = Content.Shared.Item.ItemToggle.Components.ItemToggleMeleeWeaponComponent;

namespace Content.Shared.Weapons.Melee;
Expand Down Expand Up @@ -222,6 +223,17 @@ public DamageSpecifier GetDamage(EntityUid uid, EntityUid user, MeleeWeaponCompo
return DamageSpecifier.ApplyModifierSets(ev.Damage, ev.Modifiers);
}

public DamageSpecifier GetStamina(EntityUid uid, EntityUid user, MeleeWeaponComponent? component = null)
{
if (!Resolve(uid, ref component, false) || component.Stamina == null)
return new DamageSpecifier();

var ev = new GetMeleeDamageEvent(uid, new(component.Stamina), new(), user, component.ResistanceBypass);
RaiseLocalEvent(uid, ref ev);

return DamageSpecifier.ApplyModifierSets(ev.Damage, ev.Modifiers);
}

public float GetAttackRate(EntityUid uid, EntityUid user, MeleeWeaponComponent? component = null)
{
if (!Resolve(uid, ref component))
Expand Down Expand Up @@ -451,6 +463,7 @@ protected virtual void DoLightAttack(EntityUid user, LightAttackEvent ev, Entity
{
// If I do not come back later to fix Light Attacks being Heavy Attacks you can throw me in the spider pit -Errant
var damage = GetDamage(meleeUid, user, component) * GetHeavyDamageModifier(meleeUid, user, component);
var staminaDamage = GetStamina(meleeUid, user, component) * GetHeavyDamageModifier(meleeUid, user, component);
var target = GetEntity(ev.Target);
var resistanceBypass = GetResistanceBypass(meleeUid, user, component);

Expand Down Expand Up @@ -513,12 +526,6 @@ protected virtual void DoLightAttack(EntityUid user, LightAttackEvent ev, Entity

if (damageResult is {Empty: false})
{
// If the target has stamina and is taking blunt damage, they should also take stamina damage based on their blunt to stamina factor
if (damageResult.DamageDict.TryGetValue("Blunt", out var bluntDamage))
{
_stamina.TakeStaminaDamage(target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float(), visual: false, source: user, with: meleeUid == user ? null : meleeUid);
}

if (meleeUid == user)
{
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
Expand All @@ -529,9 +536,17 @@ protected virtual void DoLightAttack(EntityUid user, LightAttackEvent ev, Entity
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
$"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(target.Value):subject} using {ToPrettyString(meleeUid):tool} and dealt {damageResult.GetTotal():damage} damage");
}

}

var modifiedStamina = DamageSpecifier.ApplyModifierSets(staminaDamage, hitEvent.ModifiersList);
FixedPoint2 staminaSum = 0;
modifiedStamina.DamageDict.All(e =>
{
staminaSum += e.Value;
return true;
});
_stamina.TakeStaminaDamage(target.Value, (float) staminaSum, visual: false, source: user, with: meleeUid == user ? null : meleeUid);

_meleeSound.PlayHitSound(target.Value, user, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, component);

if (damageResult?.GetTotal() > FixedPoint2.Zero)
Expand All @@ -558,6 +573,7 @@ private bool DoHeavyAttack(EntityUid user, HeavyAttackEvent ev, EntityUid meleeU
var distance = Math.Min(component.Range, direction.Length());

var damage = GetDamage(meleeUid, user, component);
var staminaDamage = GetStamina(meleeUid, user, component);
var entities = GetEntityList(ev.Entities);

if (entities.Count == 0)
Expand Down Expand Up @@ -671,6 +687,15 @@ private bool DoHeavyAttack(EntityUid user, HeavyAttackEvent ev, EntityUid meleeU
$"{ToPrettyString(user):actor} melee attacked (heavy) {ToPrettyString(entity):subject} using {ToPrettyString(meleeUid):tool} and dealt {damageResult.GetTotal():damage} damage");
}
}

var modifiedStamina = DamageSpecifier.ApplyModifierSets(staminaDamage, hitEvent.ModifiersList);
FixedPoint2 staminaSum = 0;
modifiedStamina.DamageDict.All(e =>
{
staminaSum += e.Value;
return true;
});
_stamina.TakeStaminaDamage(entity, (float) staminaSum, visual: false, source: user, with: meleeUid == user ? null : meleeUid);
}

if (entities.Count != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@
damage:
types:
Blunt: 10
stamina:
types:
Blunt: 20
soundHit:
collection: MetalThud
bluntStaminaDamageFactor: 2.0 # DeltaV - seclite is now a viable nonlethal takedown tool against unarmoured targets.
- type: Item
sprite: Objects/Tools/seclite.rsi
- type: PointLight
Expand Down