ID:171262
 
I'm interested in making random monsters appear randomly on the map, but not completely randomly. I only want them to appear if they are on a specific type of turf.

Could anyone help me figure out how this might be done? Thanks.
Simple really:

Create an obj, "monster spawning area".
obj/MonsterSpawn
var/list/Monsters=list()

In the Monsters list, you supply all the monsters that object will spawn. For example: var/list/Monsters=list(/mob/Monster/Beatle,/mob/Monster/ Nude_female). For each monster, you'll want to set a probability variable. The probability variable is the probability of that monster spawning in that spot. To do this, you use it as an associated list: var/list/Monsters=list(/mob/Monster/Beatle=50,/mob/Monster/ Nude_female=5). That's giving the probability of 50% (half) of it spawning, the nude_female will only have 5%.

Now, for "repoping" it.

obj/MonsterSpawn
var/list/Monsters=list()
proc/Spawn()
if(Monsters.len>0)
var/M=pick(Monsters)
if(M&&prob(Monsters[M]))
new M(src.loc)
spawn(rand(250,500)) Spawn()
New()
..()
Spawn()


Easy peasy!
In response to Crashed
Alright, thanks a lot.