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
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.
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.
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fuppix.net%2F4%2Fe%2Ff%2F3b2b5a07c1b87ca3d5dec0ffed74ct.jpg&hash=94db336fc3c66d485e29c58ea2d2f061254f00d5) (http://uppix.net/4/e/f/3b2b5a07c1b87ca3d5dec0ffed74c.html)
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
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 ? :-[
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
Oh sugarplum fairies, I missed that the alias call didn't provide the same arguments as the original. Well-spotted!
Thank you very much guys. :tpg:
I am so happy.
Feel free to translate your happiness into nice shiny +rep for us! :D
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 ?
You have to have more than 75 posts to give rep.
Okay, that's unfornate then.
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 ;)
Heh, I was only kidding anyway, don't worry. ^_^