Advertisement
Dekita

atlanddflupdatezz

Nov 7th, 2012
700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.88 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.4
  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. 21/10/2o12 - Added atl/dfl gains on lvl up,
  40. Added Options for Dekita__CORE,
  41. 19/09/2o12 - Added atl/dfl state mods,
  42. improved methods,
  43. 17/09/2o12 - improved m_d_v method,
  44. 15/09/2o12 - improved methods,
  45. 13/09/2o12 - Finished atl & dfl,
  46. 12/09/2o12 - Started Script,
  47. ================================================================================
  48. Credit and Thanks to :
  49. =======================
  50. ¥ami - for helping me alias make_damage_value the way i needed ^_^
  51.  
  52. ================================================================================
  53. Known Bugs:
  54. ============
  55. N/A
  56.  
  57. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58. If a new bug is found please contact me at
  59. http://dekitarpg.wordpress.com/
  60.  
  61. ================================================================================
  62. INSTRUCTIONS:
  63. ==============
  64. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  65.  
  66. ================================================================================
  67. Script Calls:
  68. ==============
  69. inc_atl(actor_id, value)
  70. inc_dfl(actor_id, value)
  71.  
  72. replace actor_id with the id number of the actor (found in the database)
  73. replace value with the amount you want the stat to increase(can be negative).
  74.  
  75. e.g
  76. inc_atl(1, 10) < This will increase actor 1's atl by 10
  77. inc_dfl(2, 15) < This will increase actor 2's dfl by 15
  78.  
  79. # Use these script calls to change the atl/dfl gained for actors upon level up.
  80. lv_up_atl(actor_id, value)
  81. lv_up_dfl(actor_id, value)
  82.  
  83. ================================================================================
  84. NoteTags:
  85. ==========
  86. <atl: X>
  87. <dfl: X>
  88.  
  89. Place these notetags into weapon or armor noteboxes to increase actors stats by
  90. X amount of points when the item is equipped,
  91.  
  92. Place these notetags into state noteboxes to increase stats by X amount
  93. of points when state is inflicted.
  94.  
  95. Place these notetags into enemy noteboxes to increase the enemys stats by
  96. X amount of points.
  97.  
  98. Replace X with a value, e.g <atl: 5> will increase attack level by 5
  99.  
  100. --------------------------------------------------------------------------------
  101. <no atl mod>
  102. <no dfl mod>
  103.  
  104. place these notetags into skill and item noteboxes if you DO NOT want to include
  105. attack and defence levels when that skill/item is used ^_^
  106.  
  107. ================================================================================
  108. Skill Formula's:
  109. =================
  110. you can use attack and defence level in your skill formulas if you want
  111. by using
  112. a.atl a.dfl b.atl b.dfl
  113.  
  114. .atl will return the value of a/b attack level e.g 50
  115. .dfl will return the value of a/b defence level e.g 50
  116.  
  117. ================================================================================
  118. Conditional Branch:
  119. ====================
  120. you can use the script option in conditional branches to check actors
  121. attack and defence levels, simply put either
  122.  
  123. $game_actors[x].stat == y
  124. $game_party.members[x].stat == y
  125.  
  126. replace x with actor id and replace y with a value
  127. replace "stat" with either atl or dfl, examples below
  128.  
  129. $game_actors[1].atl == 30
  130. this will check if actor id [1] has atl(attack level) equal to 30
  131.  
  132. $game_party.members[0].dfl == 30
  133. this will check if the partys member [0] (0 is the party leader) has dfl
  134. (defence level) equal to 30
  135.  
  136. you can also replace "==" with either
  137. "<=" (below/equal to) or
  138. ">=" (greater than/equal to)
  139.  
  140. =end #==========================================================================#
  141. module DPB ; module ATLANDDFL
  142. #######################
  143. # CUSTOMISATION BEGIN #
  144. #######################
  145.  
  146. ATL_VOCAB = "Attack Level" # atl
  147.  
  148. # Increase Atl on lvl up?
  149. Gain_Atl_On_Lv = true
  150.  
  151. # Default atl gain on lvl up.
  152. Atl_Lv_Up_Gain = 1
  153.  
  154. ATL_NOTETAG = /<atl: (.*)>/i
  155.  
  156. NO_ATL_NOTETAG = /<no atl mod>/i
  157.  
  158.  
  159.  
  160. DFL_VOCAB = "Defence Level" # dfl
  161.  
  162. # Increase Dfl on lvl up?
  163. Gain_Dfl_On_Lv = true
  164.  
  165. # Default dfl gain on lvl up.
  166. Dfl_Lv_Up_Gain = 1
  167.  
  168. DFL_NOTETAG = /<dfl: (.*)>/i
  169.  
  170. NO_DFL_NOTETAG = /<no dfl mod>/i
  171.  
  172. # set this to true for optimize equipments to include atl and dfl
  173. USE_OPTIMIZE_MOD = true
  174.  
  175.  
  176.  
  177. # SETTINGS IF USING Dekita__CORE
  178.  
  179. # Attack Level
  180. ATL_Icon = 781
  181.  
  182. ATL_Color_1 = Color.new(40, 0, 0)
  183.  
  184. ATL_Color_2 = Color.new(255, 120, 0)
  185.  
  186. # Defence Level
  187. DFL_Icon = 681
  188.  
  189. DFL_Color_1 = Color.new(0, 0, 40)
  190.  
  191. DFL_Color_2 = Color.new(0, 120, 255)
  192.  
  193. Draw_Atl_And_Dfl_Gauges = true
  194.  
  195. Draw_Atl_And_Dfl_Icons = true
  196.  
  197. #####################
  198. # CUSTOMISATION END #
  199. #####################
  200.  
  201. def self.atls_Gauge_Rate(target, stat)
  202. if target.is_a?(RPG::EquipItem)
  203. gauge_rate = self.Get_Equip_atls_Gauge_Rate(target, stat)
  204. return gauge_rate
  205. elsif target == false
  206. return 0
  207. else
  208. gauge_rate = self.Get_Actor_atls_Gauge_Rate(target, stat)
  209. return gauge_rate
  210. end
  211. end
  212.  
  213. def self.Get_Actor_atls_Gauge_Rate(target, stat)
  214. return (target.atl.to_f-1)/100 if stat == :vit
  215. return (target.dfl.to_f-1)/100 if stat == :str
  216. return 0# nil
  217. end
  218.  
  219. def self.Get_Equip_atls_Gauge_Rate(target, stat)
  220. return ((target.dpbzformulazS[0].to_f-1)/99).to_f if stat == :atl
  221. return ((target.dpbzformulazS[1].to_f-1)/99).to_f if stat == :dfl
  222. return 0# nil
  223. end
  224.  
  225. def self.atls_Value(target, stat)
  226. return Dekita__CORE::N_A_Vocab if target == false
  227. return atls_EquipzValue(target, stat) if target.is_a?(RPG::EquipItem)
  228. return "#{target.atl.to_i}" if stat == :atl
  229. return "#{target.dfl.to_i}" if stat == :dfl
  230. return Dekita__CORE::N_A_Vocab
  231. end
  232.  
  233. def self.atls_EquipzValue(target, stat)
  234. return Dekita__CORE::N_A_Vocab if target == false
  235. return "#{target.dpbzformulazS[0].to_i}" if stat == :atl && target.is_a?(RPG::EquipItem)
  236. return "#{target.dpbzformulazS[1].to_i}" if stat == :dfl && target.is_a?(RPG::EquipItem)
  237. return Dekita__CORE::N_A_Vocab
  238. end
  239.  
  240. def self.atls_Icons(stat)
  241. return ATL_Icon if stat == :atl
  242. return DFL_Icon if stat == :dfl
  243. return 0#nil
  244. end
  245.  
  246. def self.atls_Vocab(stat)
  247. return ATL_VOCAB if stat == :atl
  248. return DFL_VOCAB if stat == :dfl
  249. return "NuLL"#nil
  250. end
  251.  
  252. def self.Get_Gauge_Color_1(stat)
  253. return ATL_Color_1 if stat == :atl
  254. return DFL_Color_1 if stat == :dfl
  255. return Color.new(0, 0, 0)
  256. end
  257. def self.Get_Gauge_Color_2(stat)
  258. return ATL_Color_2 if stat == :atl
  259. return DFL_Color_2 if stat == :dfl
  260. return Color.new(0, 0, 0)
  261. end
  262.  
  263. end ; end # module
  264. #===============================================================================#
  265. # http://dekitarpg.wordpress.com/
  266. #===============================================================================#
  267. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  268. # YES?\.\. #
  269. # OMG, REALLY? #
  270. # WELL SLAP MY FACE AND CALL ME A DRAGON.\..\.. #
  271. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  272. #===============================================================================#
  273. # Import:
  274. #========
  275. $imported = {} if $imported.nil?
  276. $imported[:Dekita__ATL_AND_DFL] = true
  277.  
  278. #==============================================================================
  279. #module Vocab
  280. #==============================================================================
  281.  
  282. #def self.atl ; return DPB::ATLANDDFL::ATL_VOCAB ; end
  283.  
  284. #def self.dfl ; return DPB::ATLANDDFL::DFL_VOCAB ; end
  285.  
  286. #end # Vocab
  287.  
  288. module DPB ; module REGEXP ; module EQUIPITEM
  289.  
  290. INC_ATL = DPB::ATLANDDFL::ATL_NOTETAG
  291. INC_DFL = DPB::ATLANDDFL::DFL_NOTETAG
  292.  
  293. end # EQUIPITEM
  294. module USEABLEITEMDAMAGE
  295.  
  296. EXCLUDE_ATL = DPB::ATLANDDFL::NO_ATL_NOTETAG
  297. EXCLUDE_DFL = DPB::ATLANDDFL::NO_DFL_NOTETAG
  298.  
  299. end ; end ; end # USEABLEITEMDAMAGE ; REGEXP ; DPB
  300.  
  301. #==============================================================================
  302. module DataManager
  303. #==============================================================================
  304.  
  305. class <<self; alias load_database_ATL_DFL load_database; end
  306. def self.load_database
  307. load_database_ATL_DFL
  308. load_notetags_ATL_DFL
  309. end
  310.  
  311. def self.load_notetags_ATL_DFL
  312. groups = [$data_weapons, $data_armors, $data_enemies, $data_states]
  313. for group in groups
  314. for obj in group
  315. next if obj.nil?
  316. obj.load_notetags_ATL_DFL
  317. end
  318. end
  319. end
  320.  
  321. end # DataManager
  322.  
  323. #==============================================================================
  324. class RPG::State < RPG::BaseItem
  325. #==============================================================================
  326.  
  327. attr_accessor :dpbzformulazS
  328.  
  329. def load_notetags_ATL_DFL
  330. @dpbzformulazS = [0] * 2
  331. self.note.split(/[\r\n]+/).each { |line|
  332. case line
  333. when DPB::REGEXP::EQUIPITEM::INC_ATL
  334. @dpbzformulazS[0] += $1.to_i
  335. when DPB::REGEXP::EQUIPITEM::INC_DFL
  336. @dpbzformulazS[1] += $1.to_i
  337. end
  338. } # self.note.split
  339. end
  340.  
  341. end # RPG::State
  342.  
  343. #==============================================================================
  344. class RPG::EquipItem < RPG::BaseItem
  345. #==============================================================================
  346.  
  347. attr_accessor :dpbzformulazS
  348.  
  349. def load_notetags_ATL_DFL
  350. @dpbzformulazS = [0] * 2
  351. self.note.split(/[\r\n]+/).each { |line|
  352. case line
  353. when DPB::REGEXP::EQUIPITEM::INC_ATL
  354. @dpbzformulazS[0] += $1.to_i
  355. when DPB::REGEXP::EQUIPITEM::INC_DFL
  356. @dpbzformulazS[1] += $1.to_i
  357. end
  358. } # self.note.split
  359. end
  360.  
  361. end # RPG::EquipItem
  362.  
  363. #==============================================================================
  364. class RPG::Weapon < RPG::EquipItem
  365. #==============================================================================
  366.  
  367. alias atlanddflperformance performance
  368. def performance
  369. atlanddflperformance + atlanddfl_performance
  370. end
  371.  
  372. def atlanddfl_performance
  373. if DPB::ATLANDDFL::USE_OPTIMIZE_MOD
  374. (dpbzformulazS[0] * 10) + (dpbzformulazS[1] * 10)
  375. else
  376. 0 # //
  377. end
  378. end
  379.  
  380. end # class
  381.  
  382. #==============================================================================
  383. class RPG::Armor < RPG::EquipItem
  384. #==============================================================================
  385.  
  386. alias atlanddflperformance performance
  387. def performance
  388. atlanddflperformance + atlanddfl_performance
  389. end
  390.  
  391. def atlanddfl_performance
  392. if DPB::ATLANDDFL::USE_OPTIMIZE_MOD
  393. (dpbzformulazS[0] * 10) + (dpbzformulazS[1] * 10)
  394. else
  395. 0 # //
  396. end
  397. end
  398.  
  399. end # class
  400.  
  401. #==============================================================================
  402. class RPG::Enemy < RPG::BaseItem
  403. #==============================================================================
  404.  
  405. attr_accessor :dpbzformulazS
  406.  
  407. def load_notetags_ATL_DFL
  408. @dpbzformulazS = [0] * 2
  409. self.note.split(/[\r\n]+/).each { |line|
  410. case line
  411. when DPB::REGEXP::EQUIPITEM::INC_ATL
  412. @dpbzformulazS[0] += $1.to_i
  413. when DPB::REGEXP::EQUIPITEM::INC_DFL
  414. @dpbzformulazS[1] += $1.to_i
  415. end
  416. } # self.note.split
  417. end
  418.  
  419. end # RPG::Enemy
  420.  
  421. #==============================================================================
  422. class Game_Temp
  423. #==============================================================================
  424.  
  425. attr_reader :temp_atl_dfl_mod_for_user
  426. attr_reader :temp_atl_dfl_mod_for_item
  427.  
  428. alias atlanddflinit initialize
  429. def initialize
  430. atlanddflinit
  431. @temp_atl_dfl_mod_for_user = 0
  432. @temp_atl_dfl_mod_for_item = 0
  433. end
  434.  
  435. end # class
  436.  
  437. #==============================================================================
  438. class Game_BattlerBase
  439. #==============================================================================
  440.  
  441. FEATURE_DPBzFORMULAZ = 1990
  442.  
  443. alias dpb_atlanddfl_init initialize
  444. def initialize(*args, &block)
  445. clear_dpbzformulaz_plus
  446. dpb_atlanddfl_init(*args, &block)
  447. end
  448.  
  449. def atl ; dpbzformulaz(0) ; end
  450. def dfl ; dpbzformulaz(1) ; end
  451.  
  452. def dpbzformulaz(dpbzformulaz_id)
  453. (features_sum(FEATURE_DPBzFORMULAZ, dpbzformulaz_id) + dpbzformulaz_plus(dpbzformulaz_id))
  454. end
  455.  
  456. def dpbzformulaz_plus(dpbzformulaz_id)
  457. @dpbzformulaz_plus[dpbzformulaz_id]
  458. end
  459.  
  460. def clear_dpbzformulaz_plus
  461. @dpbzformulaz_plus = [0] * 2
  462. end
  463.  
  464. def add_dpbzformulaz(dpbzformulaz_id, value)
  465. @dpbzformulaz_plus[dpbzformulaz_id] += value
  466. refresh
  467. end
  468.  
  469. end # Game_BattlerBase
  470.  
  471. #==============================================================================
  472. class Game_Battler < Game_BattlerBase
  473. #==============================================================================
  474.  
  475. alias dflandatlmdv make_damage_value
  476. def make_damage_value(user, item)
  477. @temp_atl_dfl_mod_for_user = user
  478. @temp_atl_dfl_mod_for_item = item
  479. dflandatlmdv(user, item)
  480. end
  481.  
  482. alias atlanddflapplyguard apply_guard
  483. def apply_guard(damage)
  484. user = @temp_atl_dfl_mod_for_user
  485. item = @temp_atl_dfl_mod_for_item
  486. if item.note =~ DPB::REGEXP::USEABLEITEMDAMAGE::EXCLUDE_ATL
  487. atlval = 1 ; else ; atlval = ((100 + user.atl) * 0.01) ; end # if
  488. if item.note =~ DPB::REGEXP::USEABLEITEMDAMAGE::EXCLUDE_DFL
  489. dflval = 1 ; else ; dflval = (1.0 - (dfl * 0.01)) ; end # if
  490. atlanddflapplyguard(damage) * atlval * dflval
  491. end
  492.  
  493. end # Game_Battler
  494.  
  495. #==============================================================================
  496. class Game_Actor < Game_Battler
  497. #==============================================================================
  498.  
  499. attr_reader :ATL_Inc_On_Lv
  500. attr_reader :DFL_Inc_On_Lv
  501.  
  502. alias dpbzatlanddflGA_init initialize
  503. def initialize(actor_id)
  504. dpbzatlanddflGA_init(actor_id)
  505. @ATL_Inc_On_Lv = DPB::ATLANDDFL::Atl_Lv_Up_Gain
  506. @DFL_Inc_On_Lv = DPB::ATLANDDFL::Dfl_Lv_Up_Gain
  507. end
  508.  
  509. alias dpbzatlanddflGAsetup setup
  510. def setup(actor_id)
  511. dpbzatlanddflGAsetup(actor_id)
  512. clear_dpbzformulaz_plus
  513. end
  514.  
  515. alias def_lv_up_atl_dfl level_up
  516. def level_up
  517. def_lv_up_atl_dfl
  518. @dpbzformulaz_plus[0] += @ATL_Inc_On_Lv if DPB::ATLANDDFL::Gain_Atl_On_Lv
  519. @dpbzformulaz_plus[1] += @DFL_Inc_On_Lv if DPB::ATLANDDFL::Gain_Dfl_On_Lv
  520. end
  521.  
  522. def change_lv_up_atl(value)
  523. @ATL_Inc_On_Lv = value
  524. end
  525.  
  526. def change_lv_up_dfl(value)
  527. @DFL_Inc_On_Lv = value
  528. end
  529.  
  530. alias game_actor_atlanddfl_formulaz_plus dpbzformulaz_plus
  531. def dpbzformulaz_plus(dpbzformulaz_id)
  532. atlndfl = game_actor_atlanddfl_formulaz_plus(dpbzformulaz_id)
  533. atlndfl += dpbz_atlanddfl_rate(dpbzformulaz_id)
  534. atlndfl += dpbz_atlanddfl_states_rate(dpbzformulaz_id)
  535. return atlndfl
  536. end
  537.  
  538. def dpbz_atlanddfl_rate(dpbzformulaz_id)
  539. atlndflrate = 0.0
  540. atlndflrate += equips.compact.inject(0) {|r, i|
  541. r += i.dpbzformulazS[dpbzformulaz_id] rescue 0 }
  542. return atlndflrate
  543. end
  544.  
  545. def dpbz_atlanddfl_states_rate(dpbzformulaz_id)
  546. atlndflrate = 0.0
  547. atlndflrate += states.compact.inject(0) {|r, i|
  548. r += i.dpbzformulazS[dpbzformulaz_id] rescue 0 }
  549. return atlndflrate
  550. end
  551.  
  552. end # Game_Actor
  553.  
  554. #==============================================================================
  555. class Game_Enemy < Game_Battler
  556. #==============================================================================
  557.  
  558. alias game_enemy_formulaz_plus_atlanddfl dpbzformulaz_plus
  559. def dpbzformulaz_plus(dpbzformulaz_id)
  560. atlndfl = game_enemy_formulaz_plus_atlanddfl(dpbzformulaz_id)
  561. atlndfl += enemy.dpbzformulazS[dpbzformulaz_id]
  562. atlndfl += dpbz_atlanddfl_states_rate(dpbzformulaz_id)
  563. return atlndfl
  564. end
  565.  
  566. def dpbz_atlanddfl_states_rate(dpbzformulaz_id)
  567. atlndflrate = 0.0
  568. atlndflrate += states.compact.inject(0) {|r, i|
  569. r += i.dpbzformulazS[dpbzformulaz_id] rescue 0 }
  570. return atlndflrate
  571. end
  572.  
  573. end # Game_Enemy
  574.  
  575. #==============================================================================
  576. class Game_Interpreter
  577. #==============================================================================
  578.  
  579. def inc_atl(actor_id, value)
  580. actor = $game_actors[actor_id]
  581. return if actor == nil
  582. actor.add_dpbzformulaz(0, value)
  583. end
  584.  
  585. def inc_dfl(actor_id, value)
  586. actor = $game_actors[actor_id]
  587. return if actor == nil
  588. actor.add_dpbzformulaz(1, value)
  589. end
  590.  
  591. def lv_up_atl(actor_id, value)
  592. actor = $game_actors[actor_id]
  593. return if actor == nil
  594. actor.change_lv_up_atl(value)
  595. end
  596.  
  597. def lv_up_dfl(actor_id, value)
  598. actor = $game_actors[actor_id]
  599. return if actor == nil
  600. actor.change_lv_up_dfl(value)
  601. end
  602.  
  603. end# Game_Interpreter
  604.  
  605. #===============================================================================#
  606. # - SCRIPT END - #
  607. #===============================================================================#
  608. # http://dekitarpg.wordpress.com/ #
  609. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement