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 / MP Equipment Bonuses

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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


Code: [Select]
#==============================================================================
#  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


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: February 11, 2010, 09:55:29 PM by Modern Algebra »

********
Shadow Knight
Rep:
Level 91
Ruin that brick wall!
Project of the Month winner for October 2008
Thank you very much modern! ;8
Be kind, everyone you meet is fighting a hard battle.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Sorry Leventhan - I made a mistake.

Change:

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

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

It's at about line 28

**
Rep:
Level 85
Life is as easy as donut or not donut.
    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.  :)

**
Rep: +0/-0Level 72
Black Onslaught
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.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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]

**
Rep: +0/-0Level 72
Black Onslaught
The % can be worked too?
For example... 10%, 25%.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
No, not in this script at least.

**
Rep: +0/-0Level 72
Black Onslaught
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.
« Last Edit: February 11, 2011, 07:27:14 PM by Foghart »

*
Rep: +0/-0Level 62
RMRK Junior
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.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.

*
Rep: +0/-0Level 62
RMRK Junior
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!