Use chat emotes for disease (#15134)

* Use chat emote system for disease

* Use chat emotes in prototypes

* Fix sound path

* Fix prototype ids

* Update Content.Server/Disease/DiseaseSystem.cs

Co-authored-by: Flipp Syder <76629141+vulppine@users.noreply.github.com>

---------

Co-authored-by: Flipp Syder <76629141+vulppine@users.noreply.github.com>
This commit is contained in:
Morb
2023-04-07 16:17:30 -07:00
committed by GitHub
parent a9c4867c59
commit 3c06b87572
26 changed files with 150 additions and 110 deletions

View File

@@ -32,7 +32,6 @@ namespace Content.Server.Disease
/// </summary> /// </summary>
public sealed class DiseaseSystem : EntitySystem public sealed class DiseaseSystem : EntitySystem
{ {
[Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!; [Dependency] private readonly ISerializationManager _serializationManager = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
@@ -42,6 +41,7 @@ namespace Content.Server.Disease
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!; [Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -265,7 +265,7 @@ namespace Content.Server.Disease
{ {
if (TryComp<DiseaseCarrierComponent>(uid, out var carrier)) if (TryComp<DiseaseCarrierComponent>(uid, out var carrier))
{ {
SneezeCough(uid, _random.Pick(carrier.Diseases), string.Empty, null); SneezeCough(uid, _random.Pick(carrier.Diseases), string.Empty);
} }
} }
@@ -418,21 +418,17 @@ namespace Content.Server.Disease
/// and then tries to infect anyone in range /// and then tries to infect anyone in range
/// if the snougher is not wearing a mask. /// if the snougher is not wearing a mask.
/// </summary> /// </summary>
public bool SneezeCough(EntityUid uid, DiseasePrototype? disease, string snoughMessage, SoundSpecifier? snoughSound, bool airTransmit = true, TransformComponent? xform = null) public bool SneezeCough(EntityUid uid, DiseasePrototype? disease, string emoteId, bool airTransmit = true, TransformComponent? xform = null)
{ {
if (!Resolve(uid, ref xform)) return false; if (!Resolve(uid, ref xform)) return false;
if (_mobStateSystem.IsDead(uid)) return false; if (_mobStateSystem.IsDead(uid)) return false;
var attemptSneezeCoughEvent = new AttemptSneezeCoughEvent(uid, snoughMessage, snoughSound); var attemptSneezeCoughEvent = new AttemptSneezeCoughEvent(uid, emoteId);
RaiseLocalEvent(uid, ref attemptSneezeCoughEvent); RaiseLocalEvent(uid, ref attemptSneezeCoughEvent);
if (attemptSneezeCoughEvent.Cancelled) return false; if (attemptSneezeCoughEvent.Cancelled) return false;
if (!string.IsNullOrEmpty(snoughMessage)) _chatSystem.TryEmoteWithChat(uid, emoteId);
_popupSystem.PopupEntity(Loc.GetString(snoughMessage, ("person", Identity.Entity(uid, EntityManager))), uid);
if (snoughSound != null)
_audioSystem.PlayPvs(snoughSound, uid);
if (disease is not { Infectious: true } || !airTransmit) if (disease is not { Infectious: true } || !airTransmit)
return true; return true;

View File

@@ -1,6 +1,7 @@
using Content.Shared.Chat.Prototypes;
using Content.Shared.Disease; using Content.Shared.Disease;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Audio; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Disease namespace Content.Server.Disease
{ {
@@ -12,16 +13,10 @@ namespace Content.Server.Disease
public sealed class DiseaseSnough : DiseaseEffect public sealed class DiseaseSnough : DiseaseEffect
{ {
/// <summary> /// <summary>
/// Message to play when snoughing /// Emote to play when snoughing
/// </summary> /// </summary>
[DataField("snoughMessage")] [DataField("emote", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EmotePrototype>))]
public string SnoughMessage = "disease-sneeze"; public string EmoteId = String.Empty;
/// <summary>
/// Sound to play when snoughing
/// </summary>
[DataField("snoughSound")]
public SoundSpecifier? SnoughSound;
/// <summary> /// <summary>
/// Whether to spread the disease through the air /// Whether to spread the disease through the air
@@ -31,7 +26,7 @@ namespace Content.Server.Disease
public override void Effect(DiseaseEffectArgs args) public override void Effect(DiseaseEffectArgs args)
{ {
EntitySystem.Get<DiseaseSystem>().SneezeCough(args.DiseasedEntity, args.Disease, SnoughMessage, SnoughSound, AirTransmit); EntitySystem.Get<DiseaseSystem>().SneezeCough(args.DiseasedEntity, args.Disease, EmoteId, AirTransmit);
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using Robust.Shared.Audio; using Content.Shared.Chat.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Traits.Assorted; namespace Content.Server.Traits.Assorted;
@@ -9,14 +10,10 @@ namespace Content.Server.Traits.Assorted;
public sealed class UncontrollableSnoughComponent : Component public sealed class UncontrollableSnoughComponent : Component
{ {
/// <summary> /// <summary>
/// Message to play when snoughing. /// Emote to play when snoughing
/// </summary> /// </summary>
[DataField("snoughMessage")] public string SnoughMessage = "disease-sneeze"; [DataField("emote", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EmotePrototype>))]
public string EmoteId = String.Empty;
/// <summary>
/// Sound to play when snoughing.
/// </summary>
[DataField("snoughSound")] public SoundSpecifier? SnoughSound;
/// <summary> /// <summary>
/// The random time between incidents, (min, max). /// The random time between incidents, (min, max).

View File

@@ -27,7 +27,8 @@ public sealed class UncontrollableSnoughSystem : EntitySystem
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var snough in EntityQuery<UncontrollableSnoughComponent>()) var query = EntityQueryEnumerator<UncontrollableSnoughComponent>();
while (query.MoveNext(out var ent, out var snough))
{ {
snough.NextIncidentTime -= frameTime; snough.NextIncidentTime -= frameTime;
@@ -38,7 +39,7 @@ public sealed class UncontrollableSnoughSystem : EntitySystem
snough.NextIncidentTime += snough.NextIncidentTime +=
_random.NextFloat(snough.TimeBetweenIncidents.X, snough.TimeBetweenIncidents.Y); _random.NextFloat(snough.TimeBetweenIncidents.X, snough.TimeBetweenIncidents.Y);
_diseaseSystem.SneezeCough(snough.Owner, null, snough.SnoughMessage, snough.SnoughSound, false); _diseaseSystem.SneezeCough(ent, null, snough.EmoteId, false);
} }
} }
} }

View File

@@ -1,5 +1,3 @@
using Robust.Shared.Audio;
namespace Content.Shared.Disease.Events; namespace Content.Shared.Disease.Events;
/// <summary> /// <summary>
@@ -7,4 +5,4 @@ namespace Content.Shared.Disease.Events;
/// Set Cancelled to true on event handling to suppress the sneeze /// Set Cancelled to true on event handling to suppress the sneeze
/// </summary> /// </summary>
[ByRefEvent] [ByRefEvent]
public record struct AttemptSneezeCoughEvent(EntityUid uid, string SnoughMessage, SoundSpecifier? SnoughSound, bool Cancelled = false); public record struct AttemptSneezeCoughEvent(EntityUid Uid, string? EmoteId, bool Cancelled = false);

View File

@@ -1,11 +1,3 @@
cough1.ogg taken from freesound (deleted user)
cough2.ogg taken from https://freesound.org/people/Harris85/sounds/208761/
sneeze.ogg taken from https://freesound.org/people/sherby168/sounds/540771/
beepboop.ogg taken from https://freesound.org/people/Fidjo20/sounds/503526/ beepboop.ogg taken from https://freesound.org/people/Fidjo20/sounds/503526/
monkey1.ogg taken from https://freesound.org/people/TRAVELcandies/sounds/423396/ monkey1.ogg taken from https://freesound.org/people/TRAVELcandies/sounds/423396/
monkey2.ogg taken from https://freesound.org/people/Archeos/sounds/325549/ monkey2.ogg taken from https://freesound.org/people/Archeos/sounds/325549/
sneeze2.ogg taken from https://freesound.org/people/InspectorJ/sounds/352177/
vomiting.ogg taken from https://freesound.org/people/vikuserro/sounds/246308/
yawn1.ogg taken from https://freesound.org/people/ckvoiceover/sounds/401338/ user ckvoiceover CC-3.0
yawn2.ogg taken from https://freesound.org/people/Reitanna/sounds/252239/ user reitanna CC-0
snore1, snore2, snore3.ogg taken from https://freesound.org/people/mattyharm/sounds/432995/ user mattyharm CC-0

Binary file not shown.

Binary file not shown.

View File

@@ -14,3 +14,12 @@ manlaugh_1
manlaugh_2 manlaugh_2
wilhelm_scream wilhelm_scream
womanlaugh womanlaugh
female_cough_1.ogg taken from https://freesound.org/people/OwlStorm/sounds/151213/
female_cough_2.ogg taken from https://freesound.org/people/thatkellytrna/sounds/425777/ and cropped
male_cough_1.ogg taken from freesound (deleted user)
male_cough_2.ogg taken from https://freesound.org/people/Harris85/sounds/208761/
female_sneeze_1.ogg taken from https://freesound.org/people/sherby168/sounds/540771/
male_sneeze_1.ogg taken from https://freesound.org/people/InspectorJ/sounds/352177/
male_yawn_1.ogg taken from https://freesound.org/people/ckvoiceover/sounds/401338/ user ckvoiceover CC-3.0
female_yawn_1.ogg taken from https://freesound.org/people/Reitanna/sounds/252239/ user reitanna CC-0
snore1, snore2, snore3.ogg taken from https://freesound.org/people/mattyharm/sounds/432995/ user mattyharm CC-0

View File

@@ -1,12 +1,5 @@
disease-cured = You feel a bit better. disease-cured = You feel a bit better.
disease-sick-generic = You feel sick. disease-sick-generic = You feel sick.
disease-sneeze = {CAPITALIZE($person)} sneezes.
disease-cough = {CAPITALIZE($person)} coughs.
disease-screech = {CAPITALIZE($person)} screeches.
disease-yawn = {CAPITALIZE($person)} yawns.
disease-meow = {CAPITALIZE($person)} meows.
disease-hiss = {CAPITALIZE($person)} hisses.
disease-beep= {CAPITALIZE($person)} beeps.
disease-eaten-inside = You feel like you're being eaten from the inside. disease-eaten-inside = You feel like you're being eaten from the inside.
disease-banana-compulsion = You really want to eat some bananas. disease-banana-compulsion = You really want to eat some bananas.
disease-beat-chest-compulsion = {CAPITALIZE(THE($person))} beats {POSS-ADJ($person)} chest. disease-beat-chest-compulsion = {CAPITALIZE(THE($person))} beats {POSS-ADJ($person)} chest.

View File

@@ -11,8 +11,7 @@
probability: 0.025 probability: 0.025
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.025 probability: 0.025
snoughSound: emote: Sneeze
collection: Sneezes
cures: cures:
- !type:DiseaseBedrestCure - !type:DiseaseBedrestCure
maxLength: 20 maxLength: 20
@@ -33,9 +32,7 @@
visualType: Medium visualType: Medium
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.025 probability: 0.025
snoughMessage: disease-cough emote: Cough
snoughSound:
collection: Coughs
- !type:DiseaseHealthChange - !type:DiseaseHealthChange
probability: 0.015 probability: 0.015
damage: damage:
@@ -60,8 +57,7 @@
probability: 0.025 probability: 0.025
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.025 probability: 0.025
snoughSound: emote: Sneeze
collection: Sneezes
- !type:DiseaseHealthChange - !type:DiseaseHealthChange
probability: 0.015 probability: 0.015
damage: damage:
@@ -82,9 +78,7 @@
probability: 0.025 probability: 0.025
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.025 probability: 0.025
snoughMessage: disease-cough emote: Cough
snoughSound:
collection: Coughs
- !type:DiseaseHealthChange - !type:DiseaseHealthChange
probability: 0.05 probability: 0.05
damage: damage:
@@ -105,9 +99,7 @@
amount: 0.5 amount: 0.5
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.02 probability: 0.02
snoughMessage: disease-beep emote: RobotBeep
snoughSound:
collection: RobotBeeps
cures: cures:
- !type:DiseaseJustWaitCure - !type:DiseaseJustWaitCure
maxLength: 900 maxLength: 900
@@ -144,23 +136,17 @@
# Screeches - spreads disease # Screeches - spreads disease
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.01 probability: 0.01
snoughMessage: disease-screech emote: MonkeyScreeches
snoughSound:
collection: MonkeyScreeches
stages: stages:
- 0 - 0
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.02 probability: 0.02
snoughMessage: disease-screech emote: MonkeyScreeches
snoughSound:
collection: MonkeyScreeches
stages: stages:
- 1 - 1
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.04 probability: 0.04
snoughMessage: disease-screech emote: MonkeyScreeches
snoughSound:
collection: MonkeyScreeches
stages: stages:
- 2 - 2
# monkey accent chance when speaking # monkey accent chance when speaking
@@ -220,9 +206,7 @@
type: Add type: Add
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.025 probability: 0.025
snoughMessage: disease-yawn emote: Yawn
snoughSound:
collection: Yawns
- type: disease - type: disease
id: BleedersBite id: BleedersBite
@@ -259,9 +243,7 @@
probability: 0.025 probability: 0.025
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.025 probability: 0.025
snoughMessage: disease-cough emote: Cough
snoughSound:
collection: Coughs
- !type:DiseaseHealthChange - !type:DiseaseHealthChange
probability: 0.05 probability: 0.05
damage: damage:
@@ -287,14 +269,10 @@
amount: 1 amount: 1
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.01 probability: 0.01
snoughMessage: disease-meow emote: CatMeow
snoughSound:
collection: CatMeows
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.01 probability: 0.01
snoughMessage: disease-hiss emote: CatHisses
snoughSound:
collection: CatHisses
cures: cures:
- !type:DiseaseBodyTemperatureCure - !type:DiseaseBodyTemperatureCure
min: 420 ## Reachable with a flamer min: 420 ## Reachable with a flamer
@@ -312,8 +290,7 @@
component: ScrambledAccent component: ScrambledAccent
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.01 probability: 0.01
snoughSound: emote: Sneeze
collection: Sneezes
- !type:DiseasePopUp - !type:DiseasePopUp
probability: 0.02 probability: 0.02
message: disease-think message: disease-think

View File

@@ -31,9 +31,7 @@
type: Add type: Add
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.025 probability: 0.025
snoughMessage: disease-yawn emote: Yawn
snoughSound:
collection: Yawns
- !type:DiseaseHealthChange - !type:DiseaseHealthChange
probability: 0.02 probability: 0.02
damage: damage:
@@ -60,9 +58,7 @@
probability: 0.01 probability: 0.01
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.10 probability: 0.10
snoughMessage: disease-cough emote: Cough
snoughSound:
collection: Coughs
- !type:DiseasePopUp - !type:DiseasePopUp
probability: 0.03 probability: 0.03

View File

@@ -15,9 +15,7 @@
amount: 1 amount: 1
- !type:DiseaseSnough - !type:DiseaseSnough
probability: 0.01 probability: 0.01
snoughMessage: disease-cough emote: Cough
snoughSound:
collection: Coughs
- !type:DiseaseAddComponent - !type:DiseaseAddComponent
comp: ZombifyOnDeath comp: ZombifyOnDeath
cures: cures:
@@ -32,4 +30,4 @@
cureResist: 1 #no cure. Death is your cure. cureResist: 1 #no cure. Death is your cure.
effects: effects:
- !type:DiseaseAddComponent - !type:DiseaseAddComponent
comp: ZombifyOnDeath comp: ZombifyOnDeath

View File

@@ -1,14 +1,24 @@
- type: soundCollection - type: soundCollection
id: Sneezes id: MaleSneezes
files: files:
- /Audio/Effects/Diseases/sneeze1.ogg - /Audio/Voice/Human/male_sneeze_1.ogg
- /Audio/Effects/Diseases/sneeze2.ogg
- type: soundCollection - type: soundCollection
id: Coughs id: FemaleSneezes
files: files:
- /Audio/Effects/Diseases/cough1.ogg - /Audio/Voice/Human/female_sneeze_1.ogg
- /Audio/Effects/Diseases/cough2.ogg
- type: soundCollection
id: MaleCoughs
files:
- /Audio/Voice/Human/male_cough_1.ogg
- /Audio/Voice/Human/male_cough_2.ogg
- type: soundCollection
id: FemaleCoughs
files:
- /Audio/Voice/Human/female_cough_1.ogg
- /Audio/Voice/Human/female_cough_2.ogg
- type: soundCollection - type: soundCollection
id: CatMeows id: CatMeows
@@ -32,14 +42,18 @@
- /Audio/Effects/Diseases/beepboop.ogg - /Audio/Effects/Diseases/beepboop.ogg
- type: soundCollection - type: soundCollection
id: Yawns id: MaleYawn
files: files:
- /Audio/Effects/Diseases/yawn1.ogg - /Audio/Voice/Human/male_yawn_1.ogg
- /Audio/Effects/Diseases/yawn2.ogg
- type: soundCollection
id: FemaleYawn
files:
- /Audio/Voice/Human/female_yawn_1.ogg
- type: soundCollection - type: soundCollection
id: Snores id: Snores
files: files:
- /Audio/Effects/Diseases/snore1.ogg - /Audio/Voice/Human/snore1.ogg
- /Audio/Effects/Diseases/snore2.ogg - /Audio/Voice/Human/snore2.ogg
- /Audio/Effects/Diseases/snore3.ogg - /Audio/Voice/Human/snore3.ogg

View File

@@ -7,10 +7,7 @@
- DiseaseCarrier - DiseaseCarrier
components: components:
- type: UncontrollableSnough - type: UncontrollableSnough
snoughSound: emote: Sneeze
collection: Sneezes
params:
variation: 0.2
timeBetweenIncidents: 0.3, 300 timeBetweenIncidents: 0.3, 300
- type: trait - type: trait

View File

@@ -0,0 +1,45 @@
- type: emote
id: Sneeze
category: Vocal
chatMessages: [sneezes]
- type: emote
id: Cough
category: Vocal
chatMessages: [coughs]
chatTriggers:
- cough
- coughs
- type: emote
id: CatMeow
category: Vocal
chatMessages: [meows]
- type: emote
id: CatHisses
category: Vocal
chatMessages: [hisses]
- type: emote
id: MonkeyScreeches
category: Vocal
chatMessages: [screeches]
- type: emote
id: RobotBeep
category: Vocal
chatMessages: [beeps]
- type: emote
id: Yawn
category: Vocal
chatMessages: [yawns]
chatTriggers:
- yawn
- yawns
- type: emote
id: Snore
category: Vocal
chatMessages: [snores]

View File

@@ -8,6 +8,22 @@
collection: MaleScreams collection: MaleScreams
Laugh: Laugh:
collection: MaleLaugh collection: MaleLaugh
Sneeze:
collection: MaleSneezes
Cough:
collection: MaleCoughs
CatMeow:
collection: CatMeows
CatHisses:
collection: CatHisses
MonkeyScreeches:
collection: MonkeyScreeches
RobotBeep:
collection: RobotBeeps
Yawn:
collection: MaleYawn
Snore:
collection: Snores
- type: emoteSounds - type: emoteSounds
id: FemaleHuman id: FemaleHuman
@@ -18,6 +34,22 @@
collection: FemaleScreams collection: FemaleScreams
Laugh: Laugh:
collection: FemaleLaugh collection: FemaleLaugh
Sneeze:
collection: FemaleSneezes
Cough:
collection: FemaleCoughs
CatMeow:
collection: CatMeows
CatHisses:
collection: CatHisses
MonkeyScreeches:
collection: MonkeyScreeches
RobotBeep:
collection: RobotBeeps
Yawn:
collection: FemaleYawn
Snore:
collection: Snores
- type: emoteSounds - type: emoteSounds
id: UnisexReptilian id: UnisexReptilian