RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Path Finder v 0.4

0 Members and 1 Guest are viewing this topic.

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Another In Progress Script.

Won't be the best in the world, but will use a method a little different than the others.

Code: [Select]
def find_path(event_id, tile_x, tile_y)
   path = Path.new(event_id)
   path.find(tile_x,tile_y)
end

class Path

   def initialize(event_id)
      @map = $game_map
      if event_id == 9999
         @event = $game_player
      else
         @event = @map.events[event_id]
      end
      @open_tiles = set
   end

   def find(tile_x,tile_y)
      @paths = []
      if @event.lock?
         return p 'Error :  Event Position Locked Cannot Move'
      elsif !@open_tiles.include?([@event.x,@event.y])
         return p 'Error :  Movement Not Allowed From Current Possition'
      end
      @x = @event.x.deep_clone
      @y = @event.y.deep_clone
      border = [[@x, @y - 1], [@x + 1, @y], [@x, @y + 1], [@x - 1, @y]]
      total_possible_paths = 0
      for tile in border
         total_possible_paths += 1 if @open_tiles.include?(tile)
      end
      for i in 0..(total_possible_paths)
         @paths[i] = Possible_Path.new
         # Code to Map Path Goes Here
      end
      distances = []
      for i in 0..(@paths.size)
         distances[i] = @paths[i].distance
      end
      @best_path =  @paths.find{ |path| path.distance == distances.min }
   end

   def move
      # Code to move Goes Here
   end

   def set
      temp = []
      for x in 0..(@map.width / 32)
         for y in 0..(@map.height / 32)
            temp.push([x,y]) if @map.passable?(x,y,0)
        end
      end
      return temp
   end

end

class Possible_Path
   # Code for Storing Path Information Goes Here
end

class Object
   def deep_clone
      file = File.open('cloning.txt', "wb")
      Marshal.dump(self,file)
      file.close
      file = File.open('cloning.txt', "rb")
      data = Marshal.load(file)
      file.close
      return data
   end
end
« Last Edit: October 02, 2006, 12:17:15 AM by Tsunokiette »
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

********
Rep:
Level 96
2011 Most Missed Member2010 Zero To Hero
...So what does it do, exactly?

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Eventually it will test all possible paths and find the shortest route, and move the event/player to the chosen position.

EDIT : @programmers - Slight rewriting needed for the add_sub definition, I'll get it done, it's just notepad is hard to program with.

EDIT 2 : As a matter of fact, I'm going to have to rewrite the Possible_Path class all together. -_-
« Last Edit: October 01, 2006, 09:24:19 PM by Tsunokiette »
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

********
Rep:
Level 96
2011 Most Missed Member2010 Zero To Hero
Oh, sweet! I can think of all kinds of uses for this...