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.

Equipment Switching Script Help Please

I found this script where it would allow your party to be able to switch equipment during battle. I placed the script above "Main", but for some reason I'm not getting an "Equip" option during battle.

I was told that I had to switch the numbers in this part:

# Disable/Enable slot control (1 allows, 0 disallows)
# Syntax =  actor.id => [weapon, shield, armor, helmet, accessory ], ...
$ebem_slot      = { 1 => [ 1, 0, 1, 1, 1],
                    7 => [ 0, 1, 1, 1, 1],
                    8 => [ 1, 0, 0, 0, 0]  }

And I tried switching all of the numbers to 1's to allow switching of all equipment, but it still doesn't work. Right now I am only working with 1 hero. Do you think that that has anything to do with the situation? Maybe I should get rid of the ID #'s 7 and 8. Any help would be most appreciated!

#------------------------------------------------------------------------------
#
#  INTRODUCTION:
#
#  Greetings!
#
#  This script, like you must know by now,  allows you to change your equipment
#  while in combat.  Originally designed for the default battle system,  it has
#  now been modified to permit it's use in a number of battlesystems.
#
#  Unlike its predecessor,  no modifiecation to Custom Battlesystems's def main
#  is necessary to insert the 'Equip' command.  Through the use of XRSX's won-
#  derful Command Window Add-on,  the option has been added by 'ALIAS'ing it to
#  the battlesystem.  In fact, the only def in the entire Scene_Battle that had
#  to be re-written (and not aliased) is 'update_phase3',  which is primarily a
#  universal def that allows the equipment menu to be turned on.
#
#  The Equipment menu, when used,  appears like the  default menu system,  with
#  the exception  of not seeing  the possible changes  in your stats  until you
#  activly change your equipment.  The original  Japanese version  didn't even
#  have the left 'stat' window. I will leave it to you to modify the appearance
#  or behavior of this window.
#
#  NOTE:  The equipment menu is set to full opacity so as to hide battlers and
#  certain forms of AT bar sprites in certain battlesystems.  The 'Z-Depth' was
#  increased by '700' in order to accomplish this. Without this, the appearance
#  of various forms of sprites could distract or obscure the menu.
#
#------------------------------------------------------------------------------
#
#  INSTRUCTIONS:
#
#  This script is about as plug & play as they come.  Unless some form of con-
#  flict occurs, you merely paste this script  below your  Custom Battle System
#  for it to work,  or just paste it above 'MAIN' if you are using  the default
#  battle system.
#
#  It aliases nearly every  statement necessary for it to work,  other than the
#  'def update_phase3' as stated earlier, so you want it below your custom bat-
#  tlesystem.
#
#------------------------------------------------------------------------------
#
#  REGARDING XRXS's #65 BATTLESYSTEM:
#
#  Both this, and XRXS's script adds  an additional command into the actor com-
#  mand window.  XRXS's system adds the "ESCAPE" command, and this one adds the
#  "EQUIP" command.  Normally, you would paste this script below the any custom
#  battlesystem,  but this would leave the 'EQUIP' option to be shown below the
#  'ESCAPE' option.  This script can be placed 'ABOVE' XRXS's system to reverse
#  this and have 'ESCAPE' be the bottommost option.
#
#------------------------------------------------------------------------------
#
#  REGARDING LAURA'S ESCAPE BAR REMOVAL SCRIPTS (RTAB & DBS):
#  This system  is compatible  with said system.  Both IT and this system uses
#  a modified version of XRXS's Window Module, and the placement of the scripts
#  influences the options position.  If this script  is placed 'BELOW' Laura's
#  script,  then the 'Equip' option  will be below  the 'Escape' option...  and
#  visa versa.
#
#------------------------------------------------------------------------------
#
#  COMPATABILITY:
#
#  Originally, this system was designed  for the 'default' battlesystem.  It is
#  now able to support the following systems:
#
#  Agility Based Battle - Syvkal (an XRXS edit)
#  The default system  - Yoji Ojima / Enterbrain, Inc.
#  ParaDog's CTB v 2.58 - ParaDog
#  RTAB                - Cogwheel
#  SoulRage            - Blizzard
#  XRXS #65 & 65a addon - by XRXS
#
#  Currently incompatible with the Action Cost CBS by Fomar0153, yet...
#
#  Currently not compatible with Trickster's Conditional CTB, or his Active
#  Timer Battle system.  It would probably need a SDK 2.0 makeover.
#
#==============================================================================

# Command Window size controls
$command_height = 160  # Sets how many options are visible (nil auto-resizes)
$command_y_pos  = 160  # Sets the height position (160 is default, nil is auto)

# Disable/Enable slot control (1 allows, 0 disallows)
# Syntax =  actor.id => [weapon, shield, armor, helmet, accessory ], ...
$ebem_slot      = { 1 => [ 1, 0, 1, 1, 1],
                    7 => [ 0, 1, 1, 1, 1],
                    8 => [ 1, 0, 0, 0, 0]  }

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Add Equip
  #--------------------------------------------------------------------------
  alias ebem_sp1 start_phase1
  def start_phase1
    # Original Call
    ebem_sp1
    # Get index of Equip Command
    @equip_actor_command_index = @actor_command_window.height / 32 - 1
    # Add the Equip Command
    @actor_command_window.add_command($data_system.words.equip)
  end
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase)
  #--------------------------------------------------------------------------
  def update_phase3
    # Allow for RTAB system
    if $r_detected
      if victory? and @command_a
        command_delete
        @command.push(@active_actor)
        return
      end
    end
    # If enemy arrow is enabled
    if @enemy_arrow != nil
      update_phase3_enemy_select
    # If actor arrow is enabled
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # If skill window is enabled
    elsif @skill_window != nil
      update_phase3_skill_select
    # If item window is enabled
    elsif @item_window != nil
      update_phase3_item_select
    # If equip window is enabled
    elsif @right_window != nil
        update_phase3_equip_select
    # If actor command window is enabled
    elsif @actor_command_window.active
      update_phase3_basic_command
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase : basic command)
  #--------------------------------------------------------------------------
  alias ebem_up3bc update_phase3_basic_command
  def update_phase3_basic_command
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by actor command window cursor position
      case @actor_command_window.index
      when @equip_actor_command_index # Equip
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Start equip selection
        start_equip_select
      end
    end
    # Original Call
    ebem_up3bc
  end
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase : equip selection)
  #--------------------------------------------------------------------------
  def update_phase3_equip_select
    ebem_array = []
    # Allow for RTAB system
    if $r_detected
      battler = @active_actor
    else
      battler = @active_battler
    end   
    # Enable equip window
    @right_window.visible = true
    # Update Equip selection Windows
    @right_window.update
    if @right_window.index != @now_right_window
      @now_right_window =@right_window.index
      if @equip_item_window.index == -1
        @equip_item_window.index = 0
        @equip_item_window.refresh
        @equip_item_window.index = -1
      end
    end
    # Update windows
    @equip_item_window.update
    equip_item_window_select
    # If equip_item window is active: call update_phase3_equip_i_select
    if @equip_item_window.active
      update_phase3_equip_i_select
      return
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End equip selection
      end_equip_select
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If equipment is fixed
      if battler.equip_fix?(@right_window.index)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Obtain equipment slot information for actor (if any)
      ebem_array = $ebem_slot[battler.id] if $ebem_slot.include?(battler.id)
      # If equipment cannot be changed
      if ebem_array[@right_window.index] == 0
        # 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
      @equip_item_window.active = true
      @equip_item_window.index = 0
      @now_right_window = -1
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when equipment item window is active)
  #--------------------------------------------------------------------------
  def update_phase3_equip_i_select
    # Allow for RTAB system
    if $r_detected
      battler = @active_actor
    else
      battler = @active_battler
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)     
      @now_item_window = -1
      # Activate right window
      @right_window.active = true
      @equip_item_window.active = false
      @equip_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 equip window
      item = @equip_item_window.item
      # Change battler equipment
      battler.equip(@right_window.index, item == nil ? 0 : item.id)
      # Activate right window
      @right_window.active = true
      @equip_item_window.active = false
      @equip_item_window.index = -1
      # Remake left window with new stats
      @left_window.refresh
      # Remake right window and item window contents
      @right_window.refresh
      @equip_item_window.refresh
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Start Equipment Selection
  #--------------------------------------------------------------------------
  def start_equip_select
    # Allow for RTAB system
    if $r_detected
      battler = @active_actor
    else
      battler = @active_battler
    end
    # Hide Battlestatus Window
    @status_window.visible = false
    # Toggle the help window's transparency
    @help_trans = @help_window.back_opacity
    @help_window.back_opacity = 255
    # Make windows
    @left_window = Window_EquipLeft.new(battler)
    @right_window = Window_EquipRight.new(battler)
    @item_window1 = Window_EquipItem.new(battler, 0)
    @item_window2 = Window_EquipItem.new(battler, 1)
    @item_window3 = Window_EquipItem.new(battler, 2)
    @item_window4 = Window_EquipItem.new(battler, 3)
    @item_window5 = Window_EquipItem.new(battler, 4) 
    # Set new Z-Depth of windows
    @left_window.z  += 700
    @right_window.z += 700
    @item_window1.z += 700
    @item_window2.z += 700
    @item_window3.z += 700
    @item_window4.z += 700
    @item_window5.z += 700
    # 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
    @now_right_window = -1
    @right_window.index = 0
    equip_item_window_select
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # * End Equipment Selection
  #--------------------------------------------------------------------------
  def end_equip_select
    # Reset z-depth of windows
    @left_window.z -= 700
    @right_window.z -= 700
    @item_window1.z -= 700
    @item_window2.z -= 700
    @item_window3.z -= 700
    @item_window4.z -= 700
    @item_window5.z -= 700
    # Return the help window's opacity
    @help_window.back_opacity = @help_trans
    # Dispose of windows
    @left_window.dispose
    @right_window.dispose
    @item_window1.dispose
    @item_window2.dispose
    @item_window3.dispose
    @item_window4.dispose
    @item_window5.dispose
    @right_window= nil
    @item_window1= nil
    @item_window2= nil
    @item_window3= nil
    @item_window4= nil
    @item_window5= nil
    # Hide help window
    @help_window.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
    # Return Battlestatus Window
    @status_window.visible = true
  end
  #--------------------------------------------------------------------------
  # * Refresh Equipment Selection
  #--------------------------------------------------------------------------
  def equip_item_window_select 
    # Allow for RTAB system
    if $r_detected
      battler = @active_actor
    else
      battler = @active_battler
    end   
    # 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)
    # Set current item window to @item_window
    case @right_window.index
    when 0
      @equip_item_window = @item_window1
    when 1
      @equip_item_window = @item_window2
    when 2
      @equip_item_window = @item_window3
    when 3
      @equip_item_window = @item_window4
    when 4
      @equip_item_window = @item_window5
    end
  end
  #--------------------------------------------------------------------------
  # * Action Wait Decision
  #--------------------------------------------------------------------------
  def anime_wait_return
    if $r_detected
      if (@action_battlers.empty? or @anime_wait == false) and
          not $game_system.battle_interpreter.running?
        # If enemy arrow is enabled
        if @enemy_arrow != nil
          return [@active - 2, 0].min == 0
        # If actor arrow is enabled
        elsif @actor_arrow != nil
          return [@active - 2, 0].min == 0
        # If skill window is enabled
        elsif @skill_window != nil
          return [@active - 3, 0].min == 0
        # If item window is enabled
        elsif @item_window != nil
          return [@active - 3, 0].min == 0
        # If equipment window is enabled
        # -- I used the same setting that pauses the actor command window -- :)
        elsif @right_window != nil
          return [@active - 1, 0].min == 0
        # If actor command window is enabled
        elsif @actor_command_window.active
          return [@active - 1, 0].min == 0
        else
          return true
        end
      else
        return false
      end
    end
  end
