Jump to content
Sign in to follow this  
Gamesfreak13563

Level Up Item Bonus

Recommended Posts

Item Stats Bonus - v1.1

Gamesfreak13563

Introduction

Allows you to place a tag on weapons that influences a character's stat growth when they level.

 

Features

- Awesome

 


#==============================================================================
#
# â–¼ Gamesfreak13563 - Item Stats Bonus
# -- Last Updated: 2011.12.27
#	If an item with this tag is equipped when an actor levels, it will give bonus levelup stats to the actor
#	on level up.
#
#==============================================================================
#	TO USE:
#	Weapon or Armor tag - <stat: +x bonus>
#	Where STAT is mhp, mmp, atk, def, mdf, mat, agi, or luk, and X is an integer.
#==============================================================================

module GF
 module ITEMBONUS
           DEFAULT_GROWTH ={
   # ParamID => [:param, +set],
                   0 => 0,       # maxhp
                   1 => 0,       # maxmp
                   2 => 0,       # atk
                   3 => 0,       # def
                   4 => 0,       # mat
                   5 => 0,       # mdf
                   6 => 0,       # agi
                   7 => 0        # luk
   } # Do not remove this.
 end #ITEMBONUS
end #GF

#==============================================================================
# â–  Tags
#==============================================================================
module GF
 module ITEMBONUS
 module BASEITEM

   GROWTH_SET = /<(.*):[ ]([\+\-]\d+)[ ](?:BONUS|bonus)>/i

 end # BASEITEM
 end # ITEMBONUS
end # GF

#===========================================================================
# â–  DataManager
#===========================================================================


module DataManager  
   #--------------------------------------------------------------------------
   # â— Loads the database
   #--------------------------------------------------------------------------
   class << self
       alias_method(:gf_itembonus_load_database, :load_database) unless $@
   end
   def self.load_database
       gf_itembonus_load_database
       load_bonus_notetags
   end  
   #--------------------------------------------------------------------------
   # â— Loads the note tags
   #--------------------------------------------------------------------------
   def self.load_bonus_notetags
       groups = [$data_weapons, $data_armors]
       classes = [RPG::Weapon, RPG::Armor]

       for group in groups
           for obj in group
               next if obj.nil?
               obj.load_bonus_notetags if classes.include?(obj.class)
           end
       end
   end
end

#==========================================================================
#  â–   RPG::EquipItem
#==========================================================================

class RPG::EquipItem

 #--------------------------------------------------------------------------
 # public instance variables
 #--------------------------------------------------------------------------
 attr_reader :level_growth

 #--------------------------------------------------------------------------
 # common cache: load_bonus_notetags
 #--------------------------------------------------------------------------
 def load_bonus_notetags
   @level_growth = GF::ITEMBONUS::DEFAULT_GROWTH.clone
   #---
   self.note.split(/[\r\n]+/).each { |line|
         case line
         #---
         when GF::ITEMBONUS::BASEITEM::GROWTH_SET
           case $1.upcase
           when "MAXHP", "MHP", "HP"
                 type = 0
           when "MAXMP", "MMP", "MP", "MAXSP", "MSP", "SP"
                 type = 1
           when "ATK", "ATTACK"
                 type = 2
           when "DEF", "DEFENSE"
                 type = 3
           when "MAT", "MAGIC ATTACK", "INT", "INTELLIGENCE", "SPI", "SPIRIT"
                 type = 4
           when "MDF", "MAGIC DEFENSE", "RES", "RESISTANCE"
                 type = 5
           when "AGI", "AGILITY"
                 type = 6
           when "LUK", "LUCK"
                 type = 7
           else; next
           end
           @level_growth[type] = $2.to_i      
         end
   } # self.note.split
   #---
 end

end # RPG::Enemy


#==========================================================================
#  â–   Game_Actor
#==========================================================================

class Game_Actor < Game_Battler

 def level_up_sum
   @equips.each do |slot|
     next if slot.object.nil?
     item = slot.object

     (0..7).each do |stat|
       add_param(stat, item.level_growth[stat])
     end
   end  
 end


 def level_up
   @level += 1
   level_up_sum
   self.class.learnings.each do |learning|
         learn_skill(learning.skill_id) if learning.level == @level
   end
 end
end

Edited by Gamesfreak13563
  • Like 1

Share this post


Link to post
Share on other sites

This is awesome. I'm definitely going to be using this in my project!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted