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 Up -> Variable[x] + x

hello,

i cant manage it to add a specific value to a variable when i get a lvl up.
every actor should have his own variable. its for a status point distribution menu

Code:
for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
      last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          $game_variables[5] += 5   # <- this wont work :(
          actor.hp = actor.maxhp
          actor.sp = actor.maxsp
          #Show LEvel Up if need to
          actor.damage = "Level Up!" if DISPLAY_LEVELUP
          Audio.me_play("Audio/ME/" + LEVELUP_MUSIC.to_s, 100, 100) if LEVELUP_MUSIC != ""
        end
      end
    end

someone can tell me how to do this?
 
You shouldn't use anything outside Game_Actor#exp= method to determine this. Try something like this:

Code:
class Game_Actor
  Level_Up_Variables = {1 => 5, 2 => 6, 3 => 7, 4 => 8}
  alias_method :seph_levelupvariableinc_gmactr_exp=, :exp=
  def exp=(n)
    last_level = @level
    self.seph_levelupvariableinc_gmactr_exp=(n)
    while last_level < @level
      $game_variables[Level_Up_Variables[@actor_id]] += 5
      last_level += 1
    end
  end
end

Just modify Level_Up_Variables = {1 => 5, 2 => 6, 3 => 7, 4 => 8} where the number before the => is your actor's id and the number after => is your variable it will be increasing for that actor.

Let me know if that doesn't work for you.
 

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