mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Merge pull request #5789 from CHOMPStation2/upstream-merge-14393
[MIRROR] Makes cooldown between pain messages a pre-set global preference
This commit is contained in:
@@ -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 *
|
||||
********************/
|
||||
|
||||
@@ -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"].")
|
||||
|
||||
@@ -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(force || (message != last_pain_message) || (world.time >= next_pain_time))
|
||||
// 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)
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user