I know I'm a little late but wouldnt something like this do the trick
PHP Code:
public function CheckPath(x, y, dx, dy)
{
temp.check = 0;
temp.checkrate = 1;
temp.distance = distance(x, y, dx, dy);
temp.angle = getangle(dx - x, dy - y);
while (temp.check < temp.distance)
{
temp.checkx = int(x + (temp.check * cos(temp.angle)));
temp.checky = int(y + (temp.check * -sin(temp.angle)));
if (onwall(temp.checkx, temp.checky))
{
temp.onwallcounter += 1;
}
temp.check += temp.checkrate;
sleep(0.05);
}
return temp.onwallcounter;
}