From 0df26f261d90497b8649a707ec40af7a034ef524 Mon Sep 17 00:00:00 2001 From: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> Date: Thu, 29 Feb 2024 18:37:43 +0100 Subject: [PATCH] sdaf (#18574) --- code/game/objects/objs.dm | 31 ++++++++++---- .../fluffyghost-fixspecieautoadapt.yml | 42 +++++++++++++++++++ 2 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 html/changelogs/fluffyghost-fixspecieautoadapt.yml diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 52a8887900f..09a7fdccdcd 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -23,8 +23,15 @@ var/icon_species_tag = ""//If set, this holds the 3-letter shortname of a species, used for species-specific worn icons var/icon_auto_adapt = 0//If 1, this item will automatically change its species tag to match the wearer's species. //requires that the wearer's species is listed in icon_supported_species_tags - var/list/icon_supported_species_tags //Used with icon_auto_adapt, a list of species which have differing appearances for this item - var/icon_species_in_hand = 0//If 1, we will use the species tag even for rendering this item in the left/right hand. + + /** + * A list of strings used with icon_auto_adapt, a list of species which have differing appearances for this item, + * based on the specie short name + */ + var/list/icon_supported_species_tags + + ///If `TRUE`, will use the `icon_species_tag` var for rendering this item in the left/right hand + var/icon_species_in_hand = FALSE var/equip_slot = 0 var/usesound @@ -198,15 +205,23 @@ step(src, pick(NORTH,SOUTH,EAST,WEST)) sleep(rand(2,4)) - -/obj/proc/auto_adapt_species(var/mob/living/carbon/human/wearer) +/** + * Sets the `icon_species_tag` on the `/obj` based on the wearer specie, which is + * then used by the icon generator to select the correct overlay of the object + * + * * wearer - A `/mob/living/carbon/human` to adapt the object to the specie of + * + * Returns `TRUE` on successful adaptation, `FALSE` otherwise + */ +/obj/proc/auto_adapt_species(mob/living/carbon/human/wearer) + SHOULD_NOT_SLEEP(TRUE) if(icon_auto_adapt) icon_species_tag = "" - if (wearer && icon_supported_species_tags.len) - if (wearer.species.short_name in icon_supported_species_tags) + if(wearer && length(icon_supported_species_tags)) + if(wearer.species.short_name in icon_supported_species_tags) icon_species_tag = wearer.species.short_name - return 1 - return 0 + return TRUE + return FALSE //This function should be called on an item when it is: diff --git a/html/changelogs/fluffyghost-fixspecieautoadapt.yml b/html/changelogs/fluffyghost-fixspecieautoadapt.yml new file mode 100644 index 00000000000..85ae8f249a9 --- /dev/null +++ b/html/changelogs/fluffyghost-fixspecieautoadapt.yml @@ -0,0 +1,42 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: FluffyGhost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Fixed specie autoadapt to not runtime." + - backend: "Some DMdoc and minor adjustments."