ID:2199404
 
is there anyway to code something where it can check the tiles in a straight line from where im facing to a certain distance like example: it alerts me if there a mob 6 tiles in front of me if so how do i do so
Two ways come to mind:
  • Using get_step() in some sort of loop. Start from the beginning location and continuously step in the ref's initial direction.
  • Using a "collision" mover object. The idea of use is much the same as using get_step(), but there are benefits. More complex collision handling is one of these. For example, what if you only want to detect dense projectiles? This is a good way of achieving that control.
mob/proc/Sight2List()
. = list()
var i, v = 8 // 8 being the range.
var turf/t = src.loc // loc being the starting turf.
var D = src.dir // store the dir of src in a variable at the current value
for(i = 1 to v)
t = get_step(t,D)
if(t)
. += t
if(t.density)break
else break
v = list()
for(i in .){v+= i} // flip the list of turfs to nearest first
return v


I'm sure it could be improved.