Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Random Bark System #466

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions Content.Server/Speech/Components/RandomBarkComponent.cs
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify; what does this do? Not really getting from the description

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
It accelerates the rate at which barks accumulate. The higher the multiplier is, the more often the barks happen. Make it lower to make them bark less often.


/// <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",
};
}
47 changes: 47 additions & 0 deletions Content.Server/Speech/Systems/RandomBarkSystem.cs
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);
}
}
}
65 changes: 65 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- type: Tag
tags:
- VimPilot
- type: RandomBark

- type: entity
name: bee
Expand Down Expand Up @@ -132,6 +133,13 @@
- ReagentId: GroundBee
Quantity: 5
- type: ZombieImmune
- type: RandomBark
barks:
- Bzzzzz
- Bzzz bzzz
- Bzzzzzzzzzzzz
- Bzz
barkMultiplier: 1.5

- type: entity
name: bee
Expand Down Expand Up @@ -242,6 +250,7 @@
- type: NpcFactionMember
factions:
- Passive
- type: RandomBark

- type: entity
parent: MobChicken
Expand Down Expand Up @@ -620,6 +629,8 @@
- type: NpcFactionMember
factions:
- Passive
- type: RandomBark
barkMultiplier: 0.7

- type: entity
name: white duck #Quack
Expand Down Expand Up @@ -799,6 +810,16 @@
- type: GuideHelp
guides:
- Chef
- type: RandomBark
barks:
- Mooooooo
- Moo
- Huff
- Mooooooooooo
- Moooooo
- Moooo
barkMultiplier: 3


- type: entity
name: crab
Expand Down Expand Up @@ -867,6 +888,12 @@
task: RuminantCompound
- type: Body
prototype: AnimalHemocyanin
- type: RandomBark
barks:
- click clack
- clack
- clickity clack
- clack clack

- type: entity
name: goat
Expand Down Expand Up @@ -1479,6 +1506,8 @@
makeSentient: true
name: ghost-role-information-kobold-name
description: ghost-role-information-kobold-description
- type: RandomBark
barkMultiplier: 0.65

- type: entity
name: guidebook monkey
Expand Down Expand Up @@ -1641,6 +1670,8 @@
- type: BadFood
- type: NonSpreaderZombie
- type: PreventSpiller
- type: RandomBark
barkMultiplier: 0.3

- type: entity
parent: MobMouse
Expand Down Expand Up @@ -1876,6 +1907,18 @@
- type: Tag
tags:
- VimPilot
- type: RandomBark
barkMultiplier: 1.3
barks:
- Croooaaaakkk
- Ribbit
- Ribbit
- Ribbit
- Crooaak
- Ribbit
- Ribbit
- Ribbit
- Bibbit

# Would be cool to have some functionality for the parrot to be able to sit on stuff
- type: entity
Expand Down Expand Up @@ -1994,6 +2037,10 @@
heatDamage:
types:
Heat : 0.2 #per second, scales with temperature & other constants
- type: RandomBark
barks:
- Wank
barkMultiplier: 0.6

- type: entity
name: grenade penguin
Expand Down Expand Up @@ -2109,6 +2156,14 @@
- type: Damageable
damageContainer: Biological
damageModifierSet: Scale
- type: RandomBark
barkMultiplier: 1.5
barks:
- Hsssssss
- Hss
- Hsssss
- Hisss
- Hshsss

# Code unique spider prototypes or combine them all into one spider and get a
# random sprite state when you spawn it.
Expand Down Expand Up @@ -2236,6 +2291,7 @@
groups:
Brute: -0.07
Burn: -0.07
- type: RandomBark

- type: entity
name: tarantula
Expand Down Expand Up @@ -2588,6 +2644,7 @@
- type: Tag
tags:
- VimPilot
- type: RandomBark

- type: entity
name: corrupted corgi
Expand Down Expand Up @@ -2747,6 +2804,7 @@
- type: Tag
tags:
- VimPilot
- type: RandomBark

- type: entity
name: calico cat
Expand Down Expand Up @@ -2941,6 +2999,10 @@
- type: Tag
tags:
- VimPilot
- type: RandomBark
barkMultiplier: 10
barks:
- Sloth

- type: entity
name: ferret
Expand Down Expand Up @@ -3140,6 +3202,8 @@
- type: MobPrice
price: 60
- type: NonSpreaderZombie
- type: RandomBark
barkMultiplier: 0.45

- type: entity
name: pig
Expand Down Expand Up @@ -3309,3 +3373,4 @@
components:
- type: ReplacementAccent
accent: nymph
- type: RandomBark
4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/pets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
- VimPilot
- type: StealTarget
stealGroup: AnimalMcGriff
- type: RandomBark
barkMultiplier: 1.3

- type: entity
name: Paperwork
Expand Down Expand Up @@ -432,6 +434,8 @@
- VimPilot
- type: StealTarget
stealGroup: AnimalWalter
- type: RandomBark
barkMultiplier: 1.1

- type: entity
name: Morty
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@
- type: MobPrice
price: 150
- type: FloatingVisuals
- type: Speech
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to make the barks in the first place.

Loading