ID:147220
 
I'm making a side-scrolling game, using multi-tiled mobs. the way the mobs are shown is like this:
//m=mob o= multi-tile objects
oo
mo

I'd like to be able to check the density of the turfs in each direction excluding diagnols around the multi tiled mobs. To show you what I mean:
//m=mob o= multi-tile objects t= turfs I'd like to check the density of
tt
toot
tmot
tt

So how would I be able to check the density of the turfs surrounding the multi-tile mob?

Also, how would I check if an object projectile bumped into, or made contact with the multi-tile objects? (The multi-tile objects are linked to the mob by var/obj/owned = mob.ckey)

So any ideas?
Bump* I'm sorry I can't continue with my game until I can figure this out, I've been at it all night and nothing is working, so please respond with something to point me in the right direction.
Just get a reference to the tile and check its density. Also, it would make things easier if you had variables for objects that you could check to see how many tiles a multi-tiled object is.
mob
var
width=1;height=1
verb/Check_Surrounding_Density()
/*This verb is just an example on how to use the variables.
The Move function below will put them to better use, I just like to give multiple examples.*/

var/turf/T
var/dense_turf=0
for(var/index= 0 to width-1)
T=locate(x+index,y-1,z)
if(T.density)dense_turf+=1
T=locate(x+index,y+height,z)
if(T.density)dense_turf+=1
for(var/index= 0 to height-1)
T=locate(x-1,y+index,z)
if(T.density)dense_turf+=1
T=locate(x+width,y+index,z)
if(T.density)dense_turf+=1
src<<"There are [dense_turf] turf objects around you that are dense."
big_guy
width=2;height=2

The above answered your question and gave an example. Now let us put it to good use. I will also include an object placeholder to occupy the areas taken by the extra tiles. (I am assuming you use overlays to make the object look larger.)
mob
var
width=1;height=1
list/place_holders=list()
New()
//This is where the place holders are created.
for(var/indexx= 0 to width-1)
for(var/indexy= 0 to height-1)
place_holders+=new/obj/place_holder(src,indexx,indexy)
Move(NewLoc,Dir=0)
for(var/obj/place_holder/O in place_holders)
//This part disallows movement if the place holders can't move.
if(!O.Move(locate(NewLoc.x+O.offset_x,NewLoc.y+O.offset_y,Newloc.z))
return 0
//other move code (Do not return it, just alter the return value
if(.)
for(var/obj/place_holder/O in place_holders)
O.update_loc()
return .
big_guy
width=2;height=2

obj/place_holder
var
mob/owner
offset_x;offset_y
//The offset variables show where the place holder is in relation to the owner.
New(mob/M;x;y)
if(!x&&!y)
/*This part is to disallow the creation of a place holder at the loc of the owner.
The indexx/indexy nested loop above will create one at 0,0.
Now that I think about it, it would probably be better to simply bail in the nested loop.
This way looks nicer though. ;) */

del(src)
src.owner=M
offset_x=x;offset_y=y
loc=locate(M.x+x,M.y+y,M.z)
Bump(atom/A)
//You want to handle everything a place holder bumps as if the owner object had bumped.
owner.Bump(A)
Move(NewLoc)
//This does not move the place holder, rather it is used in the owner object's movement as a check.
if(loc.Exit(owner))
if(NewLoc.Enter(owner))
return 1
return 0
proc/update_loc()
/*Depending on your entered/exitted needs, you may want to make special procs for when extra tile objects
enter/exit other objects.*/

loc.Exitted(owner)
loc=locate(owner.x+offset_x,owner.y+offset_y,owner.z)
loc.Entered(owner)

obj/projectile
/*This part is to show how to strike the main object part
with projectiles like you asked.*/

Bump(atom/A)
if(istype(A,/obj/place_holder))
//If it bumps a place holder, just have it handled as though it bumped the owner instead.
var/obj/place_holder/O=A
Bump(O)
return
//normal bump code (what happens if A is not a place holder)

Keep in mind that the place holders are not visible, they are only there as place holders. Overlays are the way to go for the graphical aspect of multi-tiled objects.
In response to Loduwijk
Well, Looked through it and tested your first snippet without any luck. This is what I have been trying but I haven't gotten anything from it yet. Can anyone see what I'm doing wrong here?
mob
verb/Check_South()
var/obj/placeholder/two = new
var/obj/placeholder/one = new
one.loc=locate(usr.x+1,usr.y-1,usr.z)
two.loc=locate(usr.x,usr.y-1,usr.z)
for(var/turf/T in view())
if(T.loc==one.loc||T.loc==two.loc)
if(T.density)
usr<<"You have dense turfs below you"
else
usr<<"there are no dense turfs below you"

I also tried this, but this was also not sucessful
obj/placeholder
mob
verb
check_south()
var/obj/placeholder/A = new
A.loc = locate(usr.x+1,usr.y-1,usr.z)
var/obj/placeholder/B = new
B.loc = locate(usr.x,usr.y-1,usr.z)
for(var/turf/T in view())
if(A in T.contents||B in T.contents)
if(T.density)
usr<<"yep"
else
usr<<"nope"
del A;del B
In response to Troglodyte
You do not want to reference T.loc, you want to reference T. T.loc will be an area.

(edit)
I just tested the first example I gave in my original post, and it works perfectly for me.
In response to Loduwijk
Well, then I'm having a problem, because it is not working for me. =\