08-14-2013, 05:08 AM
sorry, I didn't know you weren't as script-savy as I am (actually I was just too lazy after work and hoped you would just magically know what to do)
Try replacing vr_in_range? with this:
Try replacing vr_in_range? with this:
Code:
#--------------------------------------------------------------------------
# * In Range?
# element : either player or other event
# object : event looking for element
# range : range in tiles
# pass_block : if terrain tiles can block view
#--------------------------------------------------------------------------
def vr_in_range?(element, object, range, pass_block = false)
# Obtain Range
dx = (element.x - object.x).abs
dy = (element.y - object.y).abs
# Obtain values to loop and counter value
x = xa
y = ya
n = 1 + dx + dy
x_inc = (xb > xa) ? 1 : -1
y_inc = (yb > ya) ? 1 : -1
error = dx - dy;
dx = dx*2 #do this to
dy = dy*2 #get rid of fractions
#check range
r = dx + dy
if r <= (range * range)
# If tiles can block view
if pass_block
n.downto(0){ |i|
if !$game_map.passable?(x, y, element.direction)
return false
end
if (error > 0)
x = x + x_inc
error = error - dy
else
y = y + y_inc
error = error + dx
end
}
end
# Return system-determined flag
return true
else
# Return default flag
return false
end
end