[pre lang="ruby"]def astarmove(to = 0,from = "self")
from = @id if from=="self"
from = from==0 ? $game_player : $game_map.events[from]
to = to==0 ? $game_player : $game_map.events[to]
#p from.id,to.id if from.is_a?(Game_Event)
unless from.moving?
if (from.x-to.x).abs<=1 and (from.y-to.y).abs<=1
else
if !@dr
@astr = AStar.new($game_map)
@astr.set_origin(from.x,from.y)
@astr.set_target(to.x,to.y)
@dr = @astr.do_search[0..5]
else
move_dr(@dr.shift)
@dr = nil if @dr.empty?
end
end
end
end[/pre]