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.

Class Change by Actor's Level

I would like a script that changes an actor's class_id based upon the level of the actor. For example, if Aluxes is normally a knight, I would like him to turn into another job/class at level 10. I'm new to RGSS, but I tried to make the script myself and don't know whats wrong with it.

My Script That Doesn't Work:
class Job_change
def main
if actor_id[1].level == 3
actor[1].class_id == 2
end
end
end


I'm guessing I placed it in the wrong section, which was directly above Main.
 
The location of the script is fine, the script itself needs some help. As well, you need to call the script from where the actor levels up.

Find Lines 173-175 of Scene_Battle 2
Code:
        if actor.level > last_level
          @status_window.level_up(i)
          class_change(actor)
        end
You'll notice I inserted a line here, "class_change(actor)". This will call the method to check for a class change.

Code:
class Scene_Battle
  def class_change(actor)
    case actor.id
    when 1
      if actor.level == 3
        actor.class_id = 2
      end
    end
  end
end
And this is the script that will check for class changes. You had the right idea, it just had some syntax issues. (Plus, I changed it into a method in Scene_Battle instead of an entire new class.)

Any questions about the script, feel free to ask.

[Edit]I suppose, I realise now, this will not work if you somehow level up *outside* of battle. As long as you never plan on giving the player EXP outside of battle, this is fine. Otherwise, I'll need to go hunting for anywhere else you might gain experience (IE. prob the interupter class...) ^^; But I wouldn't bother unless you say you plan on giving experience outside of battle.
 

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