mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 11:13:16 +00:00
Fixes wrong wound types being used
This fixes the autoheal bug, which was being caused by wound types such as tiny bruises from being used even for large amounts of damage. I imagine that relying on the order of the list returned by typesof() is always a bad idea.
This commit is contained in:
@@ -236,21 +236,8 @@ This function completely restores a damaged organ to perfect condition.
|
|||||||
return
|
return
|
||||||
|
|
||||||
//Creating wound
|
//Creating wound
|
||||||
var/datum/wound/W
|
var/wound_type = get_wound_type(type, damage)
|
||||||
var/size = min( max( 1, damage/10 ) , 6)
|
var/datum/wound/W = new wound_type(damage)
|
||||||
//Possible types of wound
|
|
||||||
var/list/size_names = list()
|
|
||||||
switch(type)
|
|
||||||
if(CUT)
|
|
||||||
size_names = typesof(/datum/wound/cut/) - /datum/wound/cut/
|
|
||||||
if(BRUISE)
|
|
||||||
size_names = typesof(/datum/wound/bruise/) - /datum/wound/bruise/
|
|
||||||
if(BURN)
|
|
||||||
size_names = typesof(/datum/wound/burn/) - /datum/wound/burn/
|
|
||||||
|
|
||||||
size = min(size,size_names.len)
|
|
||||||
var/wound_type = size_names[size]
|
|
||||||
W = new wound_type(damage)
|
|
||||||
|
|
||||||
//Possibly trigger an internal wound, too.
|
//Possibly trigger an internal wound, too.
|
||||||
var/local_damage = brute_dam + burn_dam + damage
|
var/local_damage = brute_dam + burn_dam + damage
|
||||||
@@ -270,6 +257,25 @@ This function completely restores a damaged organ to perfect condition.
|
|||||||
if(W)
|
if(W)
|
||||||
wounds += W
|
wounds += W
|
||||||
|
|
||||||
|
/datum/organ/external/proc/get_wound_type(var/type = CUT, var/damage)
|
||||||
|
//if you look a the names in the wound's stages list for each wound type you will see the logic behind these values
|
||||||
|
switch(type)
|
||||||
|
if(CUT)
|
||||||
|
if (damage <= 5) return /datum/wound/cut/small
|
||||||
|
if (damage <= 15) return /datum/wound/cut/deep
|
||||||
|
if (damage <= 25) return /datum/wound/cut/flesh
|
||||||
|
if (damage <= 50) return /datum/wound/cut/gaping
|
||||||
|
if (damage <= 60) return /datum/wound/cut/gaping_big
|
||||||
|
return /datum/wound/cut/massive
|
||||||
|
if(BRUISE)
|
||||||
|
return /datum/wound/bruise
|
||||||
|
if(BURN)
|
||||||
|
if (damage <= 5) return /datum/wound/burn/moderate
|
||||||
|
if (damage <= 15) return /datum/wound/burn/large
|
||||||
|
if (damage <= 30) return /datum/wound/burn/severe
|
||||||
|
if (damage <= 40) return /datum/wound/burn/deep
|
||||||
|
if (damage <= 50) return /datum/wound/burn/carbonised
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
PROCESSING & UPDATING
|
PROCESSING & UPDATING
|
||||||
****************************************************/
|
****************************************************/
|
||||||
@@ -388,15 +394,12 @@ This function completely restores a damaged organ to perfect condition.
|
|||||||
if(prob(1 * wound_update_accuracy))
|
if(prob(1 * wound_update_accuracy))
|
||||||
owner.custom_pain("You feel a stabbing pain in your [display_name]!",1)
|
owner.custom_pain("You feel a stabbing pain in your [display_name]!",1)
|
||||||
|
|
||||||
|
|
||||||
// slow healing
|
// slow healing
|
||||||
var/heal_amt = 0
|
var/heal_amt = 0
|
||||||
|
|
||||||
if (W.damage < 15) //this thing's edges are not in day's travel of each other, what healing?
|
// if damage >= 50 AFTER treatment then it's probably too severe to heal within the timeframe of a round.
|
||||||
heal_amt += 0.2
|
if (W.is_treated() && W.damage < 50)
|
||||||
|
heal_amt += 0.5
|
||||||
if(W.is_treated() && W.damage < 50) //whoa, not even magical band aid can hold it together
|
|
||||||
heal_amt += 0.3
|
|
||||||
|
|
||||||
//we only update wounds once in [wound_update_accuracy] ticks so have to emulate realtime
|
//we only update wounds once in [wound_update_accuracy] ticks so have to emulate realtime
|
||||||
heal_amt = heal_amt * wound_update_accuracy
|
heal_amt = heal_amt * wound_update_accuracy
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
var/damage_type = CUT
|
var/damage_type = CUT
|
||||||
|
|
||||||
// whether this wound needs a bandage/salve to heal at all
|
// whether this wound needs a bandage/salve to heal at all
|
||||||
var/needs_treatment = 0
|
// the maximum amount of damage that this wound can have and still autoheal
|
||||||
|
var/autoheal_cutoff = 15
|
||||||
|
|
||||||
// is the wound bandaged?
|
// is the wound bandaged?
|
||||||
var/tmp/bandaged = 0
|
var/tmp/bandaged = 0
|
||||||
@@ -62,37 +63,32 @@
|
|||||||
|
|
||||||
src.damage = damage
|
src.damage = damage
|
||||||
|
|
||||||
// initialize with the first stage
|
|
||||||
next_stage()
|
|
||||||
|
|
||||||
// this will ensure the size of the wound matches the damage
|
|
||||||
src.heal_damage(0)
|
|
||||||
|
|
||||||
// make the max_bleeding_stage count from the end of the list rather than the start
|
|
||||||
// this is more robust to changes to the list
|
|
||||||
max_bleeding_stage = src.desc_list.len - max_bleeding_stage
|
max_bleeding_stage = src.desc_list.len - max_bleeding_stage
|
||||||
|
|
||||||
|
// initialize with the appropriate stage
|
||||||
|
src.init_stage(damage)
|
||||||
|
|
||||||
bleed_timer += damage
|
bleed_timer += damage
|
||||||
|
|
||||||
// returns 1 if there's a next stage, 0 otherwise
|
// returns 1 if there's a next stage, 0 otherwise
|
||||||
proc/next_stage()
|
proc/init_stage(var/initial_damage)
|
||||||
if(current_stage + 1 > src.desc_list.len)
|
current_stage = stages.len
|
||||||
return 0
|
|
||||||
|
while(src.current_stage > 1 && src.damage_list[current_stage-1] <= initial_damage / src.amount)
|
||||||
current_stage++
|
src.current_stage--
|
||||||
|
|
||||||
src.min_damage = damage_list[current_stage]
|
src.min_damage = damage_list[current_stage]
|
||||||
src.desc = desc_list[current_stage]
|
src.desc = desc_list[current_stage]
|
||||||
return 1
|
|
||||||
|
|
||||||
// returns 1 if the wound has started healing
|
// returns 1 if the wound has started healing
|
||||||
proc/started_healing()
|
proc/started_healing()
|
||||||
return (current_stage > 1)
|
return (current_stage > 1)
|
||||||
|
|
||||||
// checks whether the wound has been appropriately treated
|
// checks whether the wound has been appropriately treated
|
||||||
// always returns 1 for wounds that don't need to be treated
|
// always returns 1 for wounds that are too minor to need treatment
|
||||||
proc/is_treated()
|
proc/is_treated()
|
||||||
if(!needs_treatment) return 1
|
if(src.damage <= autoheal_cutoff)
|
||||||
|
return 1
|
||||||
|
|
||||||
if(damage_type == BRUISE || damage_type == CUT)
|
if(damage_type == BRUISE || damage_type == CUT)
|
||||||
return bandaged
|
return bandaged
|
||||||
@@ -141,7 +137,7 @@
|
|||||||
src.damage += damage
|
src.damage += damage
|
||||||
bleed_timer += damage
|
bleed_timer += damage
|
||||||
|
|
||||||
while(src.current_stage > 1 && src.damage_list[current_stage-1] <= src.damage)
|
while(src.current_stage > 1 && src.damage_list[current_stage-1] <= src.damage / src.amount)
|
||||||
src.current_stage--
|
src.current_stage--
|
||||||
|
|
||||||
src.desc = desc_list[current_stage]
|
src.desc = desc_list[current_stage]
|
||||||
@@ -167,92 +163,46 @@
|
|||||||
|
|
||||||
/datum/wound/cut/gaping
|
/datum/wound/cut/gaping
|
||||||
max_bleeding_stage = 2
|
max_bleeding_stage = 2
|
||||||
stages = list("gaping wound" = 50, "large blood soaked clot" = 25, "large clot" = 15, "small angry scar" = 5, \
|
stages = list("gaping wound" = 50, "large blood soaked clot" = 25, "large clot" = 15, "small angry scar" = 5, "small straight scar" = 0)
|
||||||
"small straight scar" = 0)
|
|
||||||
|
|
||||||
/datum/wound/cut/gaping_big
|
/datum/wound/cut/gaping_big
|
||||||
max_bleeding_stage = 2
|
max_bleeding_stage = 2
|
||||||
stages = list("big gaping wound" = 60, "healing gaping wound" = 40, "large angry scar" = 10, "large straight scar" = 0)
|
stages = list("big gaping wound" = 60, "healing gaping wound" = 40, "large angry scar" = 10, "large straight scar" = 0)
|
||||||
|
|
||||||
needs_treatment = 1 // this only heals when bandaged
|
|
||||||
|
|
||||||
datum/wound/cut/massive
|
datum/wound/cut/massive
|
||||||
max_bleeding_stage = 2
|
max_bleeding_stage = 2
|
||||||
stages = list("massive wound" = 70, "massive healing wound" = 50, "massive angry scar" = 10, "massive jagged scar" = 0)
|
stages = list("massive wound" = 70, "massive healing wound" = 50, "massive angry scar" = 10, "massive jagged scar" = 0)
|
||||||
|
|
||||||
needs_treatment = 1 // this only heals when bandaged
|
|
||||||
|
|
||||||
/** BRUISES **/
|
/** BRUISES **/
|
||||||
/datum/wound/bruise
|
/datum/wound/bruise
|
||||||
stages = list("monumental bruise" = 80, "huge bruise" = 50, "large bruise" = 30,\
|
stages = list("monumental bruise" = 80, "huge bruise" = 50, "large bruise" = 30,\
|
||||||
"moderate bruise" = 20, "small bruise" = 10, "tiny bruise" = 5)
|
"moderate bruise" = 20, "small bruise" = 10, "tiny bruise" = 5)
|
||||||
|
max_bleeding_stage = 3
|
||||||
needs_treatment = 1 // this only heals when bandaged
|
autoheal_cutoff = 30
|
||||||
damage_type = BRUISE
|
|
||||||
|
|
||||||
/datum/wound/bruise/monumental
|
|
||||||
|
|
||||||
// implement sub-paths by starting at a later stage
|
|
||||||
|
|
||||||
/datum/wound/bruise/tiny
|
|
||||||
current_stage = 5
|
|
||||||
needs_treatment = 0
|
|
||||||
|
|
||||||
/datum/wound/bruise/small
|
|
||||||
current_stage = 4
|
|
||||||
needs_treatment = 0
|
|
||||||
|
|
||||||
/datum/wound/bruise/moderate
|
|
||||||
current_stage = 3
|
|
||||||
needs_treatment = 0
|
|
||||||
|
|
||||||
/datum/wound/bruise/large
|
|
||||||
current_stage = 2
|
|
||||||
|
|
||||||
/datum/wound/bruise/huge
|
|
||||||
current_stage = 1
|
|
||||||
|
|
||||||
/** BURNS **/
|
/** BURNS **/
|
||||||
/datum/wound/burn/moderate
|
/datum/wound/burn/moderate
|
||||||
stages = list("ripped burn" = 10, "moderate burn" = 5, "moderate salved burn" = 2, "fresh skin" = 0)
|
stages = list("ripped burn" = 10, "moderate burn" = 5, "moderate salved burn" = 2, "fresh skin" = 0)
|
||||||
|
|
||||||
needs_treatment = 1 // this only heals when bandaged
|
|
||||||
|
|
||||||
damage_type = BURN
|
damage_type = BURN
|
||||||
|
|
||||||
/datum/wound/burn/large
|
/datum/wound/burn/large
|
||||||
stages = list("ripped large burn" = 20, "large burn" = 15, "large salved burn" = 5, "fresh skin" = 0)
|
stages = list("ripped large burn" = 20, "large burn" = 15, "large salved burn" = 5, "fresh skin" = 0)
|
||||||
|
|
||||||
needs_treatment = 1 // this only heals when bandaged
|
|
||||||
|
|
||||||
damage_type = BURN
|
damage_type = BURN
|
||||||
|
|
||||||
/datum/wound/burn/severe
|
/datum/wound/burn/severe
|
||||||
stages = list("ripped severe burn" = 35, "severe burn" = 30, "severe salved burn" = 10, "burn scar" = 0)
|
stages = list("ripped severe burn" = 35, "severe burn" = 30, "severe salved burn" = 10, "burn scar" = 0)
|
||||||
|
|
||||||
needs_treatment = 1 // this only heals when bandaged
|
|
||||||
|
|
||||||
damage_type = BURN
|
damage_type = BURN
|
||||||
|
|
||||||
/datum/wound/burn/deep
|
/datum/wound/burn/deep
|
||||||
stages = list("ripped deep burn" = 45, "deep burn" = 40, "deep salved burn" = 15, "large burn scar" = 0)
|
stages = list("ripped deep burn" = 45, "deep burn" = 40, "deep salved burn" = 15, "large burn scar" = 0)
|
||||||
|
|
||||||
needs_treatment = 1 // this only heals when bandaged
|
|
||||||
|
|
||||||
damage_type = BURN
|
damage_type = BURN
|
||||||
|
|
||||||
|
|
||||||
/datum/wound/burn/carbonised
|
/datum/wound/burn/carbonised
|
||||||
stages = list("carbonised area" = 50, "treated carbonised area" = 20, "massive burn scar" = 0)
|
stages = list("carbonised area" = 50, "treated carbonised area" = 20, "massive burn scar" = 0)
|
||||||
|
|
||||||
needs_treatment = 1 // this only heals when bandaged
|
|
||||||
|
|
||||||
damage_type = BURN
|
damage_type = BURN
|
||||||
|
|
||||||
/datum/wound/internal_bleeding
|
/datum/wound/internal_bleeding
|
||||||
internal = 1
|
internal = 1
|
||||||
|
|
||||||
stages = list("severed vein" = 30, "cut vein" = 20, "damaged vein" = 10, "bruised vein" = 5)
|
stages = list("severed vein" = 30, "cut vein" = 20, "damaged vein" = 10, "bruised vein" = 5)
|
||||||
max_bleeding_stage = 0
|
autoheal_cutoff = 5
|
||||||
|
max_bleeding_stage = 0 //all stages bleed. It's called internal bleeding after all.
|
||||||
needs_treatment = 1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user