Vlue

Interesting Stats and Formulas

Apr 5th, 2014
1,244
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #--# Stats and Formulas v 1.0
  2. #
  3. # You know what LUK does? Just affect the chance of a state being applied. I
  4. #  thought it changed Critical hit or something. I didn't like that, so here
  5. #  this is, any easy way to change the formulas of many different parts of
  6. #  battle, as well as giving stats something more to do.
  7. #
  8. # Usage: Plug and play, customize as needed.
  9. #
  10. #------#
  11. #-- Script by: V.M of D.T
  12. #
  13. #- Questions or comments can be:
  14. #    given by email: sumptuaryspade@live.ca
  15. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  16. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  17. #
  18. #--- Free to use in any project, commercial or non-commercial, with credit given
  19. #--Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  20.  
  21. module STATS
  22.   #SPEED FORMULA use subject for stats. I.E subject.agi for agility
  23.   #ESCAPE FORMULA has no references to actors or enemies
  24.   #All the other formulas use user and self. User is the one using the ability,
  25.   #  while self is the one being hit. I.E. self.agi - user.agi
  26.  
  27.   #The speed formula determines turn order in battle
  28.   #The higher the value, the sooner they act
  29.   SPEED_FORMULA = "subject.agi + rand(5 + subject.agi / 4)"
  30.  
  31.   #State chance is the change in chance to apply a state
  32.   #The final chance will be the item's chance * STATE_CHANCE
  33.   STATE_CHANCE = "[1.0 + (user.luk - luk) * 0.001, 0.0].max"
  34.  
  35.   #The following formulas occur when a random number between 0.0 and 1.0
  36.   #  is less than ***_FORMULA
  37.   #The formula for being hit with an attack.
  38.   HIT_FORMULA = "user.hit"
  39.   #The formula for evading an attack
  40.   EVA_FORMULA = "self.eva"
  41.   #Same as above, except for magical attacks instead of physical.
  42.   MEV_FORMULA = "self.mev"
  43.   #The formula for the chance for an attack to be a critical hit
  44.   CRI_FORMULA = "user.cri * (1 - self.cev)"
  45.   #The formula for chance to counter attack
  46.   CNT_FORMULA = "self.cnt"
  47.   #The formula for chance to reflect magic
  48.   MRF_FORMULA = "self.mrf"
  49.  
  50.   #Whichever group (enemies or allies) with the greater agility recieve
  51.   # the following percentages for Preemptive and Surprise attacks
  52.   PREEMPTIVE_CHANCE = 5
  53.   SURPRISE_CHANCE = 3
  54.  
  55.   #The formula for initial chance to escape.
  56.   ESCAPE_FORMULA = "1.5 - 1.0 * $game_troop.agi / $game_party.agi"
  57.  
  58.   #Here is where you can make stats add points to secondary stats.
  59.   # Each point in a stat adds that many points to the secondary stat.
  60.   # Values for hp and mp are whole numbers, while everything else is
  61.   #  float values (i.e. :hit => 0.001 for 0.1% chance to hit per point)
  62.   #Options are :hp,  :mp,  :hit, :eva, :cri, :cev, :mev, :mrf, :cnt
  63.   #      :hrg, :mrg, :trg, :tgr, :grd, :rec, :pha, :mcr, :tcr, :pdr
  64.   #      :mdr, :fdr, :exr
  65.   ATK = {:cnt => 0.0005}
  66.   DEF = {:hp => 5, :trg => 0.001}
  67.   MAT = {:mp => 1, :mev => 0.0005}
  68.   MDF = {:mrg => 0.0001, }
  69.   AGI = {:eva => 0.0005, :hit => 0.0005}
  70.   LUK = {:cri => 0.0005, :cev => 0.0005}
  71.  
  72.   def self.all_bonuses
  73.     [ATK,DEF,MAT,MDF,AGI,LUK]
  74.   end
  75. end
  76.  
  77. class Game_Battler
  78.   def param_bonus(param_id)
  79.     return 0 if param_id > 1
  80.     param_id == 0 ? sym = :hp : sym = :mp
  81.     bonus = 0
  82.     iter = 1
  83.     STATS.all_bonuses.each do |hash|
  84.       iter += 1
  85.       next unless hash[sym]
  86.       bonus += hash[sym] * param(iter)
  87.     end
  88.     bonus
  89.   end
  90.   def xparam_bonus(param_id)
  91.     sym = [:hit,:eva,:cri,:cev,:mev,:mrf,:cnt,:hrg,:mrg,:trg][param_id]
  92.     bonus = 0
  93.     iter = 1
  94.     STATS.all_bonuses.each do |hash|
  95.       iter += 1
  96.       next unless hash[sym]
  97.       bonus += hash[sym] * param(iter)
  98.     end
  99.     bonus
  100.   end
  101.   def sparam_bonus(param_id)
  102.     sym = [:tgr,:grd,:rec,:pha,:mcr,:tcr,:pdr,:mdr,:fdr,:exr][param_id]
  103.     bonus = 0
  104.     iter = 1
  105.     STATS.all_bonuses.each do |hash|
  106.       iter += 1
  107.       next unless hash[sym]
  108.       bonus += hash[sym] * param(iter)
  109.     end
  110.     bonus
  111.   end
  112.   def param(param_id)
  113.     value = param_base(param_id) + param_plus(param_id) + param_bonus(param_id)
  114.     value *= param_rate(param_id) * param_buff_rate(param_id)
  115.     [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  116.   end
  117.   def xparam(xparam_id)
  118.     features_sum(FEATURE_XPARAM, xparam_id) + xparam_bonus(xparam_id)
  119.   end
  120.   def sparam(sparam_id)
  121.     features_pi(FEATURE_SPARAM, sparam_id) + sparam_bonus(sparam_id)
  122.   end
  123.   def luk_effect_rate(user)
  124.     eval(STATS::STATE_CHANCE)
  125.   end
  126.   def item_hit(user, item)
  127.     rate = item.success_rate * 0.01
  128.     rate *= eval(STATS::HIT_FORMULA) if item.physical?  
  129.     return rate                        
  130.   end
  131.   def item_eva(user, item)
  132.     return eval(STATS::EVA_FORMULA) if item.physical?
  133.     return eval(STATS::MEV_FORMULA) if item.magical?
  134.     return 0
  135.   end
  136.   def item_cri(user, item)
  137.     return eval(STATS::CRI_FORMULA) if item.damage.critical
  138.     return 0
  139.   end
  140.   def item_cnt(user, item)
  141.     return 0 unless item.physical?          
  142.     return 0 unless opposite?(user)        
  143.     return eval(STATS::CNT_FORMULA)                            
  144.   end
  145.   def item_mrf(user, item)
  146.     return eval(STATS::MRF_FORMULA) if item.magical?    
  147.     return 0
  148.   end
  149.   def rate_preemptive(troop_agi)
  150.     high = STATS::PREEMPTIVE_CHANCE;low = STATS::SURPRISE_CHANCE
  151.     (agi >= troop_agi ? high*0.01 : low*0.01) * (raise_preemptive? ? 4 : 1)
  152.   end
  153.   def rate_surprise(troop_agi)
  154.     high = STATS::PREEMPTIVE_CHANCE;low = STATS::SURPRISE_CHANCE
  155.     cancel_surprise? ? 0 : (agi >= troop_agi ? low*0.01 : high*0.01)
  156.   end
  157. end
  158.  
  159. class Game_Action
  160.   def speed
  161.     speed = eval(STATS::SPEED_FORMULA)
  162.     speed += item.speed if item
  163.     speed += subject.atk_speed if attack?
  164.     speed
  165.   end
  166. end
  167.  
  168. module BattleManager
  169.   def self.make_escape_ratio
  170.     @escape_ratio = eval(STATS::ESCAPE_FORMULA)
  171.   end
  172. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×