ID:148200
 
Im no math master by any means so I need some help figuring up the diagonals for this proc.
The view essentially looks like this:
XXXXXX
XXXX
XX


I just need to know how to do this for diagonals.
ob/var/sightDist = 3
var/test[] = new/list()






mob
proc
getView()
var/list/turfs[] = new/list()
for(var/turf/T as turf in view(src.sightDist,src))
switch(src.dir)
if(NORTH)
if(abs(src.x-T.x) <= T.y - src.y)
turfs += T
test += T
if(SOUTH)
if(abs(src.x-T.x) <= src.y - T.y)

turfs += T
test += T
if(EAST)
if(abs(src.y-T.y) <= T.x - src.x)
turfs += T
test += T
if(WEST)
if(abs(src.y-T.y) <= src.x - T.x)
turfs += T
test += T
return turfs
*bump*
Even onefishdown didnt know how to do this . Maybe a code guru like Lummox could help.
So you're trying to get a vision cone in the direction the mob is facing? Could be looking at some nasty maths here, depending on the field of view you want. 60 degrees? 90 degrees?
Two things I can tell you for sure:

Nobody can really help you until you actually show what the view diagram would look like for a diagonal. It would help to get the other diagram right too, since there should not be an even number of turfs in each row.

Also, doing this via a switch() is about the worst possible way you could go about it. Using procs like get_step() and turn() would serve you a lot better.

Lummox JR
In response to Lummox JR
looks like you have a 30-45 degree vision angle there, just giving a rough estimate its less then 60 because other wise it would be slightly wider in view by the way it wuld look more like this right?


XXXXXXX
XXXXX = usr field of vision
XXX
X = usr position


right?