Advertisement
Dekita

perfect attack and defence levels v1.1

Sep 20th, 2012
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.35 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.1
  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. ================================================================================
  19. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  20. ================================================================================
  21. 1. You must give credit to "Dekita"
  22. 2. You are NOT allowed to repost this script.(or modified versions)
  23. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  24. 4. You are NOT allowed to use this script for Commercial games.
  25. 5. ENJOY!
  26.  
  27. "FINE PRINT"
  28. By using this script you hereby agree to the above terms and conditions,
  29. if any violation of the above terms occurs "legal action" may be taken.
  30. Not understanding the above terms and conditions does NOT mean that
  31. they do not apply to you.
  32. If you wish to discuss the terms and conditions in further detail you can
  33. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  34.  
  35. ================================================================================
  36. History:
  37. =========
  38. D /M /Y
  39. 19/09/2o12 - Added atl/dfl state mods,
  40. improved methods,
  41. 17/09/2o12 - improved m_d_v method,
  42. 15/09/2o12 - improved methods,
  43. 13/09/2o12 - Finished atl & dfl,
  44. 12/09/2o12 - Started Script,
  45. ================================================================================
  46. Credit and Thanks to :
  47. =======================
  48. ¥ami - for helping me alias make_damage_value the way i needed ^_^
  49.  
  50. ================================================================================
  51. Known Bugs:
  52. ============
  53. N/A
  54.  
  55. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  56. If a new bug is found please contact me at
  57. http://dekitarpg.wordpress.com/
  58.  
  59. ================================================================================
  60. INSTRUCTIONS:
  61. ==============
  62. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  63.  
  64. ================================================================================
  65. Script Calls:
  66. ==============
  67. inc_atl(actor_id, value)
  68. inc_dfl(actor_id, value)
  69.  
  70. replace actor_id with the id number of the actor (found in the database)
  71. replace value with the amount you want the stat to increase(can be negative).
  72.  
  73. e.g
  74. inc_atl(1, 10) < This will increase actor 1's atl by 10
  75. inc_dfl(2, 15) < This will increase actor 2's dfl by 15
  76.  
  77. ================================================================================
  78. NoteTags:
  79. ==========
  80. <atl: X>
  81. <dfl: X>
  82.  
  83. Place these notetags into weapon or armor noteboxes to increase actors stats by
  84. X amount of points when the item is equipped,
  85.  
  86. Place these notetags into state noteboxes to increase stats by X amount
  87. of points when state is inflicted.
  88.  
  89. Place these notetags into enemy noteboxes to increase the enemys stats by
  90. X amount of points.
  91.  
  92. Replace X with a value, e.g <atl: 5> will increase attack level by 5
  93.  
  94. --------------------------------------------------------------------------------
  95. <no atl mod>
  96. <no dfl mod>
  97.  
  98. place these notetags into skill and item noteboxes if you DO NOT want to include
  99. attack and defence levels when that skill/item is used ^_^
  100.  
  101. ================================================================================
  102. Skill Formula's:
  103. =================
  104. you can use attack and defence level in your skill formulas if you want
  105. by using
  106. a.atl a.dfl b.atl b.dfl
  107.  
  108. .atl will return the value of a/b attack level e.g 50
  109. .dfl will return the value of a/b defence level e.g 50
  110.  
  111. ================================================================================
  112. Conditional Branch:
  113. ====================
  114. you can use the script option in conditional branches to check actors
  115. attack and defence levels, simply put either
  116.  
  117. $game_actors[x].stat == y
  118. $game_party.members[x].stat == y
  119.  
  120. replace x with actor id and replace y with a value
  121. replace "stat" with either atl or dfl, examples below
  122.  
  123. $game_actors[1].atl == 30
  124. this will check if actor id [1] has atl(attack level) equal to 30
  125.  
  126. $game_party.members[0].dfl == 30
  127. this will check if the partys member [0] (0 is the party leader) has dfl
  128. (defence level) equal to 30
  129.  
  130. you can also replace "==" with either
  131. "<=" (below/equal to) or
  132. ">=" (greater than/equal to)
  133.  
  134. =end #==========================================================================#
  135. module DPB ; module ATLANDDFL
  136. #######################
  137. # CUSTOMISATION BEGIN #
  138. #######################
  139.  
  140. # The vocab for your nice new damage modification stats.
  141. ATL_VOCAB = "Attack Level" # atl
  142.  
  143. DFL_VOCAB = "Defence Level" # dfl
  144.  
  145. # set this to true for optimize equipments to include atl and dfl
  146. USE_OPTIMIZE_MOD = true
  147.  
  148.  
  149. # NOTETAG CUSTOMISATION, only change these if you have to for
  150. # compatability reasons.
  151. ATL_NOTETAG = /<atl: (.*)>/i
  152.  
  153. NO_ATL_NOTETAG = /<no atl mod>/i
  154.  
  155. DFL_NOTETAG = /<dfl: (.*)>/i
  156.  
  157. NO_DFL_NOTETAG = /<no dfl mod>/i
  158. #####################
  159. # CUSTOMISATION END #
  160. end ; end # module #####################
  161. #===============================================================================#
  162. # http://dekitarpg.wordpress.com/
  163. #===============================================================================#
  164. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  165. # YES?\.\. #
  166. # OMG, REALLY? #
  167. # WELL SLAP MY FACE AND CALL ME A DRAGON.\..\.. #
  168. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  169. #===============================================================================#
  170. #================================================================================
  171. # Import:
  172. #========
  173. $imported = {} if $imported.nil?
  174. $imported["DPB-ATLANDDFL"] = true
  175.  
  176. #==============================================================================
  177. module Vocab
  178. #==============================================================================
  179.  
  180. def self.atl ; return DPB::ATLANDDFL::ATL_VOCAB ; end
  181.  
  182. def self.dfl ; return DPB::ATLANDDFL::DFL_VOCAB ; end
  183.  
  184. end # Vocab
  185.  
  186. module DPB ; module REGEXP ; module EQUIPITEM
  187.  
  188. INC_ATL = DPB::ATLANDDFL::ATL_NOTETAG
  189. INC_DFL = DPB::ATLANDDFL::DFL_NOTETAG
  190.  
  191. end # EQUIPITEM
  192. module USEABLEITEMDAMAGE
  193.  
  194. EXCLUDE_ATL = DPB::ATLANDDFL::NO_ATL_NOTETAG
  195. EXCLUDE_DFL = DPB::ATLANDDFL::NO_DFL_NOTETAG
  196.  
  197. end ; end ; end # USEABLEITEMDAMAGE ; REGEXP ; DPB
  198.  
  199. #==============================================================================
  200. module DataManager
  201. #==============================================================================
  202.  
  203. class <<self; alias load_database_ATL_DFL load_database; end
  204. def self.load_database
  205. load_database_ATL_DFL
  206. load_notetags_ATL_DFL
  207. end
  208.  
  209. def self.load_notetags_ATL_DFL
  210. groups = [$data_weapons, $data_armors, $data_enemies, $data_states]
  211. for group in groups
  212. for obj in group
  213. next if obj.nil?
  214. obj.load_notetags_ATL_DFL
  215. end
  216. end
  217. end
  218.  
  219. end # DataManager
  220.  
  221. #==============================================================================
  222. class RPG::State < RPG::BaseItem
  223. #==============================================================================
  224.  
  225. attr_accessor :dpbzformulazS
  226.  
  227. def load_notetags_ATL_DFL
  228. @dpbzformulazS = [0] * 2
  229. self.note.split(/[\r\n]+/).each { |line|
  230. case line
  231. when DPB::REGEXP::EQUIPITEM::INC_ATL
  232. @dpbzformulazS[0] += $1.to_i
  233. when DPB::REGEXP::EQUIPITEM::INC_DFL
  234. @dpbzformulazS[1] += $1.to_i
  235. end
  236. } # self.note.split
  237. end
  238.  
  239. end # RPG::State
  240.  
  241. #==============================================================================
  242. class RPG::EquipItem < RPG::BaseItem
  243. #==============================================================================
  244.  
  245. attr_accessor :dpbzformulazS
  246.  
  247. def load_notetags_ATL_DFL
  248. @dpbzformulazS = [0] * 2
  249. self.note.split(/[\r\n]+/).each { |line|
  250. case line
  251. when DPB::REGEXP::EQUIPITEM::INC_ATL
  252. @dpbzformulazS[0] += $1.to_i
  253. when DPB::REGEXP::EQUIPITEM::INC_DFL
  254. @dpbzformulazS[1] += $1.to_i
  255. end
  256. } # self.note.split
  257. end
  258.  
  259. end # RPG::EquipItem
  260.  
  261. #==============================================================================
  262. class RPG::Weapon < RPG::EquipItem
  263. #==============================================================================
  264.  
  265. alias atlanddflperformance performance
  266. def performance
  267. atlanddflperformance + atlanddfl_performance
  268. end
  269.  
  270. def atlanddfl_performance
  271. if DPB::ATLANDDFL::USE_OPTIMIZE_MOD
  272. (dpbzformulazS[0] * 10) + (dpbzformulazS[1] * 10)
  273. else
  274. 0 # //
  275. end
  276. end
  277.  
  278. end # class
  279.  
  280. #==============================================================================
  281. class RPG::Armor < RPG::EquipItem
  282. #==============================================================================
  283.  
  284. alias atlanddflperformance performance
  285. def performance
  286. atlanddflperformance + atlanddfl_performance
  287. end
  288.  
  289. def atlanddfl_performance
  290. if DPB::ATLANDDFL::USE_OPTIMIZE_MOD
  291. (dpbzformulazS[0] * 10) + (dpbzformulazS[1] * 10)
  292. else
  293. 0 # //
  294. end
  295. end
  296.  
  297. end # class
  298.  
  299. #==============================================================================
  300. class RPG::Enemy < RPG::BaseItem
  301. #==============================================================================
  302.  
  303. attr_accessor :dpbzformulazS
  304.  
  305. def load_notetags_ATL_DFL
  306. @dpbzformulazS = [0] * 2
  307. self.note.split(/[\r\n]+/).each { |line|
  308. case line
  309. when DPB::REGEXP::EQUIPITEM::INC_ATL
  310. @dpbzformulazS[0] += $1.to_i
  311. when DPB::REGEXP::EQUIPITEM::INC_DFL
  312. @dpbzformulazS[1] += $1.to_i
  313. end
  314. } # self.note.split
  315. end
  316.  
  317. end # RPG::Enemy
  318.  
  319. #==============================================================================
  320. class Game_Temp
  321. #==============================================================================
  322.  
  323. attr_reader :temp_atl_dfl_mod_for_user
  324. attr_reader :temp_atl_dfl_mod_for_item
  325.  
  326. alias atlanddflinit initialize
  327. def initialize
  328. atlanddflinit
  329. @temp_atl_dfl_mod_for_user = 0
  330. @temp_atl_dfl_mod_for_item = 0
  331. end
  332.  
  333. end # class
  334.  
  335. #==============================================================================
  336. class Game_BattlerBase
  337. #==============================================================================
  338.  
  339. FEATURE_DPBzFORMULAZ = 1990
  340.  
  341. alias dpb_atlanddfl_init initialize
  342. def initialize(*args, &block)
  343. clear_dpbzformulaz_plus
  344. dpb_atlanddfl_init(*args, &block)
  345. end
  346.  
  347. def atl ; dpbzformulaz(0) ; end
  348. def dfl ; dpbzformulaz(1) ; end
  349.  
  350. def dpbzformulaz(dpbzformulaz_id)
  351. (features_sum(FEATURE_DPBzFORMULAZ, dpbzformulaz_id) + dpbzformulaz_plus(dpbzformulaz_id))
  352. end
  353.  
  354. def dpbzformulaz_plus(dpbzformulaz_id)
  355. @dpbzformulaz_plus[dpbzformulaz_id]
  356. end
  357.  
  358. def clear_dpbzformulaz_plus
  359. @dpbzformulaz_plus = [0] * 2
  360. end
  361.  
  362. def add_dpbzformulaz(dpbzformulaz_id, value)
  363. @dpbzformulaz_plus[dpbzformulaz_id] += value
  364. refresh
  365. end
  366.  
  367. end # Game_BattlerBase
  368.  
  369. #==============================================================================
  370. class Game_Battler < Game_BattlerBase
  371. #==============================================================================
  372.  
  373. alias dflandatlmdv make_damage_value
  374. def make_damage_value(user, item)
  375. @temp_atl_dfl_mod_for_user = user
  376. @temp_atl_dfl_mod_for_item = item
  377. dflandatlmdv(user, item)
  378. end
  379.  
  380. alias atlanddflapplyguard apply_guard
  381. def apply_guard(damage)
  382. user = @temp_atl_dfl_mod_for_user
  383. item = @temp_atl_dfl_mod_for_item
  384. if item.note =~ DPB::REGEXP::USEABLEITEMDAMAGE::EXCLUDE_ATL
  385. atlval = 1 ; else ; atlval = ((100 + user.atl) * 0.01) ; end # if
  386. if item.note =~ DPB::REGEXP::USEABLEITEMDAMAGE::EXCLUDE_DFL
  387. dflval = 1 ; else ; dflval = (1.0 - (dfl * 0.01)) ; end # if
  388. atlanddflapplyguard(damage) * atlval * dflval
  389. end
  390.  
  391. end # Game_Battler
  392.  
  393. #==============================================================================
  394. class Game_Actor < Game_Battler
  395. #==============================================================================
  396.  
  397. alias dpbzatlanddflGAsetup setup
  398. def setup(actor_id)
  399. dpbzatlanddflGAsetup(actor_id)
  400. clear_dpbzformulaz_plus
  401. end
  402.  
  403. alias game_actor_atlanddfl_formulaz_plus dpbzformulaz_plus
  404. def dpbzformulaz_plus(dpbzformulaz_id)
  405. atlndfl = game_actor_atlanddfl_formulaz_plus(dpbzformulaz_id)
  406. atlndfl += dpbz_atlanddfl_rate(dpbzformulaz_id)
  407. atlndfl += dpbz_atlanddfl_states_rate(dpbzformulaz_id)
  408. return atlndfl
  409. end
  410.  
  411. def dpbz_atlanddfl_rate(dpbzformulaz_id)
  412. atlndflrate = 0.0
  413. atlndflrate += equips.compact.inject(0) {|r, i|
  414. r += i.dpbzformulazS[dpbzformulaz_id] rescue 0 }
  415. return atlndflrate
  416. end
  417.  
  418. def dpbz_atlanddfl_states_rate(dpbzformulaz_id)
  419. atlndflrate = 0.0
  420. atlndflrate += states.compact.inject(0) {|r, i|
  421. r += i.dpbzformulazS[dpbzformulaz_id] rescue 0 }
  422. return atlndflrate
  423. end
  424.  
  425. end # Game_Actor
  426.  
  427. #==============================================================================
  428. class Game_Enemy < Game_Battler
  429. #==============================================================================
  430.  
  431. alias game_enemy_formulaz_plus_atlanddfl dpbzformulaz_plus
  432. def dpbzformulaz_plus(dpbzformulaz_id)
  433. atlndfl = game_enemy_formulaz_plus_atlanddfl(dpbzformulaz_id)
  434. atlndfl += enemy.dpbzformulazS[dpbzformulaz_id]
  435. atlndfl += dpbz_atlanddfl_states_rate(dpbzformulaz_id)
  436. return atlndfl
  437. end
  438.  
  439. def dpbz_atlanddfl_states_rate(dpbzformulaz_id)
  440. atlndflrate = 0.0
  441. atlndflrate += states.compact.inject(0) {|r, i|
  442. r += i.dpbzformulazS[dpbzformulaz_id] rescue 0 }
  443. return atlndflrate
  444. end
  445.  
  446. end # Game_Enemy
  447.  
  448. #==============================================================================
  449. class Game_Interpreter
  450. #==============================================================================
  451.  
  452. def inc_atl(actor_id, value)
  453. actor = $game_actors[actor_id]
  454. return if actor == nil
  455. actor.add_dpbzformulaz(0, value)
  456. end
  457.  
  458. def inc_dfl(actor_id, value)
  459. actor = $game_actors[actor_id]
  460. return if actor == nil
  461. actor.add_dpbzformulaz(1, value)
  462. end
  463.  
  464. end# Game_Interpreter
  465.  
  466. #===============================================================================#
  467. # - SCRIPT END - #
  468. #===============================================================================#
  469. # http://dekitarpg.wordpress.com/ #
  470. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement