ID:156082
 
Well, I'm wondering how I should do this, letting mobs pop out of the grasses when you walk over it. And after a while when they're out of ur sight, it says, '[mob] has ran away.' or something like that. And the mob needs to attack your pet that you've out. I've tried it with this:
mob
var
wild=0

turf
dense
density=1
var/Spawnz2 = list()
Spawn
Entered(atom/AZ)
if(istype(AZ,/mob))
var/mob/M = AZ
var/i = rand(1,5)
if(i==1)
var/X = pick(src.Spawnz2)
var/mob/m = new X
var/LV=rand(5,6)
for(var/mob/Pokemon/P in M.pokemonlist)
if(P.level>rand(5,6))
LV = rand(5,6)
while(m.level<>LV)
m.next+=1
m.wild = 1
m.loc = src
for(var/mob/Ms in world)//for every mob in world (M)
if(get_dist(Ms,m)<10)//if M is within 10 tiles
M << "<font color=green><font size=2>A wild [m] appeared!"//outputs it to M
step_rand(m)
step_rand(m)
Testing
Spawnz2 = list(/mob/Wild_Pokemon/Bidoof,/mob/Wild_Pokemon/Pidgey)

But it just freezes up my window, making it crash.
So any suggestions, help, will be appreciated.
Why did you capitalize spawn?
In response to Darker Legends
I honestly don't know, does it matter? Because it's the name of the turf =S.
In response to Darker Legends
Because he is calling his turf "Spawn", he is not calling the spawn() proc.
In response to Raimo
Oh sorry I should have looked more carefully it was a turfs name.
Your while(), in some cases, becomes an infinite loop.

And do
turf/var/list/Spawnz2 = list()
// instead of:
turf/var/Spawnz2 = list()
In response to Ruben7
I don't have a clue how I would fix that. Can you help me or give me some guidelines?
In response to Raimo
Take a look at this:
var/LV=rand(5,6) //LV will be either a 5 or 6
while(m.level<>LV) // if your level is not 5 or 6 this condition is true and will keep running forever, which is what's causing the crash.
m.next+=1 // no idea what this is

What's the "next" supposed to be doing there?
In response to Ruben7
Hmm, a friend helped me with this. What if I just took it out? Would it cause other errors/crashes?
In response to Raimo
Here's a basic "pick a pokemon from the list and spawn him"

var/list/SpawnablePoke=list(new/mob/Pikachu,new/mob/Charizard)
turf
Spawn
Entered(mob/M)
if(istype(M,/mob))
var/mob/X=pick(SpawnablePoke) // picks a random pokemon from the list
new X.type(src) // spawn the new pokemon on the turf


You could add a system to null the list when there are no players walking around on the turfs to save resources, and restart it again when someone walks back in. Up to you.

Another solution is to place all you pokemons in a void location, and add their names to the list
SpawnablePoke=list("Pikachu","Charizard")
then loop through all the pokemons in the world and check if their name match the one picked from the list. This way you'd avoid unnecessary duplicate mobs in different lists.
What's the difference between the <> operator and the != operator? The reference says they're identical. What's the point of having 2 identical operators?