RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
HP Script issue

0 Members and 1 Guest are viewing this topic.

*
Rep: +0/-0Level 75
RMRK Junior
Hello all,

I am new to the RPG Maker series of programs and to Ruby.  I am also new this forum.  For those that wish to know, I do have experience with object oriented programming languages (Java specifically).  Anyways, here's what I was tyring to do.  The Actors tab in RPG Maker VX does not allow you to make an hp curve for an hp level higher than 9999 hp.  So I decided I could just script the rest of the curve myself.  Changing the hp limit was easy enough (I set it to 99999), but the real problem I encountered was when I wrote the script to extend the hp curve.  Here's the script I wrote (I'll include the entire method it is included in):

def change_exp(exp, show)
    last_level = @level
    count = last_level
    last_skills = skills
    @exp = [[exp, 9999999].min, 0].max
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      level_up
    end
    while @exp < @exp_list[@level]
      level_down
    end
   #Here is where my script begins.
    myActor = $game_party.members[index]
    if @hp >= 9999 && @hp < 99999
      while count < @level
        @hp = @hp + 1000
        myActor.maxhp = myActor.maxhp + 1000
        count = count + 1
      end
    else
      @hp = [@hp, maxhp].min
      @mp = [@mp, maxmp].min
    end
   #Here is where my script ends.
    if show and @level > last_level
      display_level_up(skills - last_skills)
    end
  end

The above method is located inthe Game_Actor class.  My script is between the two comments.  To test this I scripted a method gives enough xp to raise my characters 10 levels or more and I modifed one of my characters to have 9999 hp by default.  That being said, when the xp is gained, the hp caps at either 19998 or 19609.  The interesting thing is, I can use Life Up items and the hp max goes up just fine all the way to up the limit I set.  My question is, is the problem in my script or is it somewhere else?  And if it is in my script, how do I fix it?  Any help would be greatly appreciated.

P.S.

Yes I know I haven't put the checker in to see if @hp is > 99999.  It is on my todo list.  And yes, I know that this is not really needed, but I am studying to be a computer programmer and hope to one day write my own games, so the knowledge would greatly help me.  If screens are needed let me know and I can post them.

Thanks in advance for all your help.

--gamerlj
« Last Edit: September 17, 2010, 02:31:19 AM by gamerlj »

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Does it do this when you raise their levels by 1 at a time? Should be an event command for that too. Exactly how many levels are you giving them? Does the 9999 hp stay consistent all through out the actor's level in the DATABASE? If you only set it to 9999 for their starting level and didn't change the rest, you might have your issue there. =O
« Last Edit: September 18, 2010, 06:05:41 AM by Shinami »

*
Rep: +0/-0Level 75
RMRK Junior
Originally I gave them 5000000 xp, which would get them to into their 90s.  Later I dropped that to enough xp to gain 10 levels.  I took your advice and set the curve to have hp at 9999 for every level, and then tested the script one level at a time.  Still get the same issue.  It caps me at 19998.
« Last Edit: September 18, 2010, 02:22:33 PM by gamerlj »

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
I believe that the answer is in Game_Battler.
Code: [Select]
#--------------------------------------------------------------------------
  # * Set Maximum HP
  #     new_maxhp : new maximum HP
  #--------------------------------------------------------------------------
  def maxhp=(new_maxhp)
    @maxhp_plus += new_maxhp - self.maxhp
    @maxhp_plus = [[@maxhp_plus, -9999].max, 9999].min
    @hp = [@hp, self.maxhp].min
  end

@maxhp_plus = [[@maxhp_plus, -9999].max, 9999].min is what's bugging me. If @maxhp_plus is greater than 9999, it'll just set @maxhp_plus to 9999, and therefore the maximum HP you can have is 19998, 2x 9999, which is the base maxhp + 9999.

Anyways, just change the 9999 to 99999, and your good.

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
. . . I musta been really tired last night to miss that. Thankies cozzie for pointing out something I missed. =3