iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> Class Stat Rates, +10% attack for warrior, +10% spirit for mage?
Mithran
post Aug 5 2009, 01:16 AM
Post #1


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




Class Stat Rates v 1.0
by Mithran


Introduction
This script modifies the base statistics of an actor by a certain percent depending on their current class.

Features
- modifies base parameter values by a certain percent based on the current class
- choose to modify either base values to include or exclue equipment
- highly compatible, easily expandable

How to Use
Install on its own script page in the materials section of the script editor above main and below default scripts. Goes below KGC_LimitBreak, if used.

Script
Spoiler:
CODE
# Class Stat Rates
# v 1.0
# by Mithran
# Please do not redistribute without asking!
# Install: Insert in materials section above main and below KGC Limitbreak,
# if used.
# Setup as noted below.

module Mithran
  module ClassStatRates
    
    CLASS_RATES = Hash.new{ Hash.new(100) } # Do not edit this line
    
# = = = = = = = = = = = = = = = = SETUP = = = = = = = = = = = = = = = = = = = =

    INCLUDE_EQUIPMENT = false # change to true if equipment should be included
    # in the calculation for bonus stats

# TEMPLATE --- Copy paste this below.  The square brackets is the class id
# CLASS_RATES[0] <- class id 0 does nothing, change it to what you want
# the values paired up to each parameter are the percentage rates the stats are
# modified by.  100 means the stat is default, no change.

    CLASS_RATES[0] = {
    "maxhp" => 100, # percentage of normal maxhp
    "maxmp" => 100, # percentage of normal maxmp
    "atk" => 100, # percentage of normal atk
    "def" => 100, # percentage of normal def
    "spi" => 100, # percentage of normal spi
    "agi" => 100, # percentage of normal agi
    "res" => 100, # percentage of normal res (for enelvon's resist system)
    "lck" => 100, # percentage of normal lck (for enelvon's luck system)
    "cri" => 100, # amounts above 100 add directly to cri, amounts below subtract
    "eva" => 100, # amounts above 100 add directly to eva, amounts below subtract
    }
# TEMPLATE ---------------------------------------------------------------------
# ADD ADDITIONAL CLASS VALUES BELOW HERE

    # Examples, feel free to delete or change these
    CLASS_RATES[1] = { # class id 1, paladin
    "maxhp" => 105, # 5% bonus to maxhp
    "maxmp" => 110, # 10% bonus to maxmp
    "atk" => 120, # 20% bonus to atk
    "def" => 130, # 30% bonus to def
    "spi" => 50, # base spi is halved
    "agi" => 75, # 75% of normal agi
    "res" => 150, # does nothing without enelvon's resist system
    "lck" => 100, # luck is untouched, and does nothing anyway without enelvon's luck system
    "cri" => 105, # plus 5 cri
    "eva" => 98, # minus 2 eva, wont go below 0
    }

    CLASS_RATES[2] = { # class id 2, warrior
    "atk" => 150, # 50% bonus for atk
    "def" => 50, # but reduce defense by half
    # ommited entires default to (no change)
    }
    
# ADD ADDITIONAL CLASS VALUES ABOVE HERE

    CLASS_RATES.each_value {|v| v.default = 100} # DO NOT EDIT THIS LINE

# = = = = = = = = = = = = = = ADVANCED SETUP = = = = = = = = = = = = = = = = = =
$imported = {} if $imported.nil?

    UNMOD_VALUES = {
    # the code to use get the 'unmodifed' values to create the bonus from
    # base stats - normal version
    "maxhp" => "actor.parameters[0, @level] + @maxhp_plus",
    "maxmp" => "actor.parameters[1, @level] + @maxmp_plus",
    "atk" => "actor.parameters[2, @level] + @atk_plus",
    "def" => "actor.parameters[3, @level] + @def_plus",
    "spi" => "actor.parameters[4, @level] + @spi_plus",
    "agi" => "actor.parameters[5, @level] + @agi_plus",

    # Static bonuses - special cases
    "cri" => "100", # cri parameter - bonus is a static number
    "eva" => "100", # eva parmaeter - bonus is a static number

    # Other stats - user defined stats
    "res" => "actor.res(@level) + @res_plus", # for enelvon's resist system
    "lck" => "actor.lck(@level) + @lck_plus", # for enelvon's luck system
    
    }

    UNMOD_VALUES_LIMITBREAK = { # use these instead if KGC_Limitbreak
    # base stats - KGC Limitbreak version
    "maxhp" => "base_parameter(0) + @maxhp_plus",
    "maxmp" => "base_parameter(1) + @maxmp_plus",
    "atk" => "base_parameter(2) + @atk_plus",
    "def" => "base_parameter(3) + @def_plus",
    "spi" => "base_parameter(4) + @spi_plus",
    "agi" => "base_parameter(5) + @agi_plus",    
    }
    
    UNMOD_VALUES_EQUIPPED = {
    # all stats - equipped versions
# n is the local variable I have assigned below to hold the 'base' value of the
# stat before any modifictions are made.  By default, this is the equipped value
# of the stat
    "maxhp" => "n",
    "maxmp" => "n",
    "atk" => "n",
    "def" => "n",
    "spi" => "n",
    "agi" => "n",
    "res" => "n",
    "lck" => "n",
    }
    
    UNMOD_VALUES.merge!(UNMOD_VALUES_LIMITBREAK) if $imported["LimitBreak"]
    UNMOD_VALUES.merge!(UNMOD_VALUES_EQUIPPED) if INCLUDE_EQUIPMENT

  end
