Advertisement
Ocedic

OC Custom Equip Optimize 1.0

Mar 30th, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.29 KB | None | 0 0
  1. # *****************************************************************************
  2. #
  3. # OC CUSTOM EQUIP OPTIMIZE
  4. # Author: Ocedic
  5. # Site: http://ocedic.wordpress.com/
  6. # Version: 1.0
  7. # Last Updated: 3/30/13
  8. #
  9. # Updates:
  10. # 1.0  - First release
  11. #
  12. # *****************************************************************************
  13.  
  14. $imported = {} if $imported.nil?
  15. $imported["OC-CustomOptimize"] = true
  16.  
  17. #==============================================================================
  18. # ▼ Introduction
  19. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  20. # This script allows you to set custom stat weight on a per-class basis when
  21. # using the Optimize option in the Equip menu.
  22. #==============================================================================
  23. # ▼ Instructions
  24. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  25. # Plug and play script. Simply paste it above Main. Settings can be adjusted
  26. # in configuration section.
  27. #
  28. # In the notebox section of WEAPONS and ARMOR, you may add the following tag:
  29. # <optimize: x>
  30. # Where x is a flat adjustment to that item's value. This value may be negative.
  31. #==============================================================================
  32. # ▼ Compatibility
  33. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  34. # This script may not be compatible with scripts that also change the Optimize
  35. # option. It is compatible with Yanfly Ace Equip Engine.
  36. #==============================================================================
  37. # ▼ Terms of Use
  38. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  39. # Can be freely used and modified in non-commercial projects. Proper attribution
  40. # must be given to Ocedic, and this header must be preserved.
  41. # For commercial terms, see here: https://ocedic.wordpress.com/terms-of-use/
  42. #==============================================================================
  43.  
  44. module OC
  45.   module OPTIMIZE
  46.  
  47. #==============================================================================
  48. # * Archetypes *
  49. #------------------------------------------------------------------------------
  50. #   Allows you to set the stat weight of each parameter for each class.
  51. #   Item value to that class will be determined the summation of each PARAM
  52. #   multiplied by its WEIGHT.
  53. #   To add additional classes, simply copy and paste a line and change its
  54. #   CLASS ID to the appropriate index.
  55. #==============================================================================
  56.     W_ARCHETYPES = {
  57.    
  58. #     [Class ID, MaxHP, MaxMP, ATK, DEF, MAT, MDF, AGI, LUK]
  59.            1 => [  0.5,     0,   4,   1,   1,   1,   1,   1],
  60.            2 => [    1,     0,   2,   1,   2,   1,   1,   1],
  61.    
  62.     } # Don't delete this
  63.    
  64.     A_ARCHETYPES = {
  65.    
  66. #     [Class ID, MaxHP, MaxMP, ATK, DEF, MAT, MDF, AGI, LUK]
  67.            1 => [  0.5,     0,   1,   2,   1,   2,   1,   1],
  68.            2 => [    1,     0,   2,   1,   2,   1,   1,   1],
  69.    
  70.     } # Don't delete this
  71.    
  72.   end
  73. end
  74.  
  75.  
  76. #==============================================================================
  77. # ■ Game_Actor
  78. #==============================================================================
  79.  
  80. class Game_Actor < Game_Battler
  81.  
  82. #==============================================================================
  83. # * Overwrite: Optimize Equipments *
  84. #==============================================================================
  85.   def optimize_equipments
  86.     $game_temp.eds_actor = self if $imported["YEA-AceEquipEngine"]
  87.     @optimize_clear = true if $imported["YEA-AceEquipEngine"]
  88.     clear_equipments
  89.     @optimize_clear = false if $imported["YEA-AceEquipEngine"]
  90.     equip_slots.size.times do |i|
  91.       next if !equip_change_ok?(i)
  92.       if $imported["YEA-AceEquipEngine"]
  93.         next unless can_optimize?(i)
  94.       end
  95.       items = $game_party.equip_items.select do |item|
  96.         item.etype_id == equip_slots[i] &&
  97.         equippable?(item) && item.performance(@class_id) >= 0
  98.       end
  99.       change_equip(i, items.max_by {|item| item.performance(@class_id) })
  100.     end
  101.     $game_temp.eds_actor = nil if $imported["YEA-AceEquipEngine"]
  102.   end
  103.  
  104. end #class game_actor
  105.  
  106. #==============================================================================
  107. # ■ RPG::Weapon
  108. #==============================================================================
  109.  
  110. class RPG::Weapon < RPG::EquipItem
  111.  
  112. #==============================================================================
  113. # * Alias: Performance *
  114. #==============================================================================
  115.   alias oc_rpg_weapon_performance_sl39k performance
  116.   def performance(id)
  117.     if OC::OPTIMIZE::W_ARCHETYPES[id]
  118.       params.each_with_index.inject(optimize_adjust) {|result, (i, j)|
  119.         result += i * OC::OPTIMIZE::W_ARCHETYPES[id][j]}
  120.     else
  121.       oc_rpg_weapon_performance_sl39k
  122.     end    
  123.   end  
  124.  
  125. end #class RPG::Weapon
  126.  
  127. #==============================================================================
  128. # ■ RPG::Armor
  129. #==============================================================================
  130.  
  131. class RPG::Armor < RPG::EquipItem
  132.  
  133. #==============================================================================
  134. # * Alias: Performance *
  135. #==============================================================================
  136.   alias oc_rpg_armor_performance_mw93k performance
  137.   def performance(id)
  138.     if OC::OPTIMIZE::A_ARCHETYPES[id]
  139.       params.each_with_index.inject(0) {|result, (i, j)|
  140.         result += i * OC::OPTIMIZE::A_ARCHETYPES[id][j]}
  141.     else
  142.       oc_rpg_armor_performance_mw93k
  143.     end    
  144.   end  
  145.  
  146. end #class RPG::Weapon
  147.  
  148. #==============================================================================
  149. # ■ RPG::EquipItem
  150. #==============================================================================
  151.  
  152. class RPG::EquipItem
  153.  
  154. #==============================================================================
  155. # * New Method: Optimize Adjust *
  156. #==============================================================================
  157.   def optimize_adjust
  158.     if @weight_adjust == nil
  159.       if @note =~ /<optimize: (.*)>/i
  160.         @weight_adjust = $1.to_i
  161.       else
  162.         @weight_adjust = 0
  163.       end
  164.     end
  165.     @weight_adjust
  166.   end
  167.  
  168. end #class RPG::EquipItem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement