Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Custom equip menu [XP] (come on... this isn't hard... is it?)

kkxkn

Member

Hey, yeah, another request... this one's a lot simpler so hopefully it can be done...

What I want is a complete rewrite of the "Equip" menu, so that rather than how it currently is, it:

1) Doesn't display any stats or level (still displays the character's name - and if possible, their characterset graphic too, but not too worried on this)
2) Has eight slots for equipment - these are read from the variables $data_actors[*actor currently being accessed*].attackability1_id (and 2_id, 3_id, 4_id) and $data_actors[*actor currently being accessed*].defendability1_id (and 2_id, 3_id, 4_id). The first four (attack ability) are read from weapons, the last four from armours. (The data stored in these variables is just the ID number of the equipment). These variables are set to 0 when unequipped.
3) As usual, when an equipment is selected, it's item description appears at the top.

The layout I'd like, if possible, is similar to the existing one but not split into two windows, with the equipment split into two rows, the attack abilities on the left and the defend abilities on the right.

Nothing actually needs to be done upon equipping/dequipping them (except changing the variable and removing/adding the equipment from the inventory), as their effects are all handled by scripts that are more within my capability.

If there's already a script out there that can be fairly easily adjusted, let me know.

I don't use SDK so it needs to be non-SDK, but requiring MACL is fine.

EDIT: Forgot to mention: Should ignore all class checks, everyone should be able to equip everything.
 

Atoa

Member

If it was soooo easy as you say... you would do it alone.
The part of the multi-slot is really confunsing, you tried to use scripter terms, but only made an big confusion.

I didn't undertood that part.

What you want is basically equip 4 weapons and 4 armors(of the same type)?
 
Gotcher script right here. I couldn't do the layout you specified, since that would leave nowhere to put the window containing the actor's name and character graphic. Also I wasn't able to test it since I don't have the scripts which make actors equip attackability etc. Anyway:

Code:
#==============================================================================
# ** Window_EquipLeft
#------------------------------------------------------------------------------
#  This window displays actor parameter changes on the equipment screen.
#==============================================================================

class Window_EquipLeft < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 64, 320, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 32, 64)
    draw_actor_name(@actor, 68, 32)
  end
end

#==============================================================================
# ** Window_EquipRight
#------------------------------------------------------------------------------
#  This window displays items the actor is currently equipped with on the
#  equipment screen.
#==============================================================================

class Window_EquipRight < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 160, 320, 320)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @data = []
    @data.push($data_weapons[@actor.attackability1_id])
    @data.push($data_weapons[@actor.attackability2_id])
    @data.push($data_weapons[@actor.attackability3_id])
    @data.push($data_weapons[@actor.attackability4_id])
    @data.push(nil) # Creates an empty space
    @data.push($data_armors[@actor.defendability1_id])
    @data.push($data_armors[@actor.defendability2_id])
    @data.push($data_armors[@actor.defendability3_id])
    @data.push($data_armors[@actor.defendability4_id])
    @data.each_with_index {|item, i| draw_item_name(item, 0, 32 * i)}
    @data.delete(nil) # Removes the empty space from the data
    @item_max = @data.size
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rect - Make bottom four items lower than the rest
  #--------------------------------------------------------------------------
  def update_cursor_rect
    super
    self.cursor_rect.y += 32 if @index >= 4
  end
end

#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
#  This window displays choices when opting to change equipment on the
#  equipment screen.
#==============================================================================

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor      : actor
  #     equip_type : equip region (0-3)
  #--------------------------------------------------------------------------
  def initialize(actor, equip_type)
    super(320, 64, 320, 416)
    @actor = actor
    @equip_type = equip_type
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 4
    y = index * 32
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
end

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

class Scene_Equip
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Set item window to visible
    @item_window1.visible = false
    @item_window2.visible = false
    @item_window3.visible = false
    @item_window4.visible = false
    @item_window5.visible = false
    # Get currently equipped item
    item1 = @right_window.item
    # Set current item window to @item_window
    case @right_window.index
    when 0..3
      @item_window = @item_window1
    when 4..7
      @item_window = @item_window4
    end
    @item_window.visible = true
  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
      case @right_window.index
      when 0
        @actor.attackability1_id = item == nil ? 0 : item.id
      when 1
        @actor.attackability2_id = item == nil ? 0 : item.id
      when 2
        @actor.attackability3_id = item == nil ? 0 : item.id
      when 3
        @actor.attackability4_id = item == nil ? 0 : item.id
      when 4
        @actor.defendability1_id = item == nil ? 0 : item.id
      when 5
        @actor.defendability2_id = item == nil ? 0 : item.id
      when 6
        @actor.defendability3_id = item == nil ? 0 : item.id
      when 7
        @actor.defendability4_id = item == nil ? 0 : item.id
      end
      # 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
  end
end
 

kkxkn

Member

Sounds good... except the damn "Expand" won't work. >_>

Could you link to it on pastebin or something like that?

(Just to be safe: It's not something in the script that isn't working, but rather, the "Expand/Contract" link that would make these forms display the script itself is not working for me!)
 

kkxkn

Member

Nevermind, I got it but:

Script 'Main' line 14: NoMethodError occurred.
undefined method 'main' for #<Scene_Equip:0x3db0c88>

Happens immediately upon trying to enter the equip menu.
 

kkxkn

Member

Ah, nevermind, I was replacing the existing scripts. I tried adding it as an extra section and it worked.

EDIT: All the bugs I found, I've managed to fix.

The layout, however, is very good. The only thing I'd change is put a note such as "Empty" in slots which aren't equipped
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top