Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  2. #
  3. #Change equipment during battle
  4. #
  5. #Add "equipment" to command,
  6. #Equipment can be changed during battle.
  7. #
  8. #★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  9.  
  10. #------------------------------------------------------------------------------
  11. #Setting
  12. module MARU_battleequip
  13.   SWITCH = 1 #Switch to enable "equipment command"
  14. #------------------------------------------------------------------------------
  15. end
  16.  
  17. #==============================================================================
  18. # ■ Window_ActorCommand
  19. #------------------------------------------------------------------------------
  20. #  Window used to select actor actions on the battle screen.
  21. #==============================================================================
  22.  
  23. class Window_ActorCommand < Window_Command
  24.   #--------------------------------------------------------------------------
  25.   # ● Create command list
  26.   #--------------------------------------------------------------------------
  27.   alias ma0075make_command_list make_command_list
  28.   def make_command_list
  29.     ma0075make_command_list
  30.     add_equip_command if $game_switches[MARU_battleequip::SWITCH] == true
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● Add item command to list
  34.   #--------------------------------------------------------------------------
  35.   def add_equip_command
  36.     add_command("Equipment", :equip)
  37.   end
  38. end
  39.  
  40. #==============================================================================
  41. # ■ Scene_Battle
  42. #------------------------------------------------------------------------------
  43. #  Class for battle screen processing.
  44. #==============================================================================
  45.  
  46. class Scene_Battle < Scene_Base
  47.   #--------------------------------------------------------------------------
  48.   # ● Create all windows
  49.   #--------------------------------------------------------------------------
  50.   alias ma0075_create_all_windows create_all_windows
  51.   def create_all_windows
  52.     ma0075_create_all_windows
  53.     create_equip_window if $game_switches[MARU_battleequip::SWITCH] == true
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● Create actor command window
  57.   #--------------------------------------------------------------------------
  58.   alias ma0075_create_actor_command_window create_actor_command_window
  59.   def create_actor_command_window
  60.     ma0075_create_actor_command_window
  61.     @actor_command_window.set_handler(:equip, method(:command_equip))
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● Create equipment window
  65.   #--------------------------------------------------------------------------
  66.   def create_equip_window
  67.     @status_equip_window = Window_EquipStatus.new(0, @help_window.height)
  68.     @status_equip_window.visible = false
  69.     @status_equip_window.viewport = @viewport
  70.     wx = @status_equip_window.width
  71.     wy = @help_window.height
  72.     ww = Graphics.width - @status_equip_window.width
  73.     @command_equip_window = Window_EquipCommand.new(wx, wy, ww)
  74.     @command_equip_window.visible = false
  75.     @command_equip_window.deactivate
  76.     @command_equip_window.viewport = @viewport
  77.     @command_equip_window.help_window = @help_window
  78.     @command_equip_window.set_handler(:equip,    method(:command_equip_e))
  79.     @command_equip_window.set_handler(:optimize, method(:command_optimize))
  80.     @command_equip_window.set_handler(:clear,    method(:command_clear))
  81.     @command_equip_window.set_handler(:cancel,   method(:on_command_cancel))
  82.     wx = @status_equip_window.width
  83.     wy = @command_equip_window.y + @command_equip_window.height
  84.     ww = Graphics.width - @status_equip_window.width
  85.     @slot_window = Window_EquipSlot.new(wx, wy, ww)
  86.     @slot_window.visible = false
  87.     @slot_window.viewport = @viewport
  88.     @slot_window.help_window = @help_window
  89.     @slot_window.status_window = @status_equip_window
  90.     @slot_window.set_handler(:ok,       method(:on_slot_ok))
  91.     @slot_window.set_handler(:cancel,   method(:on_slot_cancel))
  92.     wx = 0
  93.     wy = @slot_window.y + @slot_window.height
  94.     ww = Graphics.width
  95.     wh = Graphics.height - wy
  96.     @item_equip_window = Window_EquipItem.new(wx, wy, ww, wh)
  97.     @item_equip_window.visible = false
  98.     @item_equip_window.viewport = @viewport
  99.     @item_equip_window.help_window = @help_window
  100.     @item_equip_window.status_window = @status_equip_window
  101.     @item_equip_window.set_handler(:ok,     method(:on_item_equip_ok))
  102.     @item_equip_window.set_handler(:cancel, method(:on_item_equip_cancel))
  103.     @slot_window.item_window = @item_equip_window
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● Command [equipment]
  107.   #--------------------------------------------------------------------------
  108.   def command_equip
  109.     @help_window.show
  110.     @actor = BattleManager.actor
  111.     @status_equip_window.actor = @actor
  112.     @slot_window.actor = @actor
  113.     @item_equip_window.actor = @actor
  114.     @status_equip_window.refresh
  115.     @status_equip_window.show
  116.     @command_equip_window.refresh
  117.     @command_equip_window.show.activate
  118.     @slot_window.refresh
  119.     @slot_window.show
  120.     @item_equip_window.refresh
  121.     @item_equip_window.show
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● Command [change equipment]
  125.   #--------------------------------------------------------------------------
  126.   def command_equip_e
  127.     @slot_window.activate
  128.     @slot_window.select(0)
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● Command [optimize]
  132.   #--------------------------------------------------------------------------
  133.   def command_optimize
  134.     Sound.play_equip
  135.     @actor.optimize_equipments
  136.     @status_equip_window.refresh
  137.     @slot_window.refresh
  138.     @command_equip_window.activate
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● Command [remove all]
  142.   #--------------------------------------------------------------------------
  143.   def command_clear
  144.     Sound.play_equip
  145.     @actor.clear_equipments
  146.     @status_equip_window.refresh
  147.     @slot_window.refresh
  148.     @command_equip_window.activate
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ● Command [cancel]
  152.   #--------------------------------------------------------------------------
  153.   def on_command_cancel
  154.     @help_window.hide
  155.     @status_equip_window.hide
  156.     @command_equip_window.hide
  157.     @slot_window.hide
  158.     @item_equip_window.hide
  159.     @actor_command_window.activate
  160.     @actor_command_window.select(0)
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● Slot [decision]
  164.   #--------------------------------------------------------------------------
  165.   def on_slot_ok
  166.     @item_equip_window.activate
  167.     @item_equip_window.select(0)
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # ● Slot [cancel]
  171.   #--------------------------------------------------------------------------
  172.   def on_slot_cancel
  173.     @slot_window.unselect
  174.     @command_equip_window.activate
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # ● Item [decision]
  178.   #--------------------------------------------------------------------------
  179.   def on_item_equip_ok
  180.     Sound.play_equip
  181.     @actor.change_equip(@slot_window.index, @item_equip_window.item)
  182.     @slot_window.activate
  183.     @slot_window.refresh
  184.     @item_equip_window.unselect
  185.     @item_equip_window.refresh
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● Item [cancel]
  189.   #--------------------------------------------------------------------------
  190.   def on_item_equip_cancel
  191.     @slot_window.activate
  192.     @item_equip_window.unselect
  193.   end
  194. end