Main Menu
  • Welcome to The RPG Maker Resource Kit.

HP / MP Equipment Bonuses

Started by modern algebra, July 07, 2008, 08:23:30 PM

0 Members and 1 Guest are viewing this topic.

modern algebra

HP / MP Equipment Bonuses
Version: 1.0
Author: modern algebra
Date: July 7, 2008

Description



This script allows you to set Equipment that give bonuses to your Max HP and Max MP

Features


  • Uses the Note box for easy configuration
  • Allows you to set bonuses to Max HP and MP to equipment individually

Instructions

Place script above Main and below other Custom scripts

   Simply use these codes in the note box of any Equipment:
   
     \maxhp[<integer>] positive or negative
     \maxmp[<integer>] positive or negative

Script




#==============================================================================
#  Max HP/MP Equipment
#  Version 1.0
#  Author: modern algebra
#  Date: July 7, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#    Place Above Main and below other Custom scripts
#
#    Simply use this code in the note box of any Equipment:
#    
#      \maxhp[<integer>] positive or negative
#      \maxmp[<integer>] positive or negative
#==============================================================================

#==============================================================================
# ** RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    new methods - maxhp, maxmp
#==============================================================================

class RPG::BaseItem
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * MaxHP Bonus
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def maxhp
   return $1.to_i if self.note[/\\maxhp\[(-*\d+)\]/i] != nil
   return 0
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * MaxMP Bonus
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def maxmp
   return $1.to_i if self.note[/\\maxmp\[(-*\d+)\]/i] != nil
   return 0
 end
end

#==============================================================================
# ** Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased method - setup, change_equip
#    new method - add_hpmp_bonuses
#==============================================================================

class Game_Actor
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Setup
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias modalg_levent_hpmpmax_upd_equipment_stup setup
 def setup (actor_id)
   # Run Original method
   modalg_levent_hpmpmax_upd_equipment_stup (actor_id)
   equips.each_index { |i| calc_hpmp_bonuses (equips[i]) }
   self.hp = self.maxhp
   self.mp = self.maxmp
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Change Equip
 #--------------------------------------------------------------------------
 #  Adds and subtracts maxhp upon equip
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias modalg_levnthn_maxhpmp_equip_change_9nej change_equip
 def change_equip (equip_type, item, test = false)
   calc_hpmp_bonuses (equips[equip_type], false)
   # Run Original Method
   modalg_levnthn_maxhpmp_equip_change_9nej (equip_type, item, test)
   calc_hpmp_bonuses (item)
   self.hp = [self.hp, self.maxhp].min
   self.mp = [self.mp, self.maxmp].min
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Add HPMP Bonuses
 #    item : the item in question
 #    sign : true => add, false => subtract
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def calc_hpmp_bonuses (item = nil, sign = true)
   return if item == nil
   hp = sign ? item.maxhp : -item.maxhp
   @maxhp_plus += hp
   mp = sign ? item.maxmp : -item.maxmp
   @maxmp_plus += mp
 end
end


Credit




  • modern algebra

Thanks


  • Leventhan, for the request

Support



Post here at rmrk.net for the swiftest response




Leventhan


Be kind, everyone you meet is fighting a hard battle.

modern algebra

Sorry Leventhan - I made a mistake.

Change:


    return $1.to_i if self.note[/\\maxhp\[-*(\d+)\]/i] != nil

to


    return $1.to_i if self.note[/\\maxhp\[(-*\d+)\]/i] != nil


It's at about line 28

Drunken Paladin

Quote from: modern algebra II on July 07, 2008, 08:23:30 PM
    Simply use these codes in the note box of any Equipment:
   
      \maxhp[<integer>] positive or negative
      \maxmp[<integer>] positive or negative

Forgive me, I'm not really very experienced with scripting, but do you mean input an actual integer inside the brackets in the note-section of an item?

I.e., \maxhp[20] will increase the Max HP by 20?

EDIT: Indeed you did! My nub ass included the < > inside the brackets and couldn't figure out what you meant. Many thanks, this is a great script.  :)

Foghart

Sorry, but I can't put this to work.
I don't know if i'm doing in the right way, but I put the code like this:
Quote\maxhp[<+10>]

You can put some example on how we can put the code?
Thanks, seeya.

modern algebra

You don't need the + and drop the <>. Those were just meant to represent that that is where you put something. So, if you wanted to add 10, you'd put:

\maxhp[10]

If you wanted it to remove 10, then:

\maxhp[-10]

Foghart

The % can be worked too?
For example... 10%, 25%.

modern algebra


Foghart

#8
Ahh... too bad, I was looking for this.

EDIT:
Anyone who can put the % to work, please contact me, I really need this kind of system to do a "equipment strategy" for my game.

glenick1

I got some kind of problem with this script. I'm totally unexperienced with scripts, so it could be an easy answer tho.

Whenever I give my armor a bonus, like \maxhp[150], the hp remains the same. But when i unequip my armor, the max hp does drop with 150 tho. How can I fix this?

EDIT: When I re-equip the armor, the max hp increases with 150 hp, but the amount is exactly the same as without the script.

modern algebra

I don't receive that error, but my best guess is that it is an incompatibility with another script - one which overwrites the setup method of Game_Actor.

Try putting this script below every one of your other custom scripts, but still above Main.

glenick1

I know it sounds weird, but today i continued my game, and the script was working. Quite weird, but atleast it's ok now :D Thanks for the script!