Jump to content
Sign in to follow this  
SpuddyGoggles

Request For Equip Menu

Recommended Posts

The more I attempt to tamper with Ruby, the more I understand that I'm very very dumb.

I have managed to get by enough to make a menu that fits my liking, along with an inventory that is also satisfactory.

However I've hit a snag with one of the more vital options of my pause menu... The equip menu!

Despite my ceaseless trial and error, I have found myself stumped due to nothing but my own incompetence.

As such, I now find myself calling upon the help of those more adept at Ruby than I am.

Below is the current pause menu.

menu_01.png.076210b6715b7942096d2e1a2360176a.png

And this is a mockup of what I want the equip menu to look like.

equip_mockup_01.png.7ac7a9e9ba00516ef5c339e927446db8.png

I know that I'm probably asking for a lot, but even some help would be appreciated.

Share this post


Link to post
Share on other sites

Is this for a single actor menu? You will only ever have one actor in the party?

Share this post


Link to post
Share on other sites
30 minutes ago, roninator2 said:

Is this for a single actor menu? You will only ever have one actor in the party?

Yes, there is only going to be one actor in the party.

Share this post


Link to post
Share on other sites

How many equipment slots will you have? 

0 - weapon 

1 - shield

2 - helmet

3 - armor 

4 - accessory

etc

Share this post


Link to post
Share on other sites
1 minute ago, roninator2 said:

How many equipment slots will you have? 

0 - weapon 

1 - shield

2 - helmet

3 - armor 

4 - accessory

etc

Hmm, I'm thinking just Weapons, Armor, and Shield/Accessory(either would work, but not both)

But I would be fine if it was just the first three slots since that would likely be easier rather than specific ones.

Share this post


Link to post
Share on other sites

Ah, so you actually want the command window to be the slot window.

weapon, shield, helmet, armor, accessory.

But which ones. It makes a difference, because each item has it's own equip type (slot_id)

You say armor, so that's the body armor? then you don't want shields or helmets?

Share this post


Link to post
Share on other sites
Posted (edited)

Does this work?

Spoiler

# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Minimal Equip Scene          ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Alternate equip menu scene        ╠════════════════════╣
# ║                                     ║    09 Apr 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Plug & Play                                            ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

#==============================================================================
# ** Window_EquipCommand
#------------------------------------------------------------------------------
#  This window is for selecting commands (change equipment/ultimate equipment
# etc.) on the skill screen.
#==============================================================================

class Window_EquipCategory < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y)
    clear_command_list
    make_command_list
    super(x, y)
    refresh
    select(0)
    activate
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(4)
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("Weapon",     :eqweapon)
    add_command("Armor",      :eqarmour)
    add_command("Accessory",  :eqaccess)
  end
  #--------------------------------------------------------------------------
  # * Set Item Window
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
end
#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
#  This window displays choices when opting to change equipment on the
# equipment screen.
#==============================================================================

