Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: PhoenixFire on April 13, 2011, 08:27:19 pm

Title: [XP] Health and level
Post by: PhoenixFire on April 13, 2011, 08:27:19 pm
Okay, so I treid to do this using common events, but, I can't seem to figure it out, without the game freezing on me.. I just want the game to check if you leveld up, and if so, to refill your health and mana/majick/whatever. That's all. No fancy menus or ABS systems that incorporate it.. I might be able to find it in the Blizz-ABS, so I'll update if I solve it, but, I dunno yet... Thanks in advance :)
Title: Re: [XP] Health and level
Post by: brewmeister on April 13, 2011, 08:50:06 pm
Did you ask this somewhere else?

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #   Add All Heal on Level up - Brew
  #--------------------------------------------------------------------------
  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
      #heal
      @hp = self.maxhp
      @sp = self.maxsp
    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
end
Title: Re: [XP] Health and level
Post by: PhoenixFire on April 13, 2011, 09:04:12 pm
No, I didn't, but thank you very much  :haha:
Title: Re: [XP] Health and level
Post by: brewmeister on April 13, 2011, 09:13:35 pm
weird, I just answered this recently.

BTW, It took me a little while to figure out how to alias a 'setter' method, but this is a little cleaner & will prevent incompatibility...

class Game_Actor
  alias :old_exp= :exp=
  def exp=(exp)
    oldlvl = @level
    self.old_exp = exp
    if @level > oldlvl
      @hp = self.maxhp
      @sp = self.maxsp
    end
  end
end
Title: Re: [XP] Health and level
Post by: ForeverZer0 on April 13, 2011, 10:23:47 pm

class Game_Actor
  alias recover_level_up level=
  def level=(level)
    if level > @level
      @hp, @sp = self.maxhp, self.maxsp
    end
    recover_level_up(level)
  end
end


This will eliminate the creation of an unneeded local variable.
Title: Re: [XP] Health and level
Post by: G_G on April 14, 2011, 12:36:50 am
pretty sure the add-on is already in Blizz-ABS. If you're not using Blizz-ABS its in Tons of Add-Ons
Title: Re: [XP] Health and level
Post by: PhoenixFire on April 14, 2011, 09:26:14 am
Thank you to everyone that responded :)