Skip to content
Open
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
69 changes: 39 additions & 30 deletions Content.Shared/Blocking/BlockingSystem.User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Content.Shared.Blocking.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;

namespace Content.Shared.Blocking;

Expand All @@ -12,6 +14,8 @@ public sealed partial class BlockingSystem : SharedBlockingSystem // Mono
[Dependency] private DamageableSystem _damageable = default!;
[Dependency] private SharedAudioSystem _audio = default!;

[Dependency] private EntityQuery<PhysicsComponent> _physQuery = default!;

private void InitializeUser()
{
SubscribeLocalEvent<BlockingUserComponent, DamageModifyEvent>(OnUserDamageModified);
Expand Down Expand Up @@ -43,38 +47,43 @@ private void OnAnchorChanged(EntityUid uid, BlockingUserComponent component, ref

private void OnUserDamageModified(EntityUid uid, BlockingUserComponent component, DamageModifyEvent args)
{
if (TryComp<BlockingComponent>(component.BlockingItem, out var blocking)) // Mono
if (!TryComp<BlockingComponent>(component.BlockingItem, out var blocking)) // Mono
return;

if (args.Origin is { } origin // mono
&& Math.Abs(Angle.ShortestDistance(_transformSystem.GetWorldRotation(uid), _transformSystem.GetWorldRotation(origin).Opposite()).Degrees) >= blocking.BlockingArc/2)
return;

if (args.Damage.GetTotal() <= 0)
return;

// A shield should only block damage it can itself absorb. To determine that we need the Damageable component on it.
if (!TryComp<DamageableComponent>(component.BlockingItem, out var dmgComp))
return;

if (TryComp<ItemToggleComponent>(component.BlockingItem, out var toggleComponent) && !toggleComponent.Activated) // Mono
return;

var blockFraction = blocking.IsBlocking ? blocking.ActiveBlockFraction : blocking.PassiveBlockFraction;
blockFraction = Math.Clamp(blockFraction, 0, 1);
_damageable.TryChangeDamage(component.BlockingItem,
blockFraction * args.OriginalDamage,
armorPenetration: args.ArmorPenetration); // Goob edit

var modify = new DamageModifierSet();
foreach (var key in dmgComp.Damage.DamageDict.Keys)
{
modify.Coefficients.TryAdd(key, 1 - blockFraction);
}

args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage,
DamageSpecifier.PenetrateArmor(modify ,args.ArmorPenetration)); // Goob edit

if (blocking.IsBlocking && !args.Damage.Equals(args.OriginalDamage))
{
if (args.Damage.GetTotal() <= 0)
return;

// A shield should only block damage it can itself absorb. To determine that we need the Damageable component on it.
if (!TryComp<DamageableComponent>(component.BlockingItem, out var dmgComp))
return;

if (TryComp<ItemToggleComponent>(component.BlockingItem, out var toggleComponent) && !toggleComponent.Activated) // Mono
return;

var blockFraction = blocking.IsBlocking ? blocking.ActiveBlockFraction : blocking.PassiveBlockFraction;
blockFraction = Math.Clamp(blockFraction, 0, 1);
_damageable.TryChangeDamage(component.BlockingItem,
blockFraction * args.OriginalDamage,
armorPenetration: args.ArmorPenetration); // Goob edit

var modify = new DamageModifierSet();
foreach (var key in dmgComp.Damage.DamageDict.Keys)
{
modify.Coefficients.TryAdd(key, 1 - blockFraction);
}

args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage,
DamageSpecifier.PenetrateArmor(modify ,args.ArmorPenetration)); // Goob edit

if (blocking.IsBlocking && !args.Damage.Equals(args.OriginalDamage))
{
_audio.PlayPvs(blocking.BlockSound, uid);
}
_audio.PlayPvs(blocking.BlockSound, uid);
}

}

private void OnDamageModified(EntityUid uid, BlockingComponent component, DamageModifyEvent args)
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/Blocking/Components/BlockingComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,11 @@ public sealed partial class BlockingComponent : Component
/// </summary>
[DataField]
public bool IsClothing = false;

/// <summary>
/// Mono - Projectiles will be blocked only
/// if it's in the arc of blocking user.
/// </summary>
[DataField]
public float BlockingArc = 105f;
}
4 changes: 1 addition & 3 deletions Resources/Prototypes/Entities/Objects/Shields/shields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@
reflects:
- Energy
- type: Blocking
blockingArc: 75 # Smaller than other shields. Mono edit.
passiveBlockModifier:
coefficients:
Blunt: 1.0
Expand Down Expand Up @@ -459,9 +460,6 @@
autoRechargeRate: 5
- type: RechargeableBlocking
# WD EDIT END
- type: ClothingSpeedModifier # Mono
sprintModifier: 0.9
- type: HeldSpeedModifier

- type: entity
name: broken energy shield
Expand Down
11 changes: 6 additions & 5 deletions Resources/Prototypes/_Mono/Entities/Objects/Shields/shields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
sprite: _Mono/Objects/Weapons/Melee/shields.rsi
state: heavy-icon
- type: Item
size: Ginormous
size: Huge
sprite: _Mono/Objects/Weapons/Melee/shields.rsi
heldPrefix: heavy
- type: Damageable
Expand All @@ -106,18 +106,19 @@
Blunt: 0.35
Slash: 0.35
Piercing: 0.20
Heat: 0.35
Heat: 0.45
Shock: 0.35
passiveBlockFraction: 1
blockingArc: 135
- type: ClothingSpeedModifier
sprintModifier: 0.3
walkModifier: 0.5
sprintModifier: 0.55
walkModifier: 0.8
- type: HeldSpeedModifier
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 200
damage: 180
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
Expand Down
Loading