mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 22:19:30 +01:00
Hypnosis code improvements
Hypnosis no longer runtimes forever if it can't generate a valid regex from the user phrase Hypnosis also no longer constantly regenerates the regex and instead just matches using the existing regex
This commit is contained in:
@@ -7,11 +7,17 @@
|
||||
resilience = TRAUMA_RESILIENCE_SURGERY
|
||||
|
||||
var/hypnotic_phrase = ""
|
||||
var/regex/target_phrase
|
||||
|
||||
/datum/brain_trauma/hypnosis/New(phrase)
|
||||
if(!phrase)
|
||||
qdel(src)
|
||||
hypnotic_phrase = phrase
|
||||
try
|
||||
target_phrase = new("(\\b[hypnotic_phrase]\\b)","ig")
|
||||
catch(var/exception/e)
|
||||
stack_trace("[e] on [e.file]:[e.line]")
|
||||
qdel(src)
|
||||
..()
|
||||
|
||||
/datum/brain_trauma/hypnosis/on_gain()
|
||||
@@ -43,6 +49,5 @@
|
||||
new /datum/hallucination/chat(owner, TRUE, FALSE, "<span class='hypnophrase'>[hypnotic_phrase]</span>")
|
||||
|
||||
/datum/brain_trauma/hypnosis/on_hear(message, speaker, message_language, raw_message, radio_freq)
|
||||
var/regex/target_phrase = new("(\\b[hypnotic_phrase]\\b)","ig")
|
||||
message = target_phrase.Replace(message, "<span class='hypnophrase'>$1</span>")
|
||||
return message
|
||||
return message
|
||||
|
||||
Reference in New Issue
Block a user