ID:263653
 
On this may be really bad but i only started coding about 3 months ago so thats probably why theres mistakes

Code:
mob/GM/verb/Spawn_Monsters()
set category="GM"
switch(input("What sort of monster do you wish to spawn?")in list("Evil Wizards","Troll"))
if("Evil Wizards")
new/obj/Monsters/Evil_Wizard(locate(usr.x,usr.y-1,usr.z))
new/obj/Monsters/Evil_Wizard(locate(usr.x,usr.y-1,usr.z))
new/obj/Monsters/Evil_Wizard(locate(usr.x,usr.y-1,usr.z))
new/obj/Monsters/Evil_Wizard(locate(usr.x,usr.y-1,usr.z))
new/obj/Monsters/Evil_Wizard(locate(usr.x,usr.y-1,usr.z))
if("Troll")
new/obj/Monsters/Troll(locate(usr.x,usr.y-1,usr.z))
new/obj/Monsters/Troll(locate(usr.x,usr.y-1,usr.z))
new/obj/Monsters/Troll(locate(usr.x,usr.y-1,usr.z))
new/obj/Monsters/Troll(locate(usr.x,usr.y-1,usr.z))
new/obj/Monsters/Troll(locate(usr.x,usr.y-1,usr.z))


Problem description:
basically i want to spawn 5 of each of these monsters when there chosen but every time that i do only 1 is spawn till i kill it then the next one spawns and so on.
can anyone help me by telling me how to spawn all 5 at once?
what if you tried it as a loop?
var/spawn = 5
while(spawn > 0)
new/mob/the mob(locate(1,1,1))
spawn --
Check the monster's New() proc. Make sure it's returning- and if it's running any other code in that New proc (say, an AI routine), make sure that's spawned off.

Otherwise the New proc will never return, so it'll pause after every monster is made. You kill the monster, thus deleting it- killing off all it's procs, allowing New() to finally return, creating a new object.

An example:
obj
Monsters
Troll
New()
world << "you created me!"
AIloop()
world << "now finishing New proc!"

proc/AIloop()
while(1)
sleep(10)
world << "searching for enemies"


If you created a new Troll, it'd never get to <code>world << "now finishing New proc"</code> - it'd be stuck in the AIloop proc forever, until you killed the troll.


Note- when I refer to "spawn", I mean the spawn keyword. Not spawn as in, to spawn a new monster. :)

That should be fixed by turning spawning off the AIloop- like so:

obj
Monsters
Troll
New()
world << "you created me!"
spawn()
AIloop()
world << "now finishing New()!"


Spawn allows a procedure to be called (in this case, AIloop) and continue with the rest of the code (in this case, the code in the New proc).
Normally it'd have to wait for the AIloop proc to return (i.e. to stop running, either by reaching the end of all it's code, or reaching the <code>return</code> keyword.) before continuing.

Read more on <code>spawn</code> here: click
Read more on <code>return</code> here: click


To be totally sure about the situation, could you show us your monster's New() procs?
In response to Upinflames
Thank you so much Elation my head has been puzzled for ages