forked from Monkestation/Monkestation2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a cooldown to HELP ARTIFACT MAKING ME SPEAK (Monkestation#4177)
- Loading branch information
1 parent
e302e9b
commit 6d84d7a
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |