ID:176346
 
Hey, anyone have an idea how to make it so...when an obj is placed randomly on a map, that they don't land on a dense turf/mob?
Goku72 wrote:
Hey, anyone have an idea how to make it so...when an obj is placed randomly on a map, that they don't land on a dense turf/mob?

You can either do this check in the random obj generator, or in the objects New() proc. (Probably safer to do it in the generator)

Something like this:
// First, I assume you have a x y and z values
// for the position of the new object.
var/turf/T = locate(myx,myy,myz)
if(T != null) //Just incase.
var/isdense = 0
for(var/atom/movable/A in T)
if(A.density != 0)
isdense = 1
break
if(T.density == 1)
isdense == 1
if(isdense == 0)
//Create object.

The for(var/atom/movable/A in T) simply checks turf T for any mobs or objs, and sees if they are dense. (If we find a dense one, break the loop because there is no point to continue.)

-<font color="#33ff#33">Nova</font>