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.

Map : Change Encounters

Map : Change Encounters
Version: 3.5
By: Kain Nobel

Introduction

I just created this so you can change map encounter list and step values... normally, you'd probably find yourself copy/pasting duplicate maps to have different encounters, but now you don't have to! It'll give your project just a little less weight, as far as 'duplicate maps' go...

Features

  • $game_map.encounter_list = [...] will change encounter list on current map
  • $game_map.encounter_step = number will change encounter steps on current map
  • $game_map.encounter_list = nil will reset encounter list to default
  • $game_map.encounter_step = nil will reset encounter step to default
  • $game_map.encounters[map_id].list = [...] will change encounter list on specified map
  • $game_map.encounters[map_id].step = number will change encounter steps on specified map
  • $game_map.encounters[map_id].list = nil will reset specified map's encounter list to default
  • $game_map.encounters[map_id].step = nil will reset specified map's encounter step to default
  • Changes to encounters and steps are effective the second you call it!
  • Enough said... wow the features are your instructions, how odd?

Script

Code:
#===============================================================================

# ** Map : Change Encounters

#===============================================================================

 

#-------------------------------------------------------------------------------

# * SDK Log

#-------------------------------------------------------------------------------

if Object.const_defined?(:SDK)

  SDK.log('Map.ChangeEncounters', 'Kain Nobel ©', 3.5, '2009.06.17')

end

 

#===============================================================================

# ** Game_Map::Encounter_List

#===============================================================================

 

class Game_Map::Encounters

  #-----------------------------------------------------------------------------

  # * Public Instance Variables

  #-----------------------------------------------------------------------------

  attr_accessor :list

  attr_accessor :step

  #-----------------------------------------------------------------------------

  # * Object Initialization

  #-----------------------------------------------------------------------------

  def initialize

    @list = nil

    @step = nil

  end

end

 

#===============================================================================

# ** Game_Map

#===============================================================================

 

class Game_Map

  #-----------------------------------------------------------------------------

  # * Public Instance Variables

  #-----------------------------------------------------------------------------

  attr_reader :encounters

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :chgencounters_gmmap_setup,          :setup

  alias_method :chgencounters_gmmap_encounterlist,  :encounter_list

  alias_method :chgencounters_gmmap_encounterstep,  :encounter_step

  #-----------------------------------------------------------------------------

  # * Setup

  #-----------------------------------------------------------------------------

  def setup(map_id)

    @encounters ||= Hash.new

    chgencounters_gmmap_setup(map_id)

    @encounters[map_id] ||= Game_Map::Encounters.new

  end

  #-----------------------------------------------------------------------------

  # * Reset Encounters

  #-----------------------------------------------------------------------------

  def reset_encounters

    encounter_list = @map.encounter_list

    encounter_step = @map.encounter_step

  end

  #-----------------------------------------------------------------------------

  # * Encounter List

  #-----------------------------------------------------------------------------

  def encounter_list

    unless @encounters[map_id].list.is_a?(Array)

      old_list = chgencounters_gmmap_encounterlist

      @encounters[map_id].list = old_list

    end

    @encounters[map_id].list

  end

  #-----------------------------------------------------------------------------

  # * Encounter Step

  #-----------------------------------------------------------------------------

  def encounter_step

    unless @encounters[map_id].step.is_a?(Numeric)

      old_step = chgencounters_gmmap_encounterstep

      @encounters[map_id].step = old_step

      $game_player.make_encounter_count

    end

    @encounters[map_id].step

  end

  #-----------------------------------------------------------------------------

  # * Encounter List = (list)

  #-----------------------------------------------------------------------------

  def encounter_list=(list)

    unless list.is_a?(Array) || list.is_a?(NilClass)

      err  = "Wrong argument for changing $game_map.encounter_list\n\nThe argum"

      err += "ent must be an :Array: (or :NilClass: object to reset), not a "

      err += ":#{list.class}:"

      raise ArgumentError.new(err)

    end

    @encounters[map_id].list = list

  end

  #-----------------------------------------------------------------------------

  # * Encounter Step = (step)

  #-----------------------------------------------------------------------------

  def encounter_step=(step)

    unless step.is_a?(Numeric) || step.is_a?(NilClass)

      err  = "Wrong argument for changing $game_map.encounter_step\n\nThe argum"

      err += "ent must be a :Numeric: (or :NilClass: object to reset), not a "

      err += ":#{step.class}:"

      raise ArgumentError.new(err)

    end

    @encounters[map_id].step = step

    $game_player.make_encounter_count

  end

