Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into BoSMidScout
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLopLop committed Nov 17, 2024
2 parents e19b82a + 683ae43 commit 909f605
Show file tree
Hide file tree
Showing 226 changed files with 1,140,474 additions and 13,829 deletions.
19 changes: 12 additions & 7 deletions Content.Server/Administration/ServerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,23 @@ private async Task ActionAhelpSend(IStatusHandlerContext context, Actor actor)
await context.RespondErrorAsync(HttpStatusCode.BadRequest);
return;
}
var _bwoinkSystem = _entitySystemManager.GetEntitySystem<BwoinkSystem>();
var playerUserId = new NetUserId(body.UserId);
var senderUserId = new NetUserId(actor.Guid);
var message = new SharedBwoinkSystem.BwoinkTextMessage(playerUserId,senderUserId, body.Text);
var bwoinkSystem = _entitySystemManager.GetEntitySystem<BwoinkSystem>();
var data = await _locator.LookupIdByNameOrIdAsync($"{body.PlayerNickname}");
if (data != null)
{
var playerUserId = new NetUserId(data.UserId);

var senderUserId = new NetUserId(body.SenderUserId);
var message = new SharedBwoinkSystem.BwoinkTextMessage(playerUserId, senderUserId, body.Text);
await RunOnMainThread(async () =>
{
if (_playerManager.TryGetSessionById(playerUserId, out var session))
{
_bwoinkSystem.DiscordAhelpSendMessage(message, new EntitySessionEventArgs(session));
bwoinkSystem.DiscordAhelpSendMessage(message, new EntitySessionEventArgs(session));
await RespondOk(context);
}
});
}
}

private async Task ShutdownAction(IStatusHandlerContext context, Actor actor)
Expand Down Expand Up @@ -731,8 +736,8 @@ private sealed class GetCkeyActionBody

private sealed class DiscordAhelpBody
{
public required Guid UserId { get; init; }
public required Guid TrueSender { get; init; }
public required string PlayerNickname { get; init; }
public required Guid SenderUserId { get; init; }
public string? Text { get; init; }
}

Expand Down
68 changes: 61 additions & 7 deletions Content.Server/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Content.Server.Administration.Managers;
using Content.Server.Afk;
using Content.Server.Database;
using Content.Server.Discord;
using Content.Server.GameTicking;
using Content.Shared.Administration;
Expand Down Expand Up @@ -35,6 +36,8 @@ public sealed class BwoinkSystem : SharedBwoinkSystem
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly IAfkManager _afkManager = default!;
[Dependency] private readonly IPlayerLocator _locator = default!;
[Dependency] private readonly IServerDbManager _db = default!;

