Equipment level bonus
Version: 1.0
Author: TDS
Date: August 8, 2011
Version History
- 1.0 08.08.2011 - Public release.
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
- Allows you to make equipment give a bonus based on the level of the character who equips it.
- Allows you to set a cap(Max bonus).
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
Script
#==============================================================================
# ** 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
- Jose moreno for requesting it.
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.