ID:270897
 
How would I go about makeing a proc that random creates 1 or 2 mobs at runtime at random postions on the map?
mob/proc/Randomness(var/path, var/totalMobs, var/minX, var/maxX, var/minY, var/maxY, var/minZ, var/maxZ)
for(var/i = 1; i <= totalMobs; i++)
new path(locate(rand(minX,maxX),rand(minY,maxY),rand(minZ,maxZ)))


Pretty straight forward, using the rand command you can get a random number between the two values you specify. So, in the code we get a random number between minX and maxX, minY and maxY, and minZ and maxZ, then we position a new mob of type path at that location. All of the variables are defined in the parameters, and it loops through until the specified number of mobs have been created.

Example of calling it;

      
mob/verb/Randomizeeee()
//Create a Monster 5 times, positioning
//them randomly between 1,1 and 10,10.
Randomness(/mob/Monster,5,1,10,1,10,1,1)

mob
Monster
icon = 'monster.dmi'

In response to The Conjuror
ok i understand that part, but how would i make it to were they cant be created on dense areas
In response to National Guardsmen
<code>locate()</code> the turf you're about to move them to and don't move them there if the turf or any <code>atom/movable</code> on it is dense.

or

Create the mob first, and then try to use the <code>Move()</code> proc to move them to a random spot. If the proc returns 0, the mob cannot move there (by default since there's something dense there) and you can retry.