[XP] Health and level

Started by PhoenixFire, April 13, 2011, 08:27:19 pm

Previous topic - Next topic

PhoenixFire

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 :)
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

brewmeister

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

PhoenixFire

No, I didn't, but thank you very much  :haha:
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

brewmeister

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

ForeverZer0


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.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

G_G

pretty sure the add-on is already in Blizz-ABS. If you're not using Blizz-ABS its in Tons of Add-Ons

PhoenixFire

Thank you to everyone that responded :)
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?