Refactors dislocation, clearer distinction between is_dislocated() and is_usable()

Dislocation no longer relies on adjusting dislocated state of children.
Fixes dislocating and relocating parent organs magically fixing children or protecting children from being dislocated.
Dislocated limbs no longer count as unusable, since they already count for stance damage and dropping items anyways.
In addition, dislocated limbs add to traumatic_shock
Also corrects a misusage of traumatic_shock
This commit is contained in:
HarpyEagle
2016-05-24 10:54:22 -04:00
committed by Yoshax
parent 3c36efa2e2
commit 9976291ca4
6 changed files with 37 additions and 26 deletions

View File

@@ -194,7 +194,7 @@
status += "hurts when touched" status += "hurts when touched"
if(org.status & ORGAN_DEAD) if(org.status & ORGAN_DEAD)
status += "is bruised and necrotic" status += "is bruised and necrotic"
if(!org.is_usable()) if(!org.is_usable() || org.is_dislocated())
status += "dangling uselessly" status += "dangling uselessly"
if(status.len) if(status.len)
src.show_message("My [org.name] is <span class='warning'> [english_list(status)].</span>",1) src.show_message("My [org.name] is <span class='warning'> [english_list(status)].</span>",1)

View File

@@ -1324,7 +1324,7 @@
var/list/limbs = list() var/list/limbs = list()
for(var/limb in organs_by_name) for(var/limb in organs_by_name)
var/obj/item/organ/external/current_limb = organs_by_name[limb] var/obj/item/organ/external/current_limb = organs_by_name[limb]
if(current_limb && current_limb.dislocated == 2) if(current_limb && current_limb.dislocated > 0 && !current_limb.is_parent_dislocated()) //if the parent is also dislocated you will have to relocate that first
limbs |= limb limbs |= limb
var/choice = input(usr,"Which joint do you wish to relocate?") as null|anything in limbs var/choice = input(usr,"Which joint do you wish to relocate?") as null|anything in limbs

View File

@@ -326,7 +326,7 @@
if(!target_zone) if(!target_zone)
return 0 return 0
var/obj/item/organ/external/organ = get_organ(check_zone(target_zone)) var/obj/item/organ/external/organ = get_organ(check_zone(target_zone))
if(!organ || organ.is_dislocated() || organ.dislocated == -1) if(!organ || organ.dislocated > 0 || organ.dislocated == -1) //don't use is_dislocated() here, that checks parent
return 0 return 0
user.visible_message("<span class='warning'>[user] begins to dislocate [src]'s [organ.joint]!</span>") user.visible_message("<span class='warning'>[user] begins to dislocate [src]'s [organ.joint]!</span>")

View File

@@ -847,7 +847,10 @@
if(!isSynthetic() && (species.flags & IS_PLANT) && (!light_organ || light_organ.is_broken())) if(!isSynthetic() && (species.flags & IS_PLANT) && (!light_organ || light_organ.is_broken()))
if(nutrition < 200) if(nutrition < 200)
take_overall_damage(2,0) take_overall_damage(2,0)
traumatic_shock++
//traumatic_shock is updated every tick, incrementing that is pointless - shock_stage is the counter.
//Not that it matters much for diona, who have NO_PAIN.
shock_stage++
// TODO: stomach and bloodstream organ. // TODO: stomach and bloodstream organ.
if(!isSynthetic()) if(!isSynthetic())

View File

@@ -23,8 +23,10 @@
if(istype(src,/mob/living/carbon/human)) if(istype(src,/mob/living/carbon/human))
var/mob/living/carbon/human/M = src var/mob/living/carbon/human/M = src
for(var/obj/item/organ/external/organ in M.organs) for(var/obj/item/organ/external/organ in M.organs)
if(organ && (organ.is_broken() || organ.open)) if(organ.is_broken() || organ.open)
src.traumatic_shock += 30 src.traumatic_shock += 30
else if(organ.is_dislocated())
src.traumatic_shock += 15
if(src.traumatic_shock < 0) if(src.traumatic_shock < 0)
src.traumatic_shock = 0 src.traumatic_shock = 0

View File

@@ -60,7 +60,7 @@
var/cannot_gib // Impossible to gib, distinct from amputation. var/cannot_gib // Impossible to gib, distinct from amputation.
var/joint = "joint" // Descriptive string used in dislocation. var/joint = "joint" // Descriptive string used in dislocation.
var/amputation_point // Descriptive string used in amputation. var/amputation_point // Descriptive string used in amputation.
var/dislocated = 0 // If you target a joint, you can dislocate the limb, causing temporary damage to the organ. var/dislocated = 0 // If you target a joint, you can dislocate the limb, impairing it's usefulness and causing pain
var/encased // Needs to be opened with a saw to access the organs. var/encased // Needs to be opened with a saw to access the organs.
// Surgery vars. // Surgery vars.
@@ -156,32 +156,38 @@
/obj/item/organ/external/proc/is_dislocated() /obj/item/organ/external/proc/is_dislocated()
if(dislocated > 0) if(dislocated > 0)
return 1 return 1
if(parent) if(is_parent_dislocated())
return parent.is_dislocated() return 1//if any parent is dislocated, we are considered dislocated as well
return 0 return 0
/obj/item/organ/external/proc/dislocate(var/primary) /obj/item/organ/external/proc/is_parent_dislocated()
if(dislocated != -1) var/obj/item/organ/external/O = parent
if(primary) while(O && O.dislocated != -1)
dislocated = 2 if(O.dislocated == 1)
else return 1
dislocated = 1 O = O.parent
owner.verbs |= /mob/living/carbon/human/proc/undislocate return 0
if(children && children.len)
for(var/obj/item/organ/external/child in children)
child.dislocate() /obj/item/organ/external/proc/dislocate()
if(dislocated == -1)
return
dislocated = 1
if(owner)
owner.verbs |= /mob/living/carbon/human/proc/undislocate
/obj/item/organ/external/proc/undislocate() /obj/item/organ/external/proc/undislocate()
if(dislocated != -1) if(dislocated == -1)
dislocated = 0 return
if(children && children.len)
for(var/obj/item/organ/external/child in children) dislocated = 0
if(child.dislocated == 1)
child.undislocate()
if(owner) if(owner)
owner.shock_stage += 20 owner.shock_stage += 20
//check to see if we still need the verb
for(var/obj/item/organ/external/limb in owner.organs) for(var/obj/item/organ/external/limb in owner.organs)
if(limb.dislocated == 2) if(limb.dislocated == 1)
return return
owner.verbs -= /mob/living/carbon/human/proc/undislocate owner.verbs -= /mob/living/carbon/human/proc/undislocate
@@ -1085,7 +1091,7 @@ Note that amputating the affected organ does in fact remove the infection from t
return 0 return 0
/obj/item/organ/external/proc/is_usable() /obj/item/organ/external/proc/is_usable()
return !is_dislocated() && !(status & (ORGAN_MUTATED|ORGAN_DEAD)) return !(status & (ORGAN_MUTATED|ORGAN_DEAD))
/obj/item/organ/external/proc/is_malfunctioning() /obj/item/organ/external/proc/is_malfunctioning()
return ((robotic >= ORGAN_ROBOT) && (brute_dam + burn_dam) >= 10 && prob(brute_dam + burn_dam)) return ((robotic >= ORGAN_ROBOT) && (brute_dam + burn_dam) >= 10 && prob(brute_dam + burn_dam))