Advertisement
Dekita

Element Control v1.5

Mar 17th, 2014
1,647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.38 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Elemental Control
  5. # -- Author : Dekita
  6. # -- Version : 1.5
  7. # -- Level : Easy / Normal
  8. # -- Requires : N/A
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Elems_Control]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 17/o3/2o14 - Added Vocanicon Module,
  21. # - FINALLY - Fixed Elemental Calculation, (*celebrates*)
  22. # 15/o3/2o14 - Fixed small bug with max attack elements,
  23. # o2/o3/2o14 - Fixed small bug with max attack elements,
  24. # 31/o5/2o13 - Added More Script Call Help Information.
  25. # 26/o3/2o13 - Finished,
  26. # - Fixed Typos,
  27. # 23/o3/2o13 - Started,
  28. #
  29. #===============================================================================
  30. # ☆ Introduction
  31. #-------------------------------------------------------------------------------
  32. # This script is the Elemental Equivalent of my Statistic Control Script.
  33. # This script 'fixes' elements, ie. differentiates between attack and defence
  34. # element types.
  35. # This script also allows Dev's control over elements that would not normally
  36. # be available, such as various script calls to modify the element value
  37. # using simple arithmatic (add/subtract/divide/multiply/modulo),
  38. # As well as actors/classes/enemies/weapons/armors/states/skills notetags.
  39. #
  40. # It also adds Max and Min limits for all elements and gives control over these
  41. # new limitations for both attack and defence.
  42. #
  43. # It also provides new ways of handling the elemental damage modification.
  44. # ie, allows for multiple element damage variances, rather than 1.
  45. #
  46. # Note :
  47. # Elements still work with percentage values, ie 0.01 is 1%, 1.0 is 100%
  48. #
  49. #===============================================================================
  50. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  51. #===============================================================================
  52. # 1. You MUST give credit to "Dekita" !!
  53. # 2. You are NOT allowed to repost this script.(or modified versions)
  54. # 3. You are NOT allowed to convert this script.
  55. # 4. You are NOT allowed to use this script for Commercial games.
  56. # 5. ENJOY!
  57. #
  58. # "FINE PRINT"
  59. # By using this script you hereby agree to the above terms and conditions,
  60. # if any violation of the above terms occurs "legal action" may be taken.
  61. # Not understanding the above terms and conditions does NOT mean that
  62. # they do not apply to you.
  63. # If you wish to discuss the terms and conditions in further detail you can
  64. # contact me at http://dekitarpg.wordpress.com/
  65. #
  66. #===============================================================================
  67. # ☆ Instructions
  68. #-------------------------------------------------------------------------------
  69. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  70. #
  71. #===============================================================================
  72. # ☆ Script Calls
  73. #-------------------------------------------------------------------------------
  74. # $game_actor[id].add_def_ele(element_id, value)
  75. # $game_actor[id].sub_def_ele(element_id, value)
  76. # $game_actor[id].mul_def_ele(element_id, value)
  77. # $game_actor[id].div_def_ele(element_id, value)
  78. # $game_actor[id].mod_def_ele(element_id, value)
  79. #
  80. # $game_actor[id].add_atk_ele(element_id, value)
  81. # $game_actor[id].sub_atk_ele(element_id, value)
  82. # $game_actor[id].mul_atk_ele(element_id, value)
  83. # $game_actor[id].div_atk_ele(element_id, value)
  84. # $game_actor[id].mod_atk_ele(element_id, value)
  85. #
  86. # id = the actors database id
  87. # element_id = the elements database id
  88. # value = the value you with to modify the element with
  89. #
  90. # these are the calculatons for each control type
  91. # add : current stat += value
  92. # sub : current stat -= value
  93. # div : current stat /= value
  94. # mul : current stat *= value
  95. # mod : current stat %= value
  96. #
  97. # These script calls modify the Actor value, other items remain in the same order.
  98. #
  99. # BIG NOTE ::
  100. # By default in Vx Ace the starting element defence is 1.0, this is because the
  101. # calculation is 1.0 * element defence (eg 1.0) which makes the damage normal
  102. # (normal = no resist or weakness) this means, if your elemental defence is 2.0
  103. # you will take 2.0* the damage from elements.
  104. # This means in order to INCREASE your resistance towards a peticular element
  105. # you must REDUCE the defencive element.
  106. # eg.
  107. # add = more elemental damage intake
  108. # sub = less elemental damage intake
  109. #
  110. # Attack elements work as you would expect.
  111. # eg.
  112. # add = more elemental attack value
  113. # sub = less elemental attack value
  114. #
  115. # There is also a third arguement for all the above script calls,
  116. # it is a boolean arguement to determine if the player should be refreshed.
  117. # eg.. $game_actors[1].add_atk_ele(3, 0.05, false)
  118. # this is very helpfull for maintaining FPS when adding LOTS of stats..
  119. # The default to this arguemet is true.
  120. # If you don't understand what this mean, just disregard this information :)
  121. #
  122. #===============================================================================
  123. # ☆ Notetags ( default )
  124. # For use with Weapons / Armors / Enemies / Actors / Classes / States / Skills
  125. #-------------------------------------------------------------------------------
  126. # <atk ele: element_id, value>
  127. # <def ele: element_id, value>
  128. # <max atk ele: element_id, value>
  129. # <max def ele: element_id, value>
  130. #
  131. # element_id = The Element ID from the database
  132. # value = the value you wish to change the element by
  133. #
  134. #-------------------------------------------------------------------------------
  135. # For Skills / Items
  136. #-------------------------------------------------------------------------------
  137. # <inc atk ele>
  138. # Use this notetag to change whether this skill includes all elemental damage
  139. # it will change from the default setting defined at- Atk_Ele_Inc_All_Dmg
  140. #
  141. # <no ele mod>
  142. # Will make the skill / item have no elemental modification when used.
  143. #
  144. #===============================================================================
  145. # ☆ HELP
  146. #-------------------------------------------------------------------------------
  147. # Remember :
  148. # All Elemental Values work with float values, eg. 1.0, 0.5, 0.1, 0.05, 0.01
  149. # 1.0 = 100%, 0.01 = 1%,
  150. #
  151. # Also, element id numbers can be found in the database.
  152. #
  153. #===============================================================================
  154. module Ele_Fixx
  155. #===============================================================================
  156. Element={0=>{:atk_ele=>[0,1],:def_ele=>[0,1]}}# << KEEP !!
  157. Notes={}# << Keep
  158.  
  159. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  160. # ☆ Calculation Settings
  161. #--------------------------------------------------------------------------
  162. # This is where you set how the script calculates elemental damage
  163. # Types :
  164. # 0 = Will take the max element modifier as the damage multiplication
  165. # This is also the Vx Ace Default Calculation.
  166. # This will make even the smallest attack elemental modifier count as full
  167. # elemental attack.
  168. #
  169. # 1 = Will calculate only weak and resisted elements, then adds/subtracts
  170. # Them accordingly and adds them onto the default attack for a total
  171. # calculation. (positive or negative)
  172. # RECOMMENDED TYPE.
  173. #
  174. # 2 = Will add each elemental modifier together for the damage multiplication
  175. # This Is An Experimental Calculation ;p
  176. #
  177. # 3 = Will take the average modifier for the damage calculation
  178. # This Is Another Experimental Calculation ;p
  179. #--------------------------------------------------------------------------
  180. DMG_Type = 1
  181. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  182. # ☆ Limit Settings
  183. #--------------------------------------------------------------------------
  184. # This is where you adjust the settings for the base min and max values
  185. # used for actors / enemies.
  186. #--------------------------------------------------------------------------
  187. #Element[id]={ :atk_ele => [ Min , Max ], :def_ele => [ Min , Max ]}
  188. Element[1] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  189. Element[2] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  190. Element[3] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  191. Element[4] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  192. Element[5] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  193. Element[6] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  194. Element[7] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  195. Element[8] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  196. Element[9] = { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  197. Element[10]= { :atk_ele => [ -2.0 , 2.0 ], :def_ele => [ -2.0 , 2.0 ]}
  198. # << Add more rows here if you have more than 10
  199. # elements in your project :)
  200. # Follow the same format as above, ie Element[ id ] = [ Min , Max ]
  201.  
  202. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  203. # ☆ Notetag Settings
  204. #--------------------------------------------------------------------------
  205. # This is where you adjust the settings for the notetags used in all
  206. # notetaggable items.
  207. # Only modify these if you understand how to.
  208. #--------------------------------------------------------------------------
  209. Notes[:atk_ele] = /<atk ele:(.*),(.*)>/i
  210. Notes[:def_ele] = /<def ele:(.*),(.*)>/i
  211. Notes[:max_atk_ele] = /<max atk ele:(.*),(.*)>/i
  212. Notes[:max_def_ele] = /<max def ele:(.*),(.*)>/i
  213. Notes[:no_element] = /<no ele mod>/i
  214. Notes[:atk_ele_dmg] = /<inc atk ele>/i
  215. #####################
  216. # CUSTOMISATION END #
  217. end #####################
  218. #===============================================================================
  219. module Vocanicon
  220. #===============================================================================
  221. #-----------------------------------------------------------------------------
  222. #
  223. #-----------------------------------------------------------------------------
  224. def self.atk_element(id)
  225. vocab = $data_system.elements[id]
  226. case id
  227. when 1 then [vocab, Text_Color::White , 216, 0]
  228. when 2 then [vocab, Text_Color::White , 26 , 0]
  229. when 3 then [vocab, Text_Color::Deep_Red , 208, 0]
  230. when 4 then [vocab, Text_Color::Dark_Blue , 209, 0]
  231. when 5 then [vocab, Text_Color::Yellow , 210, 0]
  232. when 6 then [vocab, Text_Color::Sky_Blue , 211, 0]
  233. when 7 then [vocab, Text_Color::Brown , 212, 0]
  234. when 8 then [vocab, Text_Color::Candy_Green , 213, 0]
  235. when 9 then [vocab, Text_Color::Pure_White , 214, 0]
  236. when 10 then [vocab, Text_Color::Grey , 215, 0]
  237. end
  238. end
  239. #-----------------------------------------------------------------------------
  240. #
  241. #-----------------------------------------------------------------------------
  242. def self.def_element(id)
  243. vocab = $data_system.elements[id]
  244. case id
  245. when 1 then [vocab, Text_Color::White , 200, 0]
  246. when 2 then [vocab, Text_Color::White , 26 , 0]
  247. when 3 then [vocab, Text_Color::Deep_Red , 192, 0]
  248. when 4 then [vocab, Text_Color::Dark_Blue , 193, 0]
  249. when 5 then [vocab, Text_Color::Yellow , 194, 0]
  250. when 6 then [vocab, Text_Color::Sky_Blue , 195, 0]
  251. when 7 then [vocab, Text_Color::Brown , 196, 0]
  252. when 8 then [vocab, Text_Color::Candy_Green , 197, 0]
  253. when 9 then [vocab, Text_Color::Pure_White , 198, 0]
  254. when 10 then [vocab, Text_Color::Grey , 199, 0]
  255. end
  256. end
  257. #####################
  258. # CUSTOMISATION END #
  259. end #####################
  260. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  261. # #
  262. # http://dekitarpg.wordpress.com/ #
  263. # #
  264. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  265. #===============================================================================#
  266. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  267. # YES?\.\. #
  268. # OMG, REALLY? \| #
  269. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  270. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  271. #===============================================================================#
  272. module DataManager
  273. #===============================================================================
  274. #---------------------------------------------------------------------------
  275. # Alias List
  276. #---------------------------------------------------------------------------
  277. class << self
  278. alias :lbd_elef_element :load_database
  279. end
  280. #---------------------------------------------------------------------------
  281. # Load Database (alias)
  282. #---------------------------------------------------------------------------
  283. def self.load_database
  284. lbd_elef_element
  285. loa_elef_element
  286. end
  287. #---------------------------------------------------------------------------
  288. # Load Unique Elemental Shit
  289. #---------------------------------------------------------------------------
  290. def self.loa_elef_element
  291. classes = [$data_weapons, $data_armors , $data_items , $data_skills ,
  292. $data_actors , $data_classes, $data_enemies, $data_states ]
  293. for g in classes
  294. for o in g
  295. next if o == nil
  296. o.load_elemental_control
  297. end
  298. end
  299. end
  300.  
  301. end # DataManager
  302.  
  303. #===============================================================================
  304. class RPG::BaseItem
  305. #===============================================================================
  306. #---------------------------------------------------------------------------
  307. # Pi Variables
  308. #---------------------------------------------------------------------------
  309. attr_accessor :atk_ele
  310. attr_accessor :def_ele
  311. attr_accessor :max_atk_ele
  312. attr_accessor :max_def_ele
  313. #---------------------------------------------------------------------------
  314. # Load Elemental Control
  315. #---------------------------------------------------------------------------
  316. def load_elemental_control
  317. @atk_ele = [0] * $data_system.elements.size
  318. @def_ele = [0] * $data_system.elements.size
  319. @max_atk_ele = [0] * $data_system.elements.size
  320. @max_def_ele = [0] * $data_system.elements.size
  321. check_elefixx_notetags
  322. end
  323. #---------------------------------------------------------------------------
  324. # Parse Notes
  325. #---------------------------------------------------------------------------
  326. def check_elefixx_notetags
  327. self.note.split(/[\r\n]+/).each do |line|
  328. case line
  329. when Ele_Fixx::Notes[:atk_ele] then @atk_ele[$1.to_i] = $2.to_f
  330. when Ele_Fixx::Notes[:def_ele] then @def_ele[$1.to_i] = $2.to_f
  331. # p "Loaded Element note for #{self.name} = Ele[#{$1.to_i}] = #{@def_ele[$1.to_i]}"
  332. when Ele_Fixx::Notes[:max_atk_ele] then @max_atk_ele[$1.to_i] = $2.to_f
  333. when Ele_Fixx::Notes[:max_def_ele] then @max_def_ele[$1.to_i] = $2.to_f
  334. end
  335. end
  336. end
  337.  
  338. end # << RPG::BaseItem
  339.  
  340. #===============================================================================
  341. class RPG::UsableItem < RPG::BaseItem
  342. #===============================================================================
  343. #---------------------------------------------------------------------------
  344. # Pi Variables
  345. #---------------------------------------------------------------------------
  346. attr_accessor :no_ele_mod
  347. #---------------------------------------------------------------------------
  348. # Load Elemental Control
  349. #---------------------------------------------------------------------------
  350. def load_elemental_control
  351. super
  352. @no_ele_mod = false
  353. check_elefixx_notetags
  354. end
  355. #---------------------------------------------------------------------------
  356. # Parse Notes
  357. #---------------------------------------------------------------------------
  358. def check_elefixx_notetags
  359. super
  360. self.note.split(/[\r\n]+/).each do |line|
  361. case line
  362. when Ele_Fixx::Notes[:no_element]
  363. @no_ele_mod = true
  364. end
  365. end
  366. end
  367.  
  368. end # << RPG::BaseItem
  369.  
  370. #===============================================================================
  371. class Game_BattlerBase
  372. #===============================================================================
  373. #--------------------------------------------------------------------------
  374. # Alias List
  375. #--------------------------------------------------------------------------
  376. alias :sd13x_GB_elems :initialize
  377. #--------------------------------------------------------------------------
  378. # Initialize Data
  379. #--------------------------------------------------------------------------
  380. def initialize(*a,&b)
  381. clear_def_ele_plus
  382. clear_atk_ele_plus
  383. sd13x_GB_elems(*a,&b)
  384. end
  385. #--------------------------------------------------------------------------
  386. # Get Attack Element || Old Method >> features_set(FEATURE_ATK_ELEMENT)
  387. #--------------------------------------------------------------------------
  388. def atk_elements
  389. a = []
  390. $data_system.elements.size.times do |i|
  391. e = atk_element_rate(i)
  392. a << i if e != 0.0
  393. end
  394. a
  395. end
  396. #--------------------------------------------------------------------------
  397. # Get Min Value of Defencive Elements
  398. #--------------------------------------------------------------------------
  399. def def_ele_min(element_id)
  400. return Ele_Fixx::Element[element_id][:def_ele][0]
  401. end
  402. #--------------------------------------------------------------------------
  403. # Get Maximum Value of Defencive Elements
  404. #--------------------------------------------------------------------------
  405. def def_ele_max(element_id)
  406. return Ele_Fixx::Element[element_id][:def_ele][1]
  407. end
  408. #--------------------------------------------------------------------------
  409. # Get Base Element Rate
  410. #--------------------------------------------------------------------------
  411. def def_ele_base(element_id)
  412. features_pi(FEATURE_ELEMENT_RATE, element_id)
  413. end
  414. #--------------------------------------------------------------------------
  415. # Get Real Defencive Element Rate
  416. #--------------------------------------------------------------------------
  417. def element_rate(element_id)
  418. val = ( def_ele_base(element_id) + def_ele_plus(element_id) )
  419. [[val, def_ele_max(element_id)].min, def_ele_min(element_id)].max.to_f
  420. end
  421. #--------------------------------------------------------------------------
  422. # Defencive Elements Plus
  423. #--------------------------------------------------------------------------
  424. def def_ele_plus(element_id)
  425. @def_ele_plus[element_id]
  426. end
  427. #--------------------------------------------------------------------------
  428. # Clear Defencive Elements Plus
  429. #--------------------------------------------------------------------------
  430. def clear_def_ele_plus
  431. @def_ele_plus = [0] * $data_system.elements.size
  432. end
  433. #--------------------------------------------------------------------------
  434. # Add Defencive Elements
  435. #--------------------------------------------------------------------------
  436. def add_def_ele(element_id, value, ref = true)
  437. @def_ele_plus[element_id] += value
  438. refresh if ref
  439. end
  440. #--------------------------------------------------------------------------
  441. # Sub Defencive Elements
  442. #--------------------------------------------------------------------------
  443. def sub_def_ele(element_id, value, ref = true)
  444. @def_ele_plus[element_id] -= value
  445. refresh if ref
  446. end
  447. #--------------------------------------------------------------------------
  448. # Div Defencive Elements
  449. #--------------------------------------------------------------------------
  450. def div_def_ele(element_id, value, ref = true)
  451. @def_ele_plus[element_id] /= value
  452. refresh if ref
  453. end
  454. #--------------------------------------------------------------------------
  455. # Mul Defencive Elements
  456. #--------------------------------------------------------------------------
  457. def mul_def_ele(element_id, value, ref = true)
  458. @def_ele_plus[element_id] *= value
  459. refresh if ref
  460. end
  461. #--------------------------------------------------------------------------
  462. # Mod Defencive Elements
  463. #--------------------------------------------------------------------------
  464. def mod_def_ele(element_id, value, ref = true)
  465. @def_ele_plus[element_id] %= value
  466. refresh if ref
  467. end
  468. #--------------------------------------------------------------------------
  469. # Get Min Value of Attack Elements
  470. #--------------------------------------------------------------------------
  471. def atk_ele_min(element_id)
  472. return Ele_Fixx::Element[element_id][:atk_ele][0]
  473. end
  474. #--------------------------------------------------------------------------
  475. # Get Maximum Value of Attack Elements
  476. #--------------------------------------------------------------------------
  477. def atk_ele_max(element_id)
  478. return Ele_Fixx::Element[element_id][:atk_ele][1]
  479. end
  480. #--------------------------------------------------------------------------
  481. # Get Base Attack Element Rate
  482. #--------------------------------------------------------------------------
  483. def atk_ele_base(element_id)
  484. features_sum(FEATURE_ATK_ELEMENT, element_id)
  485. end
  486. #--------------------------------------------------------------------------
  487. # Get Real Attack Elements Rate
  488. #--------------------------------------------------------------------------
  489. def atk_element_rate(element_id)
  490. val = ( atk_ele_base(element_id) + atk_ele_plus(element_id) )
  491. [[val, atk_ele_max(element_id)].min, atk_ele_min(element_id)].max.to_f
  492. end
  493. #--------------------------------------------------------------------------
  494. # Attack Elements Plus
  495. #--------------------------------------------------------------------------
  496. def atk_ele_plus(element_id)
  497. @atk_ele_plus[element_id]
  498. end
  499. #--------------------------------------------------------------------------
  500. # Clear Attack Elements Plus
  501. #--------------------------------------------------------------------------
  502. def clear_atk_ele_plus
  503. @atk_ele_plus = [0] * $data_system.elements.size
  504. end
  505. #--------------------------------------------------------------------------
  506. # Add Attack Elements
  507. #--------------------------------------------------------------------------
  508. def add_atk_ele(element_id, value, ref = true)
  509. @atk_ele_plus[element_id] += value
  510. refresh if ref
  511. end
  512. #--------------------------------------------------------------------------
  513. # Sub Attack Elements
  514. #--------------------------------------------------------------------------
  515. def sub_atk_ele(element_id, value, ref = true)
  516. @atk_ele_plus[element_id] -= value
  517. refresh if ref
  518. end
  519. #--------------------------------------------------------------------------
  520. # Div Attack Elements
  521. #--------------------------------------------------------------------------
  522. def div_atk_ele(element_id, value, ref = true)
  523. @atk_ele_plus[element_id] /= value
  524. refresh if ref
  525. end
  526. #--------------------------------------------------------------------------
  527. # Mul Attack Elements
  528. #--------------------------------------------------------------------------
  529. def mul_atk_ele(element_id, value, ref = true)
  530. @atk_ele_plus[element_id] *= value
  531. refresh if ref
  532. end
  533. #--------------------------------------------------------------------------
  534. # Mod Attack Elements
  535. #--------------------------------------------------------------------------
  536. def mod_atk_ele(element_id, value, ref = true)
  537. @atk_ele_plus[element_id] %= value
  538. refresh if ref
  539. end
  540.  
  541. end # << Game_BattlerBase
  542.  
  543. #===============================================================================
  544. class Game_Battler < Game_BattlerBase
  545. #===============================================================================
  546. #--------------------------------------------------------------------------
  547. # Get Element Modifier for Skill/Item
  548. #--------------------------------------------------------------------------
  549. def item_element_rate(user, item)
  550. all_eles = user.atk_elements.clone << item.damage.element_id
  551. return 1.0 if all_eles.empty?
  552. return 1.0 if item.no_ele_mod
  553. case Ele_Fixx::DMG_Type
  554. # // Default Type
  555. when 0 then var = elements_max_rate(user.atk_elements)
  556. # // $D13x Type
  557. when 1 then var = sD13x_element_rate(user,item)
  558. # // Adding Type
  559. when 2 then var = elements_add_rate(user.atk_elements)
  560. # // Average Type
  561. when 3 then var = elements_ave_rate(user.atk_elements)
  562. end
  563. if user.is_a?(Game_Actor)
  564. p "[ #{user.name} ] << attacker | element rate is = #{var}"
  565. end
  566. return var
  567. end
  568. #--------------------------------------------------------------------------
  569. # Elements Max Rate (For Reference)
  570. #--------------------------------------------------------------------------
  571. # def elements_max_rate(elements)
  572. # elements.inject([0.0]) {|r, i| r.push(element_rate(i)) }.max
  573. # end
  574. #--------------------------------------------------------------------------
  575. # $D13x Element Rate
  576. #--------------------------------------------------------------------------
  577. def sD13x_element_rate(user,item)
  578. atk_eles = user.atk_elements
  579. skl_eles = item.damage.element_id
  580. rate = 1.0
  581. if !atk_eles.include?(skl_eles)
  582. rate *= element_rate(skl_eles)
  583. end
  584. atk_eles.each do |i|
  585. next unless skl_eles == i
  586. rate *= element_rate(i)
  587. rate *= (1.0+user.atk_element_rate(i))
  588. if user.is_a?(Game_Actor)
  589. # p "#{$data_system.elements[i]} DMG rate is #{rate.to_f}"
  590. end
  591. end
  592. rate
  593. end
  594. #--------------------------------------------------------------------------
  595. # Elements Add Rate
  596. #--------------------------------------------------------------------------
  597. def elements_add_rate(elements)
  598. elements.inject(1.0) {|r, i| r += element_rate(i) - (1.0) }
  599. end
  600. #--------------------------------------------------------------------------
  601. # Elements Average Rate
  602. #--------------------------------------------------------------------------
  603. def elements_ave_rate(elements)
  604. data = elements.inject(0.0) {|r, i| r += element_rate(i) }
  605. (data / (elements.size)).to_f
  606. end
  607.  
  608. end
  609.  
  610. #===============================================================================
  611. class Game_Actor < Game_Battler
  612. #===============================================================================
  613. #--------------------------------------------------------------------------
  614. # Defence Element Max
  615. #--------------------------------------------------------------------------
  616. def def_ele_max(element_id)
  617. base = super
  618. base += actor.max_def_ele[element_id]
  619. base += self.class.max_def_ele[element_id]
  620. base += equips.compact.inject(0) {|r, i| r += i.max_def_ele[element_id] }
  621. base += states.compact.inject(0) {|r, i| r += i.max_def_ele[element_id] }
  622. if $D13x[:Skill_Lv]
  623. base += skills.compact.inject(0) {|r, i| r += (i.max_def_ele[element_id]*
  624. Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_f}
  625. else
  626. base += skills.compact.inject(0) {|r, i| r += i.max_def_ele[element_id] }
  627. end
  628. base
  629. end
  630. #--------------------------------------------------------------------------
  631. # Defence Element Plus
  632. #--------------------------------------------------------------------------
  633. def def_ele_plus(element_id)
  634. base = super
  635. base += actor.def_ele[element_id]
  636. base += self.class.def_ele[element_id]
  637. base += equips.compact.inject(0) {|r, i| r += (i.def_ele[element_id])}
  638. base += states.compact.inject(0) {|r, i| r += i.def_ele[element_id] }
  639. if $D13x[:Skill_Lv]
  640. base += skills.compact.inject(0) {|r, i| r += (i.def_ele[element_id]*
  641. Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_f}
  642. else
  643. base += skills.compact.inject(0) {|r, i| r += i.def_ele[element_id] }
  644. end
  645. base
  646. end
  647. #--------------------------------------------------------------------------
  648. # Attack Element Max
  649. #--------------------------------------------------------------------------
  650. def atk_ele_max(element_id)
  651. base = super
  652. base += actor.max_atk_ele[element_id]
  653. base += self.class.max_atk_ele[element_id]
  654. base += equips.compact.inject(0) {|r, i| r += i.max_atk_ele[element_id] }
  655. base += states.compact.inject(0) {|r, i| r += i.max_atk_ele[element_id] }
  656. if $D13x[:Skill_Lv]
  657. base += skills.compact.inject(0) {|r, i| r += (i.max_atk_ele[element_id]*
  658. Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_f}
  659. else
  660. base += skills.compact.inject(0) {|r, i| r += i.max_atk_ele[element_id] }
  661. end
  662. base
  663. end
  664. #--------------------------------------------------------------------------
  665. # Attack Element Plus
  666. #--------------------------------------------------------------------------
  667. def atk_ele_plus(element_id)
  668. base = super
  669. base += actor.atk_ele[element_id]
  670. base += self.class.atk_ele[element_id]
  671. base += equips.compact.inject(0) {|r, i| r += (i.atk_ele[element_id])}
  672. base += states.compact.inject(0) {|r, i| r += i.atk_ele[element_id] }
  673. if $D13x[:Skill_Lv]
  674. base += skills.compact.inject(0) {|r, i| r += (i.atk_ele[element_id]*
  675. Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_f}
  676. else
  677. base += skills.compact.inject(0) {|r, i| r += i.atk_ele[element_id] }
  678. end
  679. base
  680. end
  681.  
  682. end # << Game_Actor
  683.  
  684. #===============================================================================
  685. class Game_Enemy < Game_Battler
  686. #===============================================================================
  687. #--------------------------------------------------------------------------
  688. # Defence Element Max
  689. #--------------------------------------------------------------------------
  690. def def_ele_max(element_id)
  691. base = super
  692. base += enemy.max_def_ele[element_id]
  693. base += states.compact.inject(0) {|r, i| r += i.max_def_ele[element_id] }
  694. base
  695. end
  696. #--------------------------------------------------------------------------
  697. # Defence Element Plus
  698. #--------------------------------------------------------------------------
  699. def def_ele_plus(element_id)
  700. base = super
  701. base += enemy.def_ele[element_id]
  702. base += states.compact.inject(0) {|r, i| r += i.def_ele[element_id] }
  703. base
  704. end
  705. #--------------------------------------------------------------------------
  706. # Attack Element Max
  707. #--------------------------------------------------------------------------
  708. def atk_ele_max(element_id)
  709. base = super
  710. base += enemy.max_atk_ele[element_id]
  711. base += states.compact.inject(0) {|r, i| r += i.max_atk_ele[element_id] }
  712. base
  713. end
  714. #--------------------------------------------------------------------------
  715. # Attack Element Plus
  716. #--------------------------------------------------------------------------
  717. def atk_ele_plus(element_id)
  718. base = super
  719. base += enemy.atk_ele[element_id]
  720. base += states.compact.inject(0) {|r, i| r += i.atk_ele[element_id] }
  721. base
  722. end
  723.  
  724. end # << Game_Enemy
  725.  
  726. #==============================================================================#
  727. # http://dekitarpg.wordpress.com/ #
  728. #==============================================================================#
  729. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement