Link in Pink
Member
I really need help with Near's View Range script. I have the newest, updated version
However I need to know what the code is for viewing in a straight line.
I have a code for viewing in a circle:
However I need it to work so that the event will see in a straight line. Also, say he turns left, I need it so that he will continue to view in the direction he's facing.
Please help me
#==============================================================================
# ** View Range Module
#==============================================================================
# Near Fantastica
# Version 4
# 29.11.05
#==============================================================================
#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("View Range", "Near Fantastica", 4, "29.11.05")
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("View Range") == true
module VR
#----------------------------------------------------------------------------
def VR.in_range?(element, object, range)
x = (element.x - object.x) * (element.x - object.x)
y = (element.y - object.y) * (element.y - object.y)
r = x + y
if r <= (range * range)
return true
else
return false
end
end
#----------------------------------------------------------------------------
def VR.range(element, object)
x = (element.x - object.x) * (element.x - object.x)
y = (element.y - object.y) * (element.y - object.y)
r = x + y
r = Math.sqrt(r)
return r.to_i
end
end
#==============================================================================
class Interpreter
#----------------------------------------------------------------------------
def event
return $game_map.events[@event_id]
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
# ** View Range Module
#==============================================================================
# Near Fantastica
# Version 4
# 29.11.05
#==============================================================================
#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("View Range", "Near Fantastica", 4, "29.11.05")
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("View Range") == true
module VR
#----------------------------------------------------------------------------
def VR.in_range?(element, object, range)
x = (element.x - object.x) * (element.x - object.x)
y = (element.y - object.y) * (element.y - object.y)
r = x + y
if r <= (range * range)
return true
else
return false
end
end
#----------------------------------------------------------------------------
def VR.range(element, object)
x = (element.x - object.x) * (element.x - object.x)
y = (element.y - object.y) * (element.y - object.y)
r = x + y
r = Math.sqrt(r)
return r.to_i
end
end
#==============================================================================
class Interpreter
#----------------------------------------------------------------------------
def event
return $game_map.events[@event_id]
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
However I need to know what the code is for viewing in a straight line.
I have a code for viewing in a circle:
Code:
VR.in_range?($game_map.events[2], $game_player, 4)
However I need it to work so that the event will see in a straight line. Also, say he turns left, I need it so that he will continue to view in the direction he's facing.
Please help me