[XP] Modify Max Amount

Started by G_G, January 24, 2009, 05:58:21 pm

Previous topic - Next topic


March 30, 2015, 07:21:38 pm #20 Last Edit: March 30, 2015, 07:26:46 pm by Shaylina
Can anyone help me a bit, I installed this script, and placed what maximum stats I want. Then when I go into the game andd add parameters with an event, the maximum hp I reach is 12662 and max in other stats is 1229.
In the script I put max hp to be 100000 and the other stats 9999

Update: I tested a bit more, andd found out that I can only add a stats once, to break the limit. Like if my character has 9999 hp and I add 9999 hp in an event, he will go to 19998 but can never add again.

Tanks for the time.


The problem is that using the "Change Parameters" event command isn't working in the way you intended.

Stats are calculated as such:
Base Stat + "Change Parameters" additions
...where Base Stat refers to the actor's stat at the level you specified it to be in the Database PLUS equipment bonuses.

So at the start of the game, the number in "Change Parameters" additions is clearly 0. For your test, you set the base Max HP to 9999 and used "Change Parameters" to increase it by 9999, returning 19998 as expected. But there's a problem with "Change Parameters" additions: it has a limit.

If you look in Game_Battler 1, you can find this method:

  # * Set Maximum HP
  #     maxhp : new maximum HP
  def maxhp=(maxhp)
    @maxhp_plus += maxhp - self.maxhp
    @maxhp_plus = [[@maxhp_plus, -9999].max, 9999].min #<============= This line in particular
    @hp = [@hp, self.maxhp].min

The variable @maxhp_plus represents "Change Parameters" additions. As pointed in the code, the maximum you can increase Max HP is by 9999 and the minimum by -9999. Any subsequent calls to increase the actor's Max HP will fail as @maxhp_plus cannot go beyond 9999.

The most band-aid fix for this is to replace the 9999 with Config::Max_HP, like so
@maxhp_plus = [[@maxhp_plus, -Config::Max_HP].max, Config::Max_HP].min

However, be very careful with this. Say you have @maxhp_plus capped to 100000 (which is your limit you configured). Say you also have a status condition that increases the actor's Max HP by 5000 temporarily. @maxhp_plus cannot go beyond 100000, so it will ignore the additional 5000 being added to it. When the condition is removed, @maxhp_plus will decrease by 5000, meaning @maxhp_plus has now permanently lost 5000 points (and have your players in rage discovering the actor suddenly lost Max HP).

So to be on the safe side of things, it might be best to replace 9999 with something higher than your limit. And just be REALLY GOOD at keeping track of how much you are increasing/decreasing your stats with event calls.

(And I hope you are smart enough to realize I was only talking about one stat parameter and that you can easily fix the others yourself)

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!


Thank you very much, this worked really really good. :)