ID:165844
 
I was trying to define my own density variable so that I could have differnt types of density and I got it to work, except that Bump is not called. Is there something else that has to be done?

turf
Enter(atom/movable/e)
var/d = get_dir(src,e) //Get the direction of the object moving onto the turf
if(!ChkDen(e)||!ChkEnter(d))
e.Bump(src) //Added this to call bump, but is there something else I should do?
//Now it calls Bump twice instead of not at all...
return 0
else return ..()

turf
proc
ChkDen(atom/movable/e) //Checks for density and special density
if(src.density) return 0
if(e.pwall&&pwall) return 0
else return 1

ChkEnter(d) //Checks to see if an object can enter
if(d && (dir_to_bitflag[d] & tbit)) return 0 //Directional Blocking
else if(d&(d-1)) return 0 //Block Diag
else return 1
Instead of using something like <code>Bump()</code>, you may want to override the <code>Move()</code> proc alltoghether.

atom
var
density2=0
movable
Move(atom/newloc,newdir)
.=..()
if(.)
var/atom/A=newloc.loc
if(!A)A=newloc

if(A.density2>=src.density2).=0
for(var/atom/X in A.contents)
if(X.density2>=src.density)
.=0
break


This creates a <code>density2</code> variable. If it's equal or higher, the object is considered dense.

Now that I look at it more closely, you may be wanting to block directions. Here's a version for directions:

turf
var
//by default, only allow cardinal directions
enter=NORTH|SOUTH|EAST|WEST
exit=NORTH|SOUTH|EAST|WEST
Enter(atom/movable/M)
if(M.dir&enter)return ..()
Exit(atom/movable/M)
if(M.dir&exit)return ..()


I hope I helped ya.