The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Chaos17 on June 09, 2012, 09:43:15 AM

Title: [VXA] Level Cap
Post by: Chaos17 on June 09, 2012, 09:43:15 AM
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

Title: Re: [VXA] Level Cap
Post by: Trihan on June 09, 2012, 11:23:39 AM
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.
Title: Re: [VXA] Level Cap
Post by: Chaos17 on June 09, 2012, 03:46:42 PM
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)
Title: Re: [VXA] Level Cap
Post by: Trihan on June 09, 2012, 04:25:18 PM
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
Title: Re: [VXA] Level Cap
Post by: Chaos17 on June 09, 2012, 04:39:07 PM
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 ?  :-[
Title: Re: [VXA] Level Cap
Post by: mobychan on June 09, 2012, 05:15:34 PM
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
Title: Re: [VXA] Level Cap
Post by: Trihan on June 09, 2012, 05:22:11 PM
Oh sugarplum fairies, I missed that the alias call didn't provide the same arguments as the original. Well-spotted!
Title: Re: [VXA] Level Cap
Post by: Chaos17 on June 09, 2012, 05:31:54 PM
Thank you very much guys.  :tpg:
I am so happy.
Title: Re: [VXA] Level Cap
Post by: Trihan on June 09, 2012, 06:09:28 PM
Feel free to translate your happiness into nice shiny +rep for us! :D
Title: Re: [VXA] Level Cap
Post by: Chaos17 on June 09, 2012, 06:28:19 PM
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 ?
Title: Re: [VXA] Level Cap
Post by: Dwarra? on June 09, 2012, 06:53:54 PM
You have to have more than 75 posts to give rep.
Title: Re: [VXA] Level Cap
Post by: Chaos17 on June 09, 2012, 06:56:27 PM
Okay, that's unfornate then.
Title: Re: [VXA] Level Cap
Post by: mobychan on June 09, 2012, 06:56:47 PM
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 ;)
Title: Re: [VXA] Level Cap
Post by: Trihan on June 09, 2012, 08:37:39 PM
Heh, I was only kidding anyway, don't worry. ^_^