class Window_EquipItem < Window_ItemList
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :slot_id
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super
    @actor = nil
    @slot_id = 0
  end
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
    self.oy = 0
  end
  #--------------------------------------------------------------------------
  # * Set Equipment Slot ID
  #--------------------------------------------------------------------------
  def slot_id=(slot_id)
    return if @slot_id == slot_id
    @slot_id = slot_id
    refresh
    self.oy = 0
  end
  #--------------------------------------------------------------------------
  # * Include in Item List?
  #--------------------------------------------------------------------------
  def include?(item)
    return true if item == nil
    return false unless item.is_a?(RPG::EquipItem)
    return false if @slot_id < 0
    return false if item.etype_id != @actor.equip_slots[0]
    return false if item.etype_id != @actor.equip_slots[1]
    return @actor.equippable?(item)
  end
  #--------------------------------------------------------------------------
  # * Display in Enabled State?
  #--------------------------------------------------------------------------
  def enable?(item)
    return true
  end
  #--------------------------------------------------------------------------
  # * Restore Previous Selection Position
  #--------------------------------------------------------------------------
  def select_last
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
  def update_help
    super
    if @actor && @status_window
      temp_actor = Marshal.load(Marshal.dump(@actor))
      temp_actor.force_change_equip(@slot_id, item)
      @status_window.set_temp_actor(temp_actor)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  #--------------------------------------------------------------------------
  # * Get Activation State of Selection Item
  #--------------------------------------------------------------------------
  def current_item_enabled?
    enable?(@data[index])
  end
  #--------------------------------------------------------------------------
  # * Include in Item List?
  #--------------------------------------------------------------------------
  def include?(item)
    case @slot_id
    when 0
      item.is_a?(RPG::Weapon) && item.etype_id == 0
    when 3
      item.is_a?(RPG::Armor) && item.etype_id == 3
    when 4
      item.is_a?(RPG::Armor) && item.etype_id == 4
    else
      false
    end
  end
  #--------------------------------------------------------------------------
  # * Display if Equipped
  #--------------------------------------------------------------------------
  def on_equipped?(item)
    @actor.equips[@slot_id] == item
  end
  #--------------------------------------------------------------------------
  # * Create Item List
  #--------------------------------------------------------------------------
  def make_item_list
    @data = $game_party.all_items.select {|item| include?(item) }
    @data.push(@actor.equips[slot_id])
    @data.compact!
    @data.sort! {|a, b| a.id <=> b.id }
    @data.push(nil) if include?(nil)
  end
  #--------------------------------------------------------------------------
  # * Restore Previous Selection Position
  #--------------------------------------------------------------------------
  def select_last
    select(@data.index($game_party.last_item.object) || 0)
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 120
      draw_item_name(item, rect.x, rect.y, enable?(item))
      draw_equipped(item, rect.x, rect.y) if on_equipped?(item)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Equipped Status
  #--------------------------------------------------------------------------
  def draw_equipped(item, x, y, enabled = true, width = (Graphics.width - 160))
    return unless item
    change_color(normal_color, enabled)
    draw_text(x - 40, y, width, line_height, ":Equipped", 2)
  end
end

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

class Scene_Equip < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_command_window
    create_item_window
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    wy = Graphics.height - 120
    @command_window = Window_EquipCategory.new(0, wy)
    @command_window.viewport = @viewport
    @command_window.set_handler(:eqweapon, method(:command_weapon))
    @command_window.set_handler(:eqarmour, method(:command_armour))
    @command_window.set_handler(:eqaccess, method(:command_access))
    @command_window.set_handler(:cancel,   method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * Create Item Window
  #--------------------------------------------------------------------------
  def create_item_window
    wy = Graphics.height - 120
    ww = Graphics.width - 160
    @item_window = Window_EquipItem.new(160, wy, ww, 120)
    @item_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.actor = @actor
    @item_window.set_handler(:ok,     method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:on_item_cancel))
    @command_window.item_window = @item_window
  end
  #--------------------------------------------------------------------------
  # * Item [OK]
  #--------------------------------------------------------------------------
  def on_item_ok
    Sound.play_equip
    @actor.change_equip(determine_slot, check_item)
    @item_window.refresh
    @item_window.activate
  end
  #--------------------------------------------------------------------------
  # * Item [Cancel]
  #--------------------------------------------------------------------------
  def on_item_cancel
    @item_window.unselect
    @command_window.activate
  end
  #--------------------------------------------------------------------------
  # * Change Actors
  #--------------------------------------------------------------------------
  def check_item
    item = @item_window.item
    eqitem = @actor.equips[determine_slot]
    if item == eqitem
      return nil
    else
      return item
    end
  end
  #--------------------------------------------------------------------------
  # * Equip Weapon
  #--------------------------------------------------------------------------
  def command_weapon
    @item_window.activate
    @item_window.select(0)
    @item_window.slot_id=(0)
  end
  #--------------------------------------------------------------------------
  # * Equip Armor
  #--------------------------------------------------------------------------
  def command_armour
    @item_window.activate
    @item_window.select(0)
    @item_window.slot_id=(3)
  end
  #--------------------------------------------------------------------------
  # * Equip Accessory
  #--------------------------------------------------------------------------
  def command_access
    @item_window.activate
    @item_window.select(0)
    @item_window.slot_id=(4)
  end
  #--------------------------------------------------------------------------
  # * Determine Slot
  #--------------------------------------------------------------------------
  def determine_slot
    slot = @item_window.slot_id
    return slot
  end
end

 

 

Edited by roninator2

Share this post


Link to post
Share on other sites

