Bigace360

ACE Equipment System [RMXP]

Mar 6th, 2014
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 29.97 KB | None | 0 0
  1. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  2. # ■ ACE Equipment System [RMXP]                                        
  3. # ■ Author: Bigace360  
  4. # ■ Version: 1.15
  5. # ■ Date: August 17, 2012
  6. # ■ Blog: http://bigaceworld.wordpress.com/
  7. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  8. #                               VERSION HISTORY                                #
  9. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  10. # 08.17.2012 (v1.00) - Initial Release
  11. # 08.26.2012 (v1.11) - Improved Coding
  12. #                    - Added layout image
  13. # 01.23.2013 (v1.12) - Improved Coding
  14. # 05.12.2013 (v1.14) - Improved Coding
  15. #                    - Fiexed issue with the item window
  16. # 05.21.2013 (v1.15) - Compatibility with Scene_MenuBase to reduce lines and
  17. #                      increase compatibility with other ACMS scripts
  18. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  19. #                                INTRODUCTION                                  #
  20. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  21. # This script essentially redefines the way the equipment system works while
  22. # keeping the core without rewriting too much.  This script changes the
  23. # equipment scene with a different layout and more efficient methods. Also adds
  24. # a command window that allows the player to choose from four diffenet
  25. # methods:  Manual, Optimize, Optimize All, & Unequip All.
  26. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  27. #                                  FEATURES                                    #
  28. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  29. # ● Manual - Equip and unequip equipment one at a time.
  30. # ● Optimize & Optimize all - Chooses the best equipment for the player
  31. #   automatically
  32. # ● Unequip All - removes all equipment from the player
  33. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  34. #                                INSTRUCTIONS                                  #
  35. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  36. # To install this script, open up your script editor and copy/paste this script
  37. # to an open slot below Scene_Debug, and Warrior_Engine, but above Main.
  38. # Considering the special nature of this script, it is highly recommended that
  39. # you place this script above all non-core scripts, but below Warrior Engine,
  40. # Scene_Base, and ACE Scene_Menu. Remember to save.
  41. #
  42. # Scroll down and edit the module as you see fitting for your game.
  43. #
  44. #-------------------------------------------------------------------------------
  45. #
  46. # You can add custom layouts now, place your layout image within the Picture
  47. # folder. If you also have my ACE Menu Engine then place it in the Menu folder.
  48. #
  49. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  50. #                                  SECTIONS                                    #
  51. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  52. #  ■ Modules
  53. # ** ACE Module
  54. #
  55. #  ■ Game_Objects
  56. # ** Game_Temp
  57. # ** Game_Actor
  58. #
  59. #  ■ Windows
  60. # ** Window_Base
  61. # ** Window_Selectable
  62. # ** Window_MenuHelp
  63. # ** Window_Item
  64. # ** Window_EquipLeft
  65. # ** Window_EquipRight
  66. # ** Window_EquipItem
  67. # ** Window_EquipActor
  68. # ** Window_Command_Base
  69. # ** Window_EquipCommand
  70. #
  71. #  ■ Scenes
  72. # ** Scene_Item
  73. # ** Scene_Equip
  74. # ** Scene_Battle
  75. #
  76. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  77. #
  78. # Credits/Thanks:
  79. #   - Bigace360, for the script.
  80. #
  81. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  82. #                     Script Conflicts and Compatability                       #
  83. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  84. # Compatibility
  85. #   Requires the script 'Scene_Base' v1.5 or higher
  86. #   Requires the script 'Scene_MenuBase' v1.00 or higher
  87. #
  88. # ● Alias methods
  89. #   class Game_Temp
  90. #       def initialize
  91. #
  92. #   class Window_Base
  93. #       def initialize(*args)
  94. #
  95. # ● Overwrite methods
  96. #   class Window_EquipLeft
  97. #    Has been completely overwritten. Expect no functionality with any scripts
  98. #    that will also replace Window_EquipLeft.
  99. #      
  100. #   class Window_EquipRight
  101. #    Has been completely overwritten. Expect no functionality with any scripts
  102. #    that will also replace Window_EquipRight.
  103. #
  104. #   class Window_EquipItem
  105. #    Has been completely overwritten. Expect no functionality with any scripts
  106. #    that will also replace Window_EquipItem.
  107. #
  108. #   class Scene_Equip
  109. #    Has been completely overwritten. Expect no functionality with any scripts
  110. #    that will also replace Scene_Equip.
  111. #
  112. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  113. #
  114. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  115. # ■ Module ACE::CORE
  116. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  117. module ACE
  118.     module CORE
  119.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  120.         # ◆ Section I. General Menu Settings ◆
  121.         # -------------------------------------------------------------------------
  122.         # This changes the way Menus appear in your game. You can change their
  123.         # alignment, and the location of the help window, Note that any non-ACE
  124.         # System scripts may not conform to these Menu styles.
  125.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  126.         EQUIP_CONFIG ={
  127.             # :equip_win => [Opacity, Window Border?]. (Opacity Limit: 0~255)
  128.             :equip_win => [200, false],
  129.             # :background - Background images
  130.             :background => 'back04',
  131.             # :menu_index - If :menu_access is true, then this value determines where
  132.             # in the menu command window it is inserted.
  133.             :menu_index => 2,
  134.             # :layout - Image filename for window layout, must be in the Menu folder
  135.             :layout => '',     
  136.         }
  137.        
  138.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  139.         # ◆ Section II. Main Settings ◆
  140.         # -------------------------------------------------------------------------
  141.         # This section adjusts the commands that appear in the command window used
  142.         # for the status screen. Rearrange the commands, add new ones, remove them
  143.         # as you see fit.
  144.         #
  145.         # -------------------------------------------------------------------------
  146.         # :command         Description
  147.         # -------------------------------------------------------------------------
  148.         # :manual          Activates the manual equip window.
  149.         # :optimize        Optimizes one equipment slot for the actor.
  150.         # :optimize_all    Optimizes all equipment slots for the actor.
  151.         # :remove_all      Clears all equipment from the actor.
  152.         # :aptitude        Enter aptitude attuning menu.
  153.         #
  154.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=     
  155.         # This array arranges the order of which the commands appear in the Equip
  156.         # Command window in the Equip Scene.
  157.         EQUIP_COMMAND =[ # Do not remove this.
  158.             [:manual,       'Equip'],
  159.             [:optimize,     'Optimize'],
  160.             [:optimize_all, 'Optimize-All'],
  161.             [:remove_all,   'Clear'],
  162.         ] # Do not remove this.
  163.        
  164.         # This hash allows you change the name of the command and its description.
  165.         EQUIP_DESCRIPTIONS ={ # Do not remove this.
  166.             # :command      => 'DESCRIPTION'
  167.             :manual       => 'Allows you to manually add and remove your player\'s equipment',
  168.             :optimize     => 'Chooses the best equipment for a selected slot',
  169.             :optimize_all => 'Chooses the best equipment for all the slots but accessories',
  170.             :remove_all   => 'Removes all equipment at once',
  171.         } # Do not remove this.
  172.        
  173.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  174.         # ◆ Section III. Optimize Settings ◆
  175.         # -------------------------------------------------------------------------
  176.         # This sections allows you to customize how the system automatically adds
  177.         # equipment to your player.
  178.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  179.         WEIGHT ={
  180.             :weapon =>{
  181.                 :atk => 1.0,
  182.                 :pdef => 0.0,
  183.                 :mdef => 0.0,
  184.                 :str => 0.0,
  185.                 :dex => 0.0,
  186.                 :agi => 0.0,
  187.                 :int => 0.0,
  188.             },
  189.             :armor =>{
  190.                 :eva => 0.0,
  191.                 :pdef => 0.75,
  192.                 :mdef => 0.25,
  193.                 :str => 0.0,
  194.                 :dex => 0.0,
  195.                 :agi => 0.0,
  196.                 :int => 0.0,
  197.             },
  198.         }
  199.         # It ignores optimizations for accessories
  200.         NO_ACCESSORY_OPTIMIZATION = false
  201.        
  202.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  203.         # ◆ Section IV. Misc Window Settings ◆
  204.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  205.         # This section adjusts the minor visuals that you see inside of the newly
  206.         # organized Equip Scene. Adjust the settings as you see fit.
  207.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  208.         # This sets the un-equipment text in the slot window.
  209.         UNEQUIP_ICON = '049-Skill06'
  210.         # This sets the no-equipment text in the slot window.
  211.         NOEQUIP_ICON = '049-Skill06'
  212.         # The following determines the vocabulary used for the remade equip scene.
  213.         # Adjust it accordingly to set the way text is displayed.
  214.         VOCAB ={ # Do not remove this.
  215.             :arrow     => '→',
  216.             :stat_up   => '↑', # '▲' '↑' '»' '+' '>'
  217.             :stat_down => '↓', # '▼' '↓' '«' '-' '>'
  218.             :noequip   => '<No Equipment>',
  219.             :unequip   => '<Unequip>',
  220.             :amount    => ':%2d',
  221.             :eva       => 'EVA',
  222.         } # Do not remove this.
  223.         # These are the stats shown inside of the equip scene menu and they order
  224.         # they'll appear in. If a stat applied by a script doesn't exist, it'll be
  225.         # ignored and the next command will be shifted up by one.
  226.         #   Legal Stats:
  227.         #   :atk, :pdef, :mdef, :str, :dex, :agi, :int, :eva
  228.         SHOWN_STATS = [:atk, :pdef, :mdef, :str, :dex, :agi, :int, :eva]
  229.        
  230.     end
  231.    
  232.     #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  233.     # * BEGIN [ DON'T TOUCH THIS SECTION ]
  234.     #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  235.     #
  236.     # ▼ Warning
  237.     # Editting anything past this point may potentially result in causing
  238.     # computer damage, incontinence, explosion of user's head, coma, death,
  239.     # and/or halitosis so edit at your own risk.
  240.     #
  241.     #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  242.    
  243.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  244.     # ■  MESSAGE
  245.     # ---------------------------------------------------------------------------
  246.     #   Setting module for the ACE::MESSAGE
  247.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  248.     module MESSAGE
  249.         #--------------------------------------------------------------------------
  250.         # * required
  251.         #   This method checks for the existance of the basic module and other
  252.         #   ACMS scripts required for this script to work, don't edit this
  253.         #--------------------------------------------------------------------------
  254.         def self.required(name, req, version, type = nil)
  255.             if !$ace_script[:scene_menu_base]
  256.                 msg = "The script '%s' requires the script\n"
  257.                 msg += "'scene_MenuBase' v%s or higher above it to work properly\n"
  258.                 msg += "Go to http://bigaceworld.wordpress.com/ to download this script."
  259.                 print(sprintf(msg, self.script_name(name), version))
  260.                 exit
  261.             else
  262.                 self.required_script(name, req, version, type)
  263.             end
  264.         end
  265.         #--------------------------------------------------------------------------
  266.         # * script_name
  267.         #   Get the script name base on the imported value, don't edit this
  268.         #--------------------------------------------------------------------------
  269.         def self.script_name(name, ext = "ACMS")
  270.             name = name.to_s.gsub("_", " ").upcase.split
  271.             name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  272.             name.join(" ")
  273.         end
  274.     end
  275. end
  276. #
  277. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  278. #                         ▼ Import to Global Hash ▼                            #
  279. ($ace_script ||= {})[:ace_equip_menu] = 1.15
  280. ACE::MESSAGE.required_script(:ace_equip_menu, :scene_base, 1.5, :above)
  281. ACE::MESSAGE.required_script(:ace_equip_menu, :scene_menu_base, 1.00, :above)
  282. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  283.  
  284. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  285. # ■ Game_Temp
  286. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  287. class Game_Temp
  288.     attr_accessor(:scene_equip_index, :scene_equip_oy)
  289. end
  290.  
  291. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  292. # ■ Game_Actor
  293. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  294. class Game_Actor < Game_Battler
  295.     def equip_slots
  296.         return [0, 1, 2, 3, 4]
  297.     end
  298.     def slot_name
  299.         [
  300.             $data_system.words.weapon,
  301.             $data_system.words.armor1, $data_system.words.armor2,  
  302.             $data_system.words.armor3, $data_system.words.armor4,  
  303.         ]
  304.     end
  305.     def equip_change_ok?(slot_id)
  306.         return true
  307.     end
  308. end
  309.  
  310. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  311. # ■ Window_Base
  312. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  313. class Window_Base < Window
  314.     alias :init_equip_ace :initialize unless $@
  315.     def initialize(*args, &block)
  316.         init_equip_ace(*args, &block)
  317.         equip_opacity? if $scene.is_a?(Scene_Equip)
  318.     end
  319.     def equip_opacity?
  320.         equipment = ACE::CORE::EQUIP_CONFIG[:equip_win]
  321.         self.back_opacity = equipment[0]
  322.         self.opacity = equipment[0] if equipment[1]
  323.     end
  324.     def draw_new_parameter(actor, x, y, stats)
  325.         stats.each do |type|
  326.             case type
  327.             when :atk, :pdef, :mdef, :str, :dex, :agi, :int
  328.                 vocab = eval("$data_system.words.#{type}")
  329.                 value = eval("actor.#{type}.group")
  330.             when :eva
  331.                 vocab = ACE::CORE::VOCAB[:eva]
  332.                 value = sprintf("%d%%", [actor.eva, 100].min)
  333.             else next
  334.             end
  335.             contents.font.color = system_color
  336.             contents.draw_text(x, y, 120, 24, vocab)
  337.             contents.font.color = normal_color
  338.             contents.draw_text(x + 80, y, 36, 24, value, 2)
  339.             y += 20
  340.         end
  341.     end
  342. end
  343.  
  344. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  345. # ■ Window_EquipCommand
  346. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  347. class Window_EquipCommand < Window_CommandBase
  348.     def initialize
  349.         super(create_command_list)
  350.     end
  351.     def create_command_list
  352.         vocab = []; data = []
  353.         EQUIP_COMMAND.each do |command|
  354.             case command[0]
  355.             when :manual, :optimize, :optimize_all, :remove_all
  356.             else next
  357.             end
  358.             data << command[0]; vocab << command[1]
  359.         end
  360.         return vocab, data
  361.     end    
  362.     def visible_line_number
  363.         return [[self.height, 3].min, 1].max  
  364.     end
  365.     def cursor_pagedown
  366.         return if Input.repeat?(Input::R)
  367.         super
  368.     end
  369.     def cursor_pageup
  370.         return if Input.repeat?(Input::L)
  371.         super
  372.     end
  373.     def description
  374.         return EQUIP_DESCRIPTIONS[method]
  375.     end
  376. end
  377.  
  378. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  379. # ■ Window_EquipLeft
  380. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  381. class Window_EquipLeft < Window_Base
  382.     include ACE::CORE
  383.     def initialize(x, y)
  384.         super(x, y, 272, fitting_height(8))
  385.         self.contents = Bitmap.new(width - 32, height - 32)
  386.         @actor = nil
  387.     end
  388.     def actor=(actor)
  389.         return if @actor == actor
  390.         @actor = actor
  391.         refresh
  392.     end
  393.     def refresh
  394.         contents.clear
  395.         stats = SHOWN_STATS
  396.         contents.font.color = normal_color
  397.         draw_parameter(0, stats)
  398.         draw_right_arrow(120, 20)
  399.         draw_new_parameter(@actor, 4, 0, stats)
  400.     end
  401.     def draw_right_arrow(x, y)
  402.         contents.font.color = system_color
  403.         8.times {|i| contents.draw_text(x, y * i, 40, 20, VOCAB[:arrow], 1)}       
  404.     end
  405.     def draw_parameter(y, stats)
  406.         stats.each do |type|
  407.             case type
  408.             when :atk, :pdef, :mdef, :str, :dex, :agi, :int, :eva
  409.             else next
  410.             end
  411.             new_value = eval("@new_#{type.to_s}")
  412.             contents.draw_text(200, y, 36, 24, new_value.to_s, 2)
  413.             y += 20
  414.         end
  415.     end
  416.     def set_new_parameters(new_atk = nil, new_pdef = nil, new_mdef = nil,
  417.             new_str = nil, new_dex = nil, new_agi = nil, new_int = nil, new_eva = nil)
  418.         return unless @new_atk != new_atk || @new_pdef != new_pdef ||  
  419.         @new_mdef != new_mdef ||@new_str != new_str || @new_dex != new_dex ||
  420.         @new_agi != new_agi || @new_int != new_int || @new_eva != new_eva      
  421.         @new_atk  = new_atk
  422.         @new_pdef = new_pdef
  423.         @new_mdef = new_mdef
  424.         @new_str  = new_str
  425.         @new_dex  = new_dex
  426.         @new_agi  = new_agi
  427.         @new_int  = new_int
  428.         @new_eva  = new_eva
  429.         refresh
  430.     end
  431. end
  432.  
  433. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  434. # ■ Window_EquipRight
  435. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  436. class Window_EquipRight < Window_Selectable
  437.     include ACE::CORE
  438.     attr_reader :item_window
  439.     def initialize(x, y)
  440.         super(x, y, 368, fitting_height(8))
  441.         self.contents = Bitmap.new(width - 32, height - 32)
  442.         @actor = nil
  443.         refresh
  444.         deactivate
  445.     end
  446.     def actor=(actor)
  447.         return if @actor == actor
  448.         @actor = actor
  449.         refresh
  450.     end
  451.     def item_max
  452.         @item_max = @actor ? @actor.equip_slots.size : 0
  453.     end
  454.     def item
  455.         @actor ? @actor.equips[index] : nil
  456.     end
  457.     def slot_name(index)
  458.         @actor ? @actor.slot_name[index] : ''
  459.     end
  460.     def enable?(index)
  461.         @actor ? @actor.equip_change_ok?(index) : false
  462.     end
  463.     def refresh
  464.         super
  465.     end
  466.     def draw_item(index)
  467.         return unless @actor
  468.         rect = item_rect_for_text(index)
  469.         contents.font.color = system_color
  470.         contents.font.color.alpha = enable?(index) ? 255 : translucent_alpha
  471.         contents.draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
  472.         item = @actor.equips[index]
  473.         dx = rect.x + 100
  474.         dw = contents.width - dx - 24
  475.         if item.nil?
  476.             draw_nothing_equip(dx, rect.y, false, dw)
  477.         else
  478.             draw_item_name(item, dx, rect.y, enable?(index), dw)
  479.         end    
  480.     end
  481.     def draw_nothing_equip(dx, dy, enabled, dw)
  482.         contents.font.color = normal_color
  483.         contents.font.color.alpha = enabled ? 255 : translucent_alpha
  484.         draw_icon(NOEQUIP_ICON, dx, dy, enabled)
  485.         contents.draw_text(dx + 24, dy, dw - 24, line_height, VOCAB[:noequip])
  486.     end
  487.     def item_window=(item_window)
  488.         @item_window = item_window
  489.         update
  490.     end
  491.   def update
  492.     super
  493.     @item_window.slot_id = index if @item_window
  494.   end
  495.     def update_help
  496.         @help_window.set_text(item.nil? ? VOCAB[:noequip] : item.description)
  497.     end
  498. end
  499.  
  500. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  501. # ■ Window_EquipItem
  502. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  503. class Window_EquipItem < Window_Item
  504.     include ACE::CORE
  505.     def initialize(x, y, width)
  506.         super(x, y, width, fitting_height(8))
  507.         @actor = nil
  508.         @slot_id = 0
  509.         @column_max = 1
  510.         deactivate
  511.         unselect
  512.     end
  513.     def actor=(actor)
  514.         return if @actor == actor
  515.         @actor = actor
  516.         refresh
  517.         self.oy = 0
  518.     end
  519.     def slot_id=(slot_id)
  520.         return if @slot_id == slot_id
  521.         @slot_id = slot_id
  522.         refresh
  523.         self.oy = 0
  524.     end
  525.     def include?(item)
  526.         return true if item.nil?
  527.         if @slot_id == 0
  528.             return false unless item.is_a?(RPG::Weapon)
  529.         else
  530.             return false unless item.is_a?(RPG::Armor)
  531.             return false if item.kind != @actor.equip_slots[@slot_id - 1]
  532.         end
  533.         return @actor.equippable?(item)
  534.     end
  535.     def enable?(item)
  536.         return true
  537.     end
  538.     def draw_item(index)
  539.         item = @data[index]
  540.         rect = item_rect(index)
  541.         return draw_remove_equip(rect) if item.nil?
  542.         number = $game_party.item_number(item)
  543.         dw = contents.width - rect.x - 24
  544.         draw_item_name(item, rect.x, rect.y, enable?(item), dw)
  545.         contents.draw_text(rect, sprintf(VOCAB[:amount], number), 2)
  546.     end
  547.     def draw_remove_equip(rect)
  548.         draw_icon(UNEQUIP_ICON, rect.x, rect.y + 4)
  549.         rect.x += 26; rect.width -= 24
  550.         contents.font.color.alpha = 128
  551.         contents.draw_text(rect, VOCAB[:unequip])      
  552.     end
  553.     def update_help
  554.         @help_window.set_text(item.nil? ? VOCAB[:unequip] : item.description)
  555.     end
  556. end
  557.  
  558. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  559. # ■ Scene_Equip
  560. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  561. class Scene_Equip < Scene_MenuBase            
  562.     def initialize(actor_index = 0)
  563.         @actor_index = actor_index
  564.     end
  565.     def equip_type_max; return @actor.equip_slots.size; end
  566.     def create_menu_layout
  567.         super
  568.         return if EQUIP_CONFIG[:layout].empty?
  569.         @back.bitmap = RPG::Cache.menu("Background/#{EQUIP_CONFIG[:layout]}")
  570.     end
  571.     def start
  572.         super
  573.         @actor = $game_party.actors[@actor_index]
  574.         create_help_window
  575.         create_status_window
  576.         create_command_window
  577.         create_slot_window
  578.         create_item_windows
  579.         relocate_windows if $ace_script[:ace_main_menu]
  580.     end
  581.     def create_status_window
  582.         @status_window = Window_EquipLeft.new(368, 192)
  583.         @actor_window = Window_StatusActor.new(160, 64)
  584.         @status_window.actor = @actor
  585.         @actor_window.actor = @actor       
  586.     end
  587.     def create_command_window
  588.         @command_window = Window_EquipCommand.new
  589.         @command_window.help_window = @help_window
  590.         @command_window.y = @help_window.height
  591.         @command_window.oy = @equip_oy if !@equip_oy.nil?
  592.         @command_window.activate.select(0)
  593.     end
  594.     def create_slot_window
  595.         @equip_window = Window_EquipRight.new(0, 192)
  596.         @equip_window.help_window = @help_window
  597.         @equip_window.actor = @actor
  598.         @equip_window.select(0)    
  599.     end
  600.     def create_item_windows
  601.         @item_windows = []
  602.         equip_type_max.times do |i|
  603.             @item_windows[i] = Window_EquipItem.new(0, 192, 368)
  604.             @item_windows[i].help_window = @help_window
  605.             @item_windows[i].actor = @actor
  606.             @item_windows[i].slot_id = i
  607.             @item_windows[i].hide
  608.         end
  609.     end
  610.     def relocate_windows
  611.         relocate_help
  612.         relocate_command if Menu.main_menu_right
  613.     end
  614.     def relocate_help
  615.         case Menu.main_menu_align
  616.         when 0
  617.             @help_window.y = 0
  618.             @command_window.y = @help_window.height
  619.             @status_window.y = @command_window.y + @command_window.height
  620.         when 1
  621.             @command_window.y = 0
  622.             @help_window.y = @actor_window.height
  623.             @status_window.y = @help_window.y + @help_window.height
  624.         else
  625.             @command_window.y = 0
  626.             @status_window.y = @actor_window.height
  627.             @help_window.y = @status_window.y + @status_window.height
  628.         end
  629.         @status_window.y = @equip_window.y
  630.         @actor_window.y = @command_window.y
  631.     end
  632.     def relocate_command
  633.         @actor_window.x = 0
  634.         @command_window.x = 480
  635.     end
  636.     def background_image
  637.         EQUIP_CONFIG[:background]
  638.     end
  639.     def update
  640.         super
  641.         update_item_windows
  642.         update_status_window
  643.         if @command_window.active;  update_command_selection
  644.         elsif @equip_window.active; update_equip_selection
  645.         elsif @item_window.active;  update_item_selection
  646.         end
  647.     end
  648.     def update_item_windows
  649.         equip_type_max.times do |i|
  650.             @item_windows[i].visible = (@equip_window.index == i)
  651.         end
  652.         @item_window = @item_windows[@equip_window.index]
  653.     end
  654.     def update_status_window
  655.         item1 = @equip_window.item
  656.         @status_window.set_new_parameters if @equip_window.active
  657.         return unless @item_window.active
  658.         item2 = @item_window.item
  659.         @actor.equip(@equip_window.index, item2.nil? ? 0 : item2.id)
  660.         new_atk, new_pdef, new_mdef = @actor.atk, @actor.pdef, @actor.mdef
  661.         new_str, new_dex,  new_agi  = @actor.str, @actor.dex,  @actor.agi
  662.         new_int, new_eva = @actor.int, @actor.eva
  663.         @actor.equip(@equip_window.index, item1.nil? ? 0 : item1.id)
  664.         @status_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str,
  665.             new_dex, new_agi, new_int, new_eva)
  666.     end
  667.     def update_command_selection
  668.         equip_type_max.times {|i| @item_windows[i].hide}
  669.         update_command if Input.trigger?(Input::C)
  670.         cancel_command if Input.trigger?(Input::B)    
  671.         actors_command if Input.trigger?(Input::R) || Input.trigger?(Input::L)
  672.     end
  673.     def cancel_command
  674.         Sound.play_se(:cancel)
  675.         if $ace_script[:ace_main_menu] && !$ace_script[:ace_status_menu]
  676.             return unless $game_temp.menu_command_index.has_key?(:equip)
  677.             $scene = Scene_Menu.new($game_temp.menu_command_index[:equip])
  678.         elsif $ace_script[:ace_status_menu] && $game_temp.status_index
  679.             $scene = Scene_Status(@actor_index)
  680.         else
  681.             $scene = Scene_Menu.new(EQUIP_CONFIG[:menu_index])
  682.         end
  683.     end
  684.     def cancel_equiped
  685.         Sound.play_se(:cancel)
  686.         @equip_window.deactivate
  687.         @command_window.activate
  688.     end
  689.     def update_command
  690.         Sound.play_se(:decision)
  691.         @command_window.deactivate
  692.         case @command_window.method
  693.         when :manual, :optimize then @equip_window.activate.select(0)
  694.         when :optimize_all then optimize_all
  695.         when :remove_all   then remove_all      
  696.         end
  697.     end
  698.     def update_equip_selection
  699.         @equip_window.show
  700.         equip_type_max.times {|i| @item_windows[i].hide}
  701.         cancel_equiped if Input.trigger?(Input::B)
  702.         select_equiped if Input.trigger?(Input::C)  
  703.         actors_command if Input.trigger?(Input::R) || Input.trigger?(Input::L)
  704.     end
  705.     def select_equiped
  706.         Sound.play_se(:decision)
  707.         case @command_window.method
  708.         when :manual   then equip_manual
  709.         when :optimize then equip_optimize
  710.         end
  711.     end
  712.     def equip_manual
  713.         if @actor.equip_fix?(@equip_window.index)
  714.             Sound.play_se(:buzzer)
  715.         else
  716.             Sound.play_se(:decision)
  717.             @equip_window.deactivate
  718.             @item_window.activate.select(0)
  719.         end
  720.     end
  721.     def equip_optimize
  722.         @equip_window.deactivate
  723.         update_optimize
  724.     end
  725.     def update_optimize
  726.         cancel_optimize if Input.trigger?(Input::B)
  727.         select_optimize if Input.trigger?(Input::C)
  728.     end
  729.     def cancel_optimize
  730.         Sound.play_se(:cancel)
  731.         @equip_window.deactivate
  732.         @command_window.activate       
  733.     end
  734.     def select_optimize
  735.         Sound.play_se(:decision)
  736.         optimize(@equip_window.index)
  737.         item_refresh_windows
  738.         @equip_window.activate     
  739.     end
  740.     def optimize_all
  741.         Sound.play_se(:decision)
  742.         optimize_equipments
  743.         item_command_active
  744.     end
  745.     def remove_all
  746.         Sound.play_se(:decision)
  747.         clear_equipments
  748.         item_command_active
  749.     end
  750.     def item_refresh_windows
  751.         @equip_window.refresh
  752.         @status_window.refresh
  753.     end
  754.     def item_command_active
  755.         item_refresh_windows
  756.         @command_window.activate
  757.     end
  758.     def clear_equipments
  759.         equip_type_max.times do |slot|
  760.             @actor.equip(slot, 0) if @actor.equip_change_ok?(slot)
  761.         end
  762.     end
  763.     def optimize_equipments
  764.         equip_type_max.times do |slot|
  765.             optimize(slot) if @actor.equip_change_ok?(slot)
  766.         end
  767.     end
  768.     def optimize(slot)
  769.         if slot == 0
  770.             object = $data_weapons[@actor.weapon_id]
  771.             optimal = object.id
  772.             max = 0.00
  773.             @actor.weapon_id != 0 ? max = calc_weapon_stats(object) : optimal = 0
  774.             @actor.equip(0, 0)
  775.             flag = false; zero_flag = true
  776.             $data_weapons.each do |weapon|
  777.                 next flag = true if !flag
  778.                 evaluation = 0.00
  779.                 evaluation = calc_weapon_stats(weapon)
  780.                 zero_flag = false   if evaluation > 0
  781.                 next unless @actor.equippable?(weapon) && evaluation > max &&
  782.                 $game_party.weapon_number(weapon.id) > 0
  783.                 max = evaluation
  784.                 optimal = weapon.id
  785.             end
  786.             optimal = 0 if zero_flag
  787.             @actor.equip(0, optimal)
  788.         elsif slot >= 1
  789.             not_equipped = false
  790.             case slot
  791.             when 1
  792.                 not_equipped = true if @actor.armor1_id == 0
  793.                 not_equipped = true unless object = $data_armors[@actor.armor1_id]
  794.             when 2
  795.                 not_equipped = true if @actor.armor2_id == 0
  796.                 not_equipped = true unless object = $data_armors[@actor.armor2_id]
  797.             when 3
  798.                 not_equipped = true if @actor.armor3_id == 0
  799.                 not_equipped = true unless object = $data_armors[@actor.armor3_id]
  800.             else
  801.                 return if NO_ACCESSORY_OPTIMIZATION
  802.                 not_equipped = true if @actor.armor4_id == 0
  803.                 not_equipped = true unless object = $data_armors[@actor.armor4_id]  
  804.             end
  805.             optimal = object.id
  806.             current = 0.00
  807.             not_equipped = false ? current = calc_armor_stats(object) : optimal = 0
  808.             @actor.equip(slot, 0)
  809.             flag = false; zero_flag = true
  810.             $data_armors.each do |armor|
  811.                 next flag = true if !flag
  812.                 next if armor.kind != slot-1
  813.                 evaluation = 0.00
  814.                 evaluation = calc_armor_stats(armor)
  815.                 zero_flag = false   if evaluation > 0
  816.                 next unless @actor.equippable?(armor) &&
  817.                 $game_party.armor_number(armor.id) > 0 && evaluation > current
  818.                 current = evaluation
  819.                 optimal = armor.id
  820.             end
  821.             optimal = 0 if zero_flag
  822.             @actor.equip(slot, optimal)
  823.         end  
  824.     end
  825.     def calc_weapon_stats(object)
  826.         current = 0.00
  827.         current += object.atk * WEIGHT[:weapon][:atk]
  828.         current += object.pdef * WEIGHT[:weapon][:pdef]
  829.         current += object.mdef * WEIGHT[:weapon][:mdef]
  830.         current += object.str_plus * WEIGHT[:weapon][:str]
  831.         current += object.dex_plus * WEIGHT[:weapon][:dex]
  832.         current += object.agi_plus * WEIGHT[:weapon][:agi]
  833.         current += object.int_plus * WEIGHT[:weapon][:int]
  834.         return current
  835.     end
  836.     def calc_armor_stats(object)
  837.         current = 0.00                 
  838.         current += object.eva * WEIGHT[:armor][:eva]
  839.         current += object.pdef * WEIGHT[:armor][:pdef]
  840.         current += object.mdef * WEIGHT[:armor][:mdef]
  841.         current += object.str_plus * WEIGHT[:armor][:str]
  842.         current += object.dex_plus * WEIGHT[:armor][:dex]
  843.         current += object.agi_plus * WEIGHT[:armor][:agi]
  844.         current += object.int_plus * WEIGHT[:armor][:int]
  845.         return current
  846.     end
  847.     def update_item_selection
  848.         @equip_window.hide
  849.         cancel_item if Input.trigger?(Input::B)
  850.         select_item if Input.trigger?(Input::C)
  851.     end
  852.     def cancel_item
  853.         Sound.play_se(:cancel)
  854.         @equip_window.activate
  855.         @item_window.deactivate.unselect
  856.     end
  857.     def select_item
  858.         Sound.play_se(:equip)
  859.         item = @item_window.item
  860.         @actor.equip(@equip_window.index, item.nil? ? 0 : item.id)
  861.         @item_window.deactivate.unselect
  862.         @equip_window.activate.refresh
  863.         @item_windows.each {|x| x.refresh}
  864.     end
  865.     def actors_command
  866.         Sound.play_se(:cursor)
  867.         @actor_index += Input.trigger?(Input::L) ? -1 : 1
  868.         @actor_index %= $game_party.actors.size
  869.         $scene = Scene_Equip.new(@actor_index)
  870.     end
  871. end
Add Comment
Please, Sign In to add comment