private ISawmill _sawmill = default!;
private readonly HttpClient _httpClient = new();
Expand Down Expand Up @@ -517,10 +520,16 @@ private static string GenerateAHelpMessage(string username, string message, bool
stringbuilder.Append(message);
return stringbuilder.ToString();
}
public void DiscordAhelpSendMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
public async void DiscordAhelpSendMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
{
var senderSession = eventArgs.SenderSession;
// Confirm that this person is actually allowed to send a message here.
var data = await _locator.LookupIdByNameOrIdAsync($"{message.TrueSender}");
if (data != null)
{
var adminNickname = data.Username;

//var adminNickname = _playerManager.GetSessionById(message.TrueSender).Name;
var personalChannel = senderSession.UserId == message.UserId;
var senderAdmin = _adminManager.GetAdminData(senderSession);
var senderAHelpAdmin = senderAdmin?.HasFlag(AdminFlags.Adminhelp) ?? false;
Expand All @@ -530,51 +539,96 @@ public void DiscordAhelpSendMessage(BwoinkTextMessage message, EntitySessionEven
// Unauthorized bwoink (log?)
return;
}

var escapedText = FormattedMessage.EscapeText(message.Text);

string bwoinkText;

if (senderAdmin is not null && senderAdmin.Flags == AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently.
{
bwoinkText = $"[color=purple]{senderSession.Name}[/color]";
bwoinkText = $"[color=purple]{adminNickname}[/color]";
}
else if (senderAdmin is not null && senderAdmin.HasFlag(AdminFlags.Adminhelp))
{
bwoinkText = $"[color=red]{senderSession.Name}[/color]";
bwoinkText = $"[color=red]{adminNickname}[/color]";
}
else
{
bwoinkText = $"{senderSession.Name}";
bwoinkText = $"[color=blue]{adminNickname}[/color]";
}
bwoinkText = $"{"(Discord) "}{bwoinkText}: {escapedText}";

bwoinkText = $"{(message.PlaySound ? "" : "(S) ")}(Discord) {bwoinkText}: {escapedText}";

// If it's not an admin / admin chooses to keep the sound then play it.
var playSound = !senderAHelpAdmin || message.PlaySound;
var msg = new BwoinkTextMessage(message.UserId, message.TrueSender, bwoinkText, playSound: playSound);
var msg = new BwoinkTextMessage(message.UserId, senderSession.UserId, bwoinkText, playSound: playSound);

LogBwoink(msg);

var admins = GetTargetAdmins();

// Notify all admins
foreach (var channel in admins)
{
RaiseNetworkEvent(msg, channel);
}

// Notify player
if (_playerManager.TryGetSessionById(message.UserId, out var session))
{
if (!admins.Contains(session.Channel))
{
// If _overrideClientName is set, we generate a new message with the override name. The admins name will still be the original name for the webhooks.
if (adminNickname != string.Empty)
{
string overrideMsgText;
// Doing the same thing as above, but with the override name. Theres probably a better way to do this.
if (senderAdmin is not null && senderAdmin.Flags == AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently.
{
overrideMsgText = $"[color=purple]{adminNickname}[/color]";
}
else if (senderAdmin is not null && senderAdmin.HasFlag(AdminFlags.Adminhelp))
{
overrideMsgText = $"[color=red]{adminNickname}[/color]";
}
else
{
overrideMsgText = $"[color=blue]{adminNickname}[/color]"; // Not an admin, name is not overridden.
}

overrideMsgText = $"{(message.PlaySound ? "" : "(S) ")}(Discord){overrideMsgText}: {escapedText}";

RaiseNetworkEvent(new BwoinkTextMessage(message.UserId, senderSession.UserId, overrideMsgText, playSound: playSound), session.Channel);
}
else
RaiseNetworkEvent(msg, session.Channel);
}
}
var sendsWebhook = _webhookUrl != string.Empty;
if (sendsWebhook)
{
if (!_messageQueues.ContainsKey(msg.UserId))
_messageQueues[msg.UserId] = new Queue<string>();

var str = message.Text;
var unameLength = senderSession.Name.Length;

if (unameLength + str.Length + _maxAdditionalChars > DescriptionMax)
{
str = str[..(DescriptionMax - _maxAdditionalChars - unameLength)];
}
var nonAfkAdmins = GetNonAfkAdmins();
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, playedSound: playSound, noReceivers: nonAfkAdmins.Count == 0));
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(adminNickname, str, !personalChannel, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, playedSound: false, noReceivers: nonAfkAdmins.Count == 0));
}

if (admins.Count != 0 || sendsWebhook)
return;

// No admin online, let the player know
var systemText = Loc.GetString("bwoink-system-starmute-message-no-other-users");
var starMuteMsg = new BwoinkTextMessage(message.UserId, SystemUserId, systemText);
RaiseNetworkEvent(starMuteMsg, senderSession.Channel);
}
}
}
}
4 changes: 4 additions & 0 deletions Content.Server/Radio/Components/RadioSpeakerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ public sealed partial class RadioSpeakerComponent : Component

[DataField("enabled")]
public bool Enabled;

[DataField("IsSpeaker")] // Set to true for broadcast radio speakers so that it speaks instead of whispers the message.
public bool IsSpeaker;

}
4 changes: 3 additions & 1 deletion Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ private void OnReceiveRadio(EntityUid uid, RadioSpeakerComponent component, ref

// log to chat so people can identity the speaker/source, but avoid clogging ghost chat if there are many radios
var message = args.OriginalChatMsg.Message; // The chat system will handle the rest and re-obfuscate if needed.
_chat.TrySendInGameICMessage(uid, message, InGameICChatType.Whisper, ChatTransmitRange.GhostRangeLimit, nameOverride: name, checkRadioPrefix: false, languageOverride: args.Language);
var chatType = component.IsSpeaker ? InGameICChatType.Speak : InGameICChatType.Whisper;
_chat.TrySendInGameICMessage(uid, message, chatType, ChatTransmitRange.GhostRangeLimit, nameOverride: name, checkRadioPrefix: false, languageOverride: args.Language);

}

