diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index 142455b1dcd..060a18fe17b 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -537,6 +537,7 @@ GLOBAL_LIST_INIT(available_erp_ui_styles, list( if(ismob(mymob) && mymob.hud_used == src) show_hud(hud_version) +/// Handles dimming inventory slots that a mob can't equip items to in their current state /datum/hud/proc/update_locked_slots() return diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index 6315bad8506..62e73e2c3fd 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -309,16 +309,40 @@ /datum/hud/human/update_locked_slots() if(!mymob) return - var/mob/living/carbon/human/H = mymob - if(!istype(H) || !H.dna.species) - return - var/datum/species/S = H.dna.species + var/blocked_slots = NONE + + var/mob/living/carbon/human/human_mob = mymob + if(istype(human_mob)) + blocked_slots |= human_mob.dna?.species?.no_equip_flags + if(isnull(human_mob.w_uniform) && !HAS_TRAIT(human_mob, TRAIT_NO_JUMPSUIT)) + var/obj/item/bodypart/chest = human_mob.get_bodypart(BODY_ZONE_CHEST) + if(isnull(chest) || IS_ORGANIC_LIMB(chest)) + blocked_slots |= ITEM_SLOT_ID|ITEM_SLOT_BELT + var/obj/item/bodypart/left_leg = human_mob.get_bodypart(BODY_ZONE_L_LEG) + if(isnull(left_leg) || IS_ORGANIC_LIMB(left_leg)) + blocked_slots |= ITEM_SLOT_LPOCKET + var/obj/item/bodypart/right_leg = human_mob.get_bodypart(BODY_ZONE_R_LEG) + if(isnull(right_leg) || IS_ORGANIC_LIMB(right_leg)) + blocked_slots |= ITEM_SLOT_RPOCKET + if(isnull(human_mob.wear_suit)) + blocked_slots |= ITEM_SLOT_SUITSTORE + if(human_mob.num_hands <= 0) + blocked_slots |= ITEM_SLOT_GLOVES + if(human_mob.num_legs < 2) // update this when you can wear shoes on one foot + blocked_slots |= ITEM_SLOT_FEET + var/obj/item/bodypart/head/head = human_mob.get_bodypart(BODY_ZONE_HEAD) + if(isnull(head)) + blocked_slots |= ITEM_SLOT_HEAD|ITEM_SLOT_EARS|ITEM_SLOT_EYES|ITEM_SLOT_MASK + var/obj/item/organ/internal/eyes/eyes = human_mob.get_organ_slot(ORGAN_SLOT_EYES) + if(eyes?.no_glasses) + blocked_slots |= ITEM_SLOT_EYES + if(human_mob.bodyshape & BODYSHAPE_DIGITIGRADE) + blocked_slots |= ITEM_SLOT_FEET + for(var/atom/movable/screen/inventory/inv in (static_inventory + toggleable_inventory)) - if(inv.slot_id) - if(S.no_equip_flags & inv.slot_id) - inv.alpha = 128 - else - inv.alpha = initial(inv.alpha) + if(!inv.slot_id) + continue + inv.alpha = (blocked_slots & inv.slot_id) ? 128 : initial(inv.alpha) /datum/hud/human/hidden_inventory_update(mob/viewer) if(!mymob) diff --git a/code/modules/mob/living/carbon/human/_species.dm b/code/modules/mob/living/carbon/human/_species.dm index 7073bdb118f..1eb48e3d10e 100644 --- a/code/modules/mob/living/carbon/human/_species.dm +++ b/code/modules/mob/living/carbon/human/_species.dm @@ -434,9 +434,6 @@ GLOBAL_LIST_EMPTY(features_by_species) /datum/species/proc/on_species_gain(mob/living/carbon/human/human_who_gained_species, datum/species/old_species, pref_load) SHOULD_CALL_PARENT(TRUE) // Drop the items the new species can't wear - if(human_who_gained_species.hud_used) - human_who_gained_species.hud_used.update_locked_slots() - human_who_gained_species.mob_biotypes = inherent_biotypes human_who_gained_species.mob_respiration_type = inherent_respiration_type human_who_gained_species.butcher_results = knife_butcher_results?.Copy() @@ -444,8 +441,9 @@ GLOBAL_LIST_EMPTY(features_by_species) if(old_species.type != type) replace_body(human_who_gained_species, src) - regenerate_organs(human_who_gained_species, old_species, visual_only = human_who_gained_species.visual_only_organs) - + regenerate_organs(human_who_gained_species, old_species, replace_current = FALSE, visual_only = human_who_gained_species.visual_only_organs) + // Update locked slots AFTER all organ and body stuff is handled + human_who_gained_species.hud_used?.update_locked_slots() // Drop the items the new species can't wear INVOKE_ASYNC(src, PROC_REF(worn_items_fit_body_check), human_who_gained_species, TRUE) diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index e4f3341278a..c696d5da3e1 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -216,6 +216,7 @@ //Item is handled and in slot, valid to call callback, for this proc should always be true if(!not_handled) has_equipped(equipping, slot, initial) + hud_used?.update_locked_slots() // Send a signal for when we equip an item that used to cover our feet/shoes. Used for bloody feet if(equipping.body_parts_covered & FEET || (equipping.flags_inv | equipping.transparent_protection) & HIDESHOES) @@ -313,6 +314,7 @@ update_equipment_speed_mods() update_obscured_slots(I.flags_inv) + hud_used?.update_locked_slots() /mob/living/carbon/human/toggle_internals(obj/item/tank, is_external = FALSE) // Just close the tank if it's the one the mob already has open. diff --git a/code/modules/mob/living/carbon/inventory.dm b/code/modules/mob/living/carbon/inventory.dm index 5b43bf980c4..10af8d53c80 100644 --- a/code/modules/mob/living/carbon/inventory.dm +++ b/code/modules/mob/living/carbon/inventory.dm @@ -180,6 +180,7 @@ //in a slot (handled further down inheritance chain, probably living/carbon/human/equip_to_slot if(!not_handled) has_equipped(equipping, slot, initial) + hud_used?.update_locked_slots() return not_handled @@ -237,6 +238,7 @@ update_equipment_speed_mods() update_obscured_slots(I.flags_inv) + hud_used?.update_locked_slots() /// Returns TRUE if an air tank compatible helmet is equipped. /mob/living/carbon/proc/can_breathe_helmet() diff --git a/code/modules/surgery/bodyparts/dismemberment.dm b/code/modules/surgery/bodyparts/dismemberment.dm index 312d237339a..7cd956b5dcc 100644 --- a/code/modules/surgery/bodyparts/dismemberment.dm +++ b/code/modules/surgery/bodyparts/dismemberment.dm @@ -130,6 +130,8 @@ phantom_owner.update_health_hud() //update the healthdoll phantom_owner.update_body() phantom_owner.update_body_parts() + if(!special) + phantom_owner.hud_used?.update_locked_slots() if(bodypart_flags & BODYPART_PSEUDOPART) drop_organs(phantom_owner) //Psuedoparts shouldn't have organs, but just in case @@ -328,6 +330,8 @@ new_limb_owner.updatehealth() new_limb_owner.update_body() new_limb_owner.update_damage_overlays() + if(!special) + new_limb_owner.hud_used?.update_locked_slots() SEND_SIGNAL(new_limb_owner, COMSIG_CARBON_POST_ATTACH_LIMB, src, special) return TRUE diff --git a/code/modules/surgery/organs/organ_movement.dm b/code/modules/surgery/organs/organ_movement.dm index bcd85ed39ff..34d6b6f5251 100644 --- a/code/modules/surgery/organs/organ_movement.dm +++ b/code/modules/surgery/organs/organ_movement.dm @@ -88,6 +88,8 @@ for(var/datum/status_effect/effect as anything in organ_effects) organ_owner.apply_status_effect(effect, type) + if(!special) + organ_owner.hud_used?.update_locked_slots() RegisterSignal(owner, COMSIG_ATOM_EXAMINE, PROC_REF(on_owner_examine)) SEND_SIGNAL(src, COMSIG_ORGAN_IMPLANTED, organ_owner) SEND_SIGNAL(organ_owner, COMSIG_CARBON_GAIN_ORGAN, src, special) @@ -163,6 +165,11 @@ SEND_SIGNAL(organ_owner, COMSIG_CARBON_LOSE_ORGAN, src, special) ADD_TRAIT(src, TRAIT_USED_ORGAN, ORGAN_TRAIT) + organ_owner.synchronize_bodytypes() + organ_owner.synchronize_bodyshapes() + if(!special) + organ_owner.hud_used?.update_locked_slots() + var/list/diseases = organ_owner.get_static_viruses() if(!LAZYLEN(diseases)) return