Skip to content

Commit

Permalink
Fixes and tweaks and demodularizing
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert committed Jan 5, 2025
1 parent f210cad commit 9222291
Show file tree
Hide file tree
Showing 29 changed files with 89 additions and 175 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#define MAX_TRAUMATIC_SHOCK 200

/// Checks if a mob can feel pain.
#define CAN_FEEL_PAIN(mob) (mob?.stat <= SOFT_CRIT && mob?.pain_controller?.pain_modifier > 0.5)
#define CAN_FEEL_PAIN(mob) (mob?.stat <= SOFT_CRIT && mob?.pain_controller?.pain_modifier > 0.33)

// Keys for pain modifiers
#define PAIN_MOD_CHEMS "chems"
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@
#define DEFIB_POSSIBLE (1<<0)
#define DEFIB_FAIL_SUICIDE (1<<1)
#define DEFIB_FAIL_HUSK (1<<2)
#define DEFIB_FAIL_TISSUE_DAMAGE (1<<3)
#define DEFIB_FAIL_CON (1<<3)
#define DEFIB_FAIL_FAILING_HEART (1<<4)
#define DEFIB_FAIL_NO_HEART (1<<5)
#define DEFIB_FAIL_FAILING_BRAIN (1<<6)
Expand All @@ -540,7 +540,7 @@
#define DEFIB_NOGRAB_AGHOST (1<<10)

// Bit mask of possible return values by can_defib that would result in a revivable patient
#define DEFIB_REVIVABLE_STATES (DEFIB_FAIL_NO_HEART | DEFIB_FAIL_FAILING_HEART | DEFIB_FAIL_HUSK | DEFIB_FAIL_TISSUE_DAMAGE | DEFIB_FAIL_FAILING_BRAIN | DEFIB_POSSIBLE)
#define DEFIB_REVIVABLE_STATES (DEFIB_FAIL_NO_HEART | DEFIB_FAIL_FAILING_HEART | DEFIB_FAIL_HUSK | DEFIB_FAIL_CON | DEFIB_FAIL_FAILING_BRAIN | DEFIB_POSSIBLE)

#define SLEEP_CHECK_DEATH(X, A) \
sleep(X); \
Expand Down
5 changes: 3 additions & 2 deletions code/datums/brain_damage/mild.dm
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@
if(11)
to_chat(owner, span_warning("You faint."))
owner.Unconscious(80)

..()
if(SPT_PROB(1, seconds_per_tick))
owner.cause_pain(BODY_ZONE_HEAD, 10)
return ..()

/datum/brain_trauma/mild/healthy
name = "Anosognosia"
Expand Down
6 changes: 4 additions & 2 deletions code/datums/brain_damage/special.dm
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,13 @@

/datum/brain_trauma/special/tenacity/on_gain()
owner.add_traits(list(TRAIT_NOSOFTCRIT, TRAIT_NOHARDCRIT), TRAUMA_TRAIT)
..()
owner.set_pain_mod(type, 0)
return ..()

/datum/brain_trauma/special/tenacity/on_lose()
owner.remove_traits(list(TRAIT_NOSOFTCRIT, TRAIT_NOHARDCRIT), TRAUMA_TRAIT)
..()
owner.unset_pain_mod(type)
return ..()

/datum/brain_trauma/special/death_whispers
name = "Functional Cerebral Necrosis"
Expand Down
7 changes: 7 additions & 0 deletions code/datums/diseases/advance/symptoms/youth.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@
if(H.age > 21)
H.age = 21
to_chat(H, span_notice("You feel like you can take on the world!"))
H.set_pain_mod(name, 0.9)

/datum/symptom/youth/End(datum/disease/advance/A)
. = ..()
if(!.)
return
A.affected_mob.unset_pain_mod(name)
3 changes: 3 additions & 0 deletions code/datums/status_effects/buffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
if(need_mob_update)
owner.updatehealth()

// Heal some pain too
owner.cause_pain(BODY_ZONES_ALL, -3)

/datum/status_effect/fleshmend/proc/on_ignited(datum/source)
SIGNAL_HANDLER

Expand Down
2 changes: 2 additions & 0 deletions code/datums/status_effects/debuffs/debuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@
if(!.)
return
// NON-MODULE CHANGE
owner.set_pain_mod(id, 0.1)
owner.unset_pain_mod(id)
owner.add_traits(list(
TRAIT_IMMOBILIZED,
TRAIT_HANDS_BLOCKED,
Expand Down
2 changes: 2 additions & 0 deletions code/datums/status_effects/debuffs/drowsiness.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
if(issilicon(owner))
return FALSE

owner.set_pain_mod(id, 0.95)
RegisterSignal(owner, COMSIG_COMPONENT_CLEAN_FACE_ACT, PROC_REF(on_face_clean))
return TRUE

/datum/status_effect/drowsiness/on_remove()
owner.unset_pain_mod(id)
UnregisterSignal(owner, COMSIG_COMPONENT_CLEAN_FACE_ACT)

/// Signal proc for [COMSIG_COMPONENT_CLEAN_FACE_ACT]. When we wash our face, reduce drowsiness by a bit.
Expand Down
2 changes: 2 additions & 0 deletions code/datums/status_effects/debuffs/drunk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
. = ..()
owner.sound_environment_override = SOUND_ENVIRONMENT_PSYCHOTIC
owner.add_mood_event(id, /datum/mood_event/drunk)
owner.set_pain_mod(id, 0.9)

/datum/status_effect/inebriated/drunk/on_remove()
clear_effects()
Expand All @@ -123,6 +124,7 @@
if(owner.sound_environment_override == SOUND_ENVIRONMENT_PSYCHOTIC)
owner.sound_environment_override = SOUND_ENVIRONMENT_NONE

owner.unset_pain_mod(id)
owner.remove_max_consciousness_value(id)
owner.remove_consciousness_modifier(id)

Expand Down
8 changes: 8 additions & 0 deletions code/datums/status_effects/debuffs/screwy_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@
id = "fake_hud_healthy"
priority = 10 // fully healthy is the opposite of death, which is absolute
override_icon = "health0"

/datum/status_effect/grouped/screwy_hud/fake_healthy/on_apply()
. = ..()
owner.set_pain_mod(TRAIT_STATUS_EFFECT(id), 0.1)

/datum/status_effect/grouped/screwy_hud/fake_healthy/on_remove()
. = ..()
owner.unset_pain_mod(TRAIT_STATUS_EFFECT(id))
8 changes: 6 additions & 2 deletions code/game/objects/items/defib.dm
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@
playsound(src, SFX_BODYFALL, 50, TRUE)
playsound(src, 'sound/machines/defib_zap.ogg', 75, TRUE, -1)
shock_pulling(30, H)
if(H.getOxyLoss() > 50)
H.setOxyLoss(50)
if(H.getToxLoss() > 50)
H.setToxLoss(50)

var/defib_result = H.can_defib()
var/fail_reason
Expand All @@ -623,8 +627,8 @@
fail_reason = "Patient's heart is missing."
if (DEFIB_FAIL_FAILING_HEART)
fail_reason = "Patient's heart too damaged, replace or repair and try again."
if (DEFIB_FAIL_TISSUE_DAMAGE)
fail_reason = "Tissue damage too severe, repair and try again."
if(DEFIB_FAIL_CON)
fail_reason = "Patient's body is too damaged, continue with repairs."
if (DEFIB_FAIL_HUSK)
fail_reason = "Patient's body is a mere husk, repair and try again."
if (DEFIB_FAIL_FAILING_BRAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,7 @@
if(isnull(scrubber))
return

scrubber.widenet = (port == enable_extended_range)
scrubber.update_appearance(UPDATE_ICON)
scrubber.set_widenet(port == enable_extended_range)

/obj/item/circuit_component/air_alarm_scrubbers/proc/toggle_siphon(datum/port/input/port)
CIRCUIT_TRIGGER
Expand Down
13 changes: 11 additions & 2 deletions code/modules/mining/lavaland/tendril_loot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@
if((methods & INGEST) && show_message)
to_chat(exposed_human, span_notice("<i>You feel nothing but a terrible aftertaste.</i>"))
return
if(exposed_human.get_organ_slot(ORGAN_SLOT_EXTERNAL_WINGS))
var/has_wings = !!exposed_human.get_organ_slot(ORGAN_SLOT_EXTERNAL_WINGS)
if(has_wings)
to_chat(exposed_human, span_userdanger("A terrible pain travels down your back as your wings change shape!"))
else
to_chat(exposed_human, span_userdanger("A terrible pain travels down your back as wings burst out!"))
Expand All @@ -554,7 +555,15 @@
exposed_human.dna.species.handle_mutant_bodyparts(exposed_human)
playsound(exposed_human.loc, 'sound/items/poster_ripped.ogg', 50, TRUE, -1)
exposed_human.apply_damage(20, def_zone = BODY_ZONE_CHEST, forced = TRUE, wound_bonus = CANT_WOUND)
exposed_human.emote("scream")
if(has_wings)
exposed_human.cause_pain(BODY_ZONE_HEAD, 10)
exposed_human.cause_pain(BODY_ZONE_CHEST, 45)
exposed_human.cause_pain(list(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM), 18)
else
exposed_human.cause_pain(BODY_ZONE_HEAD, 16)
exposed_human.cause_pain(BODY_ZONE_CHEST, 75)
exposed_human.cause_pain(list(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM), 30)
exposed_human.pain_emote("scream")

/datum/reagent/flightpotion/proc/get_wing_choice(mob/needs_wings, obj/item/bodypart/chest/chest)
var/list/wing_types = chest.wing_types.Copy()
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,8 @@
if (HAS_TRAIT(src, TRAIT_DEFIB_BLACKLISTED))
return DEFIB_FAIL_BLACKLISTED

//if ((getBruteLoss() >= MAX_REVIVE_BRUTE_DAMAGE) || (getFireLoss() >= MAX_REVIVE_FIRE_DAMAGE))
// return DEFIB_FAIL_TISSUE_DAMAGE
if(consciousness + /datum/status_effect/recent_defib::base_con < 0)
return DEFIB_FAIL_CON

// Only check for a heart if they actually need a heart. Who would've thunk
if (needs_heart())
Expand Down
7 changes: 5 additions & 2 deletions code/modules/mob/living/carbon/human/_species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ GLOBAL_LIST_EMPTY(features_by_species)
// else if(old_species.exotic_bloodtype && !exotic_bloodtype)
// human_who_gained_species.dna.blood_type = random_blood_type()

if(isnum(species_pain_mod) && species_pain_mod != 1)
human_who_gained_species.set_pain_mod(PAIN_MOD_SPECIES, species_pain_mod)

//Resets blood if it is excessively high so they don't gib
normalize_blood(human_who_gained_species)

Expand All @@ -481,8 +484,6 @@ GLOBAL_LIST_EMPTY(features_by_species)
var/obj/item/organ/external/new_organ = SSwardrobe.provide_type(organ_path)
new_organ.Insert(human, special=TRUE, movement_flags = DELETE_IF_REPLACED)



if(length(inherent_traits))
human_who_gained_species.add_traits(inherent_traits, SPECIES_TRAIT)

Expand Down Expand Up @@ -541,6 +542,8 @@ GLOBAL_LIST_EMPTY(features_by_species)

clear_tail_moodlets(C)

C.unset_pain_mod(PAIN_MOD_SPECIES)

C.physiology?.cold_mod /= coldmod
C.physiology?.heat_mod /= heatmod

Expand Down
1 change: 0 additions & 1 deletion code/modules/mob/living/carbon/human/emote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
message = "screams!"
message_mime = "acts out a scream!"
emote_type = EMOTE_AUDIBLE | EMOTE_VISIBLE
only_forced_audio = TRUE
vary = TRUE

/datum/emote/living/carbon/human/scream/get_sound(mob/living/carbon/human/user)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
if(losebreath >= 1)
losebreath -= 1
if(prob(10) && consciousness > 10)
pain_emote("gasp")
pain_emote("gasp", 1 SECONDS)
if(isobj(loc))
var/obj/loc_as_obj = loc
loc_as_obj.handle_internal_lifeform(src, 0)
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/living/living_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,10 @@
if(shock_damage < 1)
return FALSE
if(!(flags & SHOCK_ILLUSION))
adjustFireLoss(shock_damage)
set_timed_pain_mod(PAIN_MOD_RECENT_SHOCK, 0.5, 30 SECONDS)
apply_damage(shock_damage, BURN, spread_damage = TRUE, wound_bonus = CANT_WOUND)
else
adjustStaminaLoss(shock_damage)
apply_damage(shock_damage, STAMINA, spread_damage = TRUE, wound_bonus = CANT_WOUND)
if(!(flags & SHOCK_SUPPRESS_MESSAGE))
visible_message(
span_danger("[src] was shocked by \the [source]!"), \
Expand Down
3 changes: 1 addition & 2 deletions code/modules/projectiles/projectile/energy/stun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@
SEND_SIGNAL(owner, COMSIG_LIVING_MINOR_SHOCK)
owner.add_mood_event("tased", /datum/mood_event/tased)
owner.add_movespeed_modifier(/datum/movespeed_modifier/being_tased)
if(owner.pain_controller?.pain_modifier > 0.5)
owner.pain_emote("scream")
owner.pain_emote("scream")
if(ishuman(owner))
var/mob/living/carbon/human/human_owner = owner
human_owner.force_say()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/surgery/organs/internal/lungs/_lungs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@
suffocator.failed_last_breath = TRUE
// Give them a chance to notice something is wrong.
if(prob(20) && suffocator.consciousness > 10)
suffocator.pain_emote("gasp")
suffocator.pain_emote("gasp", 1 SECONDS)
var/oxyloss = suffocator.getOxyLoss()
if(oxyloss >= 50)
// Suffocating = brain damage
Expand Down
4 changes: 4 additions & 0 deletions code/modules/surgery/revival.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
span_notice("[user] send a powerful shock to [target]'s brain with [tool]..."),
span_notice("[user] send a powerful shock to [target]'s brain with [tool]..."),
)
if(target.getOxyLoss() > 50)
target.setOxyLoss(50)
if(target.getToxLoss() > 50)
target.setToxLoss(50)
target.grab_ghost()
target.apply_status_effect(/datum/status_effect/recent_defib)
target.updatehealth()
Expand Down
2 changes: 0 additions & 2 deletions maplestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6148,9 +6148,7 @@
#include "maplestation_modules\code\datums\pain\pain_effects.dm"
#include "maplestation_modules\code\datums\pain\pain_helpers.dm"
#include "maplestation_modules\code\datums\pain\pain_implements.dm"
#include "maplestation_modules\code\datums\pain\pain_modifiers.dm"
#include "maplestation_modules\code\datums\pain\scrubber_tweak.dm"
#include "maplestation_modules\code\datums\pain\pain_causes\generic_pain_causes.dm"
#include "maplestation_modules\code\datums\pain\pain_causes\opioid_addiction_pain.dm"
#include "maplestation_modules\code\datums\pain\pain_reagents\modified_reagents.dm"
#include "maplestation_modules\code\datums\pain\pain_reagents\painkiller_reactions.dm"
Expand Down
21 changes: 17 additions & 4 deletions maplestation_modules/code/datums/pain/pain.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@
/datum/pain
/// The parent mob we're tracking.
VAR_PRIVATE/mob/living/carbon/parent
/// Modifier applied to all negative incoming pain ammounts
/// Below 0.5, a mob is treated as "numb", IE, feels no pain effects (though it still accumulates)
/**
* Modifier that determines how much of the "pain" the mob actually feels.]
*
* Affects:
* - Pain feedback messages
* - Doing pain-related emotes (screams or gasps)
* - Duration of some pain effects (dizziness, etc)
* - Rate of traumatic shock buildup
* - Strength of passive pain decay
*
* Below 0.5, a mob is treated as "numb", and will outright no longer
* experience pain feedback messages or effects (but it'll still accumulate!)
*/
VAR_FINAL/pain_modifier = 1
/// Lazy Assoc list [id] to [modifier], all our pain modifiers affecting our final mod
VAR_PRIVATE/list/pain_mods
Expand Down Expand Up @@ -42,7 +53,7 @@
#endif

/datum/pain/New(mob/living/carbon/human/new_parent)
if(!iscarbon(new_parent) || istype(new_parent, /mob/living/carbon/human/dummy))
if(!iscarbon(new_parent) || isdummy(new_parent))
qdel(src) // If we're not a carbon, or a dummy, delete us
return

Expand Down Expand Up @@ -582,7 +593,7 @@
else
heart_attack_counter = 0

if(traumatic_shock >= SHOCK_CRIT_THRESHOLD || curr_pain >= PAIN_CRIT_THRESOLD )
if(traumatic_shock >= SHOCK_CRIT_THRESHOLD || curr_pain >= PAIN_CRIT_THRESOLD)
parent.adjust_jitter_up_to(5 SECONDS * pain_modifier, 120 SECONDS)

parent.paincrit_check()
Expand Down Expand Up @@ -632,6 +643,8 @@
SIGNAL_HANDLER

var/pain = get_total_pain()
if(parent.stat == DEAD)
pain *= 0.1
// Consciousness penalty from pain is unnaffected by pain modifier
if(pain <= 25)
parent.remove_consciousness_modifier(PAIN)
Expand Down

This file was deleted.

Loading

0 comments on commit 9222291

Please sign in to comment.