ID:2331692
 
Is there a way to create a naked npc and give to him clothes, hair and equipments with somekind of code?

Is much easier than copy/paste each state in the icon file
...? the same way you would a player.
In response to GreatPirateEra
well I just try to add an overlay just as it was a player but it doesn't works
In response to Nezeha
Code?
In response to GreatPirateEra
I just simply added. Obviously newbie here
mob/NPCs/Enemies
Ninja
overlays += 'shirt.dmi' <------
Level=10
HP=100
MP=10000
MHP=100
MMP=1000
Attack=50
icon = 'NPCs.dmi'
icon_state = "Guard"
name_color = list("red" = 0, "green" = 0, "blue" = 100)
The easiest way would be to use the same equipping code that you use for your players, but instead doing this during mob/npc/New(). Just be aware that this adds some world/New() overhead (because that's when everything gets generated onto your map). A way of cutting down on this overhead, is to generate equipment once, and equip it to multiple NPCs during mob/npc/New().

The other method would be to do what you already talked about - creating individual unique icons and icon_states for each unique NPC. Which becomes quite tedious for even small projects with a fair amount of NPCs.

For us lazy programmers, we generally use the first method (for randomly generating NPCs and how they look) or generate the icons and icon_states dynamically and saving them using the ftp() proc.
Is there a random npc generator Library or Demo that you know?
var/item/equip/shirt/npc_shirt //one of these per equipment you want on your NPC; or use a list and loop through it

mob/npc/New()
..()
if(!npc_shirt) npc_shirt = new //if npc_shirt hasn't been initialized yet, do so
npc_shirt.equip(src) //equip the npc_shirt to the npc

item
parent_type = /obj
equip
proc/equip(var/mob/m)
if(!m) return
m.overlays += src
proc/unequip(var/mob/m)
if(!m) return
m.overlays -= src
shirt
icon = 'shirt.dmi'


Just a quick snippet I threw together to demonstrate what I mean. I would never do an equipment system in this manner. It's just to illustrate the whole "just use the same equip code you're using for players" thing as well as what I mean by "generate how NPCs look."

EDIT
Fixed the snippet I wrote.