Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a cooldown to HELP ARTIFACT MAKING ME SPEAK #4177

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions monkestation/code/modules/art_sci_overrides/faults/say.dm
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
#define SPEECH_ARTIFACT_COOLDOWN_MIN (10 SECONDS)
#define SPEECH_ARTIFACT_COOLDOWN_MAX (25 SECONDS)

/datum/artifact_fault/speech
name = "Talkative Fault"
trigger_chance = 25
research_value = 50
/// Cooldown to prevent constant chat spam.
COOLDOWN_DECLARE(spam_cooldown)

/datum/artifact_fault/speech/on_trigger()
if(!COOLDOWN_FINISHED(src, spam_cooldown))
return
var/center_turf = get_turf(our_artifact.parent)

if(!center_turf)
CRASH("[src] had attempted to trigger, but failed to find the center turf!")

var/did_anything = FALSE
for(var/mob/living/living in viewers(rand(7, 10), center_turf))
if(living.stat != CONSCIOUS || !living.can_speak())
if(living.stat != CONSCIOUS || !living.can_speak() || prob(30))
continue
var/speak_over_radio = prob(10) ? "; " : ""
var/forced_message = pick_list_replacements(ARTIFACT_FILE, "speech_artifact")
living.say(speak_over_radio + forced_message, forced = "artifact ([src])")
INVOKE_ASYNC(living, TYPE_PROC_REF(/atom/movable, say), speak_over_radio + forced_message, forced = "artifact ([src])")
did_anything = TRUE
if(did_anything)
COOLDOWN_START(src, spam_cooldown, rand(SPEECH_ARTIFACT_COOLDOWN_MIN, SPEECH_ARTIFACT_COOLDOWN_MAX))

#undef SPEECH_ARTIFACT_COOLDOWN_MAX
#undef SPEECH_ARTIFACT_COOLDOWN_MIN
Loading