mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-21 04:48:18 +01:00
Improve, cleanup, and expand wound code (#20757)
This PR includes several changes to bring our wound code up to date with baystation, nebula, and modern standards. Highlights include: - The usage of integers between 0 and 100 for ratios (expressed as a percentage), instead of 0.0 to 1.0. Small decimal values are prone to floating point precision errors, but by moving to a percentage instead, we can reduce the impact of this. - The untangling of damage flags and injury flags, which were used interchangably in the code. This could have caused issues should we expand any of these. - Larger embedded objects now halt bleeding in wounds, until they are pulled out. In exchange however, embedded objects will halt healing in wounds (it is difficult to close an open wound that currently has a rod stuck in it) - A lot of data, such as implanted objects and organs, are now stored in amputated limbs.
This commit is contained in:
@@ -104,7 +104,7 @@
|
||||
|
||||
//Apply weapon damage
|
||||
var/damage_flags = I.damage_flags()
|
||||
apply_damage(effective_force, I.damtype, hit_zone, I, damage_flags, I.armor_penetration)
|
||||
var/datum/wound/created_wound = apply_damage(effective_force, I.damtype, hit_zone, I, damage_flags, I.armor_penetration)
|
||||
|
||||
//Melee weapon embedded object code.
|
||||
if (I && I.damtype == DAMAGE_BRUTE && !I.anchored && !is_robot_module(I) && I.canremove)
|
||||
@@ -120,7 +120,7 @@
|
||||
|
||||
//Sharp objects will always embed if they do enough damage.
|
||||
if((sharp && damage > (10*I.w_class)) || (damage > embed_threshold && prob(embed_chance)))
|
||||
src.embed(I, hit_zone)
|
||||
src.embed(I, hit_zone, supplied_wound = created_wound)
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
@@ -284,6 +284,15 @@
|
||||
amount -= E.add_pain(amount)
|
||||
BITSET(hud_updateflag, HEALTH_HUD)
|
||||
|
||||
/mob/living/carbon/human/proc/can_autoheal(dam_type)
|
||||
if(!species || !dam_type) return FALSE
|
||||
|
||||
if (dam_type == DAMAGE_BRUTE)
|
||||
return(getBruteLoss() < species.total_health * species.autoheal_brute_ratio)
|
||||
else if (dam_type == DAMAGE_BURN)
|
||||
return(getFireLoss() < species.total_health * species.autoheal_burn_ratio)
|
||||
return FALSE
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
//Returns a list of damaged organs
|
||||
@@ -362,14 +371,14 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t
|
||||
if(status_flags & GODMODE)
|
||||
return //godmode
|
||||
var/list/obj/item/organ/external/parts = get_damageable_organs()
|
||||
var/update = 0
|
||||
var/update
|
||||
while(parts.len && (brute>0 || burn>0) )
|
||||
var/obj/item/organ/external/picked = pick(parts)
|
||||
|
||||
var/brute_was = picked.brute_dam
|
||||
var/burn_was = picked.burn_dam
|
||||
|
||||
update |= picked.take_damage(brute, burn, damage_flags, used_weapon)
|
||||
update = picked.take_damage(brute, burn, damage_flags, used_weapon) ? TRUE : FALSE
|
||||
brute -= (picked.brute_dam - brute_was)
|
||||
burn -= (picked.burn_dam - burn_was)
|
||||
|
||||
@@ -486,18 +495,19 @@ This function restores all organs.
|
||||
if(REAGENT_VOLUME(reagents, /singleton/reagent/adrenaline) < 15)
|
||||
make_adrenaline(round(damage/10))
|
||||
|
||||
var/datum/wound/created_wound
|
||||
switch(damagetype)
|
||||
if(DAMAGE_BRUTE)
|
||||
damageoverlaytemp = 20
|
||||
if(damage > 0)
|
||||
damage *= species.brute_mod
|
||||
organ.take_damage(damage, 0, damage_flags, used_weapon)
|
||||
created_wound = organ.take_damage(damage, 0, damage_flags, used_weapon)
|
||||
UpdateDamageIcon()
|
||||
if(DAMAGE_BURN)
|
||||
damageoverlaytemp = 20
|
||||
if(damage > 0)
|
||||
damage *= species.burn_mod
|
||||
organ.take_damage(0, damage, damage_flags, used_weapon)
|
||||
created_wound = organ.take_damage(0, damage, damage_flags, used_weapon)
|
||||
UpdateDamageIcon()
|
||||
if(DAMAGE_PAIN)
|
||||
organ.add_pain(damage)
|
||||
@@ -507,7 +517,7 @@ This function restores all organs.
|
||||
// Will set our damageoverlay icon to the next level, which will then be set back to the normal level the next mob.Life().
|
||||
updatehealth()
|
||||
BITSET(hud_updateflag, HEALTH_HUD)
|
||||
return TRUE
|
||||
return created_wound ? created_wound : TRUE
|
||||
|
||||
/mob/living/carbon/human/apply_radiation(var/rads)
|
||||
if(species && rads > 0)
|
||||
|
||||
@@ -441,12 +441,12 @@ emp_act
|
||||
Weaken(3)
|
||||
visible_message(SPAN_WARNING("[src] get knocked over by [H]!"), SPAN_WARNING("You get knocked over by [H]!"))
|
||||
|
||||
/mob/living/carbon/human/embed(var/obj/O, var/def_zone=null)
|
||||
/mob/living/carbon/human/embed(obj/O, def_zone=null, datum/wound/supplied_wound)
|
||||
if(!def_zone) ..()
|
||||
|
||||
var/obj/item/organ/external/affecting = get_organ(def_zone)
|
||||
if(affecting)
|
||||
affecting.embed(O)
|
||||
affecting.embed(O, supplied_wound = supplied_wound)
|
||||
|
||||
|
||||
/mob/living/carbon/human/proc/bloody_hands(var/mob/living/source, var/amount = 2)
|
||||
|
||||
@@ -63,10 +63,9 @@
|
||||
I.take_damage(rand(3,5))
|
||||
|
||||
//Moving makes open wounds get infected much faster
|
||||
if (E.wounds.len)
|
||||
for(var/datum/wound/W in E.wounds)
|
||||
if (W.infection_check())
|
||||
W.germ_level += 1
|
||||
for(var/datum/wound/W in E.wounds)
|
||||
if (W.infection_check())
|
||||
W.germ_level += 1
|
||||
|
||||
/mob/living/carbon/human
|
||||
var/next_stance_collapse = 0
|
||||
|
||||
@@ -122,6 +122,10 @@
|
||||
// Combat vars.
|
||||
/// Point at which the mob will enter crit.
|
||||
var/total_health = 200
|
||||
/// Ratio at which the mob will stop autohealing a wound. For brute damage.
|
||||
var/autoheal_brute_ratio = 0.5
|
||||
/// Ratio at which the mob will stop autohealing a wound. For burn damage.
|
||||
var/autoheal_burn_ratio = 0.5
|
||||
/// Possible unarmed attacks that the mob will use in combat,
|
||||
var/list/unarmed_types = list(
|
||||
/datum/unarmed_attack,
|
||||
|
||||
@@ -322,7 +322,7 @@
|
||||
src.anchored = 1
|
||||
src.pinned += O
|
||||
|
||||
/mob/living/proc/embed(var/obj/O, var/def_zone=null)
|
||||
/mob/living/proc/embed(obj/O, def_zone=null, datum/wound/supplied_wound)
|
||||
O.forceMove(src)
|
||||
src.embedded += O
|
||||
add_verb(src, /mob/proc/yank_out_object)
|
||||
|
||||
@@ -1089,13 +1089,13 @@
|
||||
/mob/proc/embedded_needs_process()
|
||||
return (embedded.len > 0)
|
||||
|
||||
/mob/proc/remove_implant(var/obj/item/implant, var/surgical_removal = FALSE)
|
||||
/mob/proc/remove_implant(obj/item/implant, surgical_removal = FALSE)
|
||||
if(!LAZYLEN(get_visible_implants(0))) //Yanking out last object - removing verb.
|
||||
remove_verb(src, /mob/proc/yank_out_object)
|
||||
for(var/obj/item/O in pinned)
|
||||
if(O == implant)
|
||||
pinned -= O
|
||||
if(!pinned.len)
|
||||
if(!length(pinned))
|
||||
anchored = 0
|
||||
implant.dropInto(loc)
|
||||
implant.add_blood(src)
|
||||
@@ -1114,6 +1114,8 @@
|
||||
break
|
||||
if(affected)
|
||||
affected.implants -= implant
|
||||
for(var/datum/wound/wound in affected.wounds)
|
||||
LAZYREMOVE(wound.embedded_objects, implant)
|
||||
if(!surgical_removal)
|
||||
shock_stage += 20
|
||||
apply_damage((implant.w_class * 7), DAMAGE_BRUTE, affected)
|
||||
@@ -1162,7 +1164,7 @@
|
||||
else
|
||||
to_chat(U, SPAN_WARNING("You attempt to get a good grip on [selection] in [S]'s body."))
|
||||
|
||||
if(!do_after(U, 30))
|
||||
if(!do_after(U, 3 SECONDS, S, DO_DEFAULT | DO_USER_UNIQUE_ACT, INCAPACITATION_DEFAULT & ~INCAPACITATION_FORCELYING)) //let people pinned to stuff yank it out, otherwise they're stuck... forever!!!
|
||||
return
|
||||
if(!selection || !S || !U)
|
||||
return
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
user.visible_message(SPAN_NOTICE("[user] starts inspecting [affecting]'s [E.name] carefully."))
|
||||
if(!do_mob(user,H, 10))
|
||||
to_chat(user, SPAN_NOTICE("You must stand still to inspect [E] for wounds."))
|
||||
else if(E.wounds.len)
|
||||
else if(LAZYLEN(E.wounds))
|
||||
to_chat(user, SPAN_WARNING("You find [E.get_wounds_desc()]"))
|
||||
else
|
||||
to_chat(user, SPAN_NOTICE("You find no visible wounds."))
|
||||
|
||||
Reference in New Issue
Block a user