shield values examine (#17245)

This commit is contained in:
Slava0135
2023-06-17 05:07:58 +03:00
committed by GitHub
parent 99cfe77557
commit 8ed4dcf0fb
7 changed files with 172 additions and 171 deletions

View File

@@ -58,10 +58,7 @@ public sealed partial class BlockingSystem
private void OnDamageModified(EntityUid uid, BlockingComponent component, DamageModifyEvent args) private void OnDamageModified(EntityUid uid, BlockingComponent component, DamageModifyEvent args)
{ {
_proto.TryIndex<DamageModifierSetPrototype>(component.PassiveBlockDamageModifer, out var passiveblockModifier); var modifier = component.IsBlocking ? component.ActiveBlockDamageModifier : component.PassiveBlockDamageModifer;
_proto.TryIndex<DamageModifierSetPrototype>(component.ActiveBlockDamageModifier, out var activeBlockModifier);
var modifier = component.IsBlocking ? activeBlockModifier : passiveblockModifier;
if (modifier == null) if (modifier == null)
{ {
return; return;

View File

@@ -1,7 +1,9 @@
using System.Linq; using System.Linq;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes; using Content.Shared.Actions.ActionTypes;
using Content.Shared.Doors.Components; using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Examine;
using Content.Shared.Hands; using Content.Shared.Hands;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems; using Content.Shared.Hands.EntitySystems;
@@ -12,11 +14,14 @@ using Content.Shared.Mobs.Components;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Toggleable; using Content.Shared.Toggleable;
using Content.Shared.Verbs;
using Robust.Shared.Network;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems; using Robust.Shared.Physics.Systems;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Blocking; namespace Content.Shared.Blocking;
@@ -30,6 +35,8 @@ public sealed partial class BlockingSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;
[Dependency] private readonly INetManager _net = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -44,6 +51,8 @@ public sealed partial class BlockingSystem : EntitySystem
SubscribeLocalEvent<BlockingComponent, ToggleActionEvent>(OnToggleAction); SubscribeLocalEvent<BlockingComponent, ToggleActionEvent>(OnToggleAction);
SubscribeLocalEvent<BlockingComponent, ComponentShutdown>(OnShutdown); SubscribeLocalEvent<BlockingComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<BlockingComponent, GetVerbsEvent<ExamineVerb>>(OnVerbExamine);
} }
private void OnEquip(EntityUid uid, BlockingComponent component, GotEquippedHandEvent args) private void OnEquip(EntityUid uid, BlockingComponent component, GotEquippedHandEvent args)
@@ -80,7 +89,7 @@ public sealed partial class BlockingSystem : EntitySystem
private void OnToggleAction(EntityUid uid, BlockingComponent component, ToggleActionEvent args) private void OnToggleAction(EntityUid uid, BlockingComponent component, ToggleActionEvent args)
{ {
if(args.Handled) if (args.Handled)
return; return;
var blockQuery = GetEntityQuery<BlockingComponent>(); var blockQuery = GetEntityQuery<BlockingComponent>();
@@ -281,4 +290,50 @@ public sealed partial class BlockingSystem : EntitySystem
component.User = null; component.User = null;
} }
private void OnVerbExamine(EntityUid uid, BlockingComponent component, GetVerbsEvent<ExamineVerb> args)
{
if (!args.CanInteract || !args.CanAccess || !_net.IsServer)
return;
var fraction = component.IsBlocking ? component.ActiveBlockFraction : component.PassiveBlockFraction;
var modifier = component.IsBlocking ? component.ActiveBlockDamageModifier : component.PassiveBlockDamageModifer;
var msg = new FormattedMessage();
msg.AddMarkup(Loc.GetString("blocking-fraction", ("value", MathF.Round(fraction * 100, 1))));
if (modifier != null)
{
AppendCoefficients(modifier, msg);
}
_examine.AddDetailedExamineVerb(args, component, msg,
Loc.GetString("blocking-examinable-verb-text"),
"/Textures/Interface/VerbIcons/dot.svg.192dpi.png",
Loc.GetString("blocking-examinable-verb-message")
);
}
private static FormattedMessage AppendCoefficients(DamageModifierSet modifiers, FormattedMessage msg)
{
foreach (var coefficient in modifiers.Coefficients)
{
msg.PushNewline();
msg.AddMarkup(Loc.GetString("blocking-coefficient-value",
("type", coefficient.Key),
("value", MathF.Round(coefficient.Value * 100, 1))
));
}
foreach (var flat in modifiers.FlatReduction)
{
msg.PushNewline();
msg.AddMarkup(Loc.GetString("blocking-reduction-value",
("type", flat.Key),
("value", flat.Value)
));
}
return msg;
}
} }

View File

@@ -1,4 +1,5 @@
using Content.Shared.Actions.ActionTypes; using Content.Shared.Actions.ActionTypes;
using Content.Shared.Damage;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Physics.Collision.Shapes; using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
@@ -31,24 +32,22 @@ public sealed class BlockingComponent : Component
/// <summary> /// <summary>
/// The shape of the blocking fixture that will be dynamically spawned /// The shape of the blocking fixture that will be dynamically spawned
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField("shape")] [DataField("shape"), ViewVariables(VVAccess.ReadWrite)]
public IPhysShape Shape = new PhysShapeCircle(0.5f); public IPhysShape Shape = new PhysShapeCircle(0.5f);
/// <summary> /// <summary>
/// The damage modifer to use while passively blocking /// The damage modifer to use while passively blocking
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField("passiveBlockModifier", required: true)]
[DataField("passiveBlockModifier")] public DamageModifierSet PassiveBlockDamageModifer = default!;
public string PassiveBlockDamageModifer = "Metallic";
/// <summary> /// <summary>
/// The damage modifier to use while actively blocking. /// The damage modifier to use while actively blocking.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField("activeBlockModifier", required: true)]
[DataField("activeBlockModifier")] public DamageModifierSet ActiveBlockDamageModifier = default!;
public string ActiveBlockDamageModifier = "Metallic";
[DataField("blockingToggleActionId", customTypeSerializer:typeof(PrototypeIdSerializer<InstantActionPrototype>))] [DataField("blockingToggleActionId", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
public string BlockingToggleActionId = "ToggleBlock"; public string BlockingToggleActionId = "ToggleBlock";
[DataField("blockingToggleAction")] [DataField("blockingToggleAction")]

View File

@@ -1,5 +1,4 @@
using Content.Shared.Damage; using Robust.Shared.Physics;
using Robust.Shared.Physics;
namespace Content.Shared.Blocking; namespace Content.Shared.Blocking;
@@ -15,14 +14,10 @@ public sealed class BlockingUserComponent : Component
[DataField("blockingItem")] [DataField("blockingItem")]
public EntityUid? BlockingItem; public EntityUid? BlockingItem;
[DataField("modifiers")]
public DamageModifierSet Modifiers = default!;
/// <summary> /// <summary>
/// Stores the entities original bodytype /// Stores the entities original bodytype
/// Used so that it can be put back to what it was after anchoring /// Used so that it can be put back to what it was after anchoring
/// </summary> /// </summary>
[DataField("originalBodyType")] [DataField("originalBodyType")]
public BodyType OriginalBodyType; public BodyType OriginalBodyType;
} }

View File

@@ -0,0 +1,6 @@
# Blocking examines
blocking-examinable-verb-text = Protection
blocking-examinable-verb-message = Examine the protection values.
blocking-fraction = It blocks [color=lightblue]{$value}%[/color] of incoming damage and:
blocking-coefficient-value = - It takes [color=lightblue]{$value}%[/color] of [color=yellow]{$type}[/color] damage.
blocking-reduction-value = - It takes [color=lightblue]{$value}[/color] less [color=yellow]{$type}[/color] damage.

View File

@@ -184,139 +184,3 @@
Cellular: 0.0 Cellular: 0.0
Radiation: 0.2 Radiation: 0.2
Caustic: 0.0 Caustic: 0.0
# Represents what a riot shield should block passively
# Each shield will probably have their own passive and active modifier sets
# Honestly it should not be too high
- type: damageModifierSet
id: PassiveRiotShieldBlock
coefficients:
Blunt: 0.9
Slash: 0.9
Piercing: 0.9
Heat: 0.9
# Represents what a riot shield should block while active
# Should be a higher reduction because you're anchored
- type: damageModifierSet
id: ActiveRiotShieldBlock
coefficients:
Blunt: 0.8
Slash: 0.8
Piercing: 0.8
Heat: 0.8
flatReductions:
Blunt: 1
Slash: 1
Piercing: 1
Heat: 1
- type: damageModifierSet
id: PassiveRiotLaserShieldBlock
coefficients:
Heat: 0.8
- type: damageModifierSet
id: ActiveRiotLaserShieldBlock
coefficients:
Heat: 0.7
flatReductions:
Heat: 2
- type: damageModifierSet
id: PassiveRiotBulletShieldBlock
coefficients:
Blunt: 0.8
Piercing: 0.8
- type: damageModifierSet
id: ActiveRiotBulletShieldBlock
coefficients:
Blunt: 0.7
Piercing: 0.7
flatReductions:
Blunt: 1.5
Piercing: 1.5
#It's made from wood, so it should probably take more heat/laser damage
- type: damageModifierSet
id: PassiveBucklerBlock
coefficients:
Blunt: 0.95
Slash: 0.95
Piercing: 0.95
Heat: 2
- type: damageModifierSet
id: ActiveBucklerBlock
coefficients:
Blunt: 0.85
Slash: 0.85
Piercing: 0.85
Heat: 2
flatReductions:
Blunt: 1
Slash: 1
Piercing: 1
#It's a really crummy shield
- type: damageModifierSet
id: PassiveMakeshiftBlock
coefficients:
Blunt: 0.95
Slash: 0.95
Piercing: 0.95
Heat: 0.9
- type: damageModifierSet
id: ActiveMakeshiftBlock
coefficients:
Blunt: 0.85
Slash: 0.85
Piercing: 0.85
Heat: 0.8
flatReductions:
Blunt: 0.5
Slash: 0.5
Piercing: 0.5
Heat: 1
#Clockwork generally takes more laser/heat damage
- type: damageModifierSet
id: PassiveClockworkShieldBlock
coefficients:
Blunt: 0.8
Slash: 0.8
Piercing: 0.8
Heat: 1.5
- type: damageModifierSet
id: ActiveClockworkShieldBlock
coefficients:
Blunt: 0.7
Slash: 0.7
Piercing: 0.7
Heat: 1.5
flatReductions:
Blunt: 1
Slash: 1
Piercing: 1
#Mirror shield should reflect heat/laser eventually, but be relatively weak to everything else.
- type: damageModifierSet
id: PassiveMirrorShieldBlock
coefficients:
Blunt: 1.2
Slash: 1.2
Piercing: 1.2
Heat: .7
- type: damageModifierSet
id: ActiveMirrorShieldBlock
coefficients:
Blunt: 1.2
Slash: 1.2
Piercing: 1.2
Heat: .6
flatReductions:
Heat: 1

