Skip to content

Commit

Permalink
Random Bark (#11)
Browse files Browse the repository at this point in the history
# Changelog

:cl:
- add: Animals will no longer be a silent, soulless shell

---------

Co-authored-by: Pspritechologist <[email protected]>
  • Loading branch information
DEATHB4DEFEAT and Pspritechologist authored Jan 18, 2024
1 parent ce823ae commit ebe8760
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace Content.Server.SimpleStation14.Speech.Components;

/// <summary>
/// Sends a random message from a list with a provided min/max time.
/// </summary>
[RegisterComponent]
public sealed partial class RandomBarkComponent : Component
{
// Should the message be sent to the chat log?
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool ChatLog = false;

// Minimum time an animal will go without speaking
[DataField, ViewVariables(VVAccess.ReadWrite)]
public int MinTime = 45;

// Maximum time an animal will go without speaking
[DataField, ViewVariables(VVAccess.ReadWrite)]
public int MaxTime = 350;

// Counter
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float BarkAccumulator = 8f;

// Multiplier applied to the random time. Good for changing the frequency without having to specify exact values
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float BarkMultiplier = 1f;

// List of things to be said. Filled with garbage to be modified by an accent, but can be specified in the .yml
[DataField, ViewVariables(VVAccess.ReadWrite)]
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/SimpleStation14/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.SimpleStation14.Speech.Components;

namespace Content.Server.SimpleStation14.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);
}
}
}
81 changes: 73 additions & 8 deletions Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
- type: Tag
tags:
- VimPilot
- type: RandomBark

- type: entity
name: bee
Expand Down Expand Up @@ -133,7 +134,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 @@ -234,6 +241,7 @@
- type: NpcFactionMember
factions:
- Passive
- type: RandomBark

- type: entity
id: FoodEggChickenFertilized
Expand Down Expand Up @@ -526,6 +534,8 @@
- type: NpcFactionMember
factions:
- Passive
- type: RandomBark
barkMultiplier: 0.7

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


- type: entity
name: crab
Expand Down Expand Up @@ -758,6 +778,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 @@ -1161,6 +1187,8 @@
path: /Audio/Animals/monkey_scream.ogg
- type: IdExaminable
- type: AlwaysRevolutionaryConvertible
- type: RandomBark
barkMultiplier: 0.65

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

- type: entity
parent: MobMouse
Expand Down Expand Up @@ -1523,6 +1553,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 @@ -1618,6 +1660,10 @@
- type: NpcFactionMember
factions:
- Passive
- type: RandomBark
barks:
- Wank
barkMultiplier: 0.6

- type: entity
name: grenade penguin
Expand Down Expand Up @@ -1842,6 +1888,14 @@
damageModifierSet: Scale
- type: Puller
needsHands: true
- 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 @@ -1926,6 +1980,7 @@
tags:
- DoorBumpOpener
- FootstepSound
- type: RandomBark

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

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

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

- type: entity
name: ferret
Expand Down Expand Up @@ -2621,13 +2682,14 @@
id: MobHamster
description: A cute, fluffy, robust hamster.
components:
- type: GhostRole
makeSentient: true
allowSpeech: true
allowMovement: true
name: ghost-role-information-hamster-name
description: ghost-role-information-hamster-description
- type: GhostTakeoverAvailable
# - type: GhostTakeoverAvailable
# makeSentient: true
# allowSpeech: true
# allowMovement: true
# whitelistRequired: false
# name: ghost-role-information-hamster-name
# description: ghost-role-information-hamster-description
# - type: GhostTakeoverAvailable
- type: Speech
speechVerb: SmallMob
speechSounds: Squeak
Expand Down Expand Up @@ -2745,6 +2807,8 @@
- type: MobPrice
price: 60
- type: NonSpreaderZombie
- type: RandomBark
barkMultiplier: 0.45

- type: entity
name: pig
Expand Down Expand Up @@ -2817,3 +2881,4 @@
- type: NpcFactionMember
factions:
- Passive
- 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 @@ -301,6 +301,8 @@
tags:
- CannotSuicide
- VimPilot
- type: RandomBark
barkMultiplier: 1.3

- type: entity
name: Paperwork
Expand Down Expand Up @@ -398,6 +400,8 @@
tags:
- CannotSuicide
- VimPilot
- type: RandomBark
barkMultiplier: 1.1

- type: entity
name: Morty
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@
- type: FloatingVisuals
- type: Puller
needsHands: True

- type: Speech

0 comments on commit ebe8760

Please sign in to comment.