Zombie SFX (#9976)

This commit is contained in:
Nemanja 2022-08-07 23:16:43 -04:00 committed by GitHub
parent 39ef4179d0
commit 123c631067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 127 additions and 7 deletions

View File

@ -0,0 +1,31 @@
namespace Content.Server.Zombies;
[RegisterComponent]
public sealed class ActiveZombieComponent : Component
{
/// <summary>
/// The chance that on a random attempt
/// that a zombie will do a groan
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float GroanChance = 0.2f;
/// <summary>
/// Minimum time between groans
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float GroanCooldown = 2;
/// <summary>
/// The length of time between each zombie's random groan
/// attempt.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float RandomGroanAttempt = 5;
[ViewVariables(VVAccess.ReadWrite)]
public float LastDamageGroanCooldown = 0f;
[ViewVariables(VVAccess.ReadWrite)]
public float Accumulator = 0f;
}

View File

@ -17,14 +17,14 @@ namespace Content.Server.Zombies
/// <summary>
/// The baseline infection chance you have if you are completely nude
/// </summary>
[ViewVariables]
[ViewVariables(VVAccess.ReadWrite)]
public float MaxZombieInfectionChance = 0.75f;
/// <summary>
/// The minimum infection chance possible. This is simply to prevent
/// being invincible by bundling up.
/// </summary>
[ViewVariables]
[ViewVariables(VVAccess.ReadWrite)]
public float MinZombieInfectionChance = 0.1f;
[ViewVariables(VVAccess.ReadWrite)]
@ -33,19 +33,19 @@ namespace Content.Server.Zombies
/// <summary>
/// The skin color of the zombie
/// </summary>
[ViewVariables, DataField("skinColor")]
[DataField("skinColor")]
public Color SkinColor = new(0.45f, 0.51f, 0.29f);
/// <summary>
/// The eye color of the zombie
/// </summary>
[ViewVariables, DataField("eyeColor")]
[DataField("eyeColor")]
public Color EyeColor = new(0.96f, 0.13f, 0.24f);
/// <summary>
/// The attack arc of the zombie
/// </summary>
[ViewVariables, DataField("attackArc", customTypeSerializer: typeof(PrototypeIdSerializer<MeleeWeaponAnimationPrototype>))]
[DataField("attackArc", customTypeSerializer: typeof(PrototypeIdSerializer<MeleeWeaponAnimationPrototype>))]
public string AttackArc = "claw";
/// <summary>

View File

@ -8,8 +8,11 @@ using Content.Shared.Chemistry.Components;
using Content.Shared.MobState.Components;
using Content.Server.Disease;
using Content.Shared.Inventory;
using Content.Shared.MobState;
using Content.Server.Inventory;
using Robust.Shared.Prototypes;
using Content.Server.Speech;
using Content.Server.Chat.Systems;
using Content.Shared.Movement.Systems;
using Content.Shared.Damage;
@ -22,6 +25,8 @@ namespace Content.Server.Zombies
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
[Dependency] private readonly ZombifyOnDeathSystem _zombify = default!;
[Dependency] private readonly ServerInventorySystem _inv = default!;
[Dependency] private readonly VocalSystem _vocal = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
@ -30,9 +35,25 @@ namespace Content.Server.Zombies
base.Initialize();
SubscribeLocalEvent<ZombieComponent, MeleeHitEvent>(OnMeleeHit);
SubscribeLocalEvent<ZombieComponent, MobStateChangedEvent>(OnMobState);
SubscribeLocalEvent<ActiveZombieComponent, DamageChangedEvent>(OnDamage);
SubscribeLocalEvent<ZombieComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshSpeed);
}
private void OnMobState(EntityUid uid, ZombieComponent component, MobStateChangedEvent args)
{
if (args.CurrentMobState == DamageState.Alive)
EnsureComp<ActiveZombieComponent>(uid);
else
RemComp<ActiveZombieComponent>(uid);
}
private void OnDamage(EntityUid uid, ActiveZombieComponent component, DamageChangedEvent args)
{
if (args.DamageIncreased)
DoGroan(uid, component);
}
private void OnRefreshSpeed(EntityUid uid, ZombieComponent component, RefreshMovementSpeedModifiersEvent args)
{
var mod = component.ZombieMovementSpeedDebuff;
@ -96,13 +117,13 @@ namespace Content.Server.Zombies
if (HasComp<ZombieComponent>(entity))
args.BonusDamage = -args.BaseDamage * zombieComp.OtherZombieDamageCoefficient;
if ((mobState.IsDead() || mobState.IsCritical())
if ((mobState.CurrentState == DamageState.Dead || mobState.CurrentState == DamageState.Critical)
&& !HasComp<ZombieComponent>(entity))
{
_zombify.ZombifyEntity(entity);
args.BonusDamage = -args.BaseDamage;
}
else if (mobState.IsAlive()) //heals when zombies bite live entities
else if (mobState.CurrentState == DamageState.Alive) //heals when zombies bite live entities
{
var healingSolution = new Solution();
healingSolution.AddReagent("Bicaridine", 1.00); //if OP, reduce/change chem
@ -110,5 +131,39 @@ namespace Content.Server.Zombies
}
}
}
public void DoGroan(EntityUid uid, ActiveZombieComponent component)
{
if (component.LastDamageGroanCooldown > 0)
return;
if (_robustRandom.Prob(0.5f)) //this message is never seen by players so it just says this for admins
_chat.TrySendInGameICMessage(uid, "[automated zombie groan]", InGameICChatType.Speak, false);
else
_vocal.TryScream(uid);
component.LastDamageGroanCooldown = component.GroanCooldown;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
foreach (var zombiecomp in EntityQuery<ActiveZombieComponent>())
{
zombiecomp.Accumulator += frameTime;
zombiecomp.LastDamageGroanCooldown -= frameTime;
if (zombiecomp.Accumulator < zombiecomp.RandomGroanAttempt)
continue;
zombiecomp.Accumulator -= zombiecomp.RandomGroanAttempt;
if (!_robustRandom.Prob(zombiecomp.GroanChance))
continue;
//either do a random accent line or scream
DoGroan(zombiecomp.Owner, zombiecomp);
}
}
}
}

