[XP] Mouse-Friendly Equipment Screen

Started by RPGManiac3030, July 08, 2011, 02:55:22 pm

Previous topic - Next topic

RPGManiac3030

July 08, 2011, 02:55:22 pm Last Edit: July 11, 2011, 01:36:14 am by RPGManiac3030
Mouse Friendly Equipment Screen
Author: RPGManiac3030
Version: 1.0
Type: Custom Menu
Key Term: Custom Menu



Introduction

This is a small edit of Scene_Equip that basically makes it more compatible with a mouse script.

If you're not using a mouse script in your game, this script also allows the player to quickly change a piece of equipment in the menu. If you equipped a sword, you can then quickly choose another sword instead of having to choose your already-equipped sword and going through the list again. See the demo to see this in action.

Features


  • Makes the default equipment screen compatible with a mouse script (i.e. Blizzard's mouse controller) so that the equipment list menu doesn't disappear when the mouse isn't selecting a piece of equipment...see the screenshot to see what I'm talking about   :^_^':

  • After equipping a weapon/armor, you can quickly select another piece.




Screenshots

This is before my edit is implemented:
Spoiler: ShowHide


This is after my edit is implemented:
Spoiler: ShowHide



Demo
Note: The demo doesn't make use of a mouse input module. It will work, though



Script
Spoiler: ShowHide
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Mouse friendly Equip Screen
# By RPGManiac3030
# Version 1.0
# www.chaos-project.com
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Version History:
#   v.1.0
#    -Original Release
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Features:
#   -Makes the Equipment screen more convenient to use with a mouse.
#   -Doesn't return to character's equip list after equipping/removing
#    a weapon/armor, allowing the player to quickly choose a different one.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Instructions:
#    -This script is designed to work with the default equipment menu, and is
#     therefore plug-and-play. If you are using a custom equip screen, you
#     will need to adapt this script to fit the Scene_Equip of whatever
#     custom script you are using.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Compatibility:
#
#   -Created with Blizzard's Mouse Controller as a reference, but should work
#    with any mouse script out there.
#
#   -This CAN be used without a mouse script, but it was made to make
#    the equipment screen compatable with a mouse.
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Author's notes:
#   I edited 2 different things in this script for the purpose of making the
#   equipment screen not glitch up with a mouse:
#
#   1)Adding an empty window to draw when the index = nil (If the mouse isn't over
#     any of the currently equipped items).
#
#   2)Editing the input update for the list of equippable items so that it
#     doesn't automatically return to the list of equipped items.
#
#   If you have a custom equipment menu script, you should edit number 1
#   ONLY.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#Begin Edit
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
#  This class performs equipment screen processing.
#==============================================================================

class Scene_Equip
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Get actor
   @actor = $game_party.actors[@actor_index]
   # Make windows
   @help_window = Window_Help.new
   @left_window = Window_EquipLeft.new(@actor)
   @right_window = Window_EquipRight.new(@actor)
   @item_window1 = Window_EquipItem.new(@actor, 0)
   @item_window2 = Window_EquipItem.new(@actor, 1)
   @item_window3 = Window_EquipItem.new(@actor, 2)
   @item_window4 = Window_EquipItem.new(@actor, 3)
   @item_window5 = Window_EquipItem.new(@actor, 4)
   @item_window6 = Window_EquipItem.new(@actor, 4)
   # Associate help window
   @right_window.help_window = @help_window
   @item_window1.help_window = @help_window
   @item_window2.help_window = @help_window
   @item_window3.help_window = @help_window
   @item_window4.help_window = @help_window
   @item_window5.help_window = @help_window
   # Set cursor position
   @right_window.index = @equip_index
   refresh
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end
   # Prepare for transition
   Graphics.freeze
   # Dispose of windows
   @help_window.dispose
   @left_window.dispose
   @right_window.dispose
   @item_window1.dispose
   @item_window2.dispose
   @item_window3.dispose
   @item_window4.dispose
   @item_window5.dispose
   @item_window6.dispose
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   # Set item window to visible
   @item_window1.visible = (@right_window.index == 0)
   @item_window2.visible = (@right_window.index == 1)
   @item_window3.visible = (@right_window.index == 2)
   @item_window4.visible = (@right_window.index == 3)
   @item_window5.visible = (@right_window.index == 4)
   # Get currently equipped item
   item1 = @right_window.item
   # Set current item window to @item_window
   @item_window6.contents.dispose
   case @right_window.index
   when 0
     @item_window = @item_window1
   when 1
     @item_window = @item_window2
   when 2
     @item_window = @item_window3
   when 3
     @item_window = @item_window4
   when 4
     @item_window = @item_window5
   else
     @item_window = @item_window6
   end
   # If right window is active
   if @right_window.active
     # Erase parameters for after equipment change
     @left_window.set_new_parameters(nil, nil, nil)
   end
   # If item window is active
   if @item_window.active
     # Get currently selected item
     item2 = @item_window.item
     # Change equipment
     last_hp = @actor.hp
     last_sp = @actor.sp
     @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
     # Get parameters for after equipment change
     new_atk = @actor.atk
     new_pdef = @actor.pdef
     new_mdef = @actor.mdef
     # Return equipment
     @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
     @actor.hp = last_hp
     @actor.sp = last_sp
     # Draw in left window
     @left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when item window is active)
 #--------------------------------------------------------------------------
 def update_item
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Activate right window
     @right_window.active = true
     @item_window.active = false
     @item_window.index = -1
     # Remake right window and item window contents
     @right_window.refresh
     @item_window.refresh
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Play equip SE
       $game_system.se_play($data_system.equip_se)
     # Get currently selected data on the item window
     item = @item_window.item
     # Change equipment
     @actor.equip(@right_window.index, item == nil ? 0 : item.id)
     # Remake right window and item window contents
     @right_window.refresh
     @item_window.refresh
     return
   end
 end
