Main Menu
  • Welcome to The RPG Maker Resource Kit.

[VXA] Level Cap

Started by Chaos17, June 09, 2012, 09:43:15 AM

0 Members and 1 Guest are viewing this topic.

Chaos17

Hello,

I've found this script to setup a level cap through a variable.
Idvariableslevel = #Numéro de la variable qui contient le niveau max.
class Game_Actor < Game_Battler
def max_level
return $game_variables[Idvariableslevel]
end
end


It works well but I've a problem.
The script doesn't stop my hero to gain exp after he reached the max level.
So the player can bank exp until the max level is unlocked.
I can't allow the player to gain 10 levels at once just because I allowed him to stock exp.

Someone suggested me a solution but the problem with this new code is that it prevent my hero to gain exp before reaching max level and I want it to do the contratry : block exp after max level is reached.

class Game_Actor < Game_Battler
alias lcap_change_exp change_exp
def change_exp(exp, show)
            return if max_level?
            lcap_change_exp
  end
end


Trihan

Try changing "return if max_level?" to "if self.level < max_level". That should make the actor only gain exp if their level is less than the max.
It's more like a big ball of wibbly wobbly...timey wimey...stuff.

Chaos17

Hello,

Thanks for your reply, I wrote this :
class Game_Actor < Game_Battler
alias lcap_change_exp change_exp
def change_exp(exp, show)
           if self.level < max_level
            lcap_change_exp
  end
end


But I got this error.

Trihan

You need another "end" after the call to lcap_change_exp:

class Game_Actor < Game_Battler
    alias lcap_change_exp change_exp
    def change_exp(exp, show)
        if self.level < max_level
            lcap_change_exp
        end
    end
end
It's more like a big ball of wibbly wobbly...timey wimey...stuff.

Chaos17

#4
This line made game bug >  lcap_change_exp
Idvariableslevel = 002 #Numéro de la variable qui contient le niveau max.
class Game_Actor < Game_Battler
def max_level
return $game_variables[Idvariableslevel]
end
end

class Game_Actor < Game_Battler
    alias lcap_change_exp change_exp
    def change_exp(exp, show)
        if self.level < max_level
            lcap_change_exp
        end
    end
end

I tried to remove it and I got the same problem as before, the hero doesn't gain anymore exp before reaching max level.


I tried this to :
Idvariableslevel = 002 #Numéro de la variable qui contient le niveau max.

class Game_Actor < Game_Battler
def max_level
return $game_variables[Idvariableslevel]
end
    def change_exp(exp, show)
        if self.level < max_level
        end
    end
end

But got the same problem as above.

Am I copy pasting the code wrong or what ?  :-[

mobychan

Using this works for me:

Idvariableslevel = 002 #Numéro de la variable qui contient le niveau max.
class Game_Actor < Game_Battler
  def max_level
    return $game_variables[Idvariableslevel]
  end
end

class Game_Actor < Game_Battler
  alias lcap_change_exp change_exp
  def change_exp(exp, show)
    if self.level < max_level
      lcap_change_exp(exp, show)
    end
  end
end




Trihan

Oh sugarplum fairies, I missed that the alias call didn't provide the same arguments as the original. Well-spotted!
It's more like a big ball of wibbly wobbly...timey wimey...stuff.

Chaos17

Thank you very much guys.  :tpg:
I am so happy.

Trihan

Feel free to translate your happiness into nice shiny +rep for us! :D
It's more like a big ball of wibbly wobbly...timey wimey...stuff.

Chaos17

Quote from: Trihan on June 09, 2012, 06:09:28 PM
Feel free to translate your happiness into nice shiny +rep for us! :D
Sorry for asking here but PM ddidn't work.
I don't know how to give rep point, do you ?

Dwarra?

You have to have more than 75 posts to give rep.

Chaos17

Okay, that's unfornate then.

mobychan

#12
you need a certain amount of posts(I don't know how much)
Then you'll see something like this: [+][-] next so everybody's Rep values
+ for rep up and - for rep down ;)




Trihan

Heh, I was only kidding anyway, don't worry. ^_^
It's more like a big ball of wibbly wobbly...timey wimey...stuff.