Custom EXP Script
#1
Custom EXP Script
by Dargor
Version: 2.2

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.

Introduction

This is the new version of my crappy old 'Reseted EXP' script.
Basicaly, it works like FF Tactic EXP system.

Here's an example:

Code:
You start at level 1
You need 25 EXP to reach level 2, 100 EXP to reach level 3
You gain 50 EXP
You're now level 2 with 25/100 EXP


Features

* Comes with a nice little EXP Editor!
* EXP is easier to handle with the RPG::Exp class
* Read/write EXP from Data/Exp.rxdata
* Allow/disallow actors to use this EXP System


Screenshots

Screenshots... You're kidding, right?

Demo

Maybe later.

Script
Code:
#==============================================================================
# ** Custom EXP Script
#------------------------------------------------------------------------------
#  Author: Dargor
#  Version 2.2
#  24/11/2007
#==============================================================================

#==============================================================================
# ** RPG::Exp
#------------------------------------------------------------------------------
#  This class handles EXP list for all actors.
#==============================================================================

module RPG
  class Exp
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    def initialize
      @list = []          # Exp list
      @actors = [1,2,7,8] # Actors affected by this EXP system
    end
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :list
    attr_accessor :actors
  end
end

#==============================================================================
# ** 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
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :total_exp
  attr_accessor :exp_list
  #--------------------------------------------------------------------------
  # * Setup
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  alias dargor_total_exp_setup setup
  alias dargor_make_exp_list make_exp_list
  def setup(actor_id)
    @exp_list = @exp_list = Array.new(101)
    @total_exp = 0
    dargor_total_exp_setup(actor_id)
  end
  #--------------------------------------------------------------------------
  # * Calculate EXP
  #--------------------------------------------------------------------------
  def make_exp_list
    if FileTest.exist?("Data/Exp.rxdata")
      $data_exp = load_data("Data/Exp.rxdata")
      if $data_exp.actors.include?(@actor_id)
        if $data_exp.list[@actor_id].nil?
          dargor_make_exp_list
        else
          @exp_list = $data_exp.list[@actor_id]
        end
      else
        dargor_make_exp_list
      end
    else
      dargor_make_exp_list
    end
  end
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    if not $data_exp.nil? and $data_exp.actors.include?(@actor_id)
      @total_exp = @exp
      # Level up
      while @total_exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
        @exp = @exp % @exp_list[@level+1]
        @level += 1
        # Learn skill
        for j in $data_classes[@class_id].learnings
          if j.level == @level
            learn_skill(j.skill_id)
          end
        end
      end
      # Level down
      while @total_exp < @exp_list[@level]
        @level -= 1
      end
    else
      # Level up
      while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
        @level += 1
        # Learn skill
        for j in $data_classes[@class_id].learnings
          if j.level == @level
            learn_skill(j.skill_id)
          end
        end
      end
      # Level down
      while @exp < @exp_list[@level]
        @level -= 1
      end
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
end

#==============================================================================
# ** Window_ExpEditor
#------------------------------------------------------------------------------
#  This window displays EXP needed for a specific level.
#==============================================================================

class Window_ExpEditor < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(320,128,320,160)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = nil
    @level = 1
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0,0,320,32,'Current EXP')
    self.contents.draw_text(0,64,320,32,'New EXP')
    unless @actor.nil?
      self.contents.font.color = normal_color
      self.contents.draw_text(32,32,160,32,"#{@actor.exp_list[@level]}")
      draw_actor_graphic(@actor,188,80)
      draw_actor_name(@actor,172,0)
    end
  end
  #--------------------------------------------------------------------------
  # * Set
  #--------------------------------------------------------------------------
  def set(actor_id, level)
    @actor = $game_actors[actor_id]
    @level = level
    refresh
  end
end

#==============================================================================
# ** Scene_ExpEditor
#------------------------------------------------------------------------------
#  This class performs EXP Editor screen processing.
#==============================================================================

