Skip to content

Commit

Permalink
Revert "Weapon Reflection Movement Mechanic (space-wizards#27219)"
Browse files Browse the repository at this point in the history
This reverts commit b903733.

# Conflicts:
#	Content.Shared/Alert/AlertType.cs
#	Content.Shared/Weapons/Reflect/ReflectSystem.cs
  • Loading branch information
metalgearsloth committed Jun 22, 2024
1 parent 1048817 commit 5e400e7
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 121 deletions.
35 changes: 5 additions & 30 deletions Content.Shared/Weapons/Reflect/ReflectComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,17 @@ public sealed partial class ReflectComponent : Component
[ViewVariables(VVAccess.ReadWrite), DataField("reflects")]
public ReflectType Reflects = ReflectType.Energy | ReflectType.NonEnergy;

[DataField("spread"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public Angle Spread = Angle.FromDegrees(45);

[DataField("soundOnReflect")]
public SoundSpecifier? SoundOnReflect = new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg");

/// <summary>
/// Is the deflection an innate power or something actively maintained? If true, this component grants a flat
/// deflection chance rather than a chance that degrades when moving/weightless/stunned/etc.
/// </summary>
[DataField]
public bool Innate = false;

/// <summary>
/// Maximum probability for a projectile to be reflected.
/// Probability for a projectile to be reflected.
/// </summary>
[DataField("reflectProb"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public float ReflectProb = 0.25f;

/// <summary>
/// The maximum velocity a wielder can move at before losing effectiveness.
/// </summary>
[DataField]
public float VelocityBeforeNotMaxProb = 2.5f; // Walking speed for a human. Suitable for a weightless deflector like an e-sword.

/// <summary>
/// The velocity a wielder has to be moving at to use the minimum effectiveness value.
/// </summary>
[DataField]
public float VelocityBeforeMinProb = 4.5f; // Sprinting speed for a human. Suitable for a weightless deflector like an e-sword.
[DataField("spread"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public Angle Spread = Angle.FromDegrees(45);

/// <summary>
/// Minimum probability for a projectile to be reflected.
/// </summary>
[DataField]
public float MinReflectProb = 0.1f;
[DataField("soundOnReflect")]
public SoundSpecifier? SoundOnReflect = new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg");
}

[Flags]
Expand Down
64 changes: 26 additions & 38 deletions Content.Shared/Weapons/Reflect/ReflectSystem.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using Content.Shared.Administration.Logs;
using Content.Shared.Alert;
using Content.Shared.Audio;
using Content.Shared.Damage.Components;
using Content.Shared.Database;
using Content.Shared.Gravity;
using Content.Shared.Hands;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Item.ItemToggle.Components;
using Content.Shared.Popups;
using Content.Shared.Projectiles;
using Content.Shared.Standing;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Network;
using Robust.Shared.Physics.Components;
Expand All @@ -38,9 +35,6 @@ public sealed class ReflectSystem : EntitySystem
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
[Dependency] private readonly StandingStateSystem _standing = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;

[ValidatePrototypeId<AlertPrototype>]
private const string DeflectingAlert = "Deflecting";
Expand Down Expand Up @@ -145,24 +139,15 @@ private bool UserCanReflect(Entity<ReflectUserComponent> user, [NotNullWhen(true

private bool TryReflectProjectile(EntityUid user, Entity<ReflectComponent> reflector, Entity<ProjectileComponent> projectile)
{
if (
// Is it on?
!reflector.Comp.Enabled ||
// Is the projectile deflectable?
if (!Resolve(reflector, ref reflect, false) ||
!reflect.Enabled ||
!TryComp<ReflectiveComponent>(projectile, out var reflective) ||
// Does the deflector deflect the type of projecitle?
(reflector.Comp.Reflects & reflective.Reflective) == 0x0 ||
// Is the projectile correctly set up with physics?
!TryComp<PhysicsComponent>(projectile, out var physics) ||
// If the user of the reflector is a mob with stamina, is it capable of deflecting?
TryComp<StaminaComponent>(user, out var staminaComponent) && staminaComponent.Critical ||
_standing.IsDown(reflector)
)
return false;

// If this dice roll fails, the shot isn't deflected
if (!_random.Prob(GetReflectChance(reflector)))
(reflect.Reflects & reflective.Reflective) == 0x0 ||
!_random.Prob(reflect.ReflectProb) ||
!TryComp<PhysicsComponent>(projectile, out var physics))
{
return false;
}

// Below handles what happens after being deflected.
var rotation = _random.NextAngle(-reflector.Comp.Spread / 2, reflector.Comp.Spread / 2).Opposite();
Expand Down Expand Up @@ -194,6 +179,21 @@ private bool TryReflectProjectile(EntityUid user, Entity<ReflectComponent> refle
return true;
}

private void OnReflectHitscan(EntityUid uid, ReflectComponent component, ref HitScanReflectAttemptEvent args)
{
if (args.Reflected ||
(component.Reflects & args.Reflective) == 0x0)
{
return;
}

if (TryReflectHitscan(uid, uid, args.Shooter, args.SourceItem, args.Direction, out var dir))
{
args.Direction = dir.Value;
args.Reflected = true;
}
}

private bool TryReflectHitscan(
EntityUid user,
Entity<ReflectComponent> reflector,
Expand All @@ -202,19 +202,9 @@ private bool TryReflectHitscan(
Vector2 direction,
[NotNullWhen(true)] out Vector2? newDirection)
{
if (
// Is the reflector enabled?
!reflector.Comp.Enabled ||
// If the user is a mob with stamina, is it capable of deflecting?
TryComp<StaminaComponent>(user, out var staminaComponent) && staminaComponent.Critical ||
_standing.IsDown(user))
{
newDirection = null;
return false;
}

// If this dice roll fails, the shot is not deflected.
if (!_random.Prob(GetReflectChance(reflector)))
if (!TryComp<ReflectComponent>(reflector, out var reflect) ||
!reflect.Enabled ||
!_random.Prob(reflect.ReflectProb))
{
newDirection = null;
return false;
Expand Down Expand Up @@ -322,8 +312,6 @@ private void RefreshReflectUser(EntityUid user)
continue;

EnsureComp<ReflectUserComponent>(user);
EnableAlert(user);

return;
}

Expand Down
3 changes: 0 additions & 3 deletions Resources/Locale/en-US/alerts/alerts.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,3 @@ alerts-revenant-essence-desc = The power of souls. It sustains you and is used f
alerts-revenant-corporeal-name = Corporeal
alerts-revenant-corporeal-desc = You have manifested physically. People around you can see and hurt you.
alerts-deflecting-name = Deflecting
alerts-deflecting-desc = You have a chance to deflect incoming projectiles. Standing still or moving slowly will increase this chance.
9 changes: 0 additions & 9 deletions Resources/Prototypes/Alerts/alerts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
- category: Thirst
- alertType: Magboots
- alertType: Pacified
- alertType: Deflecting

- type: entity
id: AlertSpriteView
Expand Down Expand Up @@ -475,11 +474,3 @@
state: critical
name: Debug6
description: Debug

- type: alert
id: Deflecting
icons:
- sprite: /Textures/Interface/Alerts/deflecting.rsi
state: deflecting0
name: alerts-deflecting-name
description: alerts-deflecting-desc
1 change: 0 additions & 1 deletion Resources/Prototypes/Anomaly/behaviours.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
description: anomaly-behavior-reflect
components:
- type: Reflect
innate: true
reflectProb: 0.5
reflects:
- Energy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
Heat: 0.4 # this technically means it protects against fires pretty well? -heat is just for lasers and stuff, not atmos temperature
- type: Reflect
reflectProb: 1
innate: true # armor grants a passive shield that does not require concentration to maintain
reflects:
- Energy

Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/hellspawn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
- type: Perishable
- type: Reflect
reflectProb: 0.7
innate: true
reflects:
- Energy
- type: Fixtures
Expand Down
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 @@ -313,15 +313,14 @@
name: mirror shield
parent: BaseShield
id: MirrorShield
description: Glows an eerie red. You hear the Geometer whispering...
description: Eerily glows red... you hear the geometer whispering
components:
- type: Sprite
state: mirror-icon
- type: Item
heldPrefix: mirror
- type: Reflect
reflectProb: 0.95
innate: true
reflects:
- Energy
- type: Blocking #Mirror shield reflects heat/laser, but is relatively weak to everything else.
Expand Down Expand Up @@ -409,7 +408,6 @@
- type: Reflect
enabled: false
reflectProb: 0.95
innate: true
reflects:
- Energy
- type: Blocking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@
malus: 0
- type: Reflect
enabled: false
reflectProb: 0.5
minReflectProb: 0.25
- type: IgnitionSource
temperature: 700

Expand Down Expand Up @@ -220,7 +218,7 @@
name: double-bladed energy sword
parent: EnergySword
id: EnergySwordDouble
description: Syndicate Command's intern thought that having only one blade on energy swords was not cool enough. This can be stored in pockets.
description: Syndicate Command Interns thought that having one blade on the energy sword was not enough. This can be stored in pockets.
components:
- type: EnergySword
- type: ItemToggle
Expand Down Expand Up @@ -271,8 +269,7 @@
size: Small
sprite: Objects/Weapons/Melee/e_sword_double-inhands.rsi
- type: Reflect
reflectProb: .80
minReflectProb: .65
reflectProb: .75
spread: 75
- type: UseDelay
delay: 1
Expand Down
21 changes: 5 additions & 16 deletions Resources/Prototypes/Entities/Objects/Weapons/Melee/sword.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@
attackRate: 1.5
damage:
types:
Slash: 15
Slash: 17 #cmon, it has to be at least BETTER than the rest.
soundHit:
path: /Audio/Weapons/bladeslice.ogg
- type: Reflect
enabled: true
# Design intent: a robust captain or tot can sacrifice movement to make the most of this weapon, but they have to
# really restrict themselves to walking speed or less.
reflectProb: 0.5
velocityBeforeNotMaxProb: 1.0
velocityBeforeMinProb: 3.0
minReflectProb: 0.1
reflectProb: .1
spread: 90
- type: Item
size: Normal
Expand Down Expand Up @@ -88,9 +83,6 @@
- Back
- Belt
- type: Reflect
reflectProb: 0.3
velocityBeforeNotMaxProb: 6.0 # don't punish ninjas for being ninjas
velocityBeforeMinProb: 10.0

- type: entity
name: machete
Expand Down Expand Up @@ -160,7 +152,7 @@
wideAnimationRotation: -135
damage:
types:
Slash: 15
Slash: 16
soundHit:
path: /Audio/Weapons/bladeslice.ogg
- type: Item
Expand All @@ -172,7 +164,7 @@
name: The Throngler
parent: BaseItem
id: Throngler
description: Why would someone make this?
description: Why would you make this?
components:
- type: Sharp
- type: Sprite
Expand All @@ -193,10 +185,7 @@
path: /Audio/Effects/explosion_small1.ogg
- type: Reflect
enabled: true
reflectProb: 0.5 # In robust hands, deflects as well as an e-sword
velocityBeforeNotMaxProb: 1.0
velocityBeforeMinProb: 3.0
minReflectProb: 0.1
reflectProb: .25
spread: 90
- type: Item
size: Ginormous
Expand Down
Binary file not shown.
14 changes: 0 additions & 14 deletions Resources/Textures/Interface/Alerts/deflecting.rsi/meta.json

This file was deleted.

0 comments on commit 5e400e7

Please sign in to comment.