Equipment Stat Bonuses on Level Up
This script must have been written already, but I couldn't find it. Someone made a request and this is simple enough, so I made it. This script will allow you to use the notes field of a weapon or armor to give the player stat bonuses when they gain a level.
Fixed a bug that occurred when the player had an empty equipment slot...oops...Configuration / UseJust drop the script in the Materials section.
To give a piece of equipment a stat bonus, simply add a line to the Notes section like this:
CODE
[stat mod]stat,num
"stat" = The name of the attribute to raise or decrease. This can be "hp", "mp", "atk", "def", "spi", or "agi", without the quotes.
"num" = The amount by which to increase the specified attribute.
For example, if you wanted a sword to increase the player's attack by two every time they gained a level, you would add this to the notes field of that sword:
CODE
[stat mod]atk,2
If you later want a sword that raises HP 10, attack 2, defense 4, but removed 3 agility points, you would do it like this:
CODE
[stat mod]hp,10
[stat mod]atk,2
[stat mod]def,4
[stat mod]agi,-3
White spaces and case are ignored.
ScriptCODE
# #
# Equipment Stat mods #
# by BigEd781 #
#==============================================================================#
module RPG
class BaseItem
def get_stat_bonuses
bonuses = {}
note.each { |line|
line.downcase!
line.gsub!(' ', '')
if line.include?("[statmod]")
pair = line.gsub("[statmod]", '').split(',')
bonuses[pair[0]] = pair[1].to_i
end
}
return bonuses
end
end
end
class Game_Actor < Game_Battler
alias :eds_old_level_up :level_up
def level_up
eds_old_level_up
equips.compact.each { |equip| apply_equip_stat_bonus(equip) }
end
def apply_equip_stat_bonus(equip)
equip.get_stat_bonuses.each_pair { |key , value|
case key
when "hp" : self.maxhp += value
when "mp" : self.maxmp += value
when "atk" : self.atk += value
when "def" : self.def += value
when "spi" : self.spi += value
when "agi" : self.agi += value
end
}
end
end
CompatibilityThis script will not be compatible with scripts that extend the number of attributes a player has. This can be easily fixed however if you give me the script that you are using. I don't foresee any other problems.