-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description Simple-Station/Parkstation-Friendly-Chainsaw#11 Later, I would like to have this system not just for animals, but for implementations of humanoid NPCs, since it can just as easily be used for human NPCs. I could make space bandits that CHEEKI BREEKI at people. # Changelog :cl: DEATHB4DEFEAT - add: Animals will no longer be a silent, soulless shell --------- Signed-off-by: VMSolidus <[email protected]> Co-authored-by: DEATHB4DEFEAT <[email protected]>
- Loading branch information
1 parent
ff6e9b7
commit bc0e2e6
Showing
5 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
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,63 @@ | ||
namespace Content.Server.Speech.Components; | ||
|
||
/// <summary> | ||
/// Sends a random message from a list with a provided min/max time. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class RandomBarkComponent : Component | ||
{ | ||
/// <summary> | ||
/// Should the message be sent to the chat log? | ||
/// </summary> | ||
[DataField] | ||
public bool ChatLog = false; | ||
|
||
/// <summary> | ||
/// Minimum time an animal will go without speaking | ||
/// </summary> | ||
[DataField] | ||
public int MinTime = 45; | ||
|
||
/// <summary> | ||
/// Maximum time an animal will go without speaking | ||
/// </summary> | ||
[DataField] | ||
public int MaxTime = 350; | ||
|
||
/// <summary> | ||
/// Accumulator for counting time since the last bark | ||
/// </summary> | ||
[DataField] | ||
public float BarkAccumulator = 8f; | ||
|
||
/// <summary> | ||
/// Multiplier applied to the random time. Good for changing the frequency without having to specify exact values | ||
/// </summary> | ||
[DataField] | ||
public float BarkMultiplier = 1f; | ||
|
||
/// <summary> | ||
/// List of things to be said. Filled with garbage to be modified by an accent, but can be specified in the .yml | ||
/// </summary> | ||
[DataField] | ||
public IReadOnlyList<string> Barks = new[] | ||
{ | ||
"Bark", | ||
"Boof", | ||
"Woofums", | ||
"Rawrl", | ||
"Eeeeeee", | ||
"Barkums", | ||
"Awooooooooooooooooooo awoo awoooo", | ||
"Grrrrrrrrrrrrrrrrrr", | ||
"Rarrwrarrwr", | ||
"Goddamn I love gold fish crackers", | ||
"Bork bork boof boof bork bork boof boof boof bork", | ||
"Bark", | ||
"Boof", | ||
"Woofums", | ||
"Rawrl", | ||
"Eeeeeee", | ||
"Barkums", | ||
}; | ||
} |
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,47 @@ | ||
using Content.Server.Chat.Systems; | ||
using Content.Shared.Mind.Components; | ||
using Robust.Shared.Random; | ||
using Content.Server.Speech.Components; | ||
|
||
namespace Content.Server.Speech.Systems; | ||
|
||
public sealed class RandomBarkSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly ChatSystem _chat = default!; | ||
[Dependency] private readonly EntityManager _entity = default!; | ||
|
||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<RandomBarkComponent, ComponentInit>(OnInit); | ||
} | ||
|
||
|
||
private void OnInit(EntityUid uid, RandomBarkComponent barker, ComponentInit args) | ||
{ | ||
barker.BarkAccumulator = _random.NextFloat(barker.MinTime, barker.MaxTime) * barker.BarkMultiplier; | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
var query = EntityQueryEnumerator<RandomBarkComponent>(); | ||
while (query.MoveNext(out var uid, out var barker)) | ||
{ | ||
barker.BarkAccumulator -= frameTime; | ||
if (barker.BarkAccumulator > 0) | ||
continue; | ||
|
||
barker.BarkAccumulator = _random.NextFloat(barker.MinTime, barker.MaxTime) * barker.BarkMultiplier; | ||
if (_entity.TryGetComponent<MindContainerComponent>(uid, out var actComp) && | ||
actComp.HasMind) | ||
continue; | ||
|
||
_chat.TrySendInGameICMessage(uid, _random.Pick(barker.Barks), InGameICChatType.Speak, barker.ChatLog ? ChatTransmitRange.Normal : ChatTransmitRange.HideChat); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,3 +104,4 @@ | |
- type: MobPrice | ||
price: 150 | ||
- type: FloatingVisuals | ||
- type: Speech |