Glorfcode (force say on damage/stun/crit) (#20562)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Damage.ForceSay;
|
||||
|
||||
/// <summary>
|
||||
/// The reason for this component's existence is slightly unintuitive, so for context: this is put on an entity
|
||||
/// to allow its next speech attempt to bypass <see cref="MobStateComponent"/> checks. The reason for this is to allow
|
||||
/// 'force saying'--for instance, with deathgasping or with <see cref="DamageForceSayComponent"/>.
|
||||
///
|
||||
/// This component is either removed in the <see cref="MobStateSystem"/> speech attempt check, or after <see cref="Timeout"/>
|
||||
/// has passed. This is to allow a player-submitted forced message in the case of <see cref="DamageForceSayComponent"/>,
|
||||
/// while also ensuring that it isn't valid forever. It has to work this way, because the server is not a keylogger and doesn't
|
||||
/// have any knowledge of what the client might actually have typed, so it gives them some leeway for ping.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class AllowNextCritSpeechComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Should be set when adding the component to specify the time that this should be valid for,
|
||||
/// if it should stay valid for some amount of time.
|
||||
/// </summary>
|
||||
public TimeSpan? Timeout = null;
|
||||
}
|
||||
66
Content.Shared/Damage/ForceSay/DamageForceSayComponent.cs
Normal file
66
Content.Shared/Damage/ForceSay/DamageForceSayComponent.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Shared.Damage.ForceSay;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for forcing clients to send messages with a suffix attached (like -GLORF) when taking large amounts
|
||||
/// of damage, or things like entering crit or being stunned.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class DamageForceSayComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The localization string that the message & suffix will be passed into
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId ForceSayMessageWrap = "damage-force-say-message-wrap";
|
||||
|
||||
/// <summary>
|
||||
/// Same as <see cref="ForceSayMessageWrap"/> but for cases where no suffix is used,
|
||||
/// such as when going into crit.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId ForceSayMessageWrapNoSuffix = "damage-force-say-message-wrap-no-suffix";
|
||||
|
||||
/// <summary>
|
||||
/// The fluent string prefix to use when picking a random suffix
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public string ForceSayStringPrefix = "damage-force-say-";
|
||||
|
||||
/// <summary>
|
||||
/// The number of suffixes that exist for use with <see cref="ForceSayStringPrefix"/>.
|
||||
/// i.e. (prefix)-1 through (prefix)-(count)
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int ForceSayStringCount = 7;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of total damage between <see cref="ValidDamageGroups"/> that needs to be taken before
|
||||
/// a force say occurs.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public FixedPoint2 DamageThreshold = FixedPoint2.New(10);
|
||||
|
||||
/// <summary>
|
||||
/// A list of damage group types that are considered when checking <see cref="DamageThreshold"/>.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public HashSet<ProtoId<DamageGroupPrototype>>? ValidDamageGroups = new()
|
||||
{
|
||||
"Brute",
|
||||
"Burn",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The time enforced between force says to avoid spam.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public TimeSpan Cooldown = TimeSpan.FromSeconds(5.0);
|
||||
|
||||
public TimeSpan? NextAllowedTime = null;
|
||||
}
|
||||
13
Content.Shared/Damage/ForceSay/DamageForceSayEvent.cs
Normal file
13
Content.Shared/Damage/ForceSay/DamageForceSayEvent.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Damage.ForceSay;
|
||||
|
||||
/// <summary>
|
||||
/// Sent to clients as a network event when their entity contains <see cref="DamageForceSayComponent"/>
|
||||
/// that COMMANDS them to speak the current message in their chatbox
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class DamageForceSayEvent : EntityEventArgs
|
||||
{
|
||||
public string? Suffix;
|
||||
}
|
||||
Reference in New Issue
Block a user