end
#End Edit



If you use Fyre's custom equipment screen, use this edit:
See instructions on how to install this!
Spoiler: ShowHide

#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
#  This class performs equipment screen processing.
#==============================================================================

class Scene_Equip
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #     equip_index : equipment index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
    @equip_index = equip_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make windows
    @char_window = Window_CharInfo.new(@actor)
    @help_window = Window_EquipHelp.new
    @left_window = Window_EquipStat.new(@actor)
    @right_window = Window_Equipment.new(@actor)
    @item_window1 = Window_EquipmentHeld.new(@actor, 0)
    @item_window2 = Window_EquipmentHeld.new(@actor, 1)
    @item_window3 = Window_EquipmentHeld.new(@actor, 2)
    @item_window4 = Window_EquipmentHeld.new(@actor, 3)
    @item_window5 = Window_EquipmentHeld.new(@actor, 4)
    @item_window6 = Window_EquipmentHeld.new(@actor, 4)
    # Associate help window
    @right_window.help_window = @help_window
    @item_window1.help_window = @help_window
    @item_window2.help_window = @help_window
    @item_window3.help_window = @help_window
    @item_window4.help_window = @help_window
    @item_window5.help_window = @help_window
    # Set cursor position
    @right_window.index = @equip_index
    refresh
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @char_window.dispose
    @help_window.dispose
    @left_window.dispose
    @right_window.dispose
    @item_window1.dispose
    @item_window2.dispose
    @item_window3.dispose
    @item_window4.dispose
    @item_window5.dispose
    @item_window6.dispose
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Set item window to visible
    @item_window1.visible = (@right_window.index == 0)
    @item_window2.visible = (@right_window.index == 1)
    @item_window3.visible = (@right_window.index == 2)
    @item_window4.visible = (@right_window.index == 3)
    @item_window5.visible = (@right_window.index == 4)
    # Get currently equipped item
    item1 = @right_window.item
    @item_window6.contents.dispose
    # Set current item window to @item_window
    case @right_window.index
    when 0
      @item_window = @item_window1
    when 1
      @item_window = @item_window2
    when 2
      @item_window = @item_window3
    when 3
      @item_window = @item_window4
    when 4
      @item_window = @item_window5
    else
      @item_window = @item_window6
    end
    # If right window is active
    if @right_window.active
      # Erase parameters for after equipment change
      @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil)
    else
      @item_window1.update
    end
    # If item window is active
    if @item_window.active
      # Get currently selected item
      item2 = @item_window.item
      # Change equipment
      last_hp = @actor.hp
      last_sp = @actor.sp
      @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
      # Get parameters for after equipment change
      new_atk = @actor.atk
      new_pdef = @actor.pdef
      new_mdef = @actor.mdef
      new_str = @actor.str
      new_dex = @actor.dex
      new_agi = @actor.agi
      new_int = @actor.int
      # Return equipment
      @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
      @actor.hp = last_hp
      @actor.sp = last_sp
      # Draw in left window
      @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @char_window.update
    @left_window.update
    @right_window.update
    @item_window.update
    refresh
    # If right window is active: call update_right
    if @right_window.active
      update_right
      return
    end
    # If item window is active: call update_item
    if @item_window.active
      update_item
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when right window is active)
  #--------------------------------------------------------------------------
  def update_right
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If equipment is fixed
      if @actor.equip_fix?(@right_window.index)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Activate item window
      @right_window.active = false
      @item_window.active = true
      @item_window.index = 0
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different equipment screen
      $scene = Scene_Equip.new(@actor_index, @right_window.index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different equipment screen
      $scene = Scene_Equip.new(@actor_index, @right_window.index)
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Activate right window
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Play equip SE
      $game_system.se_play($data_system.equip_se)
      # Get currently selected data on the item window
      item = @item_window.item
      # Change equipment
      @actor.equip(@right_window.index, item == nil ? 0 : item.id)
      # Remake right window and item window contents
      @right_window.refresh
      @item_window.refresh
      return
    end
  end
end




Instructions

If you are using the default equipment menu:
Put the script above main and below any mouse script.

If you are using Fyre's custom equipment menu:
Put the edit below Fyre's script.

If you are using a different custom equipment menu:
Place this below whatever you are using, and edit my script accordingly.
Do not make ANY edits to the frame update or else you will lose the ability to quickly change equipment in the menu.



Compatibility

  • Should be compatible with any mouse script out there, since I only edit Scene_Equip.

  • Edited for the default equipment menu.



Credits and Thanks


  • RPGManiac3030





Author's notes
If you use this in your game, please credit me :)
This is technically 2 scripts in 1, since I needed to use the quick equip feature to make the mouse compatibility better.
There were some issues when I tried testing the menu with other characters, all types of equipment, etc. and I fixed what I found. If you find any other errors like that, or any compatibility issues, please post it here!


Official Gio website:
gioadventures.freehostingcloud.com (under construction)

RPGManiac3030

I added an edit so that it is compatible with Fyre's custom equipment menu, since that's what I'm using in my game anyway :)


Official Gio website:
gioadventures.freehostingcloud.com (under construction)