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.

[RESOLVED] Level-up variable

Marpy

Member

Is there anyway to make a system where each time an actor levels up, a special variable goes up as well? Like every time actor #1 reaches a new level, variable #1 goes up a point, and every time actor #2 levels up, variable #2 goes up, etc.
 
It would work with an event. common event, to be precise.
Just set it on parallel process and start it in the beginnig of your game.
Then let it set varable one to actor one's level and so on.

Hope this helps

~Dalton~
 

Marpy

Member

Hrm.. no, not really. Perhaps I should be more precise. The variable is to be used similar to AP, used to train. Using a common event will set it to be the character's level, and therefore... infinite AP.
 
you could also set it to be v#1=Heroe's level. If v#1=x add set v#2=y Would work as well. Or you could check at the end of every battle if the level was higher than at the start and if it is so change the variable for your points...  Try around a bit ^^
 

Acera

Sponsor

but this is in the scripts requests area for a reason. Anyway I tried to figure it out for you but I can't find the part where the scripts handle the lvl up part. I found it a few days ago but can't seem to find it again. If anyone does find it, I think (note: think, my scripting skills are way below average) you could handle something like; save the current lvl of the actor in a local variable and after the battle check if the lvl is still the same. If it's not the same add 1 point to *insert variable number of choice here*.

I'll try to search again tomorrow, sleeping time now
~Acera
 
Alright, I'm pulling a 'Seph', and posting this without testing it. (You get to test it!) :scruff:

[ EDIT ] My brain fart!  This is for XP, look below for the VX version.

Code:
class Game_Actor

  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
      # increment the corresponding game variable
      $game_variables[@actor_id] += 1
      # 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
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
end

The variable will correspond to the actor ID in the database, not necessarily the party.

Be Well
 

Marpy

Member

A: Not sure what to do with this, so I assume put it in a new script.
B: Stuck it in a new script, and got an error: 'undefined method 'exp=' for class game_actor'
 
Yep, use this instead. And yes, insert it in a new script in the Materials / (Insert Here) section.

Code:
class Game_Actor
  def level_up
    @level += 1
    # increment the corresponding game variable
    $game_variables[@actor_id] += 1
    for learning in self.class.learnings
      learn_skill(learning.skill_id) if learning.level == @level
    end
  end
end

"We apologize for the inconvenience."

BTW, you totally lucked out. I'm on day 30 of my VX trial!  :scruff:

Be Well
 
Thank you, Brewmeister, for making these scripts.  I can use them in my ability grid system, which is almost complete.  If you wish to check it out, there's a link in my signature.

~Guardian1239
 

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