Skip to content

Commit

Permalink
Collapsing organ damage procs down into take_damage().
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Feb 1, 2025
1 parent 602924b commit 1a67d58
Show file tree
Hide file tree
Showing 45 changed files with 104 additions and 106 deletions.
2 changes: 1 addition & 1 deletion code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
SPAN_DANGER("You chew on your [O.name]!")
)
admin_attacker_log(src, "chewed on their [O.name]!")
O.take_external_damage(3,0, DAM_SHARP|DAM_EDGE ,"teeth marks")
O.take_damage(3, damage_flags = (DAM_SHARP|DAM_EDGE), inflicter = "teeth marks")
next_restraint_chew = world.time + (2.5 SECONDS)
return TRUE

Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@
M.take_damage(damage)
else
to_chat(M, SPAN_DANGER("You land heavily on your [affecting.name]!"))
affecting.take_external_damage(damage, 0)
affecting.take_damage(damage)
if(affecting.parent)
affecting.parent.add_autopsy_data("Misadventure", damage)

Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@
var/burn_damage = rand(my_size, round(my_size * 1.5))
var/obj/item/organ/external/organ = check_organ && holder.get_organ(check_organ)
if(istype(organ))
organ.take_external_damage(0, burn_damage)
organ.take_damage(burn_damage, BURN)
else
holder.take_damage(burn_damage, BURN)
if(held_slot in holder.get_held_item_slots())
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/_item_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
to_chat(M, SPAN_WARNING("You go blind!"))

var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, eyes.parent_organ)
affecting.take_external_damage(7)
affecting.take_damage(7)
else
M.take_organ_damage(7)
SET_STATUS_MAX(M, STAT_BLURRY, rand(3,4))
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/weapons/material/shards.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
var/obj/item/organ/external/hand = GET_EXTERNAL_ORGAN(H, H.get_active_held_item_slot())
if(istype(hand) && !BP_IS_PROSTHETIC(hand))
to_chat(H, SPAN_DANGER("You slice your hand on \the [src]!"))
hand.take_external_damage(rand(5,10), used_weapon = src)
hand.take_damage(rand(5,10), inflicter = src)

/obj/item/shard/set_material(var/new_material)
..(new_material)
Expand Down Expand Up @@ -111,7 +111,7 @@
if(!affecting || BP_IS_PROSTHETIC(affecting))
continue
to_chat(victim, SPAN_DANGER("You step on \the [src]!"))
affecting.take_external_damage(5, 0)
affecting.take_damage(5)
if(affecting.can_feel_pain())
SET_STATUS_MAX(victim, STAT_WEAK, 3)
return
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/ironing_board.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
visible_message("<span class='danger'>[user] irons [src.buckled_mob]'s [parsed]!</span>", "<span class='danger'>You iron [buckled_mob]'s [parsed]!</span>")

var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, zone)
affecting.take_external_damage(0, 15, used_weapon = "Hot metal")
affecting.take_damage(15, BURN, inflicter = "Hot metal")

return TRUE

Expand Down
2 changes: 1 addition & 1 deletion code/modules/assembly/mousetrap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
affecting = GET_EXTERNAL_ORGAN(H, type)
SET_STATUS_MAX(H, STAT_STUN, 3)
if(affecting)
affecting.take_external_damage(1, 0)
affecting.take_damage(1)

else if(ismouse(target))
var/mob/living/simple_animal/passive/mouse/M = target
Expand Down
2 changes: 1 addition & 1 deletion code/modules/implants/implant.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
if(malfunction == MALFUNCTION_PERMANENT) return
to_chat(imp_in, SPAN_DANGER("You feel something melting inside [part ? "your [part.name]" : "you"]!"))
if (part)
part.take_external_damage(burn = 15, used_weapon = "Electronics meltdown")
part.take_damage(15, BURN, inflicter = "Electronics meltdown")
else
var/mob/living/M = imp_in
M.apply_damage(15,BURN)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/implants/implant_types/explosive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
if (part)
if (istype(part,/obj/item/organ/external/chest) || \
istype(part,/obj/item/organ/external/groin))
part.take_external_damage(60, used_weapon = "Explosion")
part.take_damage(60, inflicter = "Explosion")
else
part.dismember(0,DISMEMBER_METHOD_BLUNT)
explosion(T, -1, -1, 2, 3)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/materials/_materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,10 @@ INITIALIZE_IMMEDIATE(/obj/effect/gas_overlay)
var/can_damage = I.max_damage - I.damage
if(can_damage > 0)
if(organ_damage > can_damage)
I.take_internal_damage(can_damage, silent=TRUE)
I.take_damage(can_damage, silent=TRUE)
dam -= can_damage
else
I.take_internal_damage(organ_damage, silent=TRUE)
I.take_damage(organ_damage, silent=TRUE)
dam = 0
if(dam > 0)
M.take_damage(toxicity_targets_organ ? (dam * 0.75) : dam, TOX)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
SPAN_DANGER("Your movement jostles [O] in your [organ.name] painfully."), \
SPAN_DANGER("Your movement jostles [O] in your [organ.name] painfully."))
custom_pain(msg,40,affecting = organ)
organ.take_external_damage(rand(1,3) + O.w_class, DAM_EDGE, 0)
organ.take_damage(rand(1,3) + O.w_class, damage_flags = DAM_EDGE)