end


#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within
#  the Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias equ_init initialize
  def initialize
    equ_init
    # Determine if RTAB system in use
    if @real_zoom != nil
      $r_detected = true
    end
  end
end


#==============================================================================
# --- XRXS.Command Window Add-On Module ---
#==============================================================================
module XRXS_Window_Command
  #--------------------------------------------------------------------------
  # * Add Command
  #    command  : command text string being added
  #-------------------------------------------------------------------------- 
  def add_command(command)
    #
    # Creates an empty @disabled array when first called.
    #
    @disabled = [] if @disabled.nil?
    if @commands.size != @disabled.size
      for i in 0...@commands.size
        @disabled = false
      end
    end
    #
    # Add Command
    #
    @commands.push(command)
    @disabled.push(false)
    @item_max = @commands.size
    # Position the command window
    if $command_y_pos == nil
      self.y -= 32
    else
      self.y = $command_y_pos
    end
    # Set the command window height
    if $command_height == nil
      self.height += 32
    else
      self.height = $command_height
    end
    self.contents.dispose
    self.contents = nil
    self.contents = Bitmap.new(self.width - 32, @item_max * 32)
    refresh
    for i in 0...@commands.size
      if @disabled
        disable_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #    index : item number 
  #--------------------------------------------------------------------------
  def disable_item(index)
    @disabled = [] if @disabled.nil?
    @disabled[index] = true
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # * Enable Item
  #    index : item number 
  #--------------------------------------------------------------------------
  def enable_item(index)
    @disabled = [] if @disabled.nil?
    @disabled[index] = false
    draw_item(index, normal_color)
  end
