Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
Fixes wrong limbs given after using bodypart miracle (#1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoTomahto authored Jun 23, 2024
2 parents e97a97d + 5aededa commit 281b285
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions code/modules/spells/roguetown/acolyte/pestra.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,37 @@
limbs += dismembered
return limbs

// consider adding functionality to regrow one entire organ or limb per casting?
/obj/effect/proc_holder/spell/invoked/attach_bodypart/cast(list/targets, mob/living/user)
if(ishuman(targets[1]))
var/mob/living/carbon/human/human_target = targets[1]
for(var/obj/item/bodypart/limb as anything in get_limbs(human_target, user))
if(human_target.get_bodypart(limb.body_zone) || !limb.attach_limb(human_target))
continue
human_target.visible_message(span_info("\The [limb] attaches itself to [human_target]!"), \
span_notice("\The [limb] attaches itself to me!"))
var/list/limbs_to_regenerate = human_target.get_missing_limbs()
var/list/detached_limbs = get_limbs(human_target, user)
var/list/regenerated_limbs = list()
for(var/body_zone in limbs_to_regenerate)
for(var/obj/item/bodypart/limb in detached_limbs)
if(limb.body_zone == body_zone)
regenerated_limbs += body_zone
qdel(limb)
break
if(length(regenerated_limbs))
human_target.regenerate_limbs(0, limbs_to_regenerate - regenerated_limbs)
human_target.visible_message(span_info("[human_target]'s missing limbs attach to their body!"), \
span_notice("My missing limbs attach to my body!"))
else
to_chat(user, span_warning("No detached limbs found nearby to attach."))


for(var/obj/item/organ/organ as anything in get_organs(human_target, user))
if(human_target.getorganslot(organ.slot) || !organ.Insert(human_target))
continue
human_target.visible_message(span_info("\The [organ] attaches itself to [human_target]!"), \
span_notice("\The [organ] attaches itself to me!"))

if(!(human_target.mob_biotypes & MOB_UNDEAD))
for(var/obj/item/bodypart/limb as anything in human_target.bodyparts)
limb.rotted = FALSE
limb.skeletonized = FALSE

human_target.update_body()
return TRUE
return FALSE
Expand Down

0 comments on commit 281b285

Please sign in to comment.