[RMXP] Subclass for the actors

Started by Diamond Star, October 25, 2012, 06:15:03 pm

Previous topic - Next topic

Diamond Star

I am RMXP user
I need a system add sub class to actors next to main class where that subclass
contains skills learned every level the subclass goes up and
subclass goes up when the actor gain specified EXP ,but the EXP calculated from the
moment that  the actor starts learning the subclass not from stsrting the game
and subclass must have max level to rich.

It's like main class but the different is in calculating EXP
where reach new level happened by EXP gained from stsrting lesrnung the subclass
where it must , when an actor learnes a subclass, get current EXP then set it as base EXP of subclass and calculate how many EXP nedded to next level of subclass
I have many dreams and look for who understand me and help me to achieve them

KK20

You'll have to be a bit more descriptive as to how you want the system to work. How are you setting up EXP for these sub-classes? Will these sub-classes be listed on the character's status screen in the menu? How about when they change sub-classes? Are there any restrictions? What about the skills? Max level of sub-classes? Are there "sub-class advancements" (after mastering PotionBrewing class you can advance to Alchemist class)?

As you can see, this can be a pretty extensive script. You would be better off recruiting a scripter.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Diamond Star

I'm soory for uncleared request
The subclass can levels up by gaining a certain amount of EXP that
start calculate from the moment the actor learn the subclass.
Every subclass has eight levels and the nedded EXP to reach new level go up every level
There is no restriction or element ,states efffeciency for subclasses.
There is no advanced level need mastering certain subclasses.
Every subclass has skills learned when reaching new level and actor could learnes no skills or could learnes tow skills in one new level
I hope my explaination good.if not tell me..
I have many dreams and look for who understand me and help me to achieve them

KK20

Alright, I think I have the idea down. Essentially just create another variable for Game_Actor and assign a job/class from the database to it. I'll probably start working on it this weekend.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Diamond Star

Exactly tht what I need
A subclass similar to main class in database
viz tow classes for the actor
I have many dreams and look for who understand me and help me to achieve them

KK20

Okay, I think I got it down.
Spoiler: ShowHide
=begin
--------------------------------------------------------------------------------
Side Class                                                              V. 1.0
By KK20                                                                 11/9/12
--------------------------------------------------------------------------------

First off, create your side classes in the Database. Assign skills for these
classes based on the class's level.

Second, further below you will see a 'BEGIN CONFIGURATION'. Here is where you
will create the EXP table for your classes. Instructions are shown there.

Now in order to use this script...
In an event, choose the 'Script' event command and use the following commands:
  [ Commands ]

  + To change an actor's side class
  change_side_class(actor_id, class_id)
 
  + To see actor's side class EXP or LEVEL
  side_class_exp(actor_id)
  side_class_level(actor_id)
 
  + Add EXP to an actor's side class
  side_class_add_exp(actor_id, exp_amount)
 
  + To see actor's side class EXP or LEVEL to a specific class
  side_class_exp(actor_id, class_id)
  side_class_level(actor_id, class_id)
 
  + Add EXP to an actor's specific side class
  side_class_add_exp(actor_id, exp_amount, class_id)

--------------------------------------------------------------------------------
=end
#============================================================================

