Advertisement
Dekita

crit rates damage

Jan 29th, 2013
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.30 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.0
  3. ★ Perfect Crit Rate™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8. This script simply allows for crit rate modification via states / equipment
  9. it also allows for each actor / enemy to have unique crit rates.
  10.  
  11. ================================================================================
  12. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  13. ================================================================================
  14. 1. You must give credit to "Dekita"
  15. 2. You are NOT allowed to repost this script.(or modified versions)
  16. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  17. 4. You are NOT allowed to use this script for Commercial games.
  18. 5. ENJOY!
  19.  
  20. "FINE PRINT"
  21. By using this script you hereby agree to the above terms and conditions,
  22. if any violation of the above terms occurs "legal action" may be taken.
  23. Not understanding the above terms and conditions does NOT mean that
  24. they do not apply to you.
  25. If you wish to discuss the terms and conditions in further detail you can
  26. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  27.  
  28. ================================================================================
  29. History:
  30. =========
  31. D /M /Y
  32. 22/o1/2o13 - started && finished,
  33.  
  34. ================================================================================
  35. Credit and Thanks to :
  36. =======================
  37.  
  38. ================================================================================
  39. Known Bugs:
  40. ============
  41. N/A
  42.  
  43. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  44. If a new bug is found please contact me at
  45. http://dekitarpg.wordpress.com/
  46.  
  47. ================================================================================
  48. INSTRUCTIONS:
  49. ==============
  50. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  51.  
  52. ================================================================================
  53. Notetags : (actors, enemies, weapons, armors, states)
  54. ==========
  55. <crit rate: X>
  56. Replace X with a float value, e.g 0.5
  57.  
  58. =end #=========================================================================#
  59.  
  60. module Crit_Rate
  61.  
  62. Default_Crit_Rate = 3
  63.  
  64. end #####################
  65. # CUSTOMISATION END #
  66. #####################
  67. #===============================================================================#
  68. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  69. # #
  70. # http://dekitarpg.wordpress.com/ #
  71. # #
  72. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  73. #===============================================================================#
  74. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  75. # YES?\.\. #
  76. # OMG, REALLY? \| #
  77. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  78. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  79. #################################################################################
  80.  
  81. $imported = {} if $imported.nil?
  82. $imported[:Dekita_Crit_Mod] = true
  83.  
  84. #==============================================================================
  85. module DataManager
  86. #==============================================================================
  87.  
  88. class << self
  89. alias :load_crit_notes :load_database
  90. end
  91.  
  92. def self.load_database
  93. load_crit_notes
  94. load__crit_rate
  95. end
  96.  
  97. def self.load__crit_rate
  98. groups = [$data_actors,$data_enemies,$data_weapons,$data_armors,$data_states]
  99. for group in groups
  100. for obj in group
  101. next if obj.nil?
  102. obj.load_notetags__crit_rates
  103. end
  104. end
  105. end
  106.  
  107. end # DataManager
  108.  
  109. #==============================================================================
  110. class RPG::Actor < RPG::BaseItem
  111. #==============================================================================
  112.  
  113. attr_reader :crit_rate_mod
  114.  
  115. def load_notetags__crit_rates
  116. @crit_rate_mod = Crit_Rate::Default_Crit_Rate
  117. self.note.split(/[\r\n]+/).each { |line|
  118. case line
  119. when /<crit rate: (.*)>/i
  120. @crit_rate_mod = $1.to_f
  121. end
  122. } # self.note.split
  123. end
  124.  
  125. end # RPG::EquipItem
  126.  
  127. #==============================================================================
  128. class RPG::Enemy < RPG::BaseItem
  129. #==============================================================================
  130.  
  131. attr_reader :crit_rate_mod
  132.  
  133. def load_notetags__crit_rates
  134. @crit_rate_mod = Crit_Rate::Default_Crit_Rate
  135. self.note.split(/[\r\n]+/).each { |line|
  136. case line
  137. when /<crit rate: (.*)>/i
  138. @crit_rate_mod = $1.to_f
  139. end
  140. } # self.note.split
  141. end
  142.  
  143. end # RPG::EquipItem
  144.  
  145. #==============================================================================
  146. class RPG::EquipItem < RPG::BaseItem
  147. #==============================================================================
  148.  
  149. attr_reader :crit_rate_mod
  150.  
  151. def load_notetags__crit_rates
  152. @crit_rate_mod = 0.0
  153. self.note.split(/[\r\n]+/).each { |line|
  154. case line
  155. when /<crit rate: (.*)>/i
  156. @crit_rate_mod += $1.to_f
  157. end
  158. } # self.note.split
  159. end
  160.  
  161. end # RPG::EquipItem
  162.  
  163. #==============================================================================
  164. class RPG::State < RPG::BaseItem
  165. #==============================================================================
  166.  
  167. attr_reader :crit_rate_mod
  168.  
  169. def load_notetags__crit_rates
  170. @crit_rate_mod = 0.0
  171. self.note.split(/[\r\n]+/).each { |line|
  172. case line
  173. when /<crit rate: (.*)>/i
  174. @crit_rate_mod += $1.to_f
  175. end
  176. } # self.note.split
  177. end
  178.  
  179. end # RPG::EquipItem
  180.  
  181. #==============================================================================
  182. class Game_Battler < Game_BattlerBase
  183. #==============================================================================
  184.  
  185. def apply_critical(damage)
  186. damage * self.crit_rate
  187. end
  188.  
  189. end
  190.  
  191. #==============================================================================
  192. class Game_Actor < Game_Battler
  193. #==============================================================================
  194.  
  195. def crit_rate
  196. val = actor.crit_rate_mod
  197. val -= state_mod_crit
  198. val -= equip_mod_crit
  199. val <= 1.0 ? val = 1.0 : val = val
  200. end
  201.  
  202. def state_mod_crit
  203. rlval = 0.0
  204. rlval += states.compact.inject(0) {|r, i| r += i.crit_rate_mod rescue 0 }
  205. return rlval
  206. end
  207.  
  208. def equip_mod_crit
  209. rlval = 0.0
  210. rlval += equips.compact.inject(0) {|r, i| r += i.crit_rate_mod rescue 0 }
  211. return rlval
  212. end
  213.  
  214. end # class Game_Actor < Game_Battler
  215.  
  216. #==============================================================================
  217. class Game_Enemy < Game_Battler
  218. #==============================================================================
  219.  
  220. def crit_rate
  221. val = enemy.crit_rate_mod
  222. val -= state_mod_crit
  223. val <= 1.0 ? val = 1.0 : val = val
  224. end
  225.  
  226. def state_mod_crit
  227. rlval = 0.0
  228. rlval += states.compact.inject(0) {|r, i| r += i.crit_rate_mod rescue 0 }
  229. return rlval
  230. end
  231.  
  232. end # class Game_Enemy < Game_Battler
  233.  
  234. #===============================================================================#
  235. # - SCRIPT END - #
  236. #===============================================================================#
  237. # http://dekitarpg.wordpress.com/ #
  238. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement