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.

Everytime a character levels a variable is increased by 1.

I have a viriable for every character in my database(just player characters). How would i increase said variable by one when each character levels up?
 

Star

Sponsor

Why would you need too? When you can just ask the variable to measure the character's level no matter what sense you're saying each character will have their own variable.

Anyway. Just ask this. Conditional branch if variable is not equal to characters level Variable == character's level.
 
5m script
Code:
#Game_variable modifier on level up 

#By Gerkrt,gerrtunk

 

module Wep

  Level_up = true # If the variable is modified when actors levelup

  Level_down = false # When they level down, the variable also.

  Game_variables = [] # Don't touch this

  Game_variables[1] = 1 # Game_variables[Actor id number in database] = game variable

  # id to modify

end

class Game_Actor

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

  # * Change EXP

  #     exp : new EXP

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

  def exp=(exp)

    @exp = [[exp, 9999999].min, 0].max

    # Level up

    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0

      @level += 1

      if Wep::Game_variables[@actor_id] != nil and Wep::Level_up

        $game_variables[Wep::Game_variables[@actor_id]] +=1

      end

      # Learn skill

      for j in $data_classes[@class_id].learnings

        if j.level == @level

          learn_skill(j.skill_id)

        end

      end

    end

    # Level down

    while @exp < @exp_list[@level]

      @level -= 1

      if Wep::Game_variables[@actor_id] != nil and Wep::Level_down

        $game_variables[Wep::Game_variables[@actor_id]] -=1

      end

    end

    # Correction if exceeding current max HP and max SP

    @hp = [@hp, self.maxhp].min

    @sp = [@sp, self.maxsp].min

  end

end

Good night.
 
What exactly do you need the variables for? Like Star said, you can set an actor's level to a variable, or use the following code in a conditional branch/check:
$game_party.actors[0-3].level >= ?


If it's too much work to set it when you want it, though, you can use gerrtunk's method.
 

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