ID:145379
 
Code: A special spawner which spawns a certain Enemy.
proc
Populate()
sleep(rand(20))
var/spawnE = list(/mob/Enemies)
if(prob(70))
var/mob/P = pick(spawnE)
new P
P.npc = 1
Populate()


runtime error: Cannot modify /mob/Enemies.npc.
proc name: Populate (/proc/Populate)
usr: null
src: null
call stack:
Populate()
: New()

Problem description: This should be a breeze for those who can put mobs (In and off the world) in a list, because thats what it is.

that should be rand(1, 20) I believe.

Also, that creation should look something lie this:
var/list/spawnE = list(/mob/enemies/E1, /mob/enemies/E2, /mob/enemies/E3 /* and so on*/)
if(prob(70)) // I don't know what you mean by this - is it a built-in proc?
var/mob/P - pick(spawnE)
// and so on...
//...

You need to do it that way, I think. You can't make a var into a list just by wishing it... you need t ocreate it as a list.

--Vito
In response to Vito Stolidus
Of course, in the beginning of the world you could do
for(var/mob/Enemies/e in world) spawnE.Add(e)
In response to Vito Stolidus
I was only using the Enemies subdirectory as I remember something where all of the stuff in a directory (like mob/Blah) was used in a single list. Maybe I'm dreaming...



if(prob(70)) is a Probabillity command in percent.


You don't need 2 numbers in rand() either. It means it goes from 0 to X, insted of Y to X.
In response to Mysame
When I meant "In and off the world" I meant all mob/Enemies in the code. That means it saves me writing the same directorys over and over again 300 times.
In response to RedlineM203
proc/type2list ( type )
. = list ()
for( var/_type in typesof ( type ) )
if(_type != type)
. += new _type

proc/Populate ()
while ( world )
sleep ( 20 )
if( prob (70) )
var/mob/M = pick ( type2list( /mob/Enemies ) )
M.npc = 1 //I highly disagree with this, you should be using client checks.


Something like this ought to do the trick?
In response to Papoose
It works great, but is there a way that I can make it ignore the ACTUAL mob/Enemies as a Enemy? This affects the game.
In response to RedlineM203
I have edited my post.
In response to Papoose
Sweet.