Northstar Gloves (#16021)

* Added Gloves of North Star, no sprite or talking yet...

* Added sprites for the gloves of the north star...

* Replaced more placeholder sprites for northstar gloves...

* Added gloves of the north star to uplink...

* Added speech on hit, not yet configureable

* Not functional yet, but a step in the right direction I hope...

* IT WORKS!!

* Licensing and cleanup

* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise

* Reorganized some files, final build??

* Changed the adminlog type from Verb to new type ItemConfigure

* More cleanup, fix sprite reference maybe

* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx

* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!

* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them

* Made it work with the latest changes on Master

* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click

* Set value to 0 credits, that's all

* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.

* Update MeleeWeaponSystem.cs

Iunno why this got changed in the first place, but I'm changin it back

* emptycommit

* emptycommit

* The tiny fixening
This commit is contained in:
HerCoyote23
2023-05-23 11:12:30 -07:00
committed by GitHub
parent 7ea1906c27
commit e45dd96af9
28 changed files with 383 additions and 47 deletions

View File

@@ -38,7 +38,7 @@ namespace Content.Server.Chat.Commands
return;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Emote, ChatTransmitRange.Normal, shell, player);
.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Emote, ChatTransmitRange.Normal, false, shell, player);
}
}
}

View File

@@ -38,7 +38,7 @@ namespace Content.Server.Chat.Commands
return;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Speak, ChatTransmitRange.Normal, shell, player);
.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Speak, ChatTransmitRange.Normal, false, shell, player);
}
}
}

View File

@@ -38,7 +38,7 @@ namespace Content.Server.Chat.Commands
return;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Whisper, ChatTransmitRange.Normal, shell, player);
.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Whisper, ChatTransmitRange.Normal, false, shell, player);
}
}
}

View File

