Jump to content
Sign in to follow this  
Corey Zamora

"Steps Required" Encounter Rate

Recommended Posts

I'd like to change the way the encounter rate works so that the player is required to walk a certain amount of steps before a battle can happen, instead of the default random step encounter. I haven't found any existing scripts for it, but I'm sure there's one out there.

Share this post


Link to post
Share on other sites

Here you go bro:

 

#  Place this in the map notetag: <step_range: x-y>
#
#      Where x is the minimum step, and y is the max step
#
#     ex. <step_range: 10-40>  Would make an encounter between 10 and 40 steps




class Game_Player < Game_Character
  def make_encounter_count
    map = load_data(sprintf("Data/Map%03d.rvdata2", $game_map.map_id))
    if map.note =~ /<step_range:[ ](\d+)[-](\d+)>/
        @encounter_count = (rand($2.to_i - $1.to_i) + $1.to_i + 1)
      else
        n = $game_map.encounter_step
        @encounter_count = rand(n) + rand(n) + 1
      end
  end
end
  • Like 1

Share this post


Link to post
Share on other sites

In practice, I would parse it once and store it in a variable for future reference. Performance-wise, it saves you from having to perform that regex match everytime you take a step.

Share this post


Link to post
Share on other sites

It only runs when the map is started, and when it resets after battles....so it's not running after each step.  And I'll take that into account next time.

Edited by Nelderson

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted