ID:149628
 
I need to know how to create a mob when a player uses a scroll
Buzzyboy wrote:
I need to know how to create a mob when a player uses a scroll

mob/boogyman
// define who you want to create here

obj/scroll
verb
read()
usr << "Uh oh..."
spawn(20)
var/mob/boogyman/B = new()
B.loc = locate(get_step(user, NORTH))
oview(B) << "A boogyman appears!"

This will spawn a boogyman one square to the north of the person reading the scroll. You may want to refine this to make sure he appears in a good spot (not on a wall, for example)
In response to Skysaw
Yep, you can also refine that a bit to this:

var/mob/boogyman/B = new(locate(x,y+1,z)) //will create it 1 space north
oview(B) << "A boogyman appears!"
In response to English
English wrote:
Yep, you can also refine that a bit to this:

var/mob/boogyman/B = new(locate(x,y+1,z)) //will create it 1 space north
oview(B) << "A boogyman appears!"

I wouldn't exactly call that refinement. What if y+1 > world.maxy?
In response to Skysaw
He has to make sure it is a valid location either way. (meaning it isn't dense, it's on the map, not occupied, etc.)

He could do it this way:

var/mob/boogyman/B = new(get_step(usr, NORTH))

get_step returns a location so no need to use locate.