@@ -52,13 +52,14 @@ public partial class ChatSystem
/// </summary>
/// <param name="source">The entity that is speaking</param>
/// <param name="emoteId">The id of emote prototype. Should has valid <see cref="EmotePrototype.ChatMessages"/></param>
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
public void TryEmoteWithChat(EntityUid source, string emoteId, ChatTransmitRange range = ChatTransmitRange.Normal, string? nameOverride = null)
public void TryEmoteWithChat(EntityUid source, string emoteId, ChatTransmitRange range = ChatTransmitRange.Normal, bool hideLog = false, string? nameOverride = null)
{
if (!_prototypeManager.TryIndex<EmotePrototype>(emoteId, out var proto))
return;
TryEmoteWithChat(source, proto, range, nameOverride);
TryEmoteWithChat(source, proto, range, hideLog, nameOverride);
}
/// <summary>
@@ -66,15 +67,17 @@ public partial class ChatSystem
/// </summary>
/// <param name="source">The entity that is speaking</param>
/// <param name="emote">The emote prototype. Should has valid <see cref="EmotePrototype.ChatMessages"/></param>
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="hideChat">Whether or not this message should appear in the chat window</param>
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
public void TryEmoteWithChat(EntityUid source, EmotePrototype emote, ChatTransmitRange range = ChatTransmitRange.Normal, string? nameOverride = null)
public void TryEmoteWithChat(EntityUid source, EmotePrototype emote, ChatTransmitRange range = ChatTransmitRange.Normal, bool hideLog = false, string? nameOverride = null)
{
// check if proto has valid message for chat
if (emote.ChatMessages.Count != 0)
{
var action = _random.Pick(emote.ChatMessages);
SendEntityEmote(source, action, range, nameOverride, false);
SendEntityEmote(source, action, range, nameOverride, false, hideLog);
}
// do the rest of emote event logic here

View File

@@ -100,14 +100,14 @@ public sealed partial class ChatSystem : SharedChatSystem
private void OnGameChange(GameRunLevelChangedEvent ev)
{
switch(ev.New)
switch (ev.New)
{
case GameRunLevel.InRound:
if(!_configurationManager.GetCVar(CCVars.OocEnableDuringRound))
if (!_configurationManager.GetCVar(CCVars.OocEnableDuringRound))
_configurationManager.SetCVar(CCVars.OocEnabled, false);
break;
case GameRunLevel.PostRound:
if(!_configurationManager.GetCVar(CCVars.OocEnableDuringRound))
if (!_configurationManager.GetCVar(CCVars.OocEnableDuringRound))
_configurationManager.SetCVar(CCVars.OocEnabled, true);
break;
}
@@ -120,13 +120,14 @@ public sealed partial class ChatSystem : SharedChatSystem
/// <param name="message">The message being spoken or emoted</param>
/// <param name="desiredType">The chat type</param>
/// <param name="hideChat">Whether or not this message should appear in the chat window</param>
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
public void TrySendInGameICMessage(EntityUid source, string message, InGameICChatType desiredType, bool hideChat,
public void TrySendInGameICMessage(EntityUid source, string message, InGameICChatType desiredType, bool hideChat, bool hideLog = false,
IConsoleShell? shell = null, IPlayerSession? player = null, string? nameOverride = null, bool checkRadioPrefix = true)
{
TrySendInGameICMessage(source, message, desiredType, hideChat ? ChatTransmitRange.HideChat : ChatTransmitRange.Normal, shell, player, nameOverride, checkRadioPrefix);
TrySendInGameICMessage(source, message, desiredType, hideChat ? ChatTransmitRange.HideChat : ChatTransmitRange.Normal, hideLog, shell, player, nameOverride, checkRadioPrefix);
}
/// <summary>
@@ -139,7 +140,7 @@ public sealed partial class ChatSystem : SharedChatSystem
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
public void TrySendInGameICMessage(EntityUid source, string message, InGameICChatType desiredType, ChatTransmitRange range,
public void TrySendInGameICMessage(EntityUid source, string message, InGameICChatType desiredType, ChatTransmitRange range, bool hideLog = false,
IConsoleShell? shell = null, IPlayerSession? player = null, string? nameOverride = null, bool checkRadioPrefix = true)
{
if (HasComp<GhostComponent>(source))
@@ -194,13 +195,13 @@ public sealed partial class ChatSystem : SharedChatSystem
switch (desiredType)
{
case InGameICChatType.Speak:
SendEntitySpeak(source, message, range, nameOverride);
SendEntitySpeak(source, message, range, nameOverride, hideLog);
break;
case InGameICChatType.Whisper:
SendEntityWhisper(source, message, range, null, nameOverride);
SendEntityWhisper(source, message, range, null, nameOverride, hideLog);
break;
case InGameICChatType.Emote:
SendEntityEmote(source, message, range, nameOverride);
SendEntityEmote(source, message, range, nameOverride, hideLog);
break;
}
}
@@ -294,7 +295,7 @@ public sealed partial class ChatSystem : SharedChatSystem
#region Private API
private void SendEntitySpeak(EntityUid source, string originalMessage, ChatTransmitRange range, string? nameOverride)
private void SendEntitySpeak(EntityUid source, string originalMessage, ChatTransmitRange range, string? nameOverride, bool hideLog = false)
{
if (!_actionBlocker.CanSpeak(source))
return;
@@ -326,7 +327,8 @@ public sealed partial class ChatSystem : SharedChatSystem
RaiseLocalEvent(source, ev, true);
// To avoid logging any messages sent by entities that are not players, like vendors, cloning, etc.
if (!HasComp<ActorComponent>(source))
// Also doesn't log if hideLog is true.
if (!HasComp<ActorComponent>(source) || hideLog == true)
return;
if (originalMessage == message)
@@ -347,7 +349,7 @@ public sealed partial class ChatSystem : SharedChatSystem
}
}
private void SendEntityWhisper(EntityUid source, string originalMessage, ChatTransmitRange range, RadioChannelPrototype? channel, string? nameOverride)
private void SendEntityWhisper(EntityUid source, string originalMessage, ChatTransmitRange range, RadioChannelPrototype? channel, string? nameOverride, bool hideLog = false)
{
if (!_actionBlocker.CanSpeak(source))
return;
@@ -399,26 +401,26 @@ public sealed partial class ChatSystem : SharedChatSystem
var ev = new EntitySpokeEvent(source, message, channel, obfuscatedMessage);
RaiseLocalEvent(source, ev, true);
if (originalMessage == message)
{
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Whisper from {ToPrettyString(source):user} as {name}: {originalMessage}.");
if (!hideLog)
if (originalMessage == message)
{
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Whisper from {ToPrettyString(source):user} as {name}: {originalMessage}.");
else
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Whisper from {ToPrettyString(source):user}: {originalMessage}.");
}
else
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Whisper from {ToPrettyString(source):user}: {originalMessage}.");
}
else
{
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low,
{
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low,
$"Whisper from {ToPrettyString(source):user} as {name}, original: {originalMessage}, transformed: {message}.");
else
_adminLogger.Add(LogType.Chat, LogImpact.Low,
else
_adminLogger.Add(LogType.Chat, LogImpact.Low,
$"Whisper from {ToPrettyString(source):user}, original: {originalMessage}, transformed: {message}.");
}
}
}
private void SendEntityEmote(EntityUid source, string action, ChatTransmitRange range, string? nameOverride, bool checkEmote = true)
private void SendEntityEmote(EntityUid source, string action, ChatTransmitRange range, string? nameOverride, bool hideLog = false, bool checkEmote = true)
{
if (!_actionBlocker.CanEmote(source)) return;
@@ -433,11 +435,11 @@ public sealed partial class ChatSystem : SharedChatSystem
if (checkEmote)
TryEmoteChatInput(source, action);
SendInVoiceRange(ChatChannel.Emotes, action, wrappedMessage, source, range);
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user} as {name}: {action}");
else
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user}: {action}");
if (!hideLog)
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user} as {name}: {action}");
else
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user}: {action}");
}
// ReSharper disable once InconsistentNaming
@@ -714,7 +716,7 @@ public sealed class TransformSpeakerNameEvent : EntityEventArgs
}
/// <summary>
/// Raised broadcast in order to transform speech.
/// Raised broadcast in order to transform speech.transmit
/// </summary>
public sealed class TransformSpeechEvent : EntityEventArgs
{

View File

@@ -0,0 +1,66 @@
using Content.Server.Administration.Logs;
using Content.Shared.Speech.Components;
using Content.Shared.Weapons.Melee;
using Content.Shared.Database;
namespace Content.Server.Speech.EntitySystems;
public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MeleeSpeechComponent, MeleeSpeechBattlecryChangedMessage>(OnBattlecryChanged);
}
private void OnBattlecryChanged(EntityUid uid, MeleeSpeechComponent comp, MeleeSpeechBattlecryChangedMessage args)
{
if (!TryComp<MeleeSpeechComponent>(uid, out var meleeSpeechUser))
return;
TryChangeBattlecry(uid, args.Battlecry, meleeSpeechUser);
}
/// <summary>
/// Attempts to change the battlecry of an entity.
/// Returns true/false.
/// </summary>
/// <remarks>
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
/// </remarks>
public bool TryChangeBattlecry(EntityUid uid, string? battlecry, MeleeSpeechComponent? meleeSpeechComp = null)
{
if (!Resolve(uid, ref meleeSpeechComp))
return false;
if (!string.IsNullOrWhiteSpace(battlecry))
{
battlecry = battlecry.Trim();
}
else
{
battlecry = null;
}
if (meleeSpeechComp.Battlecry == battlecry)
return true;
meleeSpeechComp.Battlecry = battlecry;
Dirty(meleeSpeechComp);
_adminLogger.Add(LogType.ItemConfigure, LogImpact.Medium, $" {ToPrettyString(uid):entity}'s battlecry has been changed to {battlecry}");
return true;
}
}

