From 71b516fa314561dad20c3d1ca4bfa94bbb5961a6 Mon Sep 17 00:00:00 2001 From: Runa Dacino Date: Sat, 28 Jan 2023 23:57:28 +0100 Subject: [PATCH] Makes pain frequency a global preference, changes values --- .../preference_setup/global/setting_datums.dm | 7 ++++++ code/modules/client/preferences_vr.dm | 13 +++++++++- code/modules/organs/pain.dm | 25 +++++++++++++++---- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/code/modules/client/preference_setup/global/setting_datums.dm b/code/modules/client/preference_setup/global/setting_datums.dm index 246a5ede25..01c6b4da97 100644 --- a/code/modules/client/preference_setup/global/setting_datums.dm +++ b/code/modules/client/preference_setup/global/setting_datums.dm @@ -368,6 +368,13 @@ var/list/_client_preferences_by_type enabled_description = "Hear" disabled_description = "Silent" +/datum/client_preference/pain_frequency + description = "Pain Messages Cooldown" + key = "PAIN_FREQUENCY" + enabled_by_default = FALSE + enabled_description = "Extended" + disabled_description = "Default" + /******************** * Staff Preferences * ********************/ diff --git a/code/modules/client/preferences_vr.dm b/code/modules/client/preferences_vr.dm index 7edee90ccf..94a62f9b82 100644 --- a/code/modules/client/preferences_vr.dm +++ b/code/modules/client/preferences_vr.dm @@ -119,4 +119,15 @@ SScharacter_setup.queue_preferences_save(prefs) - feedback_add_details("admin_verb", "TSoundMentorhelps") \ No newline at end of file + feedback_add_details("admin_verb", "TSoundMentorhelps") + +/client/verb/toggle_pain_frequency() + set name = "Toggle Pain Frequency" + set category = "Preferences" + set desc = "Toggles frequency of per-limb pain messages between default and extende" + + var/pref_path = /datum/client_preference/pain_frequency + + toggle_preference(pref_path) + + to_chat(src, "The frequency of pain messages is now [ (is_preference_enabled(pref_path)) ? "extended" : "default"].") diff --git a/code/modules/organs/pain.dm b/code/modules/organs/pain.dm index 0939201e0c..0899e2bdef 100644 --- a/code/modules/organs/pain.dm +++ b/code/modules/organs/pain.dm @@ -16,10 +16,27 @@ message = "[message]" // Anti message spam checks - if(force || (message != last_pain_message) || (world.time >= next_pain_time)) + 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 + if(6 to 20) + next_pain_time = world.time + clamp((30 - power) SECONDS, 10 SECONDS, 30 SECONDS) + if(21 to INFINITY) + next_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 + clamp((120 - power) SECONDS, 3 SECONDS, 120 SECONDS) + next_pain_time = world.time + (100 - power) /mob/living/carbon/human/proc/handle_pain() if(stat) @@ -28,8 +45,6 @@ if(!can_feel_pain() && !synth_cosmetic_pain) return - if(world.time < next_pain_time) - return var/maxdam = 0 var/obj/item/organ/external/damaged_organ = null for(var/obj/item/organ/external/E in organs) @@ -59,7 +74,7 @@ if(91 to 10000) flash_pain() msg = "OH GOD! Your [damaged_organ.name] is [burning ? "on fire" : "hurting terribly"]!" - custom_pain(msg, maxdam, prob(clamp(maxdam/10,0,100))) + custom_pain(msg, maxdam, prob(10)) // Damage to internal organs hurts a lot. for(var/obj/item/organ/I in internal_organs)