diff --git a/code/_helpers/mobs.dm b/code/_helpers/mobs.dm index e82e618651..bc111ccbcb 100644 --- a/code/_helpers/mobs.dm +++ b/code/_helpers/mobs.dm @@ -277,6 +277,15 @@ Proc for attack log creation, because really why not return humans +/proc/cached_character_icon(var/mob/desired) + var/cachekey = "\ref[desired][desired.real_name]" + + if(cached_character_icons[cachekey]) + . = cached_character_icons[cachekey] + else + . = getCompoundIcon(desired) + cached_character_icons[cachekey] = . + /proc/getviewsize(view) var/viewX var/viewY diff --git a/code/datums/datacore.dm b/code/datums/datacore.dm index 8e21740082..b665465084 100644 --- a/code/datums/datacore.dm +++ b/code/datums/datacore.dm @@ -243,7 +243,7 @@ L.fields["citizenship"] = H.citizenship L.fields["faction"] = H.personal_faction L.fields["religion"] = H.religion - L.fields["image"] = getFlatIcon(H) //This is god-awful + L.fields["image"] = icon(cached_character_icon(H), dir = SOUTH) L.fields["antagfac"] = H.antag_faction L.fields["antagvis"] = H.antag_vis if(H.exploit_record && !jobban_isbanned(H, "Records")) @@ -256,184 +256,17 @@ /proc/generate_record_id() return add_zero(num2hex(rand(1, 65535)), 4) //no point generating higher numbers because of the limitations of num2hex -/proc/get_id_photo(var/mob/living/carbon/human/H, var/assigned_role) - var/icon/preview_icon = null - - var/g = "m" - if (H.gender == FEMALE) - g = "f" - - var/icon/icobase = H.species.icobase - - preview_icon = new /icon(icobase, "torso_[g]") - var/icon/temp - temp = new /icon(icobase, "groin_[g]") - preview_icon.Blend(temp, ICON_OVERLAY) - temp = new /icon(icobase, "head_[g]") - preview_icon.Blend(temp, ICON_OVERLAY) - - for(var/obj/item/organ/external/E in H.organs) - preview_icon.Blend(E.get_icon(), ICON_OVERLAY) - - //Tail - var/use_species_tail = H.species.get_tail(H) - if(use_species_tail) - temp = new/icon("icon" = 'icons/effects/species.dmi', "icon_state" = "[use_species_tail]_s") - preview_icon.Blend(temp, ICON_OVERLAY) - - // Skin tone - if(H.species.flags & HAS_SKIN_TONE) - if (H.s_tone >= 0) - preview_icon.Blend(rgb(H.s_tone, H.s_tone, H.s_tone), ICON_ADD) - else - preview_icon.Blend(rgb(-H.s_tone, -H.s_tone, -H.s_tone), ICON_SUBTRACT) - - // Skin color - if(H.species.flags & HAS_SKIN_TONE) - if(!H.species || H.species.flags & HAS_SKIN_COLOR) - preview_icon.Blend(rgb(H.r_skin, H.g_skin, H.b_skin), ICON_ADD) - - var/use_eye_icon = "eyes_s" - var/obj/item/organ/external/head/temp_head = H.get_organ(BP_HEAD) - if(temp_head) use_eye_icon = temp_head.eye_icon - var/icon/eyes_s = new/icon("icon" = 'icons/mob/human_face.dmi', "icon_state" = use_eye_icon) - - if (H.species.flags & HAS_EYE_COLOR) - eyes_s.Blend(rgb(H.r_eyes, H.g_eyes, H.b_eyes), ICON_ADD) - - var/datum/sprite_accessory/hair_style = hair_styles_list[H.h_style] - if(hair_style) - var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s") - hair_s.Blend(rgb(H.r_hair, H.g_hair, H.b_hair), ICON_ADD) - eyes_s.Blend(hair_s, ICON_OVERLAY) - - var/datum/sprite_accessory/facial_hair_style = facial_hair_styles_list[H.f_style] - if(facial_hair_style) - var/icon/facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s") - facial_s.Blend(rgb(H.r_facial, H.g_facial, H.b_facial), ICON_ADD) - eyes_s.Blend(facial_s, ICON_OVERLAY) - - var/icon/clothes_s = null - if(!assigned_role) assigned_role = H.mind.assigned_role - switch(assigned_role) - if("Head of Personnel") - clothes_s = new /icon('icons/mob/uniform.dmi', "hop_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - if("Bartender") - clothes_s = new /icon('icons/mob/uniform.dmi', "ba_suit_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - if("Gardener") - clothes_s = new /icon('icons/mob/uniform.dmi', "hydroponics_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - if("Chef") - clothes_s = new /icon('icons/mob/uniform.dmi', "chef_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - if("Janitor") - clothes_s = new /icon('icons/mob/uniform.dmi', "janitor_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - if("Librarian") - clothes_s = new /icon('icons/mob/uniform.dmi', "red_suit_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - if("Quartermaster") - clothes_s = new /icon('icons/mob/uniform.dmi', "qm_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - if("Cargo Technician") - clothes_s = new /icon('icons/mob/uniform.dmi', "cargotech_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - if("Shaft Miner") - clothes_s = new /icon('icons/mob/uniform.dmi', "miner_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - if("Lawyer") - clothes_s = new /icon('icons/mob/uniform.dmi', "internalaffairs_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - if("Chaplain") - clothes_s = new /icon('icons/mob/uniform.dmi', "chapblack_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - if("Research Director") - clothes_s = new /icon('icons/mob/uniform.dmi', "director_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_open"), ICON_OVERLAY) - if("Scientist") - clothes_s = new /icon('icons/mob/uniform.dmi', "sciencewhite_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "white"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_tox_open"), ICON_OVERLAY) - if("Chemist") - clothes_s = new /icon('icons/mob/uniform.dmi', "chemistrywhite_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "white"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_chem_open"), ICON_OVERLAY) - if("Chief Medical Officer") - clothes_s = new /icon('icons/mob/uniform.dmi', "cmo_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_cmo_open"), ICON_OVERLAY) - if("Medical Doctor") - clothes_s = new /icon('icons/mob/uniform.dmi', "medical_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "white"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_open"), ICON_OVERLAY) - if("Geneticist") - clothes_s = new /icon('icons/mob/uniform.dmi', "geneticswhite_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "white"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_gen_open"), ICON_OVERLAY) - if("Virologist") - clothes_s = new /icon('icons/mob/uniform.dmi', "virologywhite_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "white"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_vir_open"), ICON_OVERLAY) - if("Colony Director") - clothes_s = new /icon('icons/mob/uniform.dmi', "captain_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - if("Head of Security") - clothes_s = new /icon('icons/mob/uniform.dmi', "hosred_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "jackboots"), ICON_UNDERLAY) - if("Warden") - clothes_s = new /icon('icons/mob/uniform.dmi', "warden_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "jackboots"), ICON_UNDERLAY) - if("Detective") - clothes_s = new /icon('icons/mob/uniform.dmi', "detective_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "detective"), ICON_OVERLAY) - if("Security Officer") - clothes_s = new /icon('icons/mob/uniform.dmi', "secred_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "jackboots"), ICON_UNDERLAY) - if("Chief Engineer") - clothes_s = new /icon('icons/mob/uniform.dmi', "chief_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/belt.dmi', "utility"), ICON_OVERLAY) - if("Station Engineer") - clothes_s = new /icon('icons/mob/uniform.dmi', "engine_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "orange"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/belt.dmi', "utility"), ICON_OVERLAY) - if("Atmospheric Technician") - clothes_s = new /icon('icons/mob/uniform.dmi', "atmos_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/belt.dmi', "utility"), ICON_OVERLAY) - if("Roboticist") - clothes_s = new /icon('icons/mob/uniform.dmi', "robotics_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_open"), ICON_OVERLAY) - else - clothes_s = new /icon('icons/mob/uniform.dmi', "grey_s") - clothes_s.Blend(new /icon('icons/mob/feet.dmi', "black"), ICON_UNDERLAY) - preview_icon.Blend(eyes_s, ICON_OVERLAY) - if(clothes_s) - preview_icon.Blend(clothes_s, ICON_OVERLAY) - qdel(eyes_s) - qdel(clothes_s) - - return preview_icon - /datum/datacore/proc/CreateGeneralRecord(var/mob/living/carbon/human/H, var/id) ResetPDAManifest() var/icon/front var/icon/side if(H) - front = getFlatIcon(H, SOUTH) - side = getFlatIcon(H, WEST) - else - var/mob/living/carbon/human/dummy = new() - front = new(get_id_photo(dummy), dir = SOUTH) - side = new(get_id_photo(dummy), dir = WEST) - qdel(dummy) + var/icon/charicon = cached_character_icon(H) + front = icon(charicon, dir = SOUTH) + side = icon(charicon, dir = WEST) - if(!id) id = text("[]", add_zero(num2hex(rand(1, 65536)), 4)) + if(!id) + id = text("[]", add_zero(num2hex(rand(1, 65536)), 4)) var/datum/data/record/G = new /datum/data/record() G.name = "Employee Record #[id]" G.fields["name"] = "New Record" diff --git a/code/datums/outfits/outfit.dm b/code/datums/outfits/outfit.dm index ac653e2647..a37c339e21 100644 --- a/code/datums/outfits/outfit.dm +++ b/code/datums/outfits/outfit.dm @@ -101,7 +101,6 @@ var/list/outfits_decls_by_type_ H.equip_to_slot_or_del(new path(H), slot_in_backpack) post_equip(H) - H.regenerate_icons() if(W) // We set ID info last to ensure the ID photo is as correct as possible. H.set_id_info(W) return 1 @@ -158,15 +157,18 @@ var/list/outfits_decls_by_type_ W.rank = rank if(assignment) W.assignment = assignment - H.set_id_info(W) if(H.equip_to_slot_or_del(W, id_slot)) return W -/decl/hierarchy/outfit/proc/equip_pda(mob/living/carbon/human/H, assignment) +/decl/hierarchy/outfit/proc/equip_pda(mob/living/carbon/human/H, rank, assignment) if(!pda_slot || !pda_type) return var/obj/item/device/pda/pda = new pda_type(H) if(H.equip_to_slot_or_del(pda, pda_slot)) + pda.owner = H.real_name + pda.ownjob = assignment + pda.ownrank = rank + pda.name = "PDA-[H.real_name] ([assignment])" return pda /decl/hierarchy/outfit/dd_SortValue() diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index d40330ca48..75e17bd792 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -507,7 +507,8 @@ var/global/datum/controller/occupations/job_master proc/spawnId(var/mob/living/carbon/human/H, rank, title) if(!H) return 0 - var/obj/item/weapon/card/id/C = null + var/obj/item/weapon/card/id/C = H.get_equipped_item(slot_wear_id) + if(istype(C)) return 0 var/datum/job/job = null for(var/datum/job/J in occupations) diff --git a/code/game/objects/items/weapons/id cards/station_ids.dm b/code/game/objects/items/weapons/id cards/station_ids.dm index 314320ffe7..d3d8b4d1a6 100644 --- a/code/game/objects/items/weapons/id cards/station_ids.dm +++ b/code/game/objects/items/weapons/id cards/station_ids.dm @@ -55,8 +55,9 @@ name = "[src.registered_name]'s ID Card ([src.assignment])" /obj/item/weapon/card/id/proc/set_id_photo(var/mob/M) - front = getFlatIcon(M, SOUTH) - side = getFlatIcon(M, WEST) + var/icon/charicon = cached_character_icon(M) + front = icon(charicon,dir = SOUTH) + side = icon(charicon,dir = WEST) /mob/proc/set_id_info(var/obj/item/weapon/card/id/id_card) id_card.age = 0 diff --git a/code/global.dm b/code/global.dm index 1f6124602a..8c6ae38f97 100644 --- a/code/global.dm +++ b/code/global.dm @@ -194,3 +194,7 @@ var/list/station_departments = list("Command", "Medical", "Engineering", "Scienc //Icons for in-game HUD glasses. Why don't we just share these a little bit? var/static/icon/ingame_hud = icon('icons/mob/hud.dmi') var/static/icon/ingame_hud_med = icon('icons/mob/hud_med.dmi') + +//Keyed list for caching icons so you don't need to make them for records, IDs, etc all separately. +//Could be useful for AI impersonation or something at some point? +var/static/list/cached_character_icons = list() diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 546c0594cf..0b93d1bd64 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -273,7 +273,7 @@ datum/preferences ShowChoices(usr) return 1 -/datum/preferences/proc/copy_to(mob/living/carbon/human/character, icon_updates = 1) +/datum/preferences/proc/copy_to(mob/living/carbon/human/character, icon_updates = TRUE) // Sanitizing rather than saving as someone might still be editing when copy_to occurs. player_setup.sanitize_setup() diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index e13facfc9e..1cea9e2113 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1090,7 +1090,7 @@ else usr << "You failed to check the pulse. Try again." -/mob/living/carbon/human/proc/set_species(var/new_species, var/default_colour) +/mob/living/carbon/human/proc/set_species(var/new_species, var/default_colour, var/regen_icons = TRUE) if(!dna) if(!new_species) @@ -1153,6 +1153,7 @@ maxHealth = species.total_health spawn(0) + if(regen_icons) regenerate_icons() make_blood() if(vessel.total_volume < species.blood_volume) vessel.maximum_volume = species.blood_volume diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 1d49c1aacb..ce34765ac0 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -453,7 +453,7 @@ client.prefs.real_name = random_name(new_character.gender) client.prefs.randomize_appearance_and_body_for(new_character) else - client.prefs.copy_to(new_character) + client.prefs.copy_to(new_character, icon_updates = TRUE) src << sound(null, repeat = 0, wait = 0, volume = 85, channel = 1) // MAD JAMS cant last forever yo