View File

@@ -13,8 +13,23 @@
size: 100 size: 100
heldPrefix: riot heldPrefix: riot
- type: Blocking - type: Blocking
passiveBlockModifier: PassiveRiotShieldBlock passiveBlockModifier:
activeBlockModifier: ActiveRiotShieldBlock coefficients:
Blunt: 0.9
Slash: 0.9
Piercing: 0.9
Heat: 0.9
activeBlockModifier:
coefficients:
Blunt: 0.8
Slash: 0.8
Piercing: 0.8
Heat: 0.8
flatReductions:
Blunt: 1
Slash: 1
Piercing: 1
Heat: 1
blockingToggleAction: blockingToggleAction:
name: action-name-blocking name: action-name-blocking
description: action-description-blocking description: action-description-blocking
@@ -72,8 +87,14 @@
- type: Item - type: Item
heldPrefix: riot_laser heldPrefix: riot_laser
- type: Blocking - type: Blocking
passiveBlockModifier: PassiveRiotLaserShieldBlock passiveBlockModifier:
activeBlockModifier: ActiveRiotLaserShieldBlock coefficients:
Heat: 0.8
activeBlockModifier:
coefficients:
Heat: 0.7
flatReductions:
Heat: 2
- type: entity - type: entity
name: riot bullet shield name: riot bullet shield
@@ -86,8 +107,17 @@
- type: Item - type: Item
heldPrefix: riot_bullet heldPrefix: riot_bullet
- type: Blocking - type: Blocking
passiveBlockModifier: PassiveRiotBulletShieldBlock passiveBlockModifier:
activeBlockModifier: ActiveRiotBulletShieldBlock coefficients:
Blunt: 0.8
Piercing: 0.8
activeBlockModifier:
coefficients:
Blunt: 0.7
Piercing: 0.7
flatReductions:
Blunt: 1.5
Piercing: 1.5
#Craftable shields #Craftable shields
@@ -102,8 +132,22 @@
- type: Item - type: Item
heldPrefix: buckler heldPrefix: buckler
- type: Blocking - type: Blocking
passiveBlockModifier: PassiveBucklerBlock passiveBlockModifier:
activeBlockModifier: ActiveBucklerBlock coefficients:
Blunt: 0.95
Slash: 0.95
Piercing: 0.95
Heat: 2
activeBlockModifier:
coefficients:
Blunt: 0.85
Slash: 0.85
Piercing: 0.85
Heat: 2
flatReductions:
Blunt: 1
Slash: 1
Piercing: 1
- type: Construction - type: Construction
graph: WoodenBuckler graph: WoodenBuckler
node: woodenBuckler node: woodenBuckler
@@ -142,8 +186,23 @@
- type: Item - type: Item
heldPrefix: metal heldPrefix: metal
- type: Blocking - type: Blocking
passiveBlockModifier: PassiveMakeshiftBlock passiveBlockModifier:
activeBlockModifier: ActiveMakeshiftBlock coefficients:
Blunt: 0.95
Slash: 0.95
Piercing: 0.95
Heat: 0.9
activeBlockModifier:
coefficients:
Blunt: 0.85
Slash: 0.85
Piercing: 0.85
Heat: 0.8
flatReductions:
Blunt: 0.5
Slash: 0.5
Piercing: 0.5
Heat: 1
- type: Construction - type: Construction
graph: MakeshiftShield graph: MakeshiftShield
node: makeshiftShield node: makeshiftShield
@@ -182,8 +241,22 @@
- type: Item - type: Item
heldPrefix: ratvarian heldPrefix: ratvarian
- type: Blocking - type: Blocking
passiveBlockModifier: PassiveClockworkShieldBlock passiveBlockModifier:
activeBlockModifier: ActiveClockworkShieldBlock coefficients:
Blunt: 0.8
Slash: 0.8
Piercing: 0.8
Heat: 1.5
activeBlockModifier:
coefficients:
Blunt: 0.7
Slash: 0.7
Piercing: 0.7
Heat: 1.5
flatReductions:
Blunt: 1
Slash: 1
Piercing: 1
#Have it break into brass when clock cult is in #Have it break into brass when clock cult is in
- type: entity - type: entity
@@ -196,9 +269,21 @@
state: mirror-icon state: mirror-icon
- type: Item - type: Item
heldPrefix: mirror heldPrefix: mirror
- type: Blocking - type: Blocking #Mirror shield should reflect heat/laser eventually, but be relatively weak to everything else.
passiveBlockModifier: PassiveMirrorShieldBlock passiveBlockModifier:
activeBlockModifier: ActiveMirrorShieldBlock coefficients:
Blunt: 1.2
Slash: 1.2
Piercing: 1.2
Heat: .7
activeBlockModifier:
coefficients:
Blunt: 1.2
Slash: 1.2
Piercing: 1.2
Heat: .6
flatReductions:
Heat: 1
blockSound: !type:SoundPathSpecifier blockSound: !type:SoundPathSpecifier
path: /Audio/Effects/glass_step.ogg path: /Audio/Effects/glass_step.ogg
- type: Destructible - type: Destructible