The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Daos on August 21, 2009, 05:15:57 AM

Title: custom exp script?
Post by: Daos on August 21, 2009, 05:15:57 AM
hi sorry im new and dont know if this question has been asked but is there a script that alloowed you to make your own custom exp script like 10000, 20000, 30000 etc... if there is can someone let me know please
Title: Re: custom exp script?
Post by: Grafikal on August 21, 2009, 05:21:10 AM
Hm. I might have seen this. Either I did, or I saw someone else request this. I don't remember, I'll go looking and check back.

::BLARGH::
Ok well, I didn't really find it anywhere. I think the closest I found in my 5-10 minute search was this:
http://www.rpgmakervx.net/index.php?showtopic=14594&st=0&p=127369&#entry127369

It's more for customizing the EXP for different classes compared to other classes. So like Paladins would level up faster or slower than Thieves, etc. You can already do this in the database mostly, but the script gives you much better flexibility. Maybe you can find some use out of it. If you don't use classes in your game, you could probably just set this script to one class and make your characters all the same class so that you customize the EXP easier. I don't know. Worth a try.
Title: Re: custom exp script?
Post by: Daos on August 21, 2009, 05:34:05 AM
ok thanks man :D
Title: Re: custom exp script?
Post by: jragyn on August 26, 2009, 09:22:09 PM
Though this is for rpg maker XP, I found this...somewhere, I don't recall.
I'm sure with a bit of tweaking, it could work for VX:

Mind you, I added a bit of wordage so I could understand it better, as it had no instructions prior.

[spoiler]# Manual Experience Table Enumeration 
# by RPG Advocate
=begin
To create customized xp tables for a character, make a txt document and
devise numbers for the experience.
Note: The numbers you put in are the Total experience for that level.
ie=

0
20
55
125
260

would really be this:

0 xp at level 1
20 xp to level 2
35 xp to level 3
70 xp to level 4
135 xp to level 5

Make sense?
If you don't fill in enough numbers, it will replace the numbers with the
default experience equivelant for that level.
If you put too many levels worth of experience, it will just cut off wherever
you set the max level at.

=end
  #   Displays error messages
  #   if set to true
      METE_ERROR_SHOW = true
 

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Calculate EXP
  #--------------------------------------------------------------------------
  alias mete_make_exp_list make_exp_list
  def make_exp_list
    # The original call
    mete_make_exp_list
    # Obtain actor and read outside experience chart if available
    actor = $data_actors[@actor_id]
    fname = "Data\\actor" + actor.id.to_s + "exp.rxdata"
    if FileTest.exist?(fname)
      get_exp_list_from_file(fname)
      if @exp_file_error
        @exp_list = Array.new(101)
      else
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Obtain experience table from file
  #--------------------------------------------------------------------------
  def get_exp_list_from_file(filename)
    begin
      if @exp_file_error
        return
      end
      f = File.open(filename)
      list = f.readlines
      list = correct_malformed_input(list)
      if @exp_file_error
        return
      end
      for i in 0..list.size - 1
        list[i] = list[i].to_i
      end
      list = correct_erroneous_data(list)
      for i in list.size..100
        list[i] = 0
      end
      list.unshift(0)
      @exp_list = list
      rescue StandardError
        s1 = "Unrecoverable error while reading " + @name + "'s EXP list.\n"
        s2 = "Experience curve declared in the database will be used instead."
        print(s1 + s2) if METE_ERROR_SHOW
        @exp_file_error = true
        retry
      ensure
        if f != nil
          f.close
        end
      end
  end
  #--------------------------------------------------------------------------
  # * Delete and repair experience table
  #--------------------------------------------------------------------------
  def correct_malformed_input(list)
    lines_to_delete = []
    if list.size == 0
      s1 = "Warning: " + @name + "'s experience requirement file is empty.  "
      s2 = "Experience curve declared in the database will be used instead."
      print(s1 + s2) if METE_ERROR_SHOW
      @exp_file_error = true
      return
    end
    for i in 0..list.size - 1
      delflag = false
      for j in 0..list[i].size - 1
        if list[i][j] != 10 && list[i][j] != 32 &&
          !(list[i][j] >= 48 && list[i][j] <= 57)
          delflag = true
        end
      end
      if list[i].size == 1 && list[i][0] == 10
        delflag = true
      end
      if delflag
        lines_to_delete.push(list[i])
      end
    end
    if lines_to_delete != []
      for i in 0..lines_to_delete.size - 1
        list.delete(lines_to_delete[i])
      end
    end
    for i in 0..list.size - 1
      while list[i].include?(32)
        list[i].slice!(0)
      end
    end
    return list
  end
  #--------------------------------------------------------------------------
  # * Correct the new experience table
  #--------------------------------------------------------------------------
  def correct_erroneous_data(list)
    warnings = ""
    wrong_exp = false
    if list[0] != 0
      list[0] = 0
      s1 = "Warning: " + @name + "'s experience requirement for level 1 "
      s2 = "must be zero.  Automatically correcting error.\n"
      warnings += s1 + s2
    end
    if list.size < $data_actors[@actor_id].final_level
      if list.size >= 2
        value = list[list.size - 1] - list[list.size - 2]
        for i in list.size..$data_actors[@actor_id].final_level - 1
          list[i] = list[i-1] + value
        end
      else
        list = []
        for i in 0..$data_actors[@actor_id].final_level - 1
          list[i] = i
        end
      end
      s1 = "Warning: Fewer levels than " + @name + "'s maximum level have "
      s2 = "been declared.  Creating temporary substitute values.\n"
      warnings += s1 + s2
    end
    if list.size > $data_actors[@actor_id].final_level
      new_list = []
      for i in 0..$data_actors[@actor_id].final_level - 1
        new_list[i] = list[i]
      end
      list = new_list
      s1 = "Warning: More levels than " + @name + "'s maximum level have "
      s2 = "been declared.  Ignoring excess declarations.\n"
      warnings += s1 + s2
    end
    for i in 1..list.size - 1
      if list[i] <= list[i-1]
        if i == list.size - 1 && list.size != 2
          diff = list[i-1] - list[i-2]
          list[i] = list[i-1] + diff
        elsif i == list.size - 1 && list.size == 2
          list[i] = 10
        else
          if list[i+1] > list[i-1]
            diff = list[i+1] - list[i-1]
            list[i] = list[i-1] + diff / 2
          else
            list[i] = list[i-1] + 10
          end
        end
        wrong_exp = true
      end
    end
    if wrong_exp
      s1 = "Warning: One or more experience requirements for " + @name + " "
      s2 = "is less than or equal to the previous level's requirement.  "
      s3 = "Creating temporary substitute values."
      warnings += s1 + s2 + s3
    end
    if warnings != ""
      print(warnings) if METE_ERROR_SHOW
    end
    return list
  end
end
[/spoiler]