diff --git a/code/datums/components/prosthetic_item.dm b/code/datums/components/prosthetic_item.dm index b8876f5484f..1537535974f 100644 --- a/code/datums/components/prosthetic_item.dm +++ b/code/datums/components/prosthetic_item.dm @@ -137,6 +137,9 @@ * Returns the created pseudopart */ /mob/living/carbon/proc/make_item_prosthetic(obj/item/some_thing, target_zone = BODY_ZONE_R_ARM, fall_prob = 0) + if(HAS_TRAIT_FROM(some_thing, TRAIT_NODROP, HAND_REPLACEMENT_TRAIT)) + CRASH("make_item_prosthetic given an item that is already a prosthetic limb!") + var/obj/item/bodypart/existing = get_bodypart(target_zone) existing?.drop_limb(special = TRUE) diff --git a/code/modules/jobs/job_types/chaplain/chaplain_nullrod.dm b/code/modules/jobs/job_types/chaplain/chaplain_nullrod.dm index de65b4e7021..96587e0159e 100644 --- a/code/modules/jobs/job_types/chaplain/chaplain_nullrod.dm +++ b/code/modules/jobs/job_types/chaplain/chaplain_nullrod.dm @@ -459,13 +459,14 @@ /obj/item/nullrod/chainsaw/on_selected(obj/item/nullrod/old_weapon, mob/living/picker) if(!iscarbon(picker)) return + to_chat(picker, span_warning("[src] takes the place of your arm!")) var/obj/item/bodypart/active = picker.get_active_hand() var/mob/living/carbon/new_hero = picker new_hero.make_item_prosthetic(src, active.body_zone) /obj/item/nullrod/chainsaw/equipped(mob/living/carbon/user, slot, initial) . = ..() - if(!iscarbon(user)) + if(!iscarbon(user) || HAS_TRAIT_FROM(src, TRAIT_NODROP, HAND_REPLACEMENT_TRAIT)) return if(!(slot & ITEM_SLOT_HANDS)) return diff --git a/code/modules/unit_tests/surgeries.dm b/code/modules/unit_tests/surgeries.dm index 8d2901bf77f..726e9808679 100644 --- a/code/modules/unit_tests/surgeries.dm +++ b/code/modules/unit_tests/surgeries.dm @@ -131,3 +131,25 @@ basic_brute_heal.success(user, clothed_patient, BODY_ZONE_CHEST) TEST_ASSERT(naked_patient.getBruteLoss() < clothed_patient.getBruteLoss(), "Naked patient did not heal more from wounds tending than a clothed patient") + +/// Tests items-as-prosthetic-limbs can apply +/datum/unit_test/prosthetic_item + +/datum/unit_test/prosthetic_item/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/obj/item/claymore/sword = allocate(/obj/item/claymore) + + patient.make_item_prosthetic(sword) + + TEST_ASSERT(HAS_TRAIT_FROM(sword, TRAIT_NODROP, HAND_REPLACEMENT_TRAIT), "Prosthetic item attachment failed! Item does not have the nodrop trait") + +/// Specifically checks the chainsaw nullrod +/datum/unit_test/prosthetic_item/nullrod + +/datum/unit_test/prosthetic_item/nullrod/Run() + var/mob/living/carbon/human/picker = allocate(/mob/living/carbon/human/consistent) + var/obj/item/nullrod/chainsaw/nullrod = allocate(/obj/item/nullrod/chainsaw) + + nullrod.on_selected(null, picker) + + TEST_ASSERT(HAS_TRAIT_FROM(nullrod, TRAIT_NODROP, HAND_REPLACEMENT_TRAIT), "Chainsaw nullrod item attachment failed! Item does not have the nodrop trait")