#============================================================================
class SideClass
 
  def exp_chart(index=nil)
    case (index.nil? ? @id : index)
    when 0 then return []
    #**********************************************************************
    # B E G I N   C O N F I G U R A T I O N
    #**********************************************************************
    # Determine how much EXP it requires to level up the side class.
    # FORMAT:
    #   when CLASS_ID then return [LEVEL_2_EXP, LEVEL_3_EXP, ... ]
    #
    # Example:
    #   when 3 then return [20, 100, 400, 600]
    #
    # >> Class of ID 3 requires 20 EXP to reach level 2, 100 EXP for level 3,
    #    and so forth. The class has a maximum level of 5.
    #
    # If you do not put a custom EXP chart for a side class, it will use
    # the default chart located below 'else'.
    #----------------------------------------------------------------------
    when 9 then return [20, 30]
    when 10 then return [10, 20, 30]
    else
      return [5, 25, 100, 250, 500, 1000]
    #**********************************************************************
    # E N D   C O N F I G U R A T I O N
    #**********************************************************************
    end
  end

  attr_reader :id, :level
 
  def initialize(actor)
    @actor = actor
    @id = 0
    @level = []
    @exp = []
  end
 
  def change_class(id)
    return if @id == id
    @id = id
    # Initializes the class data if it doesn't exist
    @level[@id] = 1 if @level[@id].nil?
    @exp[@id] = 0 if @exp[@id].nil?
  end
 
  def exp(index=nil)
    i = (index.nil? ? @id : index)
    return 0 if @exp[i].nil?
    if max_level?(i)
      max = self.exp_chart(i)[@level[i] - 2]
      return 0 if max.nil?
      @exp[i] = max
      return max
    else
      return @exp[i]
    end
  end
 
  def exp=(amt)
    # Side class has reached maximum level, stop adding EXP
    return 0 if max_level?
    # EXP may only be positive
    @exp[@id] = [amt, 0].max
    # Raises level and teaches skills based on class level
    while !max_level? and @exp[@id] >= exp_chart[self.level - 1]
      @level[@id] += 1
      for j in $data_classes[@id].learnings
        if j.level == @level[@id]
          @actor.learn_skill(j.skill_id)
        end
      end
    end
    # Lowers class level should the EXP be less
    while @level[@id] > 1 and @exp[@id] < exp_chart[self.level - 2]
      @level[@id] -= 1
    end
  end
 
  def add_exp(id, amt)
    # Side class has reached maximum level, stop adding EXP
    return 0 if max_level?(id)
    # EXP may only be positive
    @exp[id] += [amt, 0].max
    # Raises level and teaches skills based on class level
    while !max_level?(id) and @exp[id] >= exp_chart(id)[@level[id] - 1]
      @level[id] += 1
      for j in $data_classes[id].learnings
        if j.level == @level[id]
          @actor.learn_skill(j.skill_id)
        end
      end
    end
    # Lowers class level should the EXP be less
    while @level[id] > 1 and @exp[id] < exp_chart[@level[id] - 2]
      @level[id] -= 1
    end
  end
 
  def exp_required(index=nil)
    i = (index.nil? ? @id : index)
    return 0 if max_level?(i)
    return exp_chart(i)[@level[i]-1] - @exp[i]
  end
 
  def exp_to_next(index=nil)
    i = (index.nil? ? @id : index)
    return 0 if max_level?(i)
    return exp_chart(i)[@level[i]-1]
  end
 
  def level(index=nil)
    l = (index.nil? ? @level[@id] : @level[index])
    return 0 if l.nil?
    return l
  end
 
  def max_level?(index=nil)
    i = (index.nil? ? @id : index)
    return false if (@level[i].nil? or @level[i] == 1)
    return exp_chart(i)[@level[i]-1].nil?
  end
 
 
end
#============================================================================

#============================================================================
class Game_Actor < Game_Battler
  attr_reader :side_class
 
  alias re_init_after_side_class initialize
  def initialize(actor_id)
    re_init_after_side_class(actor_id)
    @side_class = SideClass.new(self)
  end
 
  alias after_side_class_gets_exp exp=
  def exp=(amt)
    # Add side class EXP if side class exists
    @side_class.exp += (amt - @exp) if @side_class.id != 0
    # Add actor EXP
    after_side_class_gets_exp(amt)
  end
 
end
#============================================================================

#============================================================================
def Interpreter
 
  def change_side_class(actor_id, class_id)
    $game_actors[actor_id].side_class.change_class(class_id)
  end
 
  def side_class_exp(actor_id, class_id=nil)
    $game_actors[actor_id].side_class.exp(class_id)
  end
 
  def side_class_level(actor_id, class_id=nil)
    $game_actors[actor_id].side_class.level(class_id)
  end
 
  def side_class_add_exp(actor_id, exp_amount, class_id=nil)
    $game_actors[actor_id].side_class.add_exp(class_id, exp_amount)
  end
 
end
Paste below default scripts and above Main. Instructions in script. Note this is just the base engine; there are no GUIs in this script.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Diamond Star

I'm very gratful to you
this is exactly my request that I asked for in many places
and finally I got it here .So , very thanks.

I'm happy to know person like you where you was patient on me
so I dare to ask you if I can ask you certainly for making some scripts for me that
seems simple and has subordinator job ,like some windows and menus..so on ,but for me is not
if I can ask you for them freely, reply me to send my requests followingly
to you as PM as I get progress on my project
and of course you will be given a credit
I have many dreams and look for who understand me and help me to achieve them

Diamond Star

I'm soory my friend KK20 ,but I need only small addition on this perfect script:
I use "Easy LvlUp Notifier" by blizzard ,so I wonder if you can make leveling up in subclasses be notified too,and show the learned skills as in state of normal level.

this is a link to Easy LvlUp Notifier script
http://forum.chaos-project.com/index.php/topic,117.0.html

Very thank you to you..........
I have many dreams and look for who understand me and help me to achieve them

KK20