end

# = = = = = = = = = = = = = = = END SETUP = = = = = = = = = = = = = = = = = = =


class Game_Actor
  
# uses an iterator to create an alias for the methods specified in UNMOD_VALUES
  
  Mithran::ClassStatRates::UNMOD_VALUES.each_pair { |k, v|
  methname = (k == "cri" or k == "eva") ? k : "base_#{k}"
  # in the case of 'cri' and 'eva', the method name will be the same as the key
  # value of the hash, otherwise, it will be have 'base_' appended in front of it
  # below - a double quoted string literal construct using %Q( )
  # note that comment lines within the literal are not considered comments for the
  # purposes of constructing the string (and as such will not be green in the editor)
  # they will still be skipped when evaluated
  # the blue #{ } sections below are 'expression substituions'
  # these statements are immeidately evaluated in the context of the current scope
  # and the return value is placed directly into the string, using .to_str if necessary
  aStr = %Q(
  if method_defined?(:#{methname}) && !method_defined?(:#{methname}_mith_classtatrates_autoalias)
    alias :#{methname}_mith_classtatrates_autoalias :#{methname}
  end
    def #{methname}(*args)
      n = #{methname}_mith_classtatrates_autoalias      # get stat value
      u = #{v}       # get 'unmodified value'
      return n if Mithran::ClassStatRates::CLASS_RATES[@class_id]['#{k}'].nil?
      bonus = (u * Mithran::ClassStatRates::CLASS_RATES[@class_id]['#{k}'] / 100.0) - u
      # calculate the bonus (will be negative if the rate was less than 100)
      result = (n + bonus).round # round off the value
      result = 0 if result < 0 && ('#{k}' == "cri" or '#{k}' == "eva")
      # if the value is less than 0, limit it to 0, but only for 'cri' and 'eva'
      # we do not need to limit other 'base' values because they are limited
      # in the main (eg., 'atk' does the limiting for 'base_atk')
      return result.round
    end
  ) # %Q( ) string literal end
  module_eval(aStr) # evaluates the constructed string as code in the context of
  # Game_Actor.  
  } # block end
  
end


FAQ
Q: How do I make it so that equipment is included in the calculation?
A: Change INCLUDE_EQUIPMENT = false to INCLUDE_EQUIPMENT = true.

Q: Did you base this on KGC_ClassDetailSetting?
A: No, but after another request for it and unable to find a translated version of such, I decided to just make my own.

Credit and Thanks
- Mithran

Author's Notes
Feedback is welcome. Please do not redistribute without asking.


--------------------
Go to the top of the page
 
+Quote Post
   
Daxis
post Aug 5 2009, 01:39 AM
Post #2


Current Project is A:MotI
Group Icon


Type: Writer




Hell yeah, perfect man, thanks. works like a charm.


--------------------
The same reason they call it holy water is the same reason they call it holy s***

Apparently, it's not "Caress the one, the never fading raging hard on"

Go to the top of the page
 
+Quote Post
   
MASH_MX
post Aug 5 2009, 02:06 AM
Post #3


"Everyone Is Unique In There Own Defined Way."
Group Icon


Type: Writer
Alignment: Chaotic Good




Very nice work there Mithran. biggrin.gif
You really out did your self on this one.


--------------------
My Projects:
My User bar for the thread is broken click this instead. >.> (Project XeroMX)

My new incoming Community Terraria Server! =)
Other:

Other People and things I support:
Spoiler:


Go to the top of the page
 
+Quote Post
   
i.am.Diro
post Aug 5 2009, 04:36 AM
Post #4


make.it.epic
Group Icon


Type: Designer




Im always excited with your scripts man, very useful. thanks.


--------------------
Go to the top of the page
 
+Quote Post
   
Khaosn95
post Aug 7 2009, 02:25 PM
Post #5


Myrmidon Sex Magic
Group Icon


Type: Writer
Alignment: Lawful Neutral




awsome script.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 30th July 2014 - 08:12 AM

RPGMakerVX.net is an Privacy Policy, Legal.