ID:1876196
 
(See the best response by Kaiochao.)
Code:
proc/Get_Zone96() //Works on 3x3 trucks a.k.a 96x96 pixels
var/list/turfs = list()
var/D
switch(dir)
if(NORTH) D = 1
if(EAST) D = 2
if(WEST) D = 3
if(SOUTH) D = 4

switch(D) //There is probably a way faster way to do this, but I don't feel like doing math right now.

if(1)
turfs += locate(x,y+3,z)
turfs += locate(x+1,y+3,z)
turfs += locate(x+2,y+3,z)
if(2)
turfs += locate(x+3,y,z)
turfs += locate(x+3,y+1,z)
turfs += locate(x+3,y+2,z)
if(3)
turfs += locate(x-1,y,z)
turfs += locate(x-1,y+1,z)
turfs += locate(x-1,y+2,z)
if(4)
turfs += locate(x,y-1,z)
turfs += locate(x+1,y-1,z)
turfs += locate(x+2,y-1,z)

return turfs


Problem description:

Is there a better way of doing this? Some wierd math voodoo or anything? This works fine though, I think..

Best response
Your D and turfs variables aren't necessary (you clearly only need one switch), and you could be avoiding 3 list additions by initializing the list with the 3 turfs inside.

switch(dir)
if(NORTH) return list(locate(etc.

I don't think you particularly need math voodoo in this case. It looks like you're getting turfs on the side of a 5x5 square without corners that isn't centered on src.