forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port Profanol with custom curse words (space-wizards#552)
- Loading branch information
Showing
11 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
Content.Server/Goobstation/Speech/EntitySystems/VulgarAccentSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// CREATED BY Goldminermac | ||
// https://github.com/space-wizards/space-station-14/pull/31149 | ||
// LICENSED UNDER THE MIT LICENSE | ||
// SEE README.MD AND LICENSE.TXT IN THE ROOT OF THIS REPOSITORY FOR MORE INFORMATION | ||
using Content.Shared.Speech.Components; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
using System.Text; | ||
|
||
namespace Content.Server.Speech.EntitySystems; | ||
|
||
public sealed class VulgarAccentSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly ILocalizationManager _loc = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly ReplacementAccentSystem _replacement = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<VulgarAccentComponent, AccentGetEvent>(OnAccentGet); | ||
} | ||
|
||
public string Accentuate(string message, VulgarAccentComponent component) | ||
{ | ||
string[] messageWords = message.Split(" "); | ||
|
||
for (int i = 0; i < messageWords.Length; i++) | ||
{ | ||
//Every word has a percentage chance to be replaced by a random swear word from the component's array. | ||
if (_random.Prob(component.SwearProb)) | ||
{ | ||
if (!_prototypeManager.TryIndex(component.Pack, out var messagePack)) | ||
return message; | ||
|
||
|
||
string swearWord = _loc.GetString(_random.Pick(messagePack.Values)); | ||
messageWords[i] = swearWord; | ||
} | ||
} | ||
|
||
return string.Join(" ", messageWords); | ||
} | ||
|
||
public void OnAccentGet(EntityUid uid, VulgarAccentComponent component, AccentGetEvent args) | ||
{ | ||
args.Message = Accentuate(args.Message, component); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Content.Shared/Goobstation/Speech/Components/VulgarAccentComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// CREATED BY Goldminermac | ||
// https://github.com/space-wizards/space-station-14/pull/31149 | ||
// LICENSED UNDER THE MIT LICENSE | ||
// SEE README.MD AND LICENSE.TXT IN THE ROOT OF THIS REPOSITORY FOR MORE INFORMATION | ||
using Robust.Shared.GameStates; | ||
using Content.Shared.Dataset; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Shared.Speech.Components; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class VulgarAccentComponent : Component | ||
{ | ||
[DataField] | ||
public ProtoId<LocalizedDatasetPrototype> Pack = "SwearWords"; | ||
|
||
[DataField] | ||
public float SwearProb = 0.5f; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# CREATED BY Goldminermac | ||
# https://github.com/space-wizards/space-station-14/pull/31149 | ||
# LICENSED UNDER THE MIT LICENSE | ||
# SEE README.MD AND LICENSE.TXT IN THE ROOT OF THIS REPOSITORY FOR MORE INFORMATION | ||
accent-vulgar-words-1 = CRAP | ||
accent-vulgar-words-2 = SHIT | ||
accent-vulgar-words-3 = DAMN | ||
accent-vulgar-words-4 = DAMN IT | ||
accent-vulgar-words-5 = BASTARD | ||
accent-vulgar-words-6 = SON OF A SKUB | ||
accent-vulgar-words-7 = PIECE OF SHIT | ||
accent-vulgar-words-8 = NIMWIT | ||
accent-vulgar-words-9 = SKUB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
flavor-base-futuristic = futuristic | ||
flavor-complex-cherry = like cherry | ||
flavor-base-offensive = offensive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
reagent-name-tranquility = tranquility | ||
reagent-desc-tranquility = You feel oddly calm... | ||
reagent-popup-tranquility = You feel oddly calm... | ||
# CREATED BY Goldminermac | ||
# https://github.com/space-wizards/space-station-14/pull/31149 | ||
# LICENSED UNDER THE MIT LICENSE | ||
# SEE README.MD AND LICENSE.TXT IN THE ROOT OF THIS REPOSITORY FOR MORE INFORMATION | ||
reagent-name-profanol = profanol | ||
reagent-desc-profanol = A chemical compound known to make people compulsively swear. A ruiner of countless family reunions and funerals. | ||
# END OF MIT-LICENSED CODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# CREATED BY Goldminermac | ||
# https://github.com/space-wizards/space-station-14/pull/31149 | ||
# LICENSED UNDER THE MIT LICENSE | ||
# SEE README.MD AND LICENSE.TXT IN THE ROOT OF THIS REPOSITORY FOR MORE INFORMATION | ||
- type: localizedDataset | ||
id: SwearWords | ||
values: | ||
prefix: accent-vulgar-words- | ||
count: 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters