Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Mouse Friendly Equipment Menu
RPGManiac3030
post Jul 9 2011, 08:37 PM
Post #1


Level 5
Group Icon

Group: Member
Posts: 71
Type: Developer
RM Skill: Advanced




Mouse Friendly Equipment Menu

Version 1.0
Author: RPGManiac3030
Release Date: 7/9/11


Can also be found at Chaos-Project


Introduction

This is basically a small edit of the equipment screen for anyone who uses a mouse script, such as Blizzard's, Ryex's, etc. It would most likely be for those who can't script because this is kind of easy to fix if you can. It doesn't really make sense when I try to explain how it works, but the screenshots show it perfectly. It also allows the player to quickly switch between different weapons/armor/etc. without having to select that equipment part and going through the list again.

Features
-Makes the equipment screen more compatible with a mouse script
-Allows the player to quickly switch between weapons/armor/etc. For example, if you accidentally choose the wrong sword, you can just move right to the next one instead of having to choose the equipped sword and finding the one you wanted.

Script

Script
CODE
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# 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!
CODE
#==============================================================================
# ** 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 (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



Customization
If you use a custom equipment script, you will have to adapt this one to fit whatever your custom script implements.

Compatibility
I used Blizzard's Mouse Controller to test out the script, and it's used in the demo. Other Mouse scripts should have the same problem like Blizzard's did, so this should work for all of them.

Screenshot


This is before my edit is implemented:


This is after my edit is implemented:


DEMO
Basically you can use the demo to see the quick equipping in action.
Download here

Installation
If you use the default equipment menu:
Place the script above main and below any mouse script.

If you use Fyre's equipment menu:
Place the edit under his script.

If you use a different equipment menu:
Place my edit under whatever you use, and adapt it accordingly. DO NOT edit the frame update as this is what allows the quick equipping and will glitch the menu if you do.

FAQ

Q: I use a custom equipment screen, but I can't script that well...

A: Send me a demo containing your custom equipment menu and my edit. I'll gladly do it for you, but make sure I reply or I may not have gotten it.

Q: There's an error in your demo.

A: If you find anything wrong with the script, either in the demo or in your game project, please let me know. I kept running into problems when I put the demo together and I fixed everything I found, but there may always be something...

Terms and Conditions

This can be used for both non-commercial and commercial games since it's more of an edit, as long as you credit me and let me know through pm. I'd like to keep a list of games that my work is in smile.gif


Credits

There was someone of a forum somewhere that brought this problem up. I looked into it because of him/her and came up with this edit.

RPGManiac3030 - Creator of this edit

Blizzard - His mouse controller script is what I used to test my edits.

This post has been edited by RPGManiac3030: Jul 11 2011, 11:45 AM


__________________________
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th May 2013 - 01:20 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker