The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: TDS on August 08, 2011, 07:11:11 AM

Title: Equipment level bonus
Post by: TDS on August 08, 2011, 07:11:11 AM
Equipment level bonus
Version: 1.0
Author: TDS
Date: August 8, 2011

Version History



Planned Future Versions

Add new attributes if asked.

Description


This script makes equipment give a bonus based on the character's level. If the bonus is 5 and the characters level is 5 then the bonus would be 25.

Features


Instructions

To make equipment add a bonus based on it's level, add this to it's note box.

Code: [Select]
ATK_LV_BONUS: BONUS MAX
DEF_LV_BONUS: BONUS MAX
SPI_LV_BONUS: BONUS MAX
AGI_LV_BONUS: BONUS MAX

BONUS = Bonus multiplier.
MAX   = Max bonus. (Optional)

Example:

Code: [Select]
ATK_LV_BONUS: 5 30
DEF_LV_BONUS: 2

Script


Code: [Select]
#==============================================================================
# ** TDS Equipment Level Bonus
#    Ver: 1.0
#------------------------------------------------------------------------------
#  * Description:
#  Equipment gives bonuses based on the characters level.
#------------------------------------------------------------------------------
#  * Features:
#  Allows equipment to have bonuses based on levels.
#  Allows for bonuses to be "capped" at a maximun value.
#------------------------------------------------------------------------------
#  * Instructions:
#  To make equipment add a bonus based on it's level, add this to it's note box.
#
#   ATK_LV_BONUS: BONUS MAX
#   DEF_LV_BONUS: BONUS MAX
#   SPI_LV_BONUS: BONUS MAX
#   AGI_LV_BONUS: BONUS MAX
#
#   BONUS = Bonus multiplier.
#   MAX   = Max bonus. (Optional)
#
#   Example:
#
#   ATK_LV_BONUS: 5 30
#   DEF_LV_BONUS: 2
#------------------------------------------------------------------------------
#  * Notes:
#  None.
#------------------------------------------------------------------------------
#  * New Methods:
#  RPG::BaseItem:
#  - level_attribute_bonus(level, attribute)
#    ^ Method used to determine attribute bonus total.
#
#  Game_Actor:
#  - attribute_level_bonus(attribute)   
#    ^ Used to determine the attribute bonus for the actor.
#------------------------------------------------------------------------------
#  * Aliased Methods:
#  Game_Actor:
#  - base_atk
#  - base_def
#  - base_spi
#  - base_agi
#    ^ Above methods aliased to add return equipment bonuses along normal bonus.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_equipment_level_bonus_game_actor_base_atk    base_atk   unless $@
  alias tds_equipment_level_bonus_game_actor_base_def    base_def   unless $@
  alias tds_equipment_level_bonus_game_actor_base_spi    base_spi   unless $@
  alias tds_equipment_level_bonus_game_actor_base_agi    base_agi   unless $@
  #--------------------------------------------------------------------------
  # * Get Basic Defense
  #     attribute : attribute name
  #--------------------------------------------------------------------------
  def attribute_level_bonus(attribute)   
    # Set Initial Bonus
    bonus = 0
    # Go Through Equipment and add up attribute bonus
    equips.compact.each {|equip| bonus += equip.level_attribute_bonus(@level, attribute)}   
    # Return Attribute Bonus
    return bonus
  end 
  #--------------------------------------------------------------------------
  # * Get Basic Attack
  #--------------------------------------------------------------------------
  def base_atk
    # Return Base Plus Attribute Level Bonus
    return tds_equipment_level_bonus_game_actor_base_atk + attribute_level_bonus("ATK")
  end
  #--------------------------------------------------------------------------
  # * Get Basic Defense
  #--------------------------------------------------------------------------
  def base_def
    # Return Base Plus Attribute Bonus
    return tds_equipment_level_bonus_game_actor_base_def + attribute_level_bonus("DEF")
  end
  #--------------------------------------------------------------------------
  # * Get Basic Spirit
  #--------------------------------------------------------------------------
  def base_spi     
    # Return Base Plus Attribute Bonus
    return tds_equipment_level_bonus_game_actor_base_spi + attribute_level_bonus("SPI")
  end
  #--------------------------------------------------------------------------
  # * Get Basic Agility
  #--------------------------------------------------------------------------
  def base_agi
    # Return Base Plus Attribute Bonus
    return tds_equipment_level_bonus_game_actor_base_agi + attribute_level_bonus("AGI")
  end
end


#==============================================================================
# ** RPG::BaseItem
#------------------------------------------------------------------------------
# This module handles Item, Weapons and Armor information.
#==============================================================================

module RPG
    class BaseItem
    #--------------------------------------------------------------------------
    # * Equipment Attribute Bonus
    #     level     : level multiplier
    #     attribute : attribute for bonus
    #--------------------------------------------------------------------------   
    def level_attribute_bonus(level, attribute)
      self.note[/#{attribute}_LV_BONUS: ([0-9]+[\s]?[0-9]*)/]     
      # Make Bonus and Cap Array
      bonus = $1.nil? ? nil : $1.split.collect {|b| b.to_i }
      # If Bonus is not nil
      if bonus != nil
        # Get Max Bonus Limit (If nil set to infinite)
        max = bonus.at(1).nil? ? (1.0 / 0) : bonus.at(1)       
        # Return Bonus
        return [bonus.at(0) * level, max].min
      end
      # Return 0 by default
      return 0
    end 
  end 
end

Credit



Thanks


Support


On this topic

Known Compatibility Issues

There could be some compatibility issues with custom stats.

Author's Notes


If anyone has any ideas as to what to add let me know, I was thinking stats based on class but it seems people I knew didn't like that.

Restrictions

Only for use in non-commercial games.
Title: Re: Equipment level bonus
Post by: Adon on September 17, 2011, 06:55:36 PM
This is awesome. But I have a question, you put in the data with no <>'s or /'s? Are you sure it will work?
Also, is there a way to make it give a bonus by a set amount instead of a bonus?
Title: Re: Equipment level bonus
Post by: pacdiggity on September 17, 2011, 09:20:10 PM
Tags don't need those things to work.
Title: Re: Equipment level bonus
Post by: Adon on September 17, 2011, 10:32:40 PM
Thanks Pacman. :)
Title: Re: Equipment level bonus
Post by: EvilM00s on February 23, 2014, 06:37:56 AM
I'm assuming there would be issues with, say, YEM's new stats (res and dex.) If it's not too much touble, how would you modify the script to do so? Is it as simple as adding in those expressions and aliases?