|
|
|
@@ -53,169 +53,169 @@
|
|
|
|
|
var/tmp/list/desc_list = list()
|
|
|
|
|
var/tmp/list/damage_list = list()
|
|
|
|
|
|
|
|
|
|
New(var/damage)
|
|
|
|
|
/datum/wound/New(var/damage)
|
|
|
|
|
|
|
|
|
|
created = world.time
|
|
|
|
|
created = world.time
|
|
|
|
|
|
|
|
|
|
// reading from a list("stage" = damage) is pretty difficult, so build two separate
|
|
|
|
|
// lists from them instead
|
|
|
|
|
for(var/V in stages)
|
|
|
|
|
desc_list += V
|
|
|
|
|
damage_list += stages[V]
|
|
|
|
|
// reading from a list("stage" = damage) is pretty difficult, so build two separate
|
|
|
|
|
// lists from them instead
|
|
|
|
|
for(var/V in stages)
|
|
|
|
|
desc_list += V
|
|
|
|
|
damage_list += stages[V]
|
|
|
|
|
|
|
|
|
|
src.damage = damage
|
|
|
|
|
src.damage = damage
|
|
|
|
|
|
|
|
|
|
// initialize with the appropriate stage
|
|
|
|
|
src.init_stage(damage)
|
|
|
|
|
// 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
|
|
|
|
|
proc/init_stage(var/initial_damage)
|
|
|
|
|
current_stage = stages.len
|
|
|
|
|
/datum/wound/proc/init_stage(var/initial_damage)
|
|
|
|
|
current_stage = stages.len
|
|
|
|
|
|
|
|
|
|
while(src.current_stage > 1 && src.damage_list[current_stage-1] <= initial_damage / src.amount)
|
|
|
|
|
src.current_stage--
|
|
|
|
|
while(src.current_stage > 1 && src.damage_list[current_stage-1] <= initial_damage / src.amount)
|
|
|
|
|
src.current_stage--
|
|
|
|
|
|
|
|
|
|
src.min_damage = damage_list[current_stage]
|
|
|
|
|
src.desc = desc_list[current_stage]
|
|
|
|
|
src.min_damage = damage_list[current_stage]
|
|
|
|
|
src.desc = desc_list[current_stage]
|
|
|
|
|
|
|
|
|
|
// the amount of damage per wound
|
|
|
|
|
proc/wound_damage()
|
|
|
|
|
return src.damage / src.amount
|
|
|
|
|
// the amount of damage per wound
|
|
|
|
|
/datum/wound/proc/wound_damage()
|
|
|
|
|
return src.damage / src.amount
|
|
|
|
|
|
|
|
|
|
proc/can_autoheal()
|
|
|
|
|
if(is_treated())
|
|
|
|
|
return TRUE
|
|
|
|
|
if(src.wound_damage() <= autoheal_cutoff)
|
|
|
|
|
if(created + 10 MINUTES > world.time) // Wounds don't autoheal for ten minutes if not bandaged.
|
|
|
|
|
return FALSE
|
|
|
|
|
return TRUE
|
|
|
|
|
/datum/wound/proc/can_autoheal()
|
|
|
|
|
if(is_treated())
|
|
|
|
|
return TRUE
|
|
|
|
|
if(src.wound_damage() <= autoheal_cutoff)
|
|
|
|
|
if(created + 10 MINUTES > world.time) // Wounds don't autoheal for ten minutes if not bandaged.
|
|
|
|
|
return FALSE
|
|
|
|
|
return TRUE
|
|
|
|
|
|
|
|
|
|
// checks whether the wound has been appropriately treated
|
|
|
|
|
proc/is_treated()
|
|
|
|
|
if(damage_type == BRUISE || damage_type == CUT || damage_type == PIERCE)
|
|
|
|
|
return bandaged
|
|
|
|
|
else if(damage_type == BURN)
|
|
|
|
|
return salved
|
|
|
|
|
// checks whether the wound has been appropriately treated
|
|
|
|
|
/datum/wound/proc/is_treated()
|
|
|
|
|
if(damage_type == BRUISE || damage_type == CUT || damage_type == PIERCE)
|
|
|
|
|
return bandaged
|
|
|
|
|
else if(damage_type == BURN)
|
|
|
|
|
return salved
|
|
|
|
|
|
|
|
|
|
// Checks whether other other can be merged into src.
|
|
|
|
|
proc/can_merge(var/datum/wound/other)
|
|
|
|
|
if (other.type != src.type) return 0
|
|
|
|
|
if (other.current_stage != src.current_stage) return 0
|
|
|
|
|
if (other.damage_type != src.damage_type) return 0
|
|
|
|
|
if (!(other.can_autoheal()) != !(src.can_autoheal())) return 0
|
|
|
|
|
if (!(other.bandaged) != !(src.bandaged)) return 0
|
|
|
|
|
if (!(other.clamped) != !(src.clamped)) return 0
|
|
|
|
|
if (!(other.salved) != !(src.salved)) return 0
|
|
|
|
|
if (!(other.disinfected) != !(src.disinfected)) return 0
|
|
|
|
|
//if (other.germ_level != src.germ_level) return 0
|
|
|
|
|
return 1
|
|
|
|
|
// Checks whether other other can be merged into src.
|
|
|
|
|
/datum/wound/proc/can_merge(var/datum/wound/other)
|
|
|
|
|
if (other.type != src.type) return 0
|
|
|
|
|
if (other.current_stage != src.current_stage) return 0
|
|
|
|
|
if (other.damage_type != src.damage_type) return 0
|
|
|
|
|
if (!(other.can_autoheal()) != !(src.can_autoheal())) return 0
|
|
|
|
|
if (!(other.bandaged) != !(src.bandaged)) return 0
|
|
|
|
|
if (!(other.clamped) != !(src.clamped)) return 0
|
|
|
|
|
if (!(other.salved) != !(src.salved)) return 0
|
|
|
|
|
if (!(other.disinfected) != !(src.disinfected)) return 0
|
|
|
|
|
//if (other.germ_level != src.germ_level) return 0
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
proc/merge_wound(var/datum/wound/other)
|
|
|
|
|
src.damage += other.damage
|
|
|
|
|
src.amount += other.amount
|
|
|
|
|
src.bleed_timer += other.bleed_timer
|
|
|
|
|
src.germ_level = max(src.germ_level, other.germ_level)
|
|
|
|
|
src.created = max(src.created, other.created) //take the newer created time
|
|
|
|
|
|
|
|
|
|
// checks if wound is considered open for external infections
|
|
|
|
|
// untreated cuts (and bleeding bruises) and burns are possibly infectable, chance higher if wound is bigger
|
|
|
|
|
proc/infection_check()
|
|
|
|
|
if (damage < 10) //small cuts, tiny bruises, and moderate burns shouldn't be infectable.
|
|
|
|
|
return 0
|
|
|
|
|
if (is_treated() && damage < 25) //anything less than a flesh wound (or equivalent) isn't infectable if treated properly
|
|
|
|
|
return 0
|
|
|
|
|
if (disinfected)
|
|
|
|
|
germ_level = 0 //reset this, just in case
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
if (damage_type == BRUISE && !bleeding()) //bruises only infectable if bleeding
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
var/dam_coef = round(damage/10)
|
|
|
|
|
switch (damage_type)
|
|
|
|
|
if (BRUISE)
|
|
|
|
|
return prob(dam_coef*5)
|
|
|
|
|
if (BURN)
|
|
|
|
|
return prob(dam_coef*10)
|
|
|
|
|
if (CUT)
|
|
|
|
|
return prob(dam_coef*20)
|
|
|
|
|
/datum/wound/proc/merge_wound(var/datum/wound/other)
|
|
|
|
|
src.damage += other.damage
|
|
|
|
|
src.amount += other.amount
|
|
|
|
|
src.bleed_timer += other.bleed_timer
|
|
|
|
|
src.germ_level = max(src.germ_level, other.germ_level)
|
|
|
|
|
src.created = max(src.created, other.created) //take the newer created time
|
|
|
|
|
|
|
|
|
|
// checks if wound is considered open for external infections
|
|
|
|
|
// untreated cuts (and bleeding bruises) and burns are possibly infectable, chance higher if wound is bigger
|
|
|
|
|
/datum/wound/proc/infection_check()
|
|
|
|
|
if (damage < 10) //small cuts, tiny bruises, and moderate burns shouldn't be infectable.
|
|
|
|
|
return 0
|
|
|
|
|
if (is_treated() && damage < 25) //anything less than a flesh wound (or equivalent) isn't infectable if treated properly
|
|
|
|
|
return 0
|
|
|
|
|
if (disinfected)
|
|
|
|
|
germ_level = 0 //reset this, just in case
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
proc/bandage()
|
|
|
|
|
bandaged = 1
|
|
|
|
|
if (damage_type == BRUISE && !bleeding()) //bruises only infectable if bleeding
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
proc/salve()
|
|
|
|
|
salved = 1
|
|
|
|
|
var/dam_coef = round(damage/10)
|
|
|
|
|
switch (damage_type)
|
|
|
|
|
if (BRUISE)
|
|
|
|
|
return prob(dam_coef*5)
|
|
|
|
|
if (BURN)
|
|
|
|
|
return prob(dam_coef*10)
|
|
|
|
|
if (CUT)
|
|
|
|
|
return prob(dam_coef*20)
|
|
|
|
|
|
|
|
|
|
proc/disinfect()
|
|
|
|
|
disinfected = 1
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
// heal the given amount of damage, and if the given amount of damage was more
|
|
|
|
|
// than what needed to be healed, return how much heal was left
|
|
|
|
|
// set @heals_internal to also heal internal organ damage
|
|
|
|
|
proc/heal_damage(amount, heals_internal = 0)
|
|
|
|
|
if(src.internal && !heals_internal)
|
|
|
|
|
// heal nothing
|
|
|
|
|
return amount
|
|
|
|
|
/datum/wound/proc/bandage()
|
|
|
|
|
bandaged = 1
|
|
|
|
|
|
|
|
|
|
var/healed_damage = min(src.damage, amount)
|
|
|
|
|
amount -= healed_damage
|
|
|
|
|
src.damage -= healed_damage
|
|
|
|
|
/datum/wound/proc/salve()
|
|
|
|
|
salved = 1
|
|
|
|
|
|
|
|
|
|
while(src.wound_damage() < damage_list[current_stage] && current_stage < src.desc_list.len)
|
|
|
|
|
current_stage++
|
|
|
|
|
desc = desc_list[current_stage]
|
|
|
|
|
src.min_damage = damage_list[current_stage]
|
|
|
|
|
/datum/wound/proc/disinfect()
|
|
|
|
|
disinfected = 1
|
|
|
|
|
|
|
|
|
|
// return amount of healing still leftover, can be used for other wounds
|
|
|
|
|
// heal the given amount of damage, and if the given amount of damage was more
|
|
|
|
|
// than what needed to be healed, return how much heal was left
|
|
|
|
|
// set @heals_internal to also heal internal organ damage
|
|
|
|
|
/datum/wound/proc/heal_damage(amount, heals_internal = 0)
|
|
|
|
|
if(src.internal && !heals_internal)
|
|
|
|
|
// heal nothing
|
|
|
|
|
return amount
|
|
|
|
|
|
|
|
|
|
// opens the wound again
|
|
|
|
|
proc/open_wound(damage)
|
|
|
|
|
src.damage += damage
|
|
|
|
|
bleed_timer += damage
|
|
|
|
|
var/healed_damage = min(src.damage, amount)
|
|
|
|
|
amount -= healed_damage
|
|
|
|
|
src.damage -= healed_damage
|
|
|
|
|
|
|
|
|
|
while(src.current_stage > 1 && src.damage_list[current_stage-1] <= src.damage / src.amount)
|
|
|
|
|
src.current_stage--
|
|
|
|
|
while(src.wound_damage() < damage_list[current_stage] && current_stage < src.desc_list.len)
|
|
|
|
|
current_stage++
|
|
|
|
|
desc = desc_list[current_stage]
|
|
|
|
|
src.min_damage = damage_list[current_stage]
|
|
|
|
|
|
|
|
|
|
src.desc = desc_list[current_stage]
|
|
|
|
|
src.min_damage = damage_list[current_stage]
|
|
|
|
|
// return amount of healing still leftover, can be used for other wounds
|
|
|
|
|
return amount
|
|
|
|
|
|
|
|
|
|
// returns whether this wound can absorb the given amount of damage.
|
|
|
|
|
// this will prevent large amounts of damage being trapped in less severe wound types
|
|
|
|
|
proc/can_worsen(damage_type, damage)
|
|
|
|
|
if (src.damage_type != damage_type)
|
|
|
|
|
return 0 //incompatible damage types
|
|
|
|
|
// opens the wound again
|
|
|
|
|
/datum/wound/proc/open_wound(damage)
|
|
|
|
|
src.damage += damage
|
|
|
|
|
bleed_timer += damage
|
|
|
|
|
|
|
|
|
|
if (src.amount > 1)
|
|
|
|
|
return 0//merged wounds cannot be worsened.
|
|
|
|
|
while(src.current_stage > 1 && src.damage_list[current_stage-1] <= src.damage / src.amount)
|
|
|
|
|
src.current_stage--
|
|
|
|
|
|
|
|
|
|
//with 1.5*, a shallow cut will be able to carry at most 30 damage,
|
|
|
|
|
//37.5 for a deep cut
|
|
|
|
|
//52.5 for a flesh wound, etc.
|
|
|
|
|
var/max_wound_damage = 1.5*src.damage_list[1]
|
|
|
|
|
if (src.damage + damage > max_wound_damage)
|
|
|
|
|
return 0
|
|
|
|
|
src.desc = desc_list[current_stage]
|
|
|
|
|
src.min_damage = damage_list[current_stage]
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
// returns whether this wound can absorb the given amount of damage.
|
|
|
|
|
// this will prevent large amounts of damage being trapped in less severe wound types
|
|
|
|
|
/datum/wound/proc/can_worsen(damage_type, damage)
|
|
|
|
|
if (src.damage_type != damage_type)
|
|
|
|
|
return 0 //incompatible damage types
|
|
|
|
|
|
|
|
|
|
proc/bleeding()
|
|
|
|
|
if (src.internal)
|
|
|
|
|
return 0 // internal wounds don't bleed in the sense of this function
|
|
|
|
|
if (src.amount > 1)
|
|
|
|
|
return 0//merged wounds cannot be worsened.
|
|
|
|
|
|
|
|
|
|
if (current_stage > max_bleeding_stage)
|
|
|
|
|
return 0
|
|
|
|
|
//with 1.5*, a shallow cut will be able to carry at most 30 damage,
|
|
|
|
|
//37.5 for a deep cut
|
|
|
|
|
//52.5 for a flesh wound, etc.
|
|
|
|
|
var/max_wound_damage = 1.5*src.damage_list[1]
|
|
|
|
|
if (src.damage + damage > max_wound_damage)
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
if (bandaged||clamped)
|
|
|
|
|
return 0
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
if (bleed_timer <= 0 && wound_damage() <= bleed_threshold)
|
|
|
|
|
return 0 //Bleed timer has run out. Once a wound is big enough though, you'll need a bandage to stop it
|
|
|
|
|
/datum/wound/proc/bleeding()
|
|
|
|
|
if (src.internal)
|
|
|
|
|
return 0 // internal wounds don't bleed in the sense of this function
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
if (current_stage > max_bleeding_stage)
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
if (bandaged||clamped)
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
if (bleed_timer <= 0 && wound_damage() <= bleed_threshold)
|
|
|
|
|
return 0 //Bleed timer has run out. Once a wound is big enough though, you'll need a bandage to stop it
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
/** WOUND DEFINITIONS **/
|
|
|
|
|
|
|
|
|
@@ -295,7 +295,7 @@
|
|
|
|
|
max_bleeding_stage = 3
|
|
|
|
|
stages = list("big gaping wound" = 60, "healing gaping wound" = 40, "large blood soaked clot" = 25, "large angry scar" = 10, "large straight scar" = 0)
|
|
|
|
|
|
|
|
|
|
datum/wound/cut/massive
|
|
|
|
|
/datum/wound/cut/massive
|
|
|
|
|
max_bleeding_stage = 3
|
|
|
|
|
stages = list("massive wound" = 70, "massive healing wound" = 50, "massive blood soaked clot" = 25, "massive angry scar" = 10, "massive jagged scar" = 0)
|
|
|
|
|
|
|
|
|
@@ -327,7 +327,7 @@ datum/wound/cut/massive
|
|
|
|
|
stages = list("big gaping hole" = 50, "healing gaping hole" = 20, "large blood soaked clot" = 15, "large angry scar" = 10, "large round scar" = 0)
|
|
|
|
|
damage_type = PIERCE
|
|
|
|
|
|
|
|
|
|
datum/wound/puncture/massive
|
|
|
|
|
/datum/wound/puncture/massive
|
|
|
|
|
max_bleeding_stage = 3
|
|
|
|
|
stages = list("massive wound" = 60, "massive healing wound" = 30, "massive blood soaked clot" = 25, "massive angry scar" = 10, "massive jagged scar" = 0)
|
|
|
|
|
damage_type = PIERCE
|
|
|
|
|