From: Verm <32827189+Vermidia@users.noreply.github.com>
Date: Mon, 3 Jun 2024 23:45:00 +0000 (-0500)
Subject: Humans can no longer honk on command (#28566)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=2ae5c953de0ee6bb5cafa1c983106c9c4596c8d6;p=space-station-14.git
Humans can no longer honk on command (#28566)
* Humans can no longer honk on command
* Undo change it emote file
* I hate tabs
* Some comments
---
diff --git a/Content.Server/Chat/Systems/ChatSystem.Emote.cs b/Content.Server/Chat/Systems/ChatSystem.Emote.cs
index 20a4f18746..e4e5c39eeb 100644
--- a/Content.Server/Chat/Systems/ChatSystem.Emote.cs
+++ b/Content.Server/Chat/Systems/ChatSystem.Emote.cs
@@ -49,18 +49,20 @@ public partial class ChatSystem
/// Whether or not this message should appear in the adminlog window
/// Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...
/// The name to use for the speaking entity. Usually this should just be modified via . If this is set, the event will not get raised.
+ /// Bypasses whitelist/blacklist/availibility checks for if the entity can use this emote
public void TryEmoteWithChat(
EntityUid source,
string emoteId,
ChatTransmitRange range = ChatTransmitRange.Normal,
bool hideLog = false,
string? nameOverride = null,
- bool ignoreActionBlocker = false
+ bool ignoreActionBlocker = false,
+ bool forceEmote = false
)
{
if (!_prototypeManager.TryIndex(emoteId, out var proto))
return;
- TryEmoteWithChat(source, proto, range, hideLog: hideLog, nameOverride, ignoreActionBlocker: ignoreActionBlocker);
+ TryEmoteWithChat(source, proto, range, hideLog: hideLog, nameOverride, ignoreActionBlocker: ignoreActionBlocker, forceEmote: forceEmote);
}
///
@@ -72,22 +74,18 @@ public partial class ChatSystem
/// Whether or not this message should appear in the chat window
/// Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...
/// The name to use for the speaking entity. Usually this should just be modified via . If this is set, the event will not get raised.
+ /// Bypasses whitelist/blacklist/availibility checks for if the entity can use this emote
public void TryEmoteWithChat(
EntityUid source,
EmotePrototype emote,
ChatTransmitRange range = ChatTransmitRange.Normal,
bool hideLog = false,
string? nameOverride = null,
- bool ignoreActionBlocker = false
+ bool ignoreActionBlocker = false,
+ bool forceEmote = false
)
{
-
- if (_whitelistSystem.IsWhitelistFail(emote.Whitelist, source) || _whitelistSystem.IsBlacklistPass(emote.Blacklist, source))
- return;
-
- if (!emote.Available &&
- TryComp(source, out var speech) &&
- !speech.AllowedEmotes.Contains(emote.ID))
+ if (!forceEmote && !AllowedToUseEmote(source, emote))
return;
// check if proto has valid message for chat
@@ -156,15 +154,40 @@ public partial class ChatSystem
_audio.PlayPvs(sound, uid, param);
return true;
}
-
+ ///
+ /// Checks if a valid emote was typed, to play sounds and etc and invokes an event.
+ ///
+ ///
+ ///
private void TryEmoteChatInput(EntityUid uid, string textInput)
{
var actionLower = textInput.ToLower();
if (!_wordEmoteDict.TryGetValue(actionLower, out var emote))
return;
+ if (!AllowedToUseEmote(uid, emote))
+ return;
+
InvokeEmoteEvent(uid, emote);
}
+ ///
+ /// Checks if we can use this emote based on the emotes whitelist, blacklist, and availibility to the entity.
+ ///
+ /// The entity that is speaking
+ /// The emote being used
+ ///
+ private bool AllowedToUseEmote(EntityUid source, EmotePrototype emote)
+ {
+ if ((_whitelistSystem.IsWhitelistFail(emote.Whitelist, source) || _whitelistSystem.IsBlacklistPass(emote.Blacklist, source)))
+ return false;
+
+ if (!emote.Available &&
+ TryComp(source, out var speech) &&
+ !speech.AllowedEmotes.Contains(emote.ID))
+ return false;
+
+ return true;
+ }
private void InvokeEmoteEvent(EntityUid uid, EmotePrototype proto)
{
diff --git a/Content.Server/Chemistry/ReagentEffects/Emote.cs b/Content.Server/Chemistry/ReagentEffects/Emote.cs
index a4d49e4ad1..db6de6cc75 100644
--- a/Content.Server/Chemistry/ReagentEffects/Emote.cs
+++ b/Content.Server/Chemistry/ReagentEffects/Emote.cs
@@ -8,7 +8,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Server.Chemistry.ReagentEffects;
///
-/// Tries to force someone to emote (scream, laugh, etc).
+/// Tries to force someone to emote (scream, laugh, etc). Still respects whitelists/blacklists and other limits of the specified emote unless forced.
///
[UsedImplicitly]
public sealed partial class Emote : ReagentEffect
@@ -19,6 +19,9 @@ public sealed partial class Emote : ReagentEffect
[DataField]
public bool ShowInChat;
+ [DataField]
+ public bool Force = false;
+
// JUSTIFICATION: Emoting is flavor, so same reason popup messages are not in here.
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> null;
@@ -30,7 +33,7 @@ public sealed partial class Emote : ReagentEffect
var chatSys = args.EntityManager.System();
if (ShowInChat)
- chatSys.TryEmoteWithChat(args.SolutionEntity, EmoteId, ChatTransmitRange.GhostRangeLimit);
+ chatSys.TryEmoteWithChat(args.SolutionEntity, EmoteId, ChatTransmitRange.GhostRangeLimit, forceEmote: Force);
else
chatSys.TryEmoteWithoutChat(args.SolutionEntity, EmoteId);
diff --git a/Resources/Prototypes/Reagents/fun.yml b/Resources/Prototypes/Reagents/fun.yml
index befa8d8296..1df2636c8c 100644
--- a/Resources/Prototypes/Reagents/fun.yml
+++ b/Resources/Prototypes/Reagents/fun.yml
@@ -333,6 +333,7 @@
- !type:Emote
emote: Weh
showInChat: true
+ force: true
probability: 0.5
- !type:Polymorph
prototype: ArtifactLizard # Does the same thing as the original YML I made for this reagent.
diff --git a/Resources/Prototypes/Reagents/toxins.yml b/Resources/Prototypes/Reagents/toxins.yml
index f5b196acf6..9665de7b09 100644
--- a/Resources/Prototypes/Reagents/toxins.yml
+++ b/Resources/Prototypes/Reagents/toxins.yml
@@ -560,6 +560,7 @@
- !type:Emote
emote: Honk
showInChat: true
+ force: true
probability: 0.2
- !type:HealthChange
conditions: