Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[RESOLVED][VX] Dynamic move route

For my current project, I nne to dynamically generate a forced route move, an have the player follow it.
I first tried a simple :

Code:
  case step

    when 1

      $game.player.turn_down

      $game_player.move_down

   ....

   ....

but it did something a little .... teleport-like

I then tried to fiddle with the MoveRoute class:

Code:
      route = RPG::MoveRoute.new

      route.repeat = false

      route.skippable = true

      route.wait = true

      for step in Route  # array contains 1 to 4, corresponding to standard directions

        route.list.push( RPG::MoveCommand.new( 15+step)) # look command

        route.list.push( RPG::MoveCommand.new(    step)) # move command

      end

      [b]$game_player.force_move_route( route)[/b]

but when it comes to the last line, nothing happened
Moreover, if I put the skippable attribute to false, the game hangs, as if something prevents thr player to move. Needless to say, all the surrounding are passable.

What did I forget for this to work correctly ???


Oh .... and if someone knows... What is the meaning of the first MoveCommand ( a '0' code command) automatically inserted in the lis at MoveRoute instanciation ??


EDIT : oops... I didn't mention this script is Event-called. Perhaps it has to do with queueing, ot something like that.
EDIT : changed the thread title
 
Ok... I took the time to read the Game_Character.force_move_route method, and here it is :

1/ the code 0 RPG::MiveCommand indicates the end of the route list

2/ When a RPG::MoveRoute is instanciated (by the new method), the command list is populated with a signle RPG::MiveCommand, initialized with the default code, wich is..... guess..... tadaaa..... 0

So, whatever valid command code you push in the list, your route will ALWAUS start by a 'end of route' command.... unless your start by clearing the list, and finishing with the 0 code command. And DO NOT forget this one, or you'll get an index error.

Thanks all :devil:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top