/mob/proc/set_bodytype(var/decl/bodytype/new_bodytype)
return
Expand Down
22 changes: 12 additions & 10 deletions code/modules/mob/living/human/human_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if(!(status_flags & GODMODE) && should_have_organ(BP_BRAIN))
var/obj/item/organ/internal/sponge = GET_INTERNAL_ORGAN(src, BP_BRAIN)
if(sponge)
sponge.take_internal_damage(amount)
sponge.take_damage(amount)
..()

/mob/living/human/setBrainLoss(var/amount)
Expand Down Expand Up @@ -213,10 +213,10 @@
else
var/cap_dam = I.max_damage - I.damage
if(amount >= cap_dam)
I.take_internal_damage(cap_dam, silent=TRUE)
I.take_damage(cap_dam, silent=TRUE)
amount -= cap_dam
else
I.take_internal_damage(amount, silent=TRUE)
I.take_damage(amount, silent=TRUE)
amount = 0

if(do_update_health)
Expand Down Expand Up @@ -272,9 +272,14 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t
if(!length(parts))
return
var/obj/item/organ/external/picked = pick(parts)
if(picked.take_external_damage(brute, burn, override_droplimb = override_droplimb))
. = FALSE
if(brute && picked.take_damage(brute, override_droplimb = override_droplimb, do_update_health = FALSE))
. = TRUE
if(burn && picked.take_damage(burn, BURN, override_droplimb = override_droplimb, do_update_health = FALSE))
. = TRUE
if(.)
update_health()
BITSET(hud_updateflag, HEALTH_HUD)
update_health()

//Heal MANY external organs, in random order
/mob/living/human/heal_overall_damage(var/brute, var/burn)
Expand Down Expand Up @@ -381,15 +386,12 @@ This function restores all organs.
var/datum/wound/created_wound
damageoverlaytemp = 20
switch(damagetype)
if(BRUTE)
created_wound = organ.take_external_damage(damage, 0, damage_flags, used_weapon)
if(BURN)
created_wound = organ.take_external_damage(0, damage, damage_flags, used_weapon)
if(BRUTE, BURN)
created_wound = organ.take_damage(damage, damagetype, damage_flags = damage_flags, inflicter = used_weapon, do_update_health = FALSE)
if(PAIN)
organ.add_pain(damage)
if(CLONE)
organ.add_genetic_damage(damage)

