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.

Lunar style enemies

In the most awesome game Lunar, the enemies appear on the map and if the player gets to close will move towards the player and upon contact initiate battle sequence.

Is there a way for me to set a similar system, using default battle system in RMXP. ie having an enemy sprite move randomly until player is x tiles away and then enemy sprite moves in for the kill.
 
This is the way I do.
Add the following script in the script editor somewhere before the Main:
Code:
class Game_Event
  def move_type_enemy(range, frequency = 6)
    if (self.x - $game_player.x) ** 2 + (self.y - $game_player.y) ** 2 <= range ** 2
      @move_frequency = frequency
      move_type_toward_player
    else
      @move_frequency = @page.move_frequency
      move_type_random
    end
  end
end
And then, open your enemy event set the trigger to "event touch", and the following script in the custom move route:
Code:
move_type_enemy(5, 6)
replacing 5 for the tiles distance you want, 6 for the movement frequency when the enemy is following the player.
And finnaly I add a battle processing command, allowing escape, and if the party wins, i add a Erase event command.
 

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