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.
Equipment level bonus

0 Members and 1 Guest are viewing this topic.

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
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.

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


  • TDS

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.

***
Rep:
Level 69
RESIDENT ADONKADONK
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?
« Last Edit: September 17, 2011, 06:58:36 PM by Adon »

I'm back.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Zero to Hero2014 Best IRC Quote2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Tags don't need those things to work.
it's like a metaphor or something i don't know

***
Rep:
Level 69
RESIDENT ADONKADONK
Thanks Pacman. :)

I'm back.

*
RMRK's dad
Rep:
Level 86
You know, I think its all gonna be okay.
For going the distance for a balanced breakfast.Project of the Month winner for June 2009For being a noted contributor to the RMRK Wiki2013 Best WriterSilver Writing ReviewerSecret Santa 2013 Participant
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?
:tinysmile: