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.

Level keeping

I have a request I was wondering if there was a script that allowed people to retain thereorriginal leves if they change from classes? I know thats a bit confusing so il'l give an example: A level 10 theif changes class to a lancer and is level 1 but if the lancer were to change back into a thief hey would be level 10 again. I hope that makes sense and if that can be done using battle events please let me know thanks.I am using XP
 

Ares

Member

I think this is able with events. You just need to store the player's level in a variable.
Something like:
Control Variables: 001 = Player's level

and when you need to change the level back do something like:
Change Level: level = variable 001
it's quite late here so i'll check if it;s possible tomorrow.
 
As far as I can remeber there is no way to change the level directly to a given varaibale, but you can substract 1 from your level varavle and increase your level by that after you go back to your old class (for that you must first make your character level 1 again.)
 
Save your Game Variables for something more important, here...

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

# ** Actors : Change Class Level

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

 

class Game_Actor < Game_Battler

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

  # * Alias Listings

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

  alias_method :changeclasslevel_gmactor_classid=, :class_id=

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

  # * Class ID = (id)

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

  def class_id=(class_id)

    if @class_change_levels.nil?

      @class_change_levels = Hash.new

      @class_change_levels.default = 1

    end

    @class_change_levels[self.class_id] = self.level

    changeclasslevel_gmactor_classid = class_id

    self.level = @class_change_levels[class_id]

  end

end

When you change class, your old level will be stored. Afterwards, your level is set to whatever was previously stored for the new class (which is defaulted to 1, like you said, if the actor has never been that class before.)

On a sidenote

I've got another script you might be interested in, seeing as it looks like class changing might be an important element in your game, especially during battle (kinda like FFX-2?). Basically, when you change classes normally, your skills aren't updated to the new class's skills, thats where this script comes in. It handles things like auto-updating skills between changing classes, and retaining certain individual and/or class skills, stuffs like that...

Actors : Change Class Skills

You might want to try placing the "Class Change Levels" script above the "Class Change Skills" script or I don't think it'll work properly, but there ya go incase you needed something like that too.
 
This is just the script I was looking for and no it won't be that big a deal but I hope for something simmaler to Tactics a2 grimore of the rift where your class was changed out of battle but again thanks for the scripts it will be a nice feature to add to my game.
 
Ah crap, I've gotta repost this because they had to 'roll back' the forum topics.

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

# ** Actors : Class Change Levels

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

 

class Game_Actor < Game_Battler

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

  # * Alias Listings

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

  alias_method :classchangelevel_gmactor_initialize,  :initialize

  alias_method :classchangelevel_gmactor_chglevel,    :level=

  alias_method :classchangelevel_gmactor_chgclassid,  :class_id=

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

  # * Object Initialization

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

  def initialize(actor_id)

    classchangelevel_gmactor_initialize(actor_id)

    @class_change_levels = Hash.new

    @class_change_levels.default = 1

  end

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

  # * Level = (level)

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

  def level=(level)

    classchangelevel_gmactor_chglevel(level)

    @class_change_levels[@class_id] = self.level

  end

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

  # * Class ID = (class_id)

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

  def class_id=(class_id)

    @class_change_levels[@class_id] = self.level

    classchangelevel_gmactor_chgclassid(class_id)

    self.level = @class_change_levels[@class_id]

  end

end

There's one issue you're going to encounter, I wanna know how you'd like me to handle it. Example, when you change from a Class A (Level 15) to a Class B (Level 1), your current and maximum HP/SP are obviously adjusted to be lower, no big deal I suppose. But when you change back from Class B (Level 1) to Class A (Level 15) again, your stats are restored except current HP/SP (max HP/SP will be restored to what they were, in theory).

Class A
HP : 1400/1400
SP : 800/800

Class B
HP : 850/850
SP : 350/350

Class A
HP : 850/1400
SP : 350/800

Do you want me to add a thing to check the percent of current/max HP and SP when you change class? That way, it'll do something like...

Class A
HP : 900/1000
SP : 250/500

Class B
HP : 90/100
SP : 25/50

Class A
HP : 900/1000
SP : 250/500

Besides that, stats in general will change when you change to a class with a higher/lower level, so this is something to keep in mind. Just give me some input if you want me to do anything about it or not, the current HP/SP thing I already plan to write a fix for.
 
Final bump, final update!

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

# ** Game_Battler

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

 

class Game_Battler

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

  # * Name      : Hp Percent

  #   Info      : Returns HP Percent

  #   Author    : SephirothSpawn

  #   Call Info : Two Arguments

  #               Integer truth, true for integer, false for float

  #               Float points, integer value for number of float points

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

  def hp_percent(integer = false, float_points = 2)

    # Gets Float Percent

    n = (self.hp / self.maxhp.to_f * 100.0)

    # Return Percent

    return integer ? Integer(n) : n.float_points(float_points)

  end

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

  # * Name      : Sp Percent

  #   Info      : Returns SP Percent

  #   Author    : SephirothSpawn

  #   Call Info : Two Arguments

  #               Integer truth, true for integer, false for float

  #               Float points, integer value for number of float points

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

  def sp_percent(integer = false, float_points = 2)

    # Gets Float Percent

    n = (self.sp / self.maxsp.to_f * 100.0)

    # Return Percent

    return integer ? Integer(n) : n.float_points(float_points)

  end

end

 

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

# ** Game_Actor

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

 

class Game_Actor < Game_Battler

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

  # * Alias Listings

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

  alias_method :classchangelevel_gmactor_initialize,  :initialize

  alias_method :classchangelevel_gmactor_chgclassid,  :class_id=

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

  # * Object Initialization

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

  def initialize(actor_id)

    classchangelevel_gmactor_initialize(actor_id)

    @class_change_levels = Hash.new

    @class_change_levels.default = 1

  end

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

  # * Class ID = (class_id)

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

  def class_id=(class_id)

    hp_percentile = self.hp_percent(true)

    sp_percentile = self.sp_percent(true)

    @class_change_levels[@class_id] = self.level

    classchangelevel_gmactor_chgclassid(class_id)

    self.level = @class_change_levels[@class_id]

    self.hp = Integer(self.maxhp * (hp_percentile / 100.0))

    self.sp = Integer(self.maxsp * (sp_percentile / 100.0))

  end

end

This system will now set your current HP/SP to the percentage of HP/SP you had prior to changing class.

I used the following methods from Method & Class Library 2.3...

Game_Battler.hp_percent (from 'RGSS.Actor and Party Info')
Game_Battler.sp_percent (from 'RGSS.Actor and Party Info')

...which means, if you have the MACL already, you can delete the Game_Battler snippet from this script.

Enjoy! :thumb:
 

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