end
class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # ** Include
  #--------------------------------------------------------------------------
  include XRXS_Window_Command
  #--------------------------------------------------------------------------
  # * Disable Item
  #    index : item number 
  #--------------------------------------------------------------------------
  def disable_item(index)
    super
  end
end
#==============================================================================
# --- Edited Copy of Include for SoulRage script ---
#==============================================================================
class Window_Command_Enhanced < Window_Selectable
  #--------------------------------------------------------------------------
  # ** Include
  #--------------------------------------------------------------------------
  include XRXS_Window_Command
  #--------------------------------------------------------------------------
  # * Disable Item
  #    index : item number 
  #--------------------------------------------------------------------------
  def disable_item(index)
    super
  end
end
 

khmp

Sponsor

Do you have any custom battle system scripts other than this one? I see there are a couple of instructions in the comments up top involving various CBS and where Equip appears. Would you be willing to provide your Scripts.rxdata file to allow us to debug it off forum?
 
Right now, this is my ONLY other custom script built into my game.

#============================================================================
#                            Syn's Ammo Requirements 
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 1.00
# August 15, 2007
# Tested with SDK 2.1
#============================================================================
#----------------------------------------------------------------------------
# Customization Section
#----------------------------------------------------------------------------
module Ammo
  # Format = {weapon_id => Ammo_cost}
  Range_weapons_id = {1 => 1}
  # Format = {weapon_id => Item_id
  Range_ammo_id = {1 => 1}
  # Format = {skill_id => Ammo_cost}
  Skill_ammo = {73 => 3}
  # Note on Skills: When using Skills the Current Ammo for the equipped
  # weapon will be used. So if Skill 73 is used and Weapon 17 is equipped
  # then Ammo #33 will be used.
