Main Menu
  • Welcome to The RPG Maker Resource Kit.

Encounters depending on player level?

Started by Crovean, March 08, 2010, 08:17:02 PM

0 Members and 1 Guest are viewing this topic.

Crovean

Hi all.
When you create a map you can choose different encounters from the property menu... Is there a way to have different encounters depending on players level?

If you're low level, low level monsters will attack you, and if you're high level, high level monsters will attack instead....

I don't want to meet a level 15 monster if I'm only level 3.... :)

I want this primary for when you are wandering around in fields... It won't be too funny to meet a lvl 5 monster when you are level 60 and so on.... I guess you get the point.

I could do invisible events with random movement and some random variables, but I think that will cause some major lag?

modern algebra

Try this script - I wrote it a long long time ago. It allows you to give troops levels and set a range for your heroes to encounter, so you will only encounter enemies if they are within the level range.

#=============================================================
# Encounter Levels Script
# Version: 1.0
# Author: Modern Algebra  (rmrk.net)
# Date: February 5, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#  Set up the regular map encounter lists (areas included) with all the monsters that
#  you ever want to appear in that area or map.
#
#  The system basically works by giving monster troops levels and by setting a
#  level range within which all encounters must reside. By default, this level range
#  is between (Actor's Average Level - 5) and (Actor's Average Level + 5). The
#  range can be changed at any time to make certain maps harder or easier by
#  using the following code in a call script:
#
#     $game_system.min_level = x
#     $game_system.max_level = x
#
#  Where x is the value you are changing it to.
#  Keep in mind that min level, like max level, is added to the party's average level.
#  So, if you set $game_system.min_level = 5, then the minimum level of encounters
#  would be party's average level + 5, not party's average level - 5.
#
#  You can also turn the levelling feature on and off completely at will, using this code:
#
#  $game_system.level_boolean = true (to turn it on)
#  $game_system.level_boolean = false (to turn it off)
#
#  For instructions on setting the troop levels, see the Editable Region at Line 58.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Compatibility:
#   It ought to be compatible with any script that does not modify the
#   make_encounter_troop_id method of Game_Player (and I can't think of any script
#   that would want to besides one like this).
#=============================================================
# ** Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#       aliased method - initialize
#       new instance variables - level_boolean, min_level, max_level
#       new method - troop_levels
#=============================================================

class Game_System
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Public Instance Variables
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 attr_accessor :level_boolean   # Turns on and off the level range function
 attr_accessor :min_level           # The lower limit of the encounter range
 attr_accessor :max_level         # The upper limit of the encounter range
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Retrieve Troop Level
 #     Adds an Encounter_Area object to the areas array.
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def troop_levels (id)
   # By default, level = id
   level = id
   case id
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # * Editable Region
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   #  Here is where you can set up the levels of each respective troop. As
   #  you can see below, all you need to do is use this code:
   #
   #      when id; level = X
   #
   #  where id is the ID of the troop and X is the level you want that troop to
   #  have. I also recommend placing the name of the troop next to them for
   #  easy editing, so:
   #
   #      when id; level = X     # name
   #
   #  If you do not set a level, the troop's level will be assumed to be equal to it's ID
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   when 1; level = 2     # Slime * 2
   when 2; level = 5     # Bat * 2
   when 3; level = 8    # Bee * 2
   when 4; level = 11     # Spider * 3
   when 5; level = 13
   when 6; level = 14
   when 7;
   when 8;
   when 9;
   when 10;
   when 11;
   when 12;
   when 13;
   when 14;
   when 15;
   when 16;
   when 17;
   when 18;
   when 19;
   when 20;
   when 21;
   when 22;
   when 23;
   when 24;
   when 25;
   when 26;
   when 27;
   when 28;
   when 29;
   when 30;
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # * End Editable Region
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   end
   return level
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Object Initialization
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias ma_encounter_levels_init initialize
 def initialize
   ma_encounter_levels_init
   @min_level = -5
   @max_level = 5
   @level_boolean = true
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # * End Editable Region
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 end
end

#==============================================================
# ** Game_Player
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#      overwritten methods - make_encounter_troop_id
#==============================================================

class Game_Map
 #-------------------------------------------------------------------------
 # * Encounter List
 #     returns the encounter list based on party level
 #-------------------------------------------------------------------------
 alias ma_encounter_level_restrictions_encounter_list encounter_list
 def encounter_list
   # If level feature active
   if $game_system.level_boolean
     encounters = []
     # Calculate Party Level Average
     average_level = 0
     $game_party.actors.each {|i|  average_level += i.level}
     average_level /= $game_party.actors.size
     # Set Range
     min = [average_level + $game_system.min_level,1].max
     max = [average_level + $game_system.max_level,99].min
     unless min > max
       # Test average agains all troops in the list
       ma_encounter_level_restrictions_encounter_list.each {|i|
         troop_level = $game_system.troop_levels (i)
         # Add to the returning array  If troop level within range
         encounters.push (i) if troop_level.between? (min, max)
         }
     end
   else
     # Return the full encounter list
     encounters = ma_encounter_level_restrictions_encounter_list
   end
   return encounters
 end
end

Crovean

thanks it works like a charm... Is there also a way to make encounters drop random items?