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.

Setting a game variable equal to an actor's next_exp?

For use with an evented custom menu system, I need to set a game variable equal to a specific actor's next_exp. That is, I want to set a variable to, say, actor 001 from the database. I understand that the answer is simple, but I haven't been able to figure it out yet.

Thanks in advance!
 
I believe it might be this, I'm not sure. I just had a hunch, searched through the default system scripts and put this line together based on instinct:
Code:
$game_variables[variable ID] = $game_actors[actor_id].nextexp

I'm note sure if this will work actually, so if it doesn't; try messing around with it or putting a dash mark, underscore, or period between next and exp, so it's like "next.exp" and so on.

Your welcome!
 
No, after slightly checking Game_Actor class, I don't think there's a method call included in XP.

If you look at Game_Actor's setup method, you'll see this:

@exp = @exp_list[@level]

That's exactly how the maker gets the info about the current or next level experience quota or requirement.

I guess the method may look like this...

[rgss]class Game_Actor
  def next_level_exp
    return @level < 99 ? @exp_list[@level + 1] : @exp_list[@level]
  end
end
[/rgss]

The method call should be this one...

$game_actors[actor_id].next_level_exp

or

$game_party.actors[actor_id].next_level_exp
 
Well, I guess both of you got the idea after all.

I also edited my previous post because I forgot to include a condition statement just in case the actor's level is 99. Since normally there's no level 100, I had to include that condition asap.
 
Wonderful! Thanks, everyone! I'm having one issue though. It seems to be simple enough, but I can't figure it.

As the characters' levels increase, the next_exp determined by this script doesn't update; the value stays at that amount required for level 2. In case I'm not explaining clearly, I'll give to you my specific example. As stock actors, actor 001 needs 30 EXP to level up to level 2. I increase the character's level to 4 through events, but, when I set a game variable equal to the next_exp determined by this script and then display that variable, the variable is still 30.

Did I do something wrong?

EDIT: Ah, nevermind. If I'd just waited a few minutes before posting, I would've figured it out without having to ask! Thanks, everyone :D!
 

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