end

 

Compatibility

Wow, this doesn't require SDK? How cool... however, this corrupts old save files, just to let'cha know!

Game_Map.encounter_list
Game_Map.encounter_step
Game_Map.encounter_list=
Game_Map.encounter_step=

Donno if this works for VX but maybe it does? I do recall VX using "areas" to define encounters, so I'm guessing that could be an issue, but I'm just making a general assumption that for some reason it might not work in VX. Either way, I have VX so if you need a version made for it then I'll see what I can do for ya!

Credit and Thanks

Armor King 108 : Reporting some issues I overlooked in the first couple of posts, thank you! :thumb:

Author's Notes

I want at least ONE reply, even if you find no bugs whatsoever and think this is great one reply will make me want to post more simple mini-scripts! If I get more replies on stuff, I'll start posting the more extravagant stuff I've been holding out on ;)

Terms and Conditions

Another "Free to use in commercial and non-commercial releases" script, but credit is required thanks ;)
 
Is this different than the other Map : Change Encounters script you posted about 3 days ago? It looks like there are more features now, but I'm not sure. Anyway, I haven't tried it out yet, but it sounds neat. Currently, unless I'm using a world map, I probably wouldn't use a script like this much. I used to want to do all kinds of crazy things, but spending so much time not actually making RPGs discourages me from trying all the interesting things I used to try to do. Well, I could also use this for a map that has different enemies later in the game...

Oh wait! How does this script work with Parallel Process events? Could you have a parallel process event that changes the enemy party's every few seconds? Or an item or spell that temporarily replaces all enemy parties with a specific weak monster? Couldn't you also have an ability that temporarily changes the encounter rate? Hmmm...I may try this out soon after all.

(by the way, I like all your scripts that I've seen, I'm looking forward to seeing more!)
 
I tried it out and it seemed to be working fine. Well, except for two major problems.

First of all, I tried making a parallel process common event that only worked when a certain switch was on. While testplaying I could use F9 to turn the switch on and test it out. The common event changed the encounters to enemy parties 1, 2, and 3...and after 200 frames it turned it back to normal. However, while the switch was off I couldn't fight any random encounters. While it was on, it worked perfectly! But after 200 frames on the map (10 seconds I think) when it was supposed to reset the encounter list and turn off the switch, it caused an error, this error:

HfCerroronMCE.jpg


Is it because I was using a parallel process event, I messed something up, or is it something else? Any help would be greatly appreciated!

EDIT: (Oops, I wanted to edit my previous post with this information, not make a new post! Sorry!)
 
I've updated the script, thanks for pointing out the bug I forgot one part of the method lol! Go ahead and hit Refresh and replace the version you have with this one, it should work fine now (yes, you can assign nil to reset encounters and steps now yay!)

Is this different than the other Map : Change Encounters script you posted about 3 days ago?

Did I really already post this o.O ? I'm sorry if I did then I'll have to report the old one so a mod can lock/delete it.
 
It doesn't freeze anymore, but I can't fight any battles until activating a call script for Map : Change Encounters. I tried moving the script around different parts in the script zone (different places above Main, I'm using about 3 other scripts, though I don't think they are interfering)

I'm so confused. I don't understand scripts at all...:(
 
Another small thing I overlooked, Game_Map::Encounters @list = Array.new should be @list = nil, so that it loads the old list from the MapXXX.rxdata file.

I also adjusted two lines in the Game_Map#encounter_list and #encounter_step methods, which would drop the frame rate 2 points, now it runs at a steady 40 again. Go ahead and just copy/replace the old one you have with the updated version in the post above.

Thanks for reporting that Armor King 108, now you're in the Credit and Thanks section! :thumb:
 
Cool! It's working perfectly now. I didn't notice any problems at all.

I never expected to be in the Credits/Thanks section of a script! Interesting. Glad I could help.
 

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