Clean up nitrogen lung quirk code

- Change code to store type of old lungs, not instance
- Delete old lungs instead of trying to move them to nullspace, fixes runtime
- Fix hardcoded nitrogen lungs path in mutantlungs setting
- Use the right proc to attach the dogtag to the uniform
- Fix dogtag not setting examine text properly
- Fix override of attach_accessory that was missing args
This commit is contained in:
Roxy
2025-05-17 14:36:06 -04:00
parent 78c15fdb9d
commit 5000bdef2c
3 changed files with 20 additions and 23 deletions
@@ -80,7 +80,7 @@
icon_state = icon_state = "[initial(base_icon_state)]_[current_color]"
inhand_icon_state = "[initial(base_icon_state)]_[current_color]"
/obj/item/clothing/under/costume/lewdmaid/attach_accessory(obj/item/attack_item)
/obj/item/clothing/under/costume/lewdmaid/attach_accessory(obj/item/attack_item, mob/living/user, attach_message = TRUE)
. = ..()
var/obj/item/clothing/accessory/prime_accessory = attached_accessories[1]
var/accessory_color = prime_accessory.icon_state
@@ -44,8 +44,12 @@
if(!ispath(item_path))
continue
var/item = new item_path(carbon_holder.loc)
var/success = FALSE
for(var/slot as anything in stored_items[item_path])
carbon_holder.equip_to_storage(item, slot, indirect_action = TRUE)
success = carbon_holder.equip_to_storage(item, slot, indirect_action = TRUE)
if(success)
break
equipped_items[item] = success
for (var/item as anything in equipped_items)
on_equip_item(item, equipped_items[item])
@@ -1,8 +1,7 @@
/datum/quirk/equipping/lungs
abstract_parent_type = /datum/quirk/equipping/lungs
icon = FA_ICON_LUNGS
var/obj/item/organ/lungs/lungs_holding
var/obj/item/organ/lungs/lungs_added
var/old_lungs = null
var/lungs_typepath = /obj/item/organ/lungs
stored_items = list(/obj/item/clothing/accessory/breathing = list(ITEM_SLOT_BACK))
var/breath_type = "oxygen"
@@ -11,28 +10,20 @@
var/mob/living/carbon/human/carbon_holder = quirk_holder
if (!istype(carbon_holder) || !lungs_typepath)
return
var/current_lungs = carbon_holder.get_organ_slot(ORGAN_SLOT_LUNGS)
var/obj/item/organ/lungs/current_lungs = carbon_holder.get_organ_slot(ORGAN_SLOT_LUNGS)
if (istype(current_lungs, lungs_typepath))
return
lungs_holding = current_lungs
if(!isnull(lungs_holding))
lungs_holding.organ_flags |= ORGAN_FROZEN // stop decay on the old lungs
lungs_added = new lungs_typepath
lungs_added.Insert(carbon_holder, special = TRUE)
if(!isnull(lungs_holding))
lungs_holding.moveToNullspace() // save them for later
carbon_holder.dna.species.mutantlungs = /obj/item/organ/lungs/nitrogen
old_lungs = current_lungs?.type
var/obj/item/organ/lungs/lungs_added = new lungs_typepath
lungs_added.Insert(carbon_holder, special = TRUE, movement_flags = DELETE_IF_REPLACED)
carbon_holder.dna.species.mutantlungs = lungs_typepath
/datum/quirk/equipping/lungs/remove()
var/mob/living/carbon/carbon_holder = quirk_holder
if (!istype(carbon_holder) || !istype(lungs_holding))
if (!istype(carbon_holder) || isnull(old_lungs))
return
var/obj/item/organ/lungs/lungs = carbon_holder.get_organ_slot(ORGAN_SLOT_LUNGS)
if (lungs != lungs_added && lungs != lungs_holding)
qdel(lungs_holding)
return
lungs_holding.Insert(carbon_holder, special = TRUE, movement_flags = DELETE_IF_REPLACED)
lungs_holding.organ_flags &= ~ORGAN_FROZEN
var/obj/item/organ/lungs/new_lungs = new old_lungs
new_lungs.Insert(carbon_holder, special = TRUE, movement_flags = DELETE_IF_REPLACED)
carbon_holder.dna.species.mutantlungs = initial(carbon_holder.dna.species.mutantlungs)
/datum/quirk/equipping/lungs/on_equip_item(obj/item/equipped, success)
@@ -41,10 +32,12 @@
return
var/obj/item/clothing/accessory/breathing/acc = equipped
acc.breath_type = breath_type
if(!human_holder?.w_uniform)
if(!istype(human_holder))
return
if (acc.can_attach_accessory(human_holder?.w_uniform, human_holder))
acc.attach(human_holder.w_uniform, human_holder)
var/obj/item/clothing/under/worn_uniform = human_holder.w_uniform
if(!istype(worn_uniform))
return
worn_uniform.attach_accessory(acc, human_holder, attach_message = FALSE)
/obj/item/clothing/accessory/breathing
name = "breathing dogtag"