private void OnBeforeIntercomUiOpen(EntityUid uid, IntercomComponent component, BeforeActivatableUIOpenEvent args)
Expand Down
Binary file not shown.
6 changes: 4 additions & 2 deletions Resources/Credits/Patrons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
- Name: "TheTrueRatKing"
Tier: Nuclear
- Name: "maxxorion"
Tier: Silver
Tier: Nuclear
- Name: "Baron216"
Tier: Silver
- Name: "Gruinspace"
Tier: Gold
Tier: Gold
- Name: "DeadManWalking97" # jado
Tier: Silver
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_Nuclear14/headset-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ chat-radio-bosmidwest = Brotherhood Midwest
chat-radio-boswashington = Brotherhood Washington
chat-radio-enclave = Enclave
chat-radio-ncr = NCR
chat-radio-pbs = Public Broadcast
59 changes: 57 additions & 2 deletions Resources/Locale/en-US/_Nuclear14/undecidedloadout.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,15 @@ undecided-loadout-category-bos-default-name = Brotherhood Basic Issue Kit
undecided-loadout-category-bos-default-description =
A crate containing everything a member of Brotherhood might need.
For soldiers and laser lovers alike.
Includes 1 laser rifle, 1 laser pistol, 3 MF cells, 2 energy cells, 1 stimpak, C ration MRE
Includes 1 AER-9 laser rifle, 1 laser pistol, 3 MF cells, 2 energy cells, 1 stimpak, C ration MRE
undecided-loadout-category-bos-carbine-name = Brotherhood Carbine Issue Kit
undecided-loadout-category-bos-carbine-description =
A crate containing everything a member of Brotherhood might need.
For your ballistic needs.
Includes 1 pre-war carbine rifle, 1 laser pistol, 3 carbine 556 magazines,
2 energy cells, 1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-laser-name = Brotherhood Laser Issue Kit
undecided-loadout-category-bos-laser-description =
A crate containing everything a member of the Brotherhood might need
Expand All @@ -171,7 +172,7 @@ undecided-loadout-category-bos-scribe-field-name = Brotherhood Scribe Field Kit
undecided-loadout-category-bos-scribe-field-description =
A crate containing everything a member of Brotherhood scribes.
For supporting your unit from the back.
Includes 1 varmint rifle, 1 5.56 ammo box, 1 AEP-7 pistol, 2 energy cells, 1 medical belt,
Includes 1 AEP-7 pistol, 2 energy cells, 1 medical belt,
1 field scribe clothing, 1 knife, 1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-scribe-engineer-name = Brotherhood Scribe Engineer Kit
Expand Down Expand Up @@ -202,3 +203,57 @@ undecided-loadout-category-bos-ballistics-description =
Includes 1 assault rifle, 3 5.56 magazines, 1 12.7mm pistol,
2 12.7mm pistol magazines, 5.56 ammo box, 1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-washington-default-name = Brotherhood Basic Issue Kit
undecided-loadout-category-bos-washington-default-description =
A crate containing everything a member of Brotherhood might need.
For soldiers and laser lovers alike.
Includes 1 1 plasma rifle, 1 laser pistol, 3 MF cells, 2 energy cells, 1 stimpak, C ration MRE
undecided-loadout-category-bos-washington-carbine-name = Brotherhood Carbine Issue Kit
undecided-loadout-category-bos-washington-carbine-description =
A crate containing everything a member of Brotherhood might need.
For your ballistic needs.
Includes 1 pre-war carbine rifle, 10mm pistol, 3 carbine 556 magazines,
2 10mm pistol magazines, 1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-washington-plasma-name = Brotherhood Plasma Issue Kit
undecided-loadout-category-bos-washington-plasma-description =
A crate containing everything a member of the Brotherhood might need
too lay down some laser and lead.
Includes 1 modified plasma rifle, 1 10mm pistol, 3 plasma cartridges,
2 10mm pistol magazines, 1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-washington-scribe-medic-name = Brotherhood Scribe Medical Kit
undecided-loadout-category-bos-washington-scribe-medic-description =
A crate containing everything a member of Brotherhood scribes.
For keeping the fighting forces alive.
Includes 1 AEP-7 pistol, 2 energy cells, 1 medical belt,
1 bullet wound kit, 1 medical scribe clothing, 1 knife, 1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-washington-scribe-field-name = Brotherhood Scribe Field Kit
undecided-loadout-category-bos-washington-scribe-field-description =
A crate containing everything a member of Brotherhood scribes.
For supporting your unit from the back.
Includes 1 AEP-7 pistol, 1 AEP-7 pistol, 2 energy cells, 1 medical belt,
1 field scribe clothing, 1 knife, 1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-washington-scribe-engineer-name = Brotherhood Scribe Engineer Kit
undecided-loadout-category-bos-washington-scribe-engineer-description =
A crate containing everything a member of Brotherhood scribes.
For upkeeping the base and tinkering alike.
Includes 1 AEP-7 laser pistol, 2 energy cells, 1 utility belt,
1 engineer scribe clothing, 1 fire-axe, 1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-washington-ranged-name = Brotherhood Marksman Paladin Kit
undecided-loadout-category-bos-washington-ranged-description =
A crate containing everything a paladin of Brotherhood might need.
For open range fights.
Includes 1 wattz 2000 rifle, 1 laser pistol, 3 H-MF cells, 2 energy cells,
1 stimpak, 1 C ration MRE
undecided-loadout-category-bos-washington-ballistics-name = Brotherhood Assault Paladin Kit
undecided-loadout-category-bos-washington-ballistics-description =
A crate containing everything a paladin of Brotherhood might need.
For his insane need of bullets downrange.
Includes 1 assault rifle, 3 5.56 magazines, 1 10mm pistol,
2 10mm pistol magazines, 5.56 ammo box, 1 stimpak, 1 C ration MRE
Loading

0 comments on commit 909f605

Please sign in to comment.