Merge pull request #14393 from Runa-Dacino/pain-frequency

Makes cooldown between pain messages a pre-set global preference
This commit is contained in:
Heroman3003
2023-02-26 04:32:44 +10:00
committed by CHOMPStation2
parent d1d10dcd7d
commit ebe81811db
3 changed files with 47 additions and 4 deletions

View File

@@ -382,6 +382,14 @@ var/list/_client_preferences_by_type
enabled_description = "Enabled"
disabled_description = "Disabled"
/datum/client_preference/pain_frequency
description = "Pain Messages Cooldown"
key = "PAIN_FREQUENCY"
enabled_by_default = FALSE
enabled_description = "Extended"
disabled_description = "Default"
/********************
* Staff Preferences *
********************/

View File

@@ -139,3 +139,14 @@
SScharacter_setup.queue_preferences_save(prefs)
feedback_add_details("admin_verb", "TReceivePlayerTips")
/client/verb/toggle_pain_frequency()
set name = "Toggle Pain Frequency"
set category = "Preferences"
set desc = "When toggled on, increases the cooldown of pain messages sent to chat for minor injuries"
var/pref_path = /datum/client_preference/pain_frequency
toggle_preference(pref_path)
to_chat(src, "The cooldown between pain messages for minor (under 20/5 injury. Multi-limb injuries are still faster) is now [ (is_preference_enabled(pref_path)) ? "extended" : "default"].")

View File

@@ -4,6 +4,8 @@
/mob/var/list/pain_stored = list()
/mob/var/last_pain_message = ""
/mob/var/next_pain_time = 0
/mob/var/multilimb_pain_time = 0 // Global pain cooldown exists to prevent spam for multi-limb damage
// message is the custom message to be displayed
// power decides how much painkillers will stop the message
@@ -16,10 +18,32 @@
message = "<font size=3>[message]</font>"
// Anti message spam checks
// If multiple limbs are injured, cooldown is ignored to print all injuries until all limbs are iterated over
if(src.is_preference_enabled(/datum/client_preference/pain_frequency))
switch(power)
if(0 to 5)
force = 0
if(6 to 20)
force = prob(1)
if(force || (message != last_pain_message) || (world.time >= next_pain_time))
switch(power)
if(0 to 5)
next_pain_time = world.time + 300 SECONDS
multilimb_pain_time = world.time + 45 SECONDS
if(6 to 20)
next_pain_time = world.time + clamp((30 - power) SECONDS, 10 SECONDS, 30 SECONDS)
multilimb_pain_time = world.time + clamp((30 - power) SECONDS, 10 SECONDS, 30 SECONDS)
if(21 to INFINITY)
next_pain_time = world.time + (100 - power)
multilimb_pain_time = world.time + (100 - power)
last_pain_message = message
to_chat(src,message)
next_pain_time = world.time + (100-power)
else if(force || (message != last_pain_message) || (world.time >= next_pain_time))
last_pain_message = message
to_chat(src,message)
next_pain_time = world.time + (100 - power)
multilimb_pain_time = world.time + (100 - power)
/mob/living/carbon/human/proc/handle_pain()
if(stat)
@@ -28,7 +52,7 @@
if(!can_feel_pain() && !synth_cosmetic_pain)
return
if(world.time < next_pain_time)
if(world.time < multilimb_pain_time) //prevents spam in case of multi-limb injuries.
return
var/maxdam = 0
var/obj/item/organ/external/damaged_organ = null