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