Skip to content
Chinsky edited this page Jul 18, 2020 · 2 revisions

New system of handling iconstates for objects worn by players (aka on-mob icon, single dmi system) The idea is that all icon states needed by the object are stored in its icon dmi, rather than spread across several per-slot huge dmis. Additional feature is support for smaller icons when objects are 'in world' (ground, tables etc) vs 'in inventory' (in slots, in storage) Most of code is contained in https://github.com/NebulaSS13/Nebula/blob/dev/code/game/objects/items/item_icon_experimental.dm

It coexists with usual ss13 icon storage way, items will guess automatically which one they are using. If iconstate 'world' is present in their icon dmi, they assume it's new system, otherwise fallback to old.

In dmi itself, icon states are named in such way:

  • world - default icon used by the item when it's lying around on the ground etc. Required, so items see they're on new system.
  • inventory - optional icon to be used when item is picked up, usually larger and more detailed one. If missing, world icon will be used.
  • slot icons - they are named in pattern of [body type]-[slot name]. Body types are defined in mobs.dm (BODYTYPE_HUMANOID etc) lowercased, slot names are in items_clothing.dm (slot_back_str etc). So e.g. an iten worn by a humanoid on head would use humanoid body-slot_head icon state. If there is no an icon state for specific bodytype, BODYTYPE_HUMANOID one will be used.

Procs: On mob worn icon is generated by /obj/item/proc/experimental_mob_overlay(var/mob/user_mob, var/slot) which returns an image. If you just want to apply some overlays to it, there's /obj/item/proc/apply_overlays(var/mob/user_mob, var/bodytype, var/image/overlay, var/slot) where ..() will return base image to apply your stuff to.

A handy helper is check_state_in_icon(var/checkstate, var/checkicon) which would let you check if an icon state exists in dmi, e.g. so you don't set to a non-existant one. Its results are cached so it's not as pefomance hogging as just using BYOND proc on its own.

Clone this wiki locally