View File

@ -30,6 +30,10 @@ using Content.Shared.Zombies;
using Content.Shared.Popups;
using Content.Server.Atmos.Miasma;
using Content.Server.IdentityManagement;
using Content.Shared.Audio;
using Content.Shared.Sound;
using Robust.Shared.Random;
using Content.Server.Speech;
using Content.Shared.Movement.Systems;
namespace Content.Server.Zombies
@ -111,6 +115,11 @@ namespace Content.Server.Zombies
RemComp<CombatModeComponent>(target);
AddComp<CombatModeComponent>(target);
var vocal = EnsureComp<VocalComponent>(target);
var scream = new SoundCollectionSpecifier ("ZombieScreams");
vocal.FemaleScream = scream;
vocal.MaleScream = scream;
///This is the actual damage of the zombie. We assign the visual appearance
///and range here because of stuff we'll find out later
var melee = EnsureComp<MeleeWeaponComponent>(target);

View File

@ -0,0 +1,12 @@
- files: ["zombie-1.ogg"]
license: "CC-BY-NC-SA-3.0"
copyright: "Zombie 1 by Under7dude. Converted from MP3 to OGG."
source: "https://freesound.org/people/Under7dude/sounds/163440/"
- files: ["zombie-2.ogg"]
license: "CC-BY-NC-SA-3.0"
copyright: "Zombie gargles by Breviceps. Converted from MP3 to OGG."
source: "https://freesound.org/people/Breviceps/sounds/445983/"
- files: ["zombie-3.ogg"]
license: "CC-BY-NC-SA-3.0"
copyright: "Zombie Snarl by gneube. Converted from MP3 to OGG."
source: "https://freesound.org/people/gneube/sounds/315844/"

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -40,6 +40,9 @@ accent-words-zombie-1 = Gruaahhhh...
accent-words-zombie-2 = Mmuaaaa..
accent-words-zombie-3 = Braainnssss...
accent-words-zombie-4 = Grrrrr...
accent-words-zombie-5 = Ouuaahhhhh...
accent-words-zombie-6 = Graaaaaooohhlll...
accent-words-zombie-7 = Brainsss... Braaaiiinnsss..
# Generic Aggressive
accent-words-generic-aggressive-1 = Grr!

View File

@ -26,3 +26,10 @@
- /Audio/Voice/Human/science_scream4.ogg
- /Audio/Voice/Human/science_scream5.ogg
- /Audio/Voice/Human/science_scream6.ogg
- type: soundCollection
id: ZombieScreams
files:
- /Audio/Voice/Zombie/zombie-1.ogg
- /Audio/Voice/Zombie/zombie-2.ogg
- /Audio/Voice/Zombie/zombie-3.ogg

View File

@ -54,6 +54,9 @@
- accent-words-zombie-2
- accent-words-zombie-3
- accent-words-zombie-4
- accent-words-zombie-5
- accent-words-zombie-6
- accent-words-zombie-7
- type: accent
id: genericAggressive