Sorry for the delay.

It worked somewhat, but only when I don't have any items.

When I do have a weapon or armor it just crashes and gives this error.

equip_error_01.PNG.20174310df867bd3c8c24855ffa64c46.PNG

Share this post


Link to post
Share on other sites

Alright so I managed to "fix" it by simply commenting out the problematic bit of code. (I am not certain of it's importance.)

And after some window size tweaks and command changes it seems to be working at least as I described.

yay_it_works_kinda_01.png.c86a8776d12dd7f6f253db237956bf56.png

However it does have some issues that I probably should be able to fix on my own. Such as the help window being slightly inconsistent, the itemlist being incorrectly previewed, and the inability to 'unequip' items.

Share this post


Link to post
Share on other sites
1 hour ago, SpuddyGoggles said:

When I do have a weapon or armor it just crashes and gives this error.

What other scripts do you have? That line simply reorganizes the items so that they are in order. Otherwise it swaps around so that the item you have equipped is at the bottom of the list.

And it works perfectly for me in a blank demo. I found the problem. It is trying to sort nil values. I'm updating the code above.

Didn't know you wanted to unequip.

To do that I would simple change one method. There's also a method I forgot to remove.

Why you had to make any changes, I don't know. Is your game running at 640x480? The script was made for 544x416.

 

Share this post


Link to post
Share on other sites
Posted (edited)

Yes it's still using the default sizing, I just changed the command window to be 120x120 rather than 120x160, along with changing the size of the item window to accommodate it.

Edited by SpuddyGoggles

Share this post


Link to post
Share on other sites
10 minutes ago, roninator2 said:

I bet that when you changed the number for the size you removed a )

I have yet to have altered this newer version, I just pasted it in materials and hit playtest.

image.png.7de86ae4ed37af74e611d80f87bbc3de.png

Share this post


Link to post
Share on other sites

And my playtest works fine.

Here it is again, with the size at 120

Spoiler

# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Minimal Equip Scene          ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Alternate equip menu scene        ╠════════════════════╣
# ║                                     ║    09 Apr 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Plug & Play                                            ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

#==============================================================================
# ** Window_EquipCommand
#------------------------------------------------------------------------------
#  This window is for selecting commands (change equipment/ultimate equipment
# etc.) on the skill screen.
#==============================================================================

class Window_EquipCategory < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y)
    clear_command_list
    make_command_list
    super(x, y)
    refresh
    select(0)
    activate
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 120
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(4)
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("Weapon",     :eqweapon)
    add_command("Armor",      :eqarmour)
    add_command("Trinket",  :eqaccess)
  end
  #--------------------------------------------------------------------------
  # * Set Item Window
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
end
#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
#  This window displays choices when opting to change equipment on the
# equipment screen.
#==============================================================================

class Window_EquipItem < Window_ItemList
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :slot_id
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super
    @actor = nil
    @slot_id = 0
  end
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
    self.oy = 0
  end
  #--------------------------------------------------------------------------
  # * Set Equipment Slot ID
  #--------------------------------------------------------------------------
  def slot_id=(slot_id)
    return if @slot_id == slot_id
    @slot_id = slot_id
    refresh
    self.oy = 0
  end
  #--------------------------------------------------------------------------
  # * Include in Item List?
  #--------------------------------------------------------------------------
  def include?(item)
    return true if item == nil
    return false unless item.is_a?(RPG::EquipItem)
    return false if @slot_id < 0
    return false if item.etype_id != @actor.equip_slots[0]
    return false if item.etype_id != @actor.equip_slots[1]
    return @actor.equippable?(item)
  end
  #--------------------------------------------------------------------------
  # * Display in Enabled State?
  #--------------------------------------------------------------------------
  def enable?(item)
    return true
  end
  #--------------------------------------------------------------------------
  # * Restore Previous Selection Position
  #--------------------------------------------------------------------------
  def select_last
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
  def update_help
    super
    if @actor && @status_window
      temp_actor = Marshal.load(Marshal.dump(@actor))
      temp_actor.force_change_equip(@slot_id, item)
      @status_window.set_temp_actor(temp_actor)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  #--------------------------------------------------------------------------
  # * Get Activation State of Selection Item
  #--------------------------------------------------------------------------
  def current_item_enabled?
    enable?(@data[index])
  end
  #--------------------------------------------------------------------------
  # * Include in Item List?
  #--------------------------------------------------------------------------
  def include?(item)
    case @slot_id
    when 0
      item.is_a?(RPG::Weapon) && item.etype_id == 0
    when 3
      item.is_a?(RPG::Armor) && item.etype_id == 3
    when 4
      item.is_a?(RPG::Armor) && item.etype_id == 4
    else
      false
    end
  end
  #--------------------------------------------------------------------------
  # * Display if Equipped
  #--------------------------------------------------------------------------
  def on_equipped?(item)
    @actor.equips[@slot_id] == item
  end
  #--------------------------------------------------------------------------
  # * Create Item List
  #--------------------------------------------------------------------------
  def make_item_list
    @data = $game_party.all_items.select {|item| include?(item) }
    @data.push(@actor.equips[slot_id])
    @data.compact!
    @data.sort! {|a, b| a.id <=> b.id }
    @data.push(nil) if include?(nil)
  end
  #--------------------------------------------------------------------------
  # * Restore Previous Selection Position
  #--------------------------------------------------------------------------
  def select_last
    select(@data.index($game_party.last_item.object) || 0)
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 120
      draw_item_name(item, rect.x, rect.y, enable?(item))
      draw_equipped(item, rect.x, rect.y) if on_equipped?(item)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Equipped Status
  #--------------------------------------------------------------------------
  def draw_equipped(item, x, y, enabled = true, width = (Graphics.width - 120))
    return unless item
    change_color(normal_color, enabled)
    draw_text(x - 40, y, width, line_height, ":Equipped", 2)
  end
end

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

class Scene_Equip < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_command_window
    create_item_window
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    wy = Graphics.height - 120
    @command_window = Window_EquipCategory.new(0, wy)
    @command_window.viewport = @viewport
    @command_window.set_handler(:eqweapon, method(:command_weapon))
    @command_window.set_handler(:eqarmour, method(:command_armour))
    @command_window.set_handler(:eqaccess, method(:command_access))
    @command_window.set_handler(:cancel,   method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * Create Item Window
  #--------------------------------------------------------------------------
  def create_item_window
    wy = Graphics.height - 120
    ww = Graphics.width - 120
    @item_window = Window_EquipItem.new(120, wy, ww, 120)
    @item_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.actor = @actor
    @item_window.set_handler(:ok,     method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:on_item_cancel))
    @command_window.item_window = @item_window
  end
  #--------------------------------------------------------------------------
  # * Item [OK]
  #--------------------------------------------------------------------------
  def on_item_ok
    Sound.play_equip
    @actor.change_equip(determine_slot, check_item)
    @item_window.refresh
    @item_window.activate
  end
  #--------------------------------------------------------------------------
  # * Item [Cancel]
  #--------------------------------------------------------------------------
  def on_item_cancel
    @item_window.unselect
    @command_window.activate
  end
  #--------------------------------------------------------------------------
  # * Change Actors
  #--------------------------------------------------------------------------
  def check_item
    item = @item_window.item
    eqitem = @actor.equips[determine_slot]
    if item == eqitem
      return nil
    else
      return item
    end
  end
  #--------------------------------------------------------------------------
  # * Equip Weapon
  #--------------------------------------------------------------------------
  def command_weapon
    @item_window.activate
    @item_window.select(0)
    @item_window.slot_id=(0)
  end
  #--------------------------------------------------------------------------
  # * Equip Armor
  #--------------------------------------------------------------------------
  def command_armour
    @item_window.activate
    @item_window.select(0)
    @item_window.slot_id=(3)
  end
  #--------------------------------------------------------------------------
  # * Equip Accessory
  #--------------------------------------------------------------------------
  def command_access
    @item_window.activate
    @item_window.select(0)
    @item_window.slot_id=(4)
  end
  #--------------------------------------------------------------------------
  # * Determine Slot
  #--------------------------------------------------------------------------
  def determine_slot
    slot = @item_window.slot_id
    return slot
  end
end

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

It works perfectly!

I'm not certain what I did to cause the error though. 😐

Thank you for the help though! It's almost exactly what  I wanted!

Edited by SpuddyGoggles

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted