public bool TryScream(EntityUid uid, VocalComponent?component = null) { if (!Resolve(uid, ref component, false)) { return(false); } if (!_blocker.CanSpeak(uid)) { return(false); } var sex = Sex.Male; //the default is male because requiring humanoid appearance for this is dogshit if (TryComp(uid, out HumanoidAppearanceComponent? humanoid)) { sex = humanoid.Sex; } if (_random.Prob(component.WilhelmProbability)) { SoundSystem.Play(component.Wilhelm.GetSound(), Filter.Pvs(uid), uid, component.AudioParams); return(true); } var scale = (float)_random.NextGaussian(1, VocalComponent.Variation); var pitchedParams = component.AudioParams.WithPitchScale(scale); switch (sex) { case Sex.Male: SoundSystem.Play(component.MaleScream.GetSound(), Filter.Pvs(uid), uid, pitchedParams); break; case Sex.Female: SoundSystem.Play(component.FemaleScream.GetSound(), Filter.Pvs(uid), uid, pitchedParams); break; default: throw new ArgumentOutOfRangeException(); } return(true); }
public bool TryScream(EntityUid uid, VocalComponent?component = null) { if (!Resolve(uid, ref component, false)) { return(false); } if (!_blocker.CanSpeak(uid)) { return(false); } // Currently this requires humanoid appearance & doesn't have any sort of fall-back or gender-neutral scream. if (!TryComp(uid, out HumanoidAppearanceComponent? humanoid)) { return(false); } if (_random.Prob(.01f)) { SoundSystem.Play(Filter.Pvs(uid), component.Wilhelm.GetSound(), uid, component.AudioParams); return(true); } var scale = (float)_random.NextGaussian(1, VocalComponent.Variation); var pitchedParams = component.AudioParams.WithPitchScale(scale); switch (humanoid.Sex) { case Sex.Male: SoundSystem.Play(Filter.Pvs(uid), component.MaleScream.GetSound(), uid, pitchedParams); break; case Sex.Female: SoundSystem.Play(Filter.Pvs(uid), component.FemaleScream.GetSound(), uid, pitchedParams); break; default: throw new ArgumentOutOfRangeException(); } return(true); }
private void TryEmitSound(BaseEmitSoundComponent component) { var audioParams = component.AudioParams.WithPitchScale((float)_random.NextGaussian(1, component.PitchVariation)); SoundSystem.Play(component.Sound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, audioParams); }