class Scene_ExpEditor
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Initialize EXP object
    if FileTest.exist?("Data/Exp.rxdata")
      $data_exp = load_data("Data/Exp.rxdata")
    else
      $data_exp = RPG::Exp.new
    end
    # Make system object
    $data_system = load_data("Data/System.rxdata")
    $game_system = Game_System.new
    # Make actor object
    $data_actors = load_data("Data/Actors.rxdata")
    $game_actors        = Game_Actors.new
    # Make classes and armors object
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    # Make title graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    # Make command window
    commands = ['Initialize', 'Save', 'Quit']
    @command_window = Window_Command.new(320, commands)
    @command_window.active = false
    @command_window.x = 320
    @command_window.y = 64
    @command_window.back_opacity = 160
    # Make help window
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    # Make actor window
    actors = []
    for i in 1...$data_actors.size
      case i
      when 0...10
        id = "00#{i}:"
      when 10...99
        id = "0#{i}:"
      else
        id = "#{i}:"
      end
      actors << id + $data_actors[i].name
    end
    @actor_window = Window_Command.new(160,actors)
    @actor_window.y = 64
    @actor_window.height = 12 * 32 + 32
    @actor_window.back_opacity = 160
    # Make level window
    levels = []
    for i in 1..99
      levels << "Level #{i}"
    end
    @level_window = Window_Command.new(160,levels)
    @level_window.active = false
    @level_window.x = 160
    @level_window.y = 64
    @level_window.height = 12 * 32 + 32
    @level_window.back_opacity = 160
    # Make exp window
    @exp_window = Window_InputNumber.new(7)
    @exp_window.active = false
    @exp_window.x = 348
    @exp_window.y = 288
    @exp_window.back_opacity = 160
    # Make editor window
    @editor_window = Window_ExpEditor.new
    @editor_window.y = 192
    @editor_window.back_opacity = 160
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of sprites
    @sprite.bitmap.dispose
    @sprite.dispose
    # Dispose of windows
    @command_window.dispose
    @actor_window.dispose
    @level_window.dispose
    @exp_window.dispose
    @editor_window.dispose
    @help_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @command_window.update
    @actor_window.update
    @level_window.update
    @help_window.update
    if @command_window.active
      update_command
      return
    end
    if @actor_window.active
      update_actor
      return
    end
    if @level_window.active
      update_level
      return
    end
    if @exp_window.active
      update_exp
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Load actors data
  #--------------------------------------------------------------------------
  def load_actors_data
    $data_actors = load_data("Data/Actors.rxdata")
    $game_actors        = Game_Actors.new
    level = @level_window.index + 1
    actor = @actor_window.index + 1
    @editor_window.set(actor, level)
    exp = $game_actors[actor].exp_list[level]
    @exp_window.number = exp
    @exp_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Command Window)
  #--------------------------------------------------------------------------
  def update_command
    if Input.trigger?(Input::B)
      @actor_window.active = true
      @command_window.active = false
    end
    case @command_window.index
    when 0
      @help_window.set_text("Reset modifications")
    when 1
      @help_window.set_text("Save modifications")
    when 2
      @help_window.set_text("Quit the editor")
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        load_actors_data
      when 1
        save_exp
        Audio.se_play("Audio/SE/056-Right02", 80, 110)
      when 2
        $scene = nil
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Actor Window)
  #--------------------------------------------------------------------------
  def update_actor
    level = @level_window.index + 1
    actor_id = @actor_window.index + 1
    actor = $game_actors[actor_id]
    @help_window.set_text("Change #{actor.name}'s EXP list.")
    if Input.trigger?(Input::B)
      @actor_window.active = false
      @command_window.active = true
    elsif Input.trigger?(Input::C)
      @actor_window.active = false
      @level_window.active = true
    end
    @editor_window.set(actor_id, level)
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Level Window)
  #--------------------------------------------------------------------------
  def update_level
    level = @level_window.index + 1
    actor_id = @actor_window.index + 1
    actor = $game_actors[actor_id]
    @help_window.set_text("Change #{actor.name}'s EXP list for level #{level}.")
    if Input.trigger?(Input::B)
      @level_window.active = false
      @actor_window.active = true
    elsif Input.trigger?(Input::C)
      @level_window.active = false
      @exp_window.active = true
    end
    actor = @actor_window.index + 1
    @editor_window.set(actor_id, level)
    exp = $game_actors[actor].exp_list[level]
    @exp_window.number = exp
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Exp Window)
  #--------------------------------------------------------------------------
  def update_exp
    level = @level_window.index + 1
    actor_id = @actor_window.index + 1
    actor = $game_actors[actor_id]
    @help_window.set_text("Choose the amount of EXP needed for #{actor.name} to reach level #{level}")
    @exp_window.update
    if Input.trigger?(Input::B)
      @exp_window.active = false
      @level_window.active = true
    elsif Input.trigger?(Input::C)
      level = @level_window.index + 1
      actor = @actor_window.index + 1
      $game_actors[actor].exp_list[level] = @exp_window.number
      @exp_window.active = false
      @level_window.active = true
    end
  end
  #--------------------------------------------------------------------------
  # * Save EXP object
  #--------------------------------------------------------------------------
  def save_exp
    for i in 1...$data_actors.size
      if $data_exp.actors.include?(i)
        for j in 1..99
          $data_exp.list[i] = $game_actors[i].exp_list
        end
      end
    end
    save_data($data_exp, "Data/Exp.rxdata")
  end
end


Instructions

Place the script above main, below all other script. The usual.

To choose which actors will be affected by this system, find the @actors under initialize in class EXP (at the top of the script).
Then, include any actor's id you want in the array.

Code:
@actors = [1, 3, 10000, etc.]

To enter the EXP Editor, go in main. Find this line:
Code:
$scene = Scene_Title.new

and replace it for
Code:
$scene = Scene_ExpEditor.new


FAQ

none


Compatibility

Might be incompatible with other EXP systems.


Credits and Thanks

Credits goes to me (Dargor) obviously but also to FireStalker5 for requesting this script.
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Steal and Mug Script Lethrface 0 3,040 08-08-2011, 01:00 PM
Last Post: Lethrface
  Book Script and Utility Bruth 0 2,738 06-10-2009, 01:00 PM
Last Post: Bruth
  Clan Script ShockWave 0 2,612 08-27-2007, 01:00 PM
Last Post: ShockWave
  ARMS Script El Conductor 0 2,564 08-04-2007, 01:00 PM
Last Post: El Conductor
  Juke Box Script polraudio 0 2,729 06-17-2007, 01:00 PM
Last Post: polraudio
  Quest Script Samo the thief 0 2,558 03-12-2007, 01:00 PM
Last Post: Samo the thief
  Quest Script by SAMO Samo the thief 0 2,524 12-29-2006, 01:00 PM
Last Post: Samo the thief
  An easier WORKING party change script The Ghost 0 2,493 07-09-2006, 01:00 PM
Last Post: The Ghost
  Mission Script Leon Westbrooke 0 2,725 07-04-2006, 01:00 PM
Last Post: Leon Westbrooke
  Mining Script GoldenShadow 0 2,501 03-05-2006, 01:00 PM
Last Post: GoldenShadow



Users browsing this thread: 1 Guest(s)