View File

@@ -42,6 +42,13 @@ namespace Content.Server.UserInterface
[DataField("requireHands")]
public bool RequireHands = true;
/// <summary>
/// Whether you can activate this ui with activateinhand or not
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("rightClickOnly")]
public bool rightClickOnly = false;
/// <summary>
/// Whether spectators (non-admin ghosts) should be allowed to view this UI.
/// </summary>

View File

@@ -91,6 +91,7 @@ public sealed partial class ActivatableUISystem : EntitySystem
private void OnUseInHand(EntityUid uid, ActivatableUIComponent component, UseInHandEvent args)
{
if (args.Handled) return;
if (component.rightClickOnly) return;
args.Handled = InteractUI(args.User, component);
}

View File

@@ -1,14 +1,16 @@
using System.Linq;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chat.Systems;
using Content.Server.Chemistry.Components;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.CombatMode.Disarm;
using Content.Server.Contests;
using Content.Server.Examine;
using Content.Server.Movement.Systems;
using Content.Shared.Actions.Events;
using Content.Server.Popups;
using Content.Shared.Administration.Components;
using Content.Shared.Actions.Events;
using Content.Shared.CombatMode;
using Content.Shared.Damage;
using Content.Shared.Database;
@@ -17,6 +19,7 @@ using Content.Shared.Hands.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Inventory;
using Content.Shared.Popups;
using Content.Shared.Speech.Components;
using Content.Shared.StatusEffect;
using Content.Shared.Tag;
using Content.Shared.Verbs;
@@ -42,11 +45,15 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
[Dependency] private readonly LagCompensationSystem _lag = default!;
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MeleeChemicalInjectorComponent, MeleeHitEvent>(OnChemicalInjectorHit);
SubscribeLocalEvent<MeleeSpeechComponent, MeleeHitEvent>(OnSpeechHit);
SubscribeLocalEvent<MeleeWeaponComponent, GetVerbsEvent<ExamineVerb>>(OnMeleeExaminableVerb);
}
@@ -79,7 +86,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
Text = Loc.GetString("damage-examinable-verb-text"),
Message = Loc.GetString("damage-examinable-verb-message"),
Category = VerbCategory.Examine,
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/smite.svg.192dpi.png")),
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/smite.svg.192dpi.png")),
};
args.Verbs.Add(verb);
@@ -189,7 +196,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
("performerName", Identity.Entity(user, EntityManager)),
("targetName", Identity.Entity(target, EntityManager)));
var msgUser = Loc.GetString(msgPrefix + "popup-message-cursor", ("targetName", Identity.Entity(target, EntityManager)));
var msgUser = Loc.GetString(msgPrefix + "popup-message-cursor", ("targetName", Identity.Entity(target, EntityManager)));
PopupSystem.PopupEntity(msgOther, user, filterOther, true);
PopupSystem.PopupEntity(msgUser, target, user);
@@ -200,7 +207,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
var eventArgs = new DisarmedEvent { Target = target, Source = user, PushProbability = 1 - chance };
RaiseLocalEvent(target, eventArgs);
RaiseNetworkEvent(new DamageEffectEvent(Color.Aqua, new List<EntityUid>() {target}));
RaiseNetworkEvent(new DamageEffectEvent(Color.Aqua, new List<EntityUid>() { target }));
return true;
}
@@ -265,6 +272,21 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
RaiseNetworkEvent(new MeleeLungeEvent(user, angle, localPos, animation), filter);
}
private void OnSpeechHit(EntityUid owner, MeleeSpeechComponent comp, MeleeHitEvent args)
{
if (!args.IsHit ||
!args.HitEntities.Any())
{
return;
}
if (comp.Battlecry != null)//If the battlecry is set to empty, doesn't speak
{
_chat.TrySendInGameICMessage(args.User, comp.Battlecry, InGameICChatType.Speak, true, true); //Speech that isn't sent to chat or adminlogs
}
}
private void OnChemicalInjectorHit(EntityUid owner, MeleeChemicalInjectorComponent comp, MeleeHitEvent args)
{
if (!args.IsHit ||