// Will set our damageoverlay icon to the next level, which will then be set back to the normal level the next mob.Life().
update_health()
BITSET(hud_updateflag, HEALTH_HUD)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/human/human_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
"<span class='danger'>[self ? "You pop" : "[U] pops"] your [current_limb.joint] in the WRONG place!</span>" \
)
current_limb.add_pain(30)
current_limb.take_external_damage(5)
current_limb.take_damage(5)
shock_stage += 20
else
visible_message( \
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
if(QDELETED(O) || !(O.owner == src))
continue
if(O.damage + (LOW_PRESSURE_DAMAGE) < O.min_broken_damage) //vacuum does not break bones
O.take_external_damage(brute = LOW_PRESSURE_DAMAGE, used_weapon = "Low Pressure")
O.take_damage(LOW_PRESSURE_DAMAGE, inflicter = "Low Pressure")
if(getOxyLossPercent() < 55) // 11 OxyLoss per 4 ticks when wearing internals; unconsciousness in 16 ticks, roughly half a minute
take_damage(4) // 16 OxyLoss per 4 ticks when no internals present; unconsciousness in 13 ticks, OXY, roughly twenty seconds
SET_HUD_ALERT(src, HUD_PRESSURE, -2)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/human/unarmed_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
var/obj/item/organ/internal/eyes = GET_INTERNAL_ORGAN(target, BP_EYES)
var/decl/pronouns/pronouns = user.get_pronouns()
if(eyes)
eyes.take_internal_damage(rand(3,4), 1)
eyes.take_damage(rand(3,4), 1)
user.visible_message(SPAN_DANGER("\The [user] jams [pronouns.his] [eye_attack_text] into \the [target]'s [eyes.name]!"))
if(eyes.can_feel_pain())
to_chat(target, SPAN_DANGER("You experience immense pain as [eye_attack_text_victim] are jammed into your [eyes.name]!"))
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ default behaviour is:
for(var/datum/wound/wound in affected.wounds)
LAZYREMOVE(wound.embedded_objects, implant)
if(!surgical_removal)
affected.take_external_damage((implant.w_class * 3), 0, DAM_EDGE, "Embedded object extraction")
affected.take_damage((implant.w_class * 3), damage_flags = DAM_EDGE, inflicter = "Embedded object extraction")
if(!BP_IS_PROSTHETIC(affected) && prob(implant.w_class * 5) && affected.sever_artery()) //I'M SO ANEMIC I COULD JUST -DIE-.
custom_pain("Something tears wetly in your [affected.name] as [implant] is pulled free!", 50, affecting = affected)

Expand Down Expand Up @@ -1762,7 +1762,7 @@ default behaviour is:
playsound(user.loc, 'sound/effects/attackblob.ogg', 50, 1)
var/obj/item/organ/external/organ = GET_EXTERNAL_ORGAN(src, BP_CHEST)
if(istype(organ))
organ.take_external_damage(d, 0)
organ.take_damage(d)
else
take_organ_damage(d)
if(prob(get_damage(BRUTE) - 50))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living_fires.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
if(has_external_organs())
for(var/obj/item/organ/external/E in get_external_organs())
if(!(E.body_part & protected_limbs) && prob(20))
E.take_external_damage(burn = round(species_heat_mod * log(10, (burn_temperature + 10)), 0.1), used_weapon = "fire")
E.take_damage(round(species_heat_mod * log(10, (burn_temperature + 10)), 0.1), BURN, inflicter = "fire")
else // fallback for simplemobs
take_damage(round(species_heat_mod * log(10, (burn_temperature + 10))), 0.1, BURN, DAM_DISPERSED)

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/pai/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ var/global/list/possible_say_verbs = list(
var/mob/living/human/H = holder
for(var/obj/item/organ/external/affecting in H.get_external_organs())
if(card in affecting.implants)
affecting.take_external_damage(rand(30,50))
affecting.take_damage(rand(30,50))
LAZYREMOVE(affecting.implants, card)
H.visible_message("<span class='danger'>\The [src] explodes out of \the [H]'s [affecting.name] in a shower of gore!</span>")
break
Expand Down
4 changes: 2 additions & 2 deletions code/modules/organs/external/_external.dm
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@

if(owner && burn_damage)
owner.custom_pain("Something inside your [src] burns a [severity < 2 ? "bit" : "lot"]!", power * 15) //robotic organs won't feel it anyway
take_external_damage(0, burn_damage, 0, used_weapon = "Hot metal")
take_damage(burn_damage, BURN, inflicter = "Hot metal")
check_pain_disarm()

if(owner && (limb_flags & ORGAN_FLAG_CAN_STAND))
Expand Down Expand Up @@ -1506,7 +1506,7 @@ Note that amputating the affected organ does in fact remove the infection from t
if(LAZYLEN(internal_organs) && prob(brute_dam + force))
owner.custom_pain("A piece of bone in your [encased ? encased : name] moves painfully!", 50, affecting = src)
var/obj/item/organ/internal/internal_organ = pick(internal_organs)
internal_organ.take_internal_damage(rand(3,5))
internal_organ.take_damage(rand(3,5))

/obj/item/organ/external/proc/jointlock(mob/attacker)
if(!can_feel_pain())
Expand Down
24 changes: 11 additions & 13 deletions code/modules/organs/external/_external_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
//Continued damage to vital organs can kill you, and robot organs don't count towards total damage so no need to cap them.
return (BP_IS_PROSTHETIC(src) || brute_dam + burn_dam + additional_damage < max_damage * 4)

/obj/item/organ/external/take_general_damage(var/amount, var/silent = FALSE)
take_external_damage(amount)

/obj/item/organ/external/proc/take_external_damage(brute, burn, damage_flags, used_weapon, override_droplimb)
/obj/item/organ/external/take_damage(damage, damage_type = BRUTE, damage_flags, inflicter, armor_pen = 0, silent, do_update_health, override_droplimb)

if(!owner)
return

brute = round(brute * get_brute_mod(damage_flags), 0.1)
burn = round(burn * get_burn_mod(damage_flags), 0.1)
var/brute = damage_type == BRUTE ? round(damage * get_brute_mod(damage_flags), 0.1) : 0
var/burn = damage_type == BURN ? round(damage * get_burn_mod(damage_flags), 0.1) : 0

if((brute <= 0) && (burn <= 0))
return 0
Expand All @@ -33,8 +30,8 @@
if(prob(25))
owner.visible_message(SPAN_WARNING("\The [owner]'s crystalline [name] shines with absorbed energy!"))

if(used_weapon)
add_autopsy_data(used_weapon, brute + burn)
if(inflicter)
add_autopsy_data(inflicter, brute + burn)

var/spillover = 0
var/pure_brute = brute
Expand All @@ -54,7 +51,7 @@
var/total_damage = brute_dam + burn_dam + brute + burn + spillover
var/threshold = max_damage * get_config_value(/decl/config/num/health_organ_health_multiplier)
if(total_damage > threshold)
if(attempt_dismemberment(pure_brute, burn, sharp, edge, used_weapon, spillover, total_damage > threshold*6, override_droplimb = override_droplimb))
if(attempt_dismemberment(pure_brute, burn, sharp, edge, inflicter, spillover, total_damage > threshold*6, override_droplimb = override_droplimb))
return

//blunt damage is gud at fracturing
Expand Down Expand Up @@ -114,15 +111,16 @@

// sync the organ's damage with its wounds
update_damages()
owner.update_health()
if(do_update_health)
owner.update_health()
if(status & ORGAN_BLEEDING)
owner.update_bandages()

if(owner && update_damstate())
owner.update_damage_overlays()

if(created_wound && isobj(used_weapon))
var/obj/O = used_weapon
if(created_wound && isobj(inflicter))
var/obj/O = inflicter
O.after_wounding(src, created_wound)

return created_wound
Expand Down Expand Up @@ -171,7 +169,7 @@
if(prob(organ_hit_chance))
var/obj/item/organ/internal/victim = pickweight(victims)
damage_amt -= max(damage_amt*victim.damage_reduction, 0)
victim.take_internal_damage(damage_amt)
victim.take_damage(damage_amt)
return TRUE

/obj/item/organ/external/heal_damage(brute, burn, internal = 0, robo_repair = 0)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/organs/external/head.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
. = ..()
can_intake_reagents = !(bodytype.body_flags & BODY_FLAG_NO_EAT)

/obj/item/organ/external/head/take_external_damage(brute, burn, damage_flags, used_weapon, override_droplimb)
/obj/item/organ/external/head/take_damage(damage, damage_type, damage_flags, inflicter, armor_pen, silent, do_update_health, override_droplimb)
. = ..()
if (!(status & ORGAN_DISFIGURED))
if (brute_dam > 40)
Expand Down
19 changes: 8 additions & 11 deletions code/modules/organs/internal/_internal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,22 @@
if(damage_threshold_count > 0)
damage_threshold_value = round(max_damage / damage_threshold_count)

/obj/item/organ/internal/take_general_damage(var/amount, var/silent = FALSE)
take_internal_damage(amount, silent)

/obj/item/organ/internal/proc/take_internal_damage(amount, var/silent=0)
/obj/item/organ/internal/take_damage(damage, damage_type = BRUTE, damage_flags, inflicter, armor_pen = 0, silent, do_update_health)
if(BP_IS_PROSTHETIC(src))
damage = clamp(src.damage + (amount * 0.8), 0, max_damage)
damage = clamp(src.damage + (damage * 0.8), 0, max_damage)
else
damage = clamp(src.damage + amount, 0, max_damage)
damage = clamp(src.damage + damage, 0, max_damage)

//only show this if the organ is not robotic
if(owner && can_feel_pain() && parent_organ && (amount > 5 || prob(10)))
if(owner && can_feel_pain() && parent_organ && (damage > 5 || prob(10)))
var/obj/item/organ/external/parent = GET_EXTERNAL_ORGAN(owner, parent_organ)
if(parent && !silent)
var/degree = ""
if(is_bruised())
degree = " a lot"
if(damage < 5)
degree = " a bit"
owner.custom_pain("Something inside your [parent.name] hurts[degree].", amount, affecting = parent)
owner.custom_pain("Something inside your [parent.name] hurts[degree].", damage, affecting = parent)

/obj/item/organ/internal/proc/get_visible_state()
if(damage > max_damage)
Expand Down Expand Up @@ -234,11 +231,11 @@
return
switch (severity)
if (1)
take_internal_damage(16)
take_damage(16)
if (2)
take_internal_damage(9)
take_damage(9)
if (3)
take_internal_damage(6.5)
take_damage(6.5)

/obj/item/organ/internal/on_update_icon()
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/organs/internal/appendix.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
owner.visible_message("<B>\The [owner]</B> winces slightly.")
if(inflamed > 200)
if(prob(3))
take_internal_damage(0.1)
take_damage(0.1)
if(owner.can_feel_pain())
owner.visible_message("<B>\The [owner]</B> winces painfully.")
owner.take_damage(1, TOX)
Expand Down
Loading

0 comments on commit 1a67d58

Please sign in to comment.