ID:162211
 
there is any way to make byond choose a hair style and hair color to a NPC?(i create the icon base without hair)
or even for a char you create
its would be great if it choose you a randomally hair style and hair color(i will define the hair style and the color of hair)but i dont really know how to code somthing like this.
is it even possebole?

also i want to create a mirror NPC that will look just like the player,he will have the same hair color and hair style
doest that possebole too?

tnks for reading this topic

hope you understand what i mean
It's really quite simple.
/mob/npc/
New(var/autogen=TRUE)
..()
if(autogen){var/obj/O=new;O.icon='hair.dmi';O.icon_state=pick("bald","spikey","long");O.icon+=rgb(rand(1,255),rand(1,255),rand(1,255);src.overlays+=O}
//This will give the npc randomly generated hair upon
//creation. *WARNING: UNTESTED CODE!

//--
//For the mirror, that's really simple too.
mob/verb/create_mirror()
var/mob/npc/N = new(0)//So hair is not randomly generated.
N.icon=src.icon
N.overlays=src.overlays
N.loc=locate(src.x,src.y+1,src.z)
//Also untested.
In response to Flame Sage
I like your autgen hair code :)
Ami425 wrote:
there is any way to make byond choose a hair style and hair color to a NPC?(i create the icon base without hair)

What you would want to do for this, is to create a list that contains the names of the icon_states of the hair styles, and then when you override the New() proc for the NPC, you can use the pick() function to randomly pick a variable in that list, and then use that to create the hair style on the NPC. The same can also be used with the colour, except you use rand(0,255), and have it generate it for 3 variables that should be used for the red, green and blue component for the icon manipulation functions.

also i want to create a mirror NPC that will look just like the player,he will have the same hair color and hair style

One of the easier ways is to create a 'backup' set of variables that house what the player selects when creating their character, and then when you want the NPC to mirror the player, you can use those backup variables (name of hair icon_state, and the r,g,b values used to colour the hair) to determine what the NPC would look like on the fly.
In response to Saucepan Man
but my hairs are at deffernt icons and i dont really get how to code it
example what ";" is that thing? and also { }
thats making lots of errors at my code

In response to Ami425
It's just condensing the code. It can also be written as...
/mob/npc/
New(var/autogen=TRUE)
..()
if(autogen)
var/obj/O=new
O.icon='hair.dmi'
O.icon_state=pick("long","spikey")
//etc

Post what errors you having@
In response to Flame Sage
umm but how i can do this if my hairs at deffernt icons?
and the create mirror work great but its a verb and i want to make it when you teleport to place its will create you a mirror that will attack
you think its possebole?(the error was src: missing comma ',' or right-paren ')

and one more question
how can i make that i will get attack beetween lvl 28-50 and if the player pass lvl 50 and still didn't get he will get it at the next lvl for sure
In response to Ami425
Pseudo code
if(level <= 50 && level >= 28 && prob(20)) // 20% chance
get skill
else if(level > 50) get skill

In response to Iuss
Iuss wrote:
Pseudo code
> if(level <= 50 && level >= 28 && prob(20)) // 20% chance
> get skill
> else if(level > 50) get skill
>


            if(src.kombatent == "Cage"||src.kombatent == "Liu Kang")
if(src.flykick == 0)
if(src.level <= 450 && level>= 440 && prob(20))
if(src.kombatent != "Reiko")
src.client.screen += new/obj/flyingk
src.flykick = 1
world << "<b><font color = lime>Ability Info: [src] has learned new skill."
if(src.kombatent == "Reiko")
src.overlays -= 'headhuman.dmi'
src.shadg = 1
src.overlays -= 'headhuman.dmi'
src.overlays -= 'headhuman.dmi'
src.overlays += 'headoutworld.dmi'
src.verbs += new /mob/reiku/verb/shadow_grab()
else if(level >450)
if(src.kombatent != "Reiko")
src.client.screen += new/obj/flyingk
src.flykick = 1

world << "<b><font color = lime>Ability Info: [src] has learned new skill."
if(src.kombatent == "Reiko")
src.overlays -= 'headhuman.dmi'
src.shadg = 1
src.overlays -= 'headhuman.dmi'
src.overlays -= 'headhuman.dmi'
src.overlays += 'headoutworld.dmi'
src.verbs += new /mob/reiko/verb/shadow_grab()


is that good if i am doing it like this?