Skip to content

Commit

Permalink
bugfix: fix surgeryize organs (#4909)
Browse files Browse the repository at this point in the history
* fix surgeryize

* check damage now

* remove unused args

* autodoc

* remove damage check in end step

* better text
  • Loading branch information
Rerik007 authored Apr 20, 2024
1 parent 8ba2d72 commit d5b6dfc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
7 changes: 7 additions & 0 deletions code/modules/surgery/organs/ears.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@



/obj/item/organ/internal/ears/has_damage()
. = ..()
if(.)
return .
if(owner.AmountDeaf())
return TRUE

/obj/item/organ/internal/ears/surgeryize()
owner?.SetDeaf(0)
heal_internal_damage(100)
Expand Down
11 changes: 11 additions & 0 deletions code/modules/surgery/organs/eyes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@
owner.SetEyeBlurry(0)
owner.SetEyeBlind(0)

/obj/item/organ/internal/eyes/has_damage()
. = ..()
if(.)
return .
if(owner.AmountEyeBlurry() || owner.AmountBlinded())
return TRUE
if(NEARSIGHTED in owner.mutations)
return TRUE
if(BLINDNESS in owner.mutations)
return TRUE

/obj/item/organ/internal/eyes/robotize(make_tough = FALSE)
colourmatrix = null
..() //Make sure the organ's got the robotic status indicators before updating the client colour.
Expand Down
8 changes: 8 additions & 0 deletions code/modules/surgery/organs/organ.dm
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,14 @@
/obj/item/organ/proc/surgeryize()
return

/**
* Checks if organ has damage that can be cured in the "mend organs" operation.
* Returns TRUE if there is damage, otherwise FALSE.
*/
/obj/item/organ/proc/has_damage()
if(damage)
return TRUE
return FALSE

/obj/item/organ/proc/is_robotic()
return (status & ORGAN_ROBOT)
Expand Down
14 changes: 7 additions & 7 deletions code/modules/surgery/organs_internal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
var/any_organs_damaged = FALSE

for(var/obj/item/organ/internal/organ as anything in get_organ_list(target_zone, target, affected))
if(!organ.damage)
if(!organ.has_damage())
continue
any_organs_damaged = TRUE
var/can_treat_robotic = organ.is_robotic() && istype(tool, /obj/item/stack/nanopaste)
Expand All @@ -327,6 +327,7 @@
to_chat(user, "[organ] can't be treated with [tool_name].")

if(!any_organs_damaged)
to_chat(user, "There are no damaged organs in [affected ? affected.name : parse_zone(target_zone)].")
return SURGERY_BEGINSTEP_SKIP

if(affected)
Expand All @@ -347,12 +348,11 @@
if(treated_robotic || treated_organic)
if(organ.is_dead())
continue
if(organ.damage)
user.visible_message(
span_notice("[user] treats damage to [target]'s [organ.name] with [tool_name]."),
span_notice("You treat damage to [target]'s [organ.name] with [tool_name].")
)
organ.damage = 0
user.visible_message(
span_notice("[user] treats damage to [target]'s [organ.name] with [tool_name]."),
span_notice("You treat damage to [target]'s [organ.name] with [tool_name].")
)
organ.damage = 0
organ.surgeryize()

return SURGERY_STEP_CONTINUE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/surgery/robotics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@

var/found_damaged_organ = FALSE
for(var/obj/item/organ/internal/organ as anything in affected.internal_organs)
if(organ.damage && organ.is_robotic())
if(organ.has_damage() && organ.is_robotic())
user.visible_message(
"[user] starts mending the damage to [target]'s [organ.name]'s mechanisms.",
"You start mending the damage to [target]'s [organ.name]'s mechanisms."
Expand Down

0 comments on commit d5b6dfc

Please sign in to comment.