Notice: fwrite(): Write of 44 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96
Print Page - heal upon lvl up [RESOLVED]

The RPG Maker Resource Kit

Other Game Creation => Program Troubleshooting => Topic started by: ryuzaki95 on August 24, 2009, 11:57:07 PM

Title: heal upon lvl up [RESOLVED]
Post by: ryuzaki95 on August 24, 2009, 11:57:07 PM
i dont know whether to put this in troubleshooting or script request but instead of using a script to auto heal your char when he lvls up i heard you can change something in game_actor. im terrible with scripting so can someone tell me what to change in game_actor to auto heal your character when he lvls up?
Title: Re: heal upon lvl up
Post by: Kokowam on August 25, 2009, 02:48:08 AM
http://rmrk.net/index.php/board,108.0.html

I suppose looking at the description that says "Discussion on Scripts for the RPG Maker XP" doesn't mean anything to you either.

http://rmrk.net/index.php/topic,18051.0.html

This sticky doesn't mean anything, either, I suppose.

Also, I'll see if I can help, but next time, post in the right place.

EDIT: Eh. I'm too lazy to do this. I probably could do this but only with quite a bit of work and searching for syntax because I'm not very good with scripting.
Title: Re: heal upon lvl up
Post by: modern algebra on August 25, 2009, 03:46:33 AM
How modifying Game_Actor is "instead of using a script" I can't figure out, but all you need to change is the exp= method of Game_Actor.

Around line 454 you'll see:


  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end



Where you have:


    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1


add recover_all, so:


    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      recover_all


I think that will work.
Title: Re: heal upon lvl up
Post by: ryuzaki95 on August 25, 2009, 06:05:25 AM
it works thank you so much for your help :)