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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 150 additions and 110 deletions

View File

@ -32,7 +32,6 @@ namespace Content.Server.Disease
/// </summary>
public sealed class DiseaseSystem : EntitySystem
{
[Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
@ -42,6 +41,7 @@ namespace Content.Server.Disease
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
public override void Initialize()
{
base.Initialize();
@ -265,7 +265,7 @@ namespace Content.Server.Disease
{
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
/// if the snougher is not wearing a mask.
/// </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 (_mobStateSystem.IsDead(uid)) return false;
var attemptSneezeCoughEvent = new AttemptSneezeCoughEvent(uid, snoughMessage, snoughSound);
var attemptSneezeCoughEvent = new AttemptSneezeCoughEvent(uid, emoteId);
RaiseLocalEvent(uid, ref attemptSneezeCoughEvent);
if (attemptSneezeCoughEvent.Cancelled) return false;
if (!string.IsNullOrEmpty(snoughMessage))
_popupSystem.PopupEntity(Loc.GetString(snoughMessage, ("person", Identity.Entity(uid, EntityManager))), uid);
if (snoughSound != null)
_audioSystem.PlayPvs(snoughSound, uid);
_chatSystem.TryEmoteWithChat(uid, emoteId);
if (disease is not { Infectious: true } || !airTransmit)
return true;

View File

@ -1,6 +1,7 @@
using Content.Shared.Chat.Prototypes;
using Content.Shared.Disease;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Disease
{
@ -12,16 +13,10 @@ namespace Content.Server.Disease
public sealed class DiseaseSnough : DiseaseEffect
{
/// <summary>
/// Message to play when snoughing
/// Emote to play when snoughing
/// </summary>
[DataField("snoughMessage")]
public string SnoughMessage = "disease-sneeze";
/// <summary>
/// Sound to play when snoughing
/// </summary>
[DataField("snoughSound")]
public SoundSpecifier? SnoughSound;
[DataField("emote", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EmotePrototype>))]
public string EmoteId = String.Empty;
/// <summary>
/// Whether to spread the disease through the air
@ -31,7 +26,7 @@ namespace Content.Server.Disease
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;
@ -9,14 +10,10 @@ namespace Content.Server.Traits.Assorted;
public sealed class UncontrollableSnoughComponent : Component
{
/// <summary>
/// Message to play when snoughing.
/// Emote to play when snoughing
/// </summary>
[DataField("snoughMessage")] public string SnoughMessage = "disease-sneeze";
/// <summary>
/// Sound to play when snoughing.
/// </summary>
[DataField("snoughSound")] public SoundSpecifier? SnoughSound;
[DataField("emote", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EmotePrototype>))]
public string EmoteId = String.Empty;
/// <summary>
/// The random time between incidents, (min, max).

View File

@ -27,7 +27,8 @@ public sealed class UncontrollableSnoughSystem : EntitySystem
{
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;
@ -38,7 +39,7 @@ public sealed class UncontrollableSnoughSystem : EntitySystem
snough.NextIncidentTime +=
_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;
/// <summary>
@ -7,4 +5,4 @@ namespace Content.Shared.Disease.Events;
/// Set Cancelled to true on event handling to suppress the sneeze
/// </summary>
[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/
monkey1.ogg taken from https://freesound.org/people/TRAVELcandies/sounds/423396/
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
wilhelm_scream
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-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-banana-compulsion = You really want to eat some bananas.
disease-beat-chest-compulsion = {CAPITALIZE(THE($person))} beats {POSS-ADJ($person)} chest.

View File

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

View File

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

View File

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

View File

@ -1,14 +1,24 @@
- type: soundCollection
id: Sneezes
id: MaleSneezes
files:
- /Audio/Effects/Diseases/sneeze1.ogg
- /Audio/Effects/Diseases/sneeze2.ogg
- /Audio/Voice/Human/male_sneeze_1.ogg
- type: soundCollection
id: Coughs
id: FemaleSneezes
files:
- /Audio/Effects/Diseases/cough1.ogg
- /Audio/Effects/Diseases/cough2.ogg
- /Audio/Voice/Human/female_sneeze_1.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
id: CatMeows
@ -32,14 +42,18 @@
- /Audio/Effects/Diseases/beepboop.ogg
- type: soundCollection
id: Yawns
id: MaleYawn
files:
- /Audio/Effects/Diseases/yawn1.ogg
- /Audio/Effects/Diseases/yawn2.ogg
- /Audio/Voice/Human/male_yawn_1.ogg
- type: soundCollection
id: FemaleYawn
files:
- /Audio/Voice/Human/female_yawn_1.ogg
- type: soundCollection
id: Snores
files:
- /Audio/Effects/Diseases/snore1.ogg
- /Audio/Effects/Diseases/snore2.ogg
- /Audio/Effects/Diseases/snore3.ogg
- /Audio/Voice/Human/snore1.ogg
- /Audio/Voice/Human/snore2.ogg
- /Audio/Voice/Human/snore3.ogg

View File

@ -7,10 +7,7 @@
- DiseaseCarrier
components:
- type: UncontrollableSnough
snoughSound:
collection: Sneezes
params:
variation: 0.2
emote: Sneeze
timeBetweenIncidents: 0.3, 300
- 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
Laugh:
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
id: FemaleHuman
@ -18,6 +34,22 @@
collection: FemaleScreams
Laugh:
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
id: UnisexReptilian