Add cooldown for unintentional emotes (#19078)

* Add cooldown for unintentional emotes

* Oops, let's try that again.
- Adds a separate cooldown system for unintentional emotes.
- Unintentional emotes will fire audio at most once every 2 seconds.
- Emotes like deathgasp can override this out of necessity.
- Scream's is longer because...come on.

* The part that makes the rest of it actualy work
This commit is contained in:
Luc
2022-09-25 12:31:26 -04:00
committed by GitHub
parent 6aefc49682
commit 96aab66dc6
7 changed files with 43 additions and 18 deletions
+6 -2
View File
@@ -97,6 +97,10 @@
var/cooldown = DEFAULT_EMOTE_COOLDOWN
/// How long is the cooldown on the audio of the emote, if it has one?
var/audio_cooldown = AUDIO_EMOTE_COOLDOWN
/// If the emote is triggered unintentionally, how long would that cooldown be?
var/unintentional_audio_cooldown = AUDIO_EMOTE_UNINTENTIONAL_COOLDOWN
/// If true, an emote will completely bypass any cooldown when called unintentionally. Necessary for things like deathgasp.
var/bypass_unintentional_cooldown = FALSE
/// How loud is the audio emote?
var/volume = 50
@@ -184,7 +188,7 @@
var/sound_volume = get_volume(user)
// If our sound emote is forced by code, don't worry about cooldowns at all.
if(tmp_sound && should_play_sound(user, intentional) && sound_volume > 0)
if(!intentional || user.start_audio_emote_cooldown(audio_cooldown))
if(bypass_unintentional_cooldown || user.start_audio_emote_cooldown(intentional, intentional ? audio_cooldown : unintentional_audio_cooldown))
play_sound_effect(user, intentional, tmp_sound, sound_volume)
if(msg)
@@ -303,7 +307,7 @@
return TRUE
// if our emote would play sound but another audio emote is on cooldown, prevent this emote from being used.
// Note that this only applies to intentional emotes
if(get_sound(user) && should_play_sound(user, intentional) && !user.can_use_audio_emote())
if(get_sound(user) && should_play_sound(user, intentional) && !user.can_use_audio_emote(intentional))
return FALSE
var/cooldown_in_use
if(!isnull(user.emote_cooldown_override))