end
#----------------------------------------------------------------------------
# Begin Scene_Battle
#----------------------------------------------------------------------------
class Scene_Battle
  # Alias Methods
  alias syn_scene_battle_range make_basic_action_result
  alias syn_scene_battle_skill make_skill_action_result
  #----------------------------------------------------
  # Alias the Attacking method
  #----------------------------------------------------
  def make_basic_action_result
    # Gather the current Ammo Cost
    gather_ammo_cost = Ammo::Range_weapons_id[@active_battler.weapon_id]
    # Gather the Current Ammo
    gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]
    # Check if the Active Battler is attacking and if they are using a ranged weapon
    if @active_battler.current_action.basic == 0 and Ammo::Range_weapons_id.has_key?(@active_battler.weapon_id)
      # Check the Ammo Count
      if $game_party.item_number(gather_ammo) >= gather_ammo_cost
        # Sufficient Ammo, remove item
        $game_party.lose_item(gather_ammo,gather_ammo_cost)
        syn_scene_battle_range
      else
        # Insufficient Ammo
        @help_window.set_text("#{@active_battler.name} cannot attack due to insufficient Ammo", 1)
      end
      # Call Default Code
    else
      syn_scene_battle_range
    end
  end
  #----------------------------------------------------
  # Alias the Skill method
  #----------------------------------------------------
  def make_skill_action_result
    # Gather the current Ammo Cost
    gather_ammo_cost = Ammo::Skill_ammo[@active_battler.current_action.skill_id]
    # Gather Ammo
    gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]
    # Check if the Actor is using a defiend skill
    if Ammo::Skill_ammo.has_key?(@active_battler.current_action.skill_id)
      # Check if Ammo is present
      if $game_party.item_number(gather_ammo) >= gather_ammo_cost
        # Sufficient Ammo, remove item
        $game_party.lose_item(gather_ammo,gather_ammo_cost)
        # Call Default Code
        syn_scene_battle_skill
      else
        # Set Window; Do Nothing
        @help_window.set_text("#{@active_battler.name} cannot attack due to insufficient Ammo", 1)
      end
      # Otherwise SKip the check and call default code
    else
      syn_scene_battle_skill
    end
  end
end
#============================================================================
# Written by Synthesize
# Special Thanks: ~Emo~ for the request
#----------------------------------------------------------------------------
#                            Ammo Requirements
#============================================================================

It's an ammunition script so that certain weapons require ammo in order to use them.

Other than that script right there, everything else is basic from what you receive when you click "Create New Game".

EDIT: Here is a copy of my game. I don't have anything else done visually, but I just have the 2 scripts added above "Main". http://www.savefile.com/files/1483974
 

khmp

Sponsor

Your game wouldn't happen to be about zombies per chance? :wink:

Unfortunately I loaded the demo up and it worked perfectly. Equip was the fifth option in the list of possible battle commands. Although admittedly the battler's picture kind of obscures the arrow signifying there are more than the four standard options. I was able to replace the handgun with the shotgun without any problem. Just in case you think I'm just saying that:
http://i300.photobucket.com/albums/nn5/ ... _equip.png[/img]
 
Lmao are you KIDDING ME!?!?!? I spent 2 days feeling like a total IDIOT because I couldnt see the stupid arrow. lol... after you said that I opened up my game and literally said out loud "I'm gonna be pissed if its because I couldn't see the damned arrow." and there you go...

Oh boy... It's going to be a loooong night.

Anyway, thanks a lot for taking the time out of your day to test my demo and find my issues. I appreciate it!

EDIT: Also, only if you know it off of the top of your head (a link that is), would you happen to know where I can find all of the damage formulas? I need to figure out some of the damage because there is going to be a universal HP amount throughout my game to make it more realistic. Thanks again.
 

khmp

Sponsor

vVTalonVv":2j4q8y1k said:
Lmao are you KIDDING ME!?!?!? I spent 2 days feeling like a total IDIOT because I couldnt see the stupid arrow. lol... after you said that I opened up my game and literally said out loud "I'm gonna be pissed if its because I couldn't see the damned arrow." and there you go...

Oh boy... It's going to be a loooong night.

Anyway, thanks a lot for taking the time out of your day to test my demo and find my issues. I appreciate it!

EDIT: Also, only if you know it off of the top of your head (a link that is), would you happen to know where I can find all of the damage formulas? I need to figure out some of the damage because there is going to be a universal HP amount throughout my game to make it more realistic. Thanks again.

Problem was fixed wasn't it? No time was wasted then.

The damage formulas are in Readme that comes with RMXP(battle formulas). I won't lie though. For me, its like reading some math problem that's far too complicated for what it accomplishes.
 

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