How's this? Replace the Easy LvlUp script with this.
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Easy LvlUp Notifier by Blizzard
# Version: 2.11b
# Type: Battle Report Display
# Date: 27.8.2006
# Date v1.2b: 3.11.2006
# Date v1.3b: 11.3.2007
# Date v1.4b: 22.8.2007
# Date v2.0: 25.9.2007
# Date v2.1: 4.12.2009
# Date v2.1b: 15.3.2010
# Date v2.11b: 19.3.2010
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   98% compatible with SDK v1.x. 80% compatible with SDK 2.x. WILL corrupt old
#   savegames. May cause slight problems with following systems and would need
#   therefore slight recalibration:
#   - exotic CBS-es
#   - exotic skill systems
#   - exotic stat systems (additional stats like Wisdom, Luck etc.)
#
#
# Features:
#
#   - shows increased stats and learned skills at level up
#   - animated
#   - shows EXP gain for each actor (!) only after gaining EXP after a battle
#   - more simple and less laggy than other Level Up Notifiers
#   - you can set up any sound to be played when a higher level is reached or a
#     new skill is learned (LVLUP_SE and LEARN_SE further below)
#
# new in v1.2b:
#   - better window movement
#   - higher compatibility
#   - fixed a few "eventual" bugs
#
# new in v1.3b:
#   - fully compatible with Tons of Add-ons
#
# new in v1.4b:
#   - improved coding
#   - rewritten conditions using classic syntax to avoid RGSS conditioning bug
#
# new in v2.0:
#   - completely overworked and improved
#   - now MUCH more simple than other Level Up Notifiers
#   - halved the number of lines of code
#   - much more compatible: can show increase of any stats after the battle in
#     combination with any script, just put this script below those attribute
#     modifying scripts
#
# new in v2.1:
#   - improved coding
#   - increased compatibility with CBS-es
#
# new in v2.1b:
#   - fixed "stack level too deep" problem
#
# new in v2.11b:
#   - fixed crash during escape
#
#
# Instructions:
#
# - Explanation:
#
#   This script will notify you when any character is leveled up after a
#   battle. It will show any stats that were increased and any skills that were
#   learned. The windows are animated, the code is less complex than any other
#   so far and it is most efficient as well as highly optimized and detailed
#   worked out.
#
# - Configuration:
#   
#   There are a few options you can set up below.
#   
#   LVLUP_SE            - sound effect played when a new level was reached
#   LEARN_SE            - sound effect played when a new skill was learned,
#                         keep in mind that the script takes into account that
#                         skills can only be learned after a level up
#   WINDOW_BACK_OPACITY - set this value to the window's back opacity (0-255)
#   NO_EXP_DISPLAY      - set this value to true if you want to disable the EXP
#                         gaining display in the level up windows
#   OLD_EXP_DISPLAY     - set this value to true if you want to display the EXP
#                         in the normal result window again
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#          RPG::AudioFile.new('FILENAME', VOLUME, PITCH)
LVLUP_SE = RPG::AudioFile.new('087-Action02', 80, 100)
LEARN_SE = RPG::AudioFile.new('106-Heal02', 80, 100)
WINDOW_BACK_OPACITY = 160
NO_EXP_DISPLAY = false
OLD_EXP_DISPLAY = false

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

$easy_lvlup_notifier = 2.11

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
 
  def all_exp
    return @exp
  end
 
  def all_exp=(exp)
    @exp = exp
  end

end

#==============================================================================
# Window_BattleResult
#==============================================================================

class Window_BattleResult < Window_Base
 
  alias easy_lvlup_notfier_refresh refresh
  def refresh
    if $tons_version != nil && $tons_version >= 4.02 &&
        $game_system.WINDOW_BATTLERESULT || OLD_EXP_DISPLAY
      easy_lvlup_notfier_refresh
    else
      self.contents.clear
      x = 4
      self.contents.font.color = system_color
      cx = contents.text_size('Gained').width
      self.contents.draw_text(x, 0, cx+4, 32, 'Gained')
      x += cx + 4
      self.contents.font.color = normal_color
      cx = contents.text_size(@gold.to_s).width
      self.contents.draw_text(x, 0, cx+4, 32, @gold.to_s)
      x += cx + 4
      self.contents.font.color = system_color
      self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
      (0...@treasures.size).each {|i| draw_item_name(@treasures[i], 4, (i+1)*32)}
    end
  end
 
end

#==============================================================================
# Window_LevelUp
#==============================================================================

