Advertisement
Dekita

perfect attack and defence levels

Sep 17th, 2012
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.00 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.0
  3. ★ Perfect Attack and Defence Levels™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8. This script is a replica of a feature from an MMORPG game called Pwi (perfect
  9. world international) called attack and defence levels.
  10. This basically gives you two new stats called attack level and defence level.
  11. For each 1 attack level you have above your opponents defence level you deal
  12. 1% more damage,
  13. For each 1 defence level you have above your opponents attack level you receive
  14. 1% less damage,
  15. If you have 100 defence level and opponent has no attack level NO damage will
  16. be received.
  17.  
  18. NOTE: for now this modification acts as an elemental weakness.
  19.  
  20. ================================================================================
  21. TERMS OF USE:
  22. ==============
  23.  
  24. 1. You MUST give credit to Dekita.
  25.  
  26. 2. This script is for NON-Commercial use ONLY!*
  27.  
  28. 3. You CANNOT give credit to yourself for Re-posting this script
  29. or Posting a modified version.*
  30.  
  31. 4. Do not Re-Distribute/Re-Post this script.
  32.  
  33. 5. You are NOT allowed to convert this script to any other engine,
  34. E.G converting it from RGSS3 into RGSS2.*
  35.  
  36. 6. ENJOY!
  37.  
  38. -------------------------------------------------------------------------------
  39. * = Unless permissions are given by Dekita.
  40. http://dekitarpg.wordpress.com/
  41.  
  42. ================================================================================
  43. History:
  44. =========
  45. D /M /Y
  46. 15/09/2o12 - improved methods,
  47. 13/09/2o12 - Finished atl & dfl,
  48. 12/09/2o12 - Started Script,
  49. ================================================================================
  50. Credit and Thanks to :
  51. =======================
  52. N/A
  53.  
  54. ================================================================================
  55. Known Bugs:
  56. ============
  57. N/A
  58.  
  59. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  60. If a new bug is found please contact me at
  61. http://dekitarpg.wordpress.com/
  62.  
  63. ================================================================================
  64. INSTRUCTIONS:
  65. ==============
  66. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  67.  
  68. ================================================================================
  69. Script Calls:
  70. ==============
  71. inc_atl(actor_id, value)
  72. inc_dfl(actor_id, value)
  73.  
  74. replace actor_id with the id number of the actor (found in the database)
  75. replace value with the amount you want the stat to increase(can be negative).
  76.  
  77. e.g
  78. inc_atl(1, 10) < This will increase actor 1's atl by 10
  79. inc_dfl(2, 15) < This will increase actor 2's dfl by 15
  80.  
  81. ================================================================================
  82. NoteTags:
  83. ==========
  84. <atl: X>
  85. <dfl: X>
  86.  
  87. Place these notetags into weapon or armor noteboxes to increase actors stats by
  88. X amount of points when the item is equipped,
  89.  
  90. Place these notetags into enemy noteboxes to increase the enemys stats by
  91. X amount of points.
  92.  
  93. Replace X with a value, e.g <atl: 5> will increase attack level by 5
  94.  
  95. --------------------------------------------------------------------------------
  96. <no atl mod>
  97. <no dfl mod>
  98.  
  99. place these notetags into skill and item noteboxes if you DO NOT want to include
  100. attack and defence levels when that skill/item is used ^_^
  101.  
  102. ================================================================================
  103. Other:
  104. =======
  105. you can use attack and defence level in your skill formulas if you want
  106. by using
  107. a.atl a.dfl b.atl b.dfl
  108.  
  109. .atl will return the value of a/b attack level e.g 50
  110. .dfl will return the value of a/b defence level e.g 50
  111.  
  112. =end #==========================================================================#
  113. module DPB ; module ATLANDDFL
  114. #######################
  115. # CUSTOMISATION BEGIN #
  116. #######################
  117.  
  118.  
  119. # The vocab for your nice new damage modification stats.
  120.  
  121. ATL_VOCAB = "Attack Level" # atl
  122.  
  123. DFL_VOCAB = "Defence Level" # dfl
  124.  
  125.  
  126. #####################
  127. # CUSTOMISATION END #
  128. end ; end # module #####################
  129. #===============================================================================#
  130. # http://dekitarpg.wordpress.com/
  131. #===============================================================================#
  132. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  133. # YES?\.\. #
  134. # OMG, REALLY? #
  135. # WELL SLAP MY FACE AND CALL ME A DRAGON.\..\.. #
  136. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  137. #===============================================================================#
  138. #================================================================================
  139. # Import:
  140. #========
  141. $imported = {} if $imported.nil?
  142. $imported["DPB-ATLANDDFL"] = true
  143.  
  144. #==============================================================================
  145. module Vocab
  146. #==============================================================================
  147.  
  148. def self.atl ; return DPB::ATLANDDFL::ATL_VOCAB ; end
  149.  
  150. def self.dfl ; return DPB::ATLANDDFL::DFL_VOCAB ; end
  151.  
  152. end # Vocab
  153.  
  154. module DPB ; module REGEXP ; module EQUIPITEM
  155.  
  156. INC_ATL = /<atl: (.*)>/i
  157. INC_DFL = /<dfl: (.*)>/i
  158.  
  159. end # EQUIPITEM
  160. module USEABLEITEMDAMAGE
  161.  
  162. EXCLUDE_ATL = /<no atl mod>/i
  163. EXCLUDE_DFL = /<no dfl mod>/i
  164.  
  165. end ; end ; end # USEABLEITEMDAMAGE ; REGEXP ; DPB
  166.  
  167. #==============================================================================
  168. module DataManager
  169. #==============================================================================
  170.  
  171. class <<self; alias load_database_ATL_DFL load_database; end
  172. def self.load_database
  173. load_database_ATL_DFL
  174. load_notetags_ATL_DFL
  175. end
  176.  
  177. def self.load_notetags_ATL_DFL
  178. groups = [$data_weapons, $data_armors, $data_enemies]
  179. for group in groups
  180. for obj in group
  181. next if obj.nil?
  182. obj.load_notetags_ATL_DFL
  183. end
  184. end
  185. end
  186.  
  187. end # DataManager
  188.  
  189. #==============================================================================
  190. class RPG::EquipItem < RPG::BaseItem
  191. #==============================================================================
  192.  
  193. attr_accessor :dpbzformulazS
  194.  
  195. def load_notetags_ATL_DFL
  196. @dpbzformulazS = [0] * 2
  197. self.note.split(/[\r\n]+/).each { |line|
  198. case line
  199. when DPB::REGEXP::EQUIPITEM::INC_ATL
  200. @dpbzformulazS[0] += $1.to_i
  201. when DPB::REGEXP::EQUIPITEM::INC_DFL
  202. @dpbzformulazS[1] += $1.to_i
  203. end
  204. } # self.note.split
  205. end
  206.  
  207. end # RPG::EquipItem
  208.  
  209. #==============================================================================
  210. class RPG::Enemy < RPG::BaseItem
  211. #==============================================================================
  212.  
  213. attr_accessor :dpbzformulazS
  214.  
  215. def load_notetags_ATL_DFL
  216. @dpbzformulazS = [0] * 2
  217. self.note.split(/[\r\n]+/).each { |line|
  218. case line
  219. when DPB::REGEXP::EQUIPITEM::INC_ATL
  220. @dpbzformulazS[0] += $1.to_i
  221. when DPB::REGEXP::EQUIPITEM::INC_DFL
  222. @dpbzformulazS[1] += $1.to_i
  223. end
  224. } # self.note.split
  225. end
  226.  
  227. end # RPG::Enemy
  228.  
  229. #==============================================================================
  230. class Game_BattlerBase
  231. #==============================================================================
  232.  
  233. alias dpb_atlanddfl_init initialize
  234. def initialize(*args, &block)
  235. clear_dpbzformulaz_plus
  236. dpb_atlanddfl_init(*args, &block)
  237. end
  238.  
  239. def atl; dpbzformulaz(0); end
  240. def dfl; dpbzformulaz(1); end
  241.  
  242. def dpbzformulaz(dpbzformulaz_id)
  243. (features_sum(FEATURE_PARAM, dpbzformulaz_id) + dpbzformulaz_plus(dpbzformulaz_id))
  244. end
  245.  
  246. def dpbzformulaz_plus(dpbzformulaz_id)
  247. @dpbzformulaz_plus[dpbzformulaz_id]
  248. end
  249.  
  250. def clear_dpbzformulaz_plus
  251. @dpbzformulaz_plus = [0] * 2
  252. end
  253.  
  254. def add_dpbzformulaz(dpbzformulaz_id, value)
  255. @dpbzformulaz_plus[dpbzformulaz_id] += value
  256. refresh
  257. end
  258.  
  259. end # Game_BattlerBase
  260.  
  261. #==============================================================================
  262. class Game_Battler < Game_BattlerBase
  263. #==============================================================================
  264.  
  265. alias atlanddfl_item_element_rate item_element_rate
  266. def item_element_rate(user, item)
  267. if item.note =~ DPB::REGEXP::USEABLEITEMDAMAGE::EXCLUDE_ATL
  268. atlval = 1 ; else ; atlval = ((100 + user.atl) * 0.01) ; end # if
  269. if item.note =~ DPB::REGEXP::USEABLEITEMDAMAGE::EXCLUDE_DFL
  270. dflval = 1 ; else ; dflval = (1.0 - (dfl * 0.01)) ; end # if
  271. atlanddfl_item_element_rate(user, item) * atlval * dflval
  272. end
  273.  
  274. end # Game_Battler
  275.  
  276. #==============================================================================
  277. class Game_Actor < Game_Battler
  278. #==============================================================================
  279.  
  280. alias dpbzatlanddflGAsetup setup
  281. def setup(actor_id)
  282. dpbzatlanddflGAsetup(actor_id)
  283. clear_dpbzformulaz_plus
  284. end
  285.  
  286. alias game_actor_atlanddfl_formulaz_plus dpbzformulaz_plus
  287. def dpbzformulaz_plus(dpbzformulaz_id)
  288. atlndfl = game_actor_atlanddfl_formulaz_plus(dpbzformulaz_id)
  289. atlndfl += dpbz_atlanddfl_rate(dpbzformulaz_id)
  290. return atlndfl
  291. end
  292.  
  293. def dpbz_atlanddfl_rate(dpbzformulaz_id)
  294. atlndflrate = 0.0
  295. atlndflrate += equips.compact.inject(0) {|r, i|
  296. r += i.dpbzformulazS[dpbzformulaz_id] rescue 0 }
  297. return atlndflrate
  298. end
  299.  
  300. end # Game_Actor
  301.  
  302. #==============================================================================
  303. class Game_Enemy < Game_Battler
  304. #==============================================================================
  305.  
  306. alias game_enemy_formulaz_plus_atlanddfl dpbzformulaz_plus
  307. def dpbzformulaz_plus(dpbzformulaz_id)
  308. atlndfl = game_enemy_formulaz_plus_atlanddfl(dpbzformulaz_id)
  309. atlndfl += enemy.dpbzformulazS[dpbzformulaz_id]
  310. return atlndfl
  311. end
  312.  
  313. end # Game_Enemy
  314.  
  315. #==============================================================================
  316. class Game_Interpreter
  317. #==============================================================================
  318.  
  319. def inc_atl(actor_id, value)
  320. actor = $game_actors[actor_id]
  321. return if actor == nil
  322. actor.add_dpbzformulaz(0, value)
  323. end
  324.  
  325. def inc_dfl(actor_id, value)
  326. actor = $game_actors[actor_id]
  327. return if actor == nil
  328. actor.add_dpbzformulaz(1, value)
  329. end
  330.  
  331. end# Game_Interpreter
  332.  
  333. #===============================================================================#
  334. # - SCRIPT END - #
  335. #===============================================================================#
  336. # http://dekitarpg.wordpress.com/ #
  337. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement