ID:169673
 
I've been really sick today so my brains going dialup speed. I'd rather not wait tomorrow to do this so i'll just ask here. Could anyone post a simple explanation to checking if somethings loc is dense. Monsters randomly spawn on my maps but I don't want them spawning on water, if they do I'll have the game reteleport them but I have to figure out a way to check if their loc is dense first.
If your only concern is turfs then this'll work:

var/turf/T = monster.loc
if(T.density)
//Insert respawn code
else
//The turf is not dense and you can do everything as normal.
In response to DeathAwaitsU
Okay Thanks alot but I ran into another problem. I usually don't ask any questions but I can't think today. I'm trying to save many lines of code by doing new/P.type(loc) which is the monster that is dying's type but it's not working out. I knew I couldn't do it but well, is there any way I can without making an if statement for each monster? Please don't yell at me for using usr in a proc. -.- You try catching the flu or something then try to make a game with it.

[ src is the monster ]
[ usr is the player that killed it ]

Respawn()
retry
var/P=src.type
var/a=rand(1,50)
var/b=rand(1,48)
var/c=usr.z
var/mob/R = new/P(locate(a,b,c))
var/turf/T = R.loc
if(T.density)
goto retry
else
return


The problem is quite obvious, it's trying to use P as an atom path.
In response to InuTracy
My brains kinda fuzzy but can this work?

var/mob/R = new Type(P)
In response to InuTracy
new P

And for redoing the spawn location you could do it easily with a do-while loop.
...
var/turf/T
do
//find location for T
while(T.density)
...
In response to InuTracy
Ok try this, notice I took out usr.

mob/verb/Attack(mob/M in oview(1)) //this is your attack verb
M.Respawn(usr) //Call respawn for the monster who died and pass the parameter(usr).

Respawn(mob/M)
//Respawn asks for a mob to be sent. That mob will be used as the person who killed the monster.
retry
var/a=rand(1,50)
var/b=rand(1,48)
var/c=M.z
var/mob/P = new src.type(locate(a,b,c))
var/turf/T = R.loc
if(T.density)
goto retry
else
return


I'd strongly suggest not using goto here. I'll let someone else give you a better example because my one will probably suck.