class Window_LevelUp < Window_Base
 
  attr_reader :limit
 
  def initialize(a, d)
    if $tons_version != nil && $tons_version >= 4.98 &&
        $game_system.CENTER_BATTLER
      x = case $game_party.actors.size
      when 1 then 240
      when 2 then a.index * 320 + 80
      when 3 then a.index * 160 + 80
      when 4 then a.index * 160
      end
    else
      x = a.index * 160
    end
    text = []
    text.push(['Level:', d[0], a.level]) if d[0] != a.level
    text.push([$data_system.words.hp[0, 3], d[1], a.maxhp]) if d[1] != a.maxhp
    text.push([$data_system.words.sp[0, 3], d[2], a.maxsp]) if d[2] != a.maxsp
    text.push([$data_system.words.str[0, 3], d[3], a.str]) if d[3] != a.str
    text.push([$data_system.words.dex[0, 3], d[4], a.dex]) if d[4] != a.dex
    text.push([$data_system.words.agi[0, 3], d[5], a.agi]) if d[5] != a.agi
    text.push([$data_system.words.int[0, 3], d[6], a.int]) if d[6] != a.int
    h = text.size * 24 + (NO_EXP_DISPLAY ? 32 : 56)
    @limit, y = 320 - h, 480 - h + (h/64+1)*64
    super(x, y, 160, h)
    self.z, self.back_opacity = 100, WINDOW_BACK_OPACITY
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    if $fontface != nil
      self.contents.font.name = $fontface
    elsif $defaultfonttype != nil
      self.contents.font.name = $defaultfonttype
    end
    self.contents.font.size, self.contents.font.bold = 20, true
    unless NO_EXP_DISPLAY
      self.contents.font.color = normal_color
      self.contents.draw_text(0, 0, 128, 24, "#{a.exp - d[7]} EXP", 1)
    end
    text.each_index {|i|
        index = NO_EXP_DISPLAY ? i : i + 1
        self.contents.font.color = system_color
        self.contents.draw_text(0, index*24, 128, 24, text[i][0])
        self.contents.draw_text(80, index*24, 32, 24, 'ยป')
        self.contents.font.color = normal_color
        self.contents.draw_text(0, index*24, 76, 24, text[i][1].to_s, 2)
        if text[i][1] > text[i][2]
          self.contents.font.color = Color.new(255, 64, 0)
        else
          self.contents.font.color = Color.new(0, 255, 64)
        end
        self.contents.draw_text(0, index*24, 128, 24, text[i][2].to_s, 2)}
  end
 
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle
 
  alias main_lvlup_later main
  def main
    @lvlup_data = {}
    @moving_windows, @pending_windows = [], []
    (1...$data_actors.size).each {|i|
        actor = $game_actors[i]
        @lvlup_data[actor] = [actor.level, actor.maxhp, actor.maxsp, actor.str,
            actor.dex, actor.agi, actor.int, actor.exp, actor.skills.clone, actor.side_class.level]}
    main_lvlup_later
    (@moving_windows + @pending_windows).each {|win| win.dispose if win != nil}
  end
 
  alias start_phase5_lvlup_later start_phase5
  def start_phase5
    start_phase5_lvlup_later
    @skill_texts = []
    $game_party.actors.each {|actor|
        actor.remove_states_battle
        if @lvlup_data[actor][9] != actor.side_class.level
          @skill_texts.push("#{actor.name} raised #{$data_classes[actor.side_class.id].name} to Level #{actor.side_class.level}")
          new_skills = actor.skills - @lvlup_data[actor][8]
          if new_skills.size > 0
            new_skills.each {|id|
                @skill_texts.push("#{actor.name} learned #{$data_skills[id].name}!")}
          end
        end
        if @lvlup_data[actor][0, 7] != [actor.level, actor.maxhp, actor.maxsp,
            actor.str, actor.dex, actor.agi, actor.int]
          @pending_windows.push(Window_LevelUp.new(actor, @lvlup_data[actor]))
          @skill_texts.push('')
          new_skills = actor.skills - @lvlup_data[actor][8]
          if new_skills.size > 0
            new_skills.each {|id|
                @skill_texts.push("#{actor.name} learned #{$data_skills[id].name}!")}
          end
        elsif @lvlup_data[actor][7] != actor.exp && !NO_EXP_DISPLAY
          @moving_windows.push(Window_LevelUp.new(actor, @lvlup_data[actor]))
        end}
  end
 
  alias update_phase5_lvlup_later update_phase5
  def update_phase5
    update_phase5_lvlup_later
    if @phase5_wait_count <= 0 && !Input.trigger?(Input::C)
      @moving_windows.each {|win|
          win.y -= [((win.y - win.limit) / 2.0).ceil, 64].min if win.y > win.limit}
    end
  end
 
  alias battle_end_lvlup_later battle_end
  def battle_end(result)
    if @result_window == nil
      battle_end_lvlup_later(result)
      return
    end
    @result_window.visible = false
    if @skill_texts.size > 0
      text = @skill_texts.shift
      if text == ''
        $game_system.se_play(LVLUP_SE)
        @moving_windows.push(@pending_windows.shift)
        @help_window.visible = false
      else
        $game_system.se_play(LEARN_SE)
        @help_window.set_text(text, 1)
      end
    else
      battle_end_lvlup_later(result)
    end
  end
 
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Diamond Star

I appriciate your work and helping me in my many requests.you helped me much and
you have a part in developing my game and will give my credit.

I read about your project, but I don't like armies game much ,but I wish all success in this project and
indeed want to be your friend......
I have many dreams and look for who understand me and help me to achieve them