How to add more armor slots

Started by Blizzard, June 13, 2008, 02:00:03 pm

Previous topic - Next topic

Blizzard

June 13, 2008, 02:00:03 pm Last Edit: January 10, 2009, 07:40:51 am by Blizzard
1. The Problem


Have you ever wanted another accessory slot in your game? But for that you needed a complicated script that would render half of your other scripts faulty due to incompatiblity. That is why I will show you now how you can add any armor slot with a couple simple script edits. We will add an accessory slot, but this method can be applied to any slot type. This tutorial is intended for non-scripters. Code will be located precisely but not explained beyond the necessary. This tutorial was written for the default equip scene, you might need a different approach if you are using a very irregular CMS.



2. The Actor - Basics


In order to add another accessory, your actors first need to store that value. Open up your Game_Actor. On top you will find this piece of code:

Spoiler: ShowHide
  attr_reader   :armor1_id                # shield ID
  attr_reader   :armor2_id                # helmet ID
  attr_reader   :armor3_id                # body armor ID
  attr_reader   :armor4_id                # accessory ID


Add another line for the accessory.

Spoiler: ShowHide
  attr_reader   :armor1_id                # shield ID
  attr_reader   :armor2_id                # helmet ID
  attr_reader   :armor3_id                # body armor ID
  attr_reader   :armor4_id                # accessory ID
  attr_reader   :armor5_id                # accessory ID 2 :)


Below "def setup" you will find these lines:

Spoiler: ShowHide
    @armor1_id = actor.armor1_id
    @armor2_id = actor.armor2_id
    @armor3_id = actor.armor3_id
    @armor4_id = actor.armor4_id


Add another one and it should look like this afterwards:

Spoiler: ShowHide
    @armor1_id = actor.armor1_id
    @armor2_id = actor.armor2_id
    @armor3_id = actor.armor3_id
    @armor4_id = actor.armor4_id
    @armor5_id = 0


The 0 represents that this equipment slot is empty right now as RMXP default setup doesn't have another slot. Now our actor has a new slot available. Keep in mind that this will eventually corrupt your older savegames without that additional armor slot.



3. The Actor - Attributes


Now that we have a way to store our extra accessory, we need to add the processing of additional attributes. I will demonstrate how this is done for Strength. Scroll further below for (or use the local search feature by pressing CTRL+F and typing into the window) "def base_str" (without the double quotes). You will find this piece of code:

Spoiler: ShowHide
  def base_str
    n = $data_actors[@actor_id].parameters[2, @level]
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.str_plus : 0
    n += armor1 != nil ? armor1.str_plus : 0
    n += armor2 != nil ? armor2.str_plus : 0
    n += armor3 != nil ? armor3.str_plus : 0
    n += armor4 != nil ? armor4.str_plus : 0
    return [[n, 1].max, 999].min
  end


Yet again you need to add something. After the edit the code should look like:

Spoiler: ShowHide
  def base_str
    n = $data_actors[@actor_id].parameters[2, @level]
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    armor5 = $data_armors[@armor5_id]
    n += weapon != nil ? weapon.str_plus : 0
    n += armor1 != nil ? armor1.str_plus : 0
    n += armor2 != nil ? armor2.str_plus : 0
    n += armor3 != nil ? armor3.str_plus : 0
    n += armor4 != nil ? armor4.str_plus : 0
    n += armor5 != nil ? armor5.str_plus : 0
    return [[n, 1].max, 999].min
  end


As you can see we have added those two lines:

Spoiler: ShowHide
    armor5 = $data_armors[@armor5_id]

    n += armor5 != nil ? armor5.str_plus : 0



And that it what is important. This needs to be repeated for other 6 methods below "def base_str":

Spoiler: ShowHide

  • base_dex
  • base_agi
  • base_int
  • base_pdef
  • base_mdef
  • base_eva


Keep in mind that you pay attention to what you are editing. This line here is tricky:

Spoiler: ShowHide
    n += armor5 != nil ? armor5.str_plus : 0


As you can see, it asks for "str_plus". When you are editing the "base_dex" method, this line HAS TO look like this:

Spoiler: ShowHide
    n += armor5 != nil ? armor5.dex_plus : 0


The best way to do it correctly from the first time is that you simply copy-paste the last line and change the 4 into a 5.

Spoiler: ShowHide
    n += armor4 != nil ? armor4.ATR_plus : 0

    n += armor5 != nil ? armor5.ATR_plus : 0


Also keep in mind that other methods might slight differ, but the part that needs to be edit is always the same.



4. The Actor - The Rest


There are a couple of other methods you need to modify in the Game_Actor class in order to make the accessory work right. Scroll up to the beginning. Now you need to find the method labeled "def element_rate". The code of the method should look like this:

Spoiler: ShowHide
  def element_rate(element_id)
    # Get values corresponding to element effectiveness
    table = [0,200,150,100,50,0,-100]
    result = table[$data_classes[@class_id].element_ranks[element_id]]
    # If this element is protected by armor, then it's reduced by half
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
      armor = $data_armors[i]
      if armor != nil and armor.guard_element_set.include?(element_id)
        result /= 2
      end
    end
    # If this element is protected by states, then it's reduced by half
    for i in @states
      if $data_states[i].guard_element_set.include?(element_id)
        result /= 2
      end
    end
    # End Method
    return result
  end


Pay attention to this line of the code:

Spoiler: ShowHide
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]


This line needs to be changed by adding the new ID. It should look like this afterwards:

Spoiler: ShowHide
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, armor5_id]


Don't forget the comma.
Now, scroll further down and find the method "def state_guard?". This method should look like this:

Spoiler: ShowHide
  def state_guard?(state_id)
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
      armor = $data_armors[i]
      if armor != nil
        if armor.guard_state_set.include?(state_id)
          return true
        end
      end
    end
    return false
  end


Again, you will see an identical line like the one before.

Spoiler: ShowHide
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]


Again, change it to:

Spoiler: ShowHide
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, armor5_id]


The next target is "def equip" which is located below the base_ATR methods. This method's code is a bit longer, but don't worry, we will only do a little modification.

Spoiler: ShowHide
  def equip(equip_type, id)
    case equip_type
    when 0  # Weapon
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1)
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end
    when 1  # Shield
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor1_id], $data_armors[id])
        $game_party.gain_armor(@armor1_id, 1)
        @armor1_id = id
        $game_party.lose_armor(id, 1)
      end
    when 2  # Head
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor2_id], $data_armors[id])
        $game_party.gain_armor(@armor2_id, 1)
        @armor2_id = id
        $game_party.lose_armor(id, 1)
      end
    when 3  # Body
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor3_id], $data_armors[id])
        $game_party.gain_armor(@armor3_id, 1)
        @armor3_id = id
        $game_party.lose_armor(id, 1)
      end
    when 4  # Accessory
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor4_id], $data_armors[id])
        $game_party.gain_armor(@armor4_id, 1)
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end
    end
  end


At the bottom you will find this piece of code:

Spoiler: ShowHide
    when 4  # Accessory
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor4_id], $data_armors[id])
        $game_party.gain_armor(@armor4_id, 1)
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end


This code needs to be copied EXACTLY as I marked it in the codebox above. You have to include the "when 4", the "if ..." line and ONLY 1 "end". You need to make a copy of that piece of code and add it below, then comes the editing. Afterwards it should look like this:

Spoiler: ShowHide
    when 4  # Accessory
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor4_id], $data_armors[id])
        $game_party.gain_armor(@armor4_id, 1)
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end
    when 5  # Accessory
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor5_id], $data_armors[id])
        $game_party.gain_armor(@armor5_id, 1)
        @armor5_id = id
        $game_party.lose_armor(id, 1)
      end


Be sure to apply the changes EXACTLY since any mistake is an error in your game and you don't want that.
Don't worry, we're almost done. Find the method "def class_id=" further below. It should look like this:

Spoiler: ShowHide
  def class_id=(class_id)
    if $data_classes[class_id] != nil
      @class_id = class_id
      # Remove items that are no longer equippable
      unless equippable?($data_weapons[@weapon_id])
        equip(0, 0)
      end
      unless equippable?($data_armors[@armor1_id])
        equip(1, 0)
      end
      unless equippable?($data_armors[@armor2_id])
        equip(2, 0)
      end
      unless equippable?($data_armors[@armor3_id])
        equip(3, 0)
      end
      unless equippable?($data_armors[@armor4_id])
        equip(4, 0)
      end
    end
  end


Again, concentrate on the last piece of code.

Spoiler: ShowHide
      unless equippable?($data_armors[@armor4_id])
        equip(4, 0)
      end


Add another section and do the appropriate edits. It should look like this afterwards:

Spoiler: ShowHide
      unless equippable?($data_armors[@armor4_id])
        equip(4, 0)
      end
      unless equippable?($data_armors[@armor5_id])
        equip(5, 0)
      end




5. Equipment Screens


Now that our actors are fully able to handle the new slot, it would be nice if the player could actually equip it. For this purpose we will modify the equipment scene. That means that you have to open the "Window_EquipRight" script. Down below should be the method "def refresh".

Spoiler: ShowHide
  def refresh
    self.contents.clear
    @data = []
    @data.push($data_weapons[@actor.weapon_id])
    @data.push($data_armors[@actor.armor1_id])
    @data.push($data_armors[@actor.armor2_id])
    @data.push($data_armors[@actor.armor3_id])
    @data.push($data_armors[@actor.armor4_id])
    @item_max = @data.size
    self.contents.font.color = system_color
    self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
    self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
    self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
    self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
    self.contents.draw_text(4, 32 * 4, 92, 32, $data_system.words.armor4)
    draw_item_name(@data[0], 92, 32 * 0)
    draw_item_name(@data[1], 92, 32 * 1)
    draw_item_name(@data[2], 92, 32 * 2)
    draw_item_name(@data[3], 92, 32 * 3)
    draw_item_name(@data[4], 92, 32 * 4)
  end


Yet again we have to add something. It should look like this afterwards:

Spoiler: ShowHide
  def refresh
    self.contents.clear
    @data = []
    @data.push($data_weapons[@actor.weapon_id])
    @data.push($data_armors[@actor.armor1_id])
    @data.push($data_armors[@actor.armor2_id])
    @data.push($data_armors[@actor.armor3_id])
    @data.push($data_armors[@actor.armor4_id])
    @data.push($data_armors[@actor.armor5_id])
    @item_max = @data.size
    self.contents.font.color = system_color
    self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
    self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
    self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
    self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
    self.contents.draw_text(4, 32 * 4, 92, 32, $data_system.words.armor4)
    self.contents.draw_text(4, 32 * 5, 92, 32, $data_system.words.armor4)
    draw_item_name(@data[0], 92, 32 * 0)
    draw_item_name(@data[1], 92, 32 * 1)
    draw_item_name(@data[2], 92, 32 * 2)
    draw_item_name(@data[3], 92, 32 * 3)
    draw_item_name(@data[4], 92, 32 * 4)
    draw_item_name(@data[5], 92, 32 * 5)
  end


There are two things you need to consider. The first thing is why I am keeping the "$data_system.words.armor4" and why I am not using "$data_system.words.armor5" instead. The reason is simple: It doesn't exist. If I used the latter, it would mean that we are actually creating a new slot type which is not true. We are using the accessory slot type, so we have to use "$data_system.words.armor4". Here is a quick list with types and corresponding variables:

Spoiler: ShowHide

  • $data_system.words.armor1 - Shield
  • $data_system.words.armor2 - Helmet
  • $data_system.words.armor3 - Body Armor
  • $data_system.words.armor4 - accessory


The second thing is a little edit that will make your code more suitable for future changes. I will explain here how to do it, please see the following, optional chapter for more information. It is one of the optional things as your game will work fine without it, it's not necessary.
Now open your "Window_Status" script and find the "def refresh" method.

Spoiler: ShowHide
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 112)
    draw_actor_name(@actor, 4, 0)
    draw_actor_class(@actor, 4 + 144, 0)
    draw_actor_level(@actor, 96, 32)
    draw_actor_state(@actor, 96, 64)
    draw_actor_hp(@actor, 96, 112, 172)
    draw_actor_sp(@actor, 96, 144, 172)
    draw_actor_parameter(@actor, 96, 192, 0)
    draw_actor_parameter(@actor, 96, 224, 1)
    draw_actor_parameter(@actor, 96, 256, 2)
    draw_actor_parameter(@actor, 96, 304, 3)
    draw_actor_parameter(@actor, 96, 336, 4)
    draw_actor_parameter(@actor, 96, 368, 5)
    draw_actor_parameter(@actor, 96, 400, 6)
    self.contents.font.color = system_color
    self.contents.draw_text(320, 48, 80, 32, "EXP")
    self.contents.draw_text(320, 80, 80, 32, "NEXT")
    self.contents.font.color = normal_color
    self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2)
    self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(320, 160, 96, 32, "equipment")
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)
  end


Concentrate on the bottom part:

Spoiler: ShowHide
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)


Add another line and edit it appropriately. It should look like this afterwards:

Spoiler: ShowHide
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)
    draw_item_name($data_armors[@actor.armor5_id], 320 + 16, 448)


Please note that this might look "ugly" on your screen. In fact, you won't see any changes. I recommend using a different y drawing coordinate offset for the armor parts. In other words, change the last values in each line so that this piece of code above looks like this one:

Spoiler: ShowHide
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 240)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 272)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 304)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 336)
    draw_item_name($data_armors[@actor.armor5_id], 320 + 16, 368)


Right below you will find the "def dummy" method which you need to edit as well. The method should look like this:

Spoiler: ShowHide
  def dummy
    self.contents.font.color = system_color
    self.contents.draw_text(320, 112, 96, 32, $data_system.words.weapon)
    self.contents.draw_text(320, 176, 96, 32, $data_system.words.armor1)
    self.contents.draw_text(320, 240, 96, 32, $data_system.words.armor2)
    self.contents.draw_text(320, 304, 96, 32, $data_system.words.armor3)
    self.contents.draw_text(320, 368, 96, 32, $data_system.words.armor4)
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 24, 144)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 24, 208)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 24, 272)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 24, 336)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 24, 400)
  end


Again, I recommed using different y drawing coordinate offset so that you can actually see the armor parts. The code should look like this after the editing:

Spoiler: ShowHide
  def dummy
    self.contents.font.color = system_color
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 240)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 272)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 304)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 336)
    draw_item_name($data_armors[@actor.armor5_id], 320 + 16, 368)
  end


This is a rather tricky piece of code. The problem is that drawing out the equipment types takes up too much screen to allow another piece of equipment to be shown. I have removed the drawing of the equipment type names, keep that in mind.
Our next target is the script "Scene_Equip". First find "def refresh" which should look like this:

Spoiler: ShowHide
  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
    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
    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


Concentrate on this first piece of code:

Spoiler: ShowHide
    @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)


The editing this time is not as easy as it used to be before, keep that in mind. We will NOT add another line which is simply a copy-paste from the last line with the numbers changed. Each other windows represent another equipment type.

Spoiler: ShowHide

  • @item_window1 - weapon window
  • @item_window2 - shield window
  • @item_window3 - helmet window
  • @item_window4 - body armor window
  • @item_window5 - accessory window


Now, if we want the right window to be diplayed, we need to edit the right line. Our 6th (or 5th if you start counting from 0) equipment part is the new one and it's an accessory, hence we have to edit the code so that it looks like this afterwards:

Spoiler: ShowHide
    @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 or @right_window.index == 5)


If we wanted to add another body armor, we would have edited the line above. Keep that in mind when you add new slots. Also, if you wish to add yet another accessory slot, you simply add another "or" branch like in this example:

Spoiler: ShowHide
    @item_window5.visible = (@right_window.index == 4 or @right_window.index == 5 or @right_window.index == 6)


Finally take a look at the second piece of code:

Spoiler: ShowHide
    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
    end


This edit is simplier than the one before, but still a bit tricky. Edit the code so it looks like this here:

Spoiler: ShowHide
    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
    when 5
      @item_window = @item_window5
    end


As you see, there is a 5th branch, but the window is still @item_window5. This is out of the same reason as above: @item_window5 is the window for accessories. You're almost done.
Scroll up again. In "def main", whose code I won't display here has a line that should look like this one:

Spoiler: ShowHide
    @right_window = Window_EquipRight.new(@actor)


Below that line add this one:

Spoiler: ShowHide
    @right_window.height = 192




6. Equipment Screens Extras (optional)


This chapter will show you some extra edits which will make your equipment scene look better. For that remove the last edit from the chapter before, remove this line again:

Spoiler: ShowHide
    @right_window.height = 192


Now open the "Window_EquipItem" script and take a look at "def initialize". The code of this method should look like this here:

Spoiler: ShowHide
  def initialize(actor, equip_type)
    super(0, 256, 640, 224)
    @actor = actor
    @equip_type = equip_type
    @column_max = 2
    refresh
    self.active = false
    self.index = -1
  end


Take a look at this line:

Spoiler: ShowHide
    super(0, 256, 640, 224)


That line needs to be changed. The second parameter needs to be increased by 32 and the fourth parameter needs to be decreased by 32. If you are adding your first extra slot, the line should look like this afterwards:

Spoiler: ShowHide
    super(0, 288, 640, 192)


If you already have one or more extra slots, you need to increase and decrease the appropriate values. Keep in mind that the fourth parameter must not be below 64, 64 is the minimum. If you have many additional equipment slots, it is recommended that you skip this chapter.



7. The tricky Extras


There are still a few things that are right. One of them is the event command that checks whether an equipment part is equipped or not. To fix that you have to open the "Interpreter 3" script. Find the method "def command_111" which should look like this:

Spoiler: ShowHide
  def command_111
    # Initialize local variable: result
    result = false
    case @parameters[0]
    when 0  # switch
      result = ($game_switches[@parameters[1]] == (@parameters[2] == 0))
    when 1  # variable
      value1 = $game_variables[@parameters[1]]
      if @parameters[2] == 0
        value2 = @parameters[3]
      else
        value2 = $game_variables[@parameters[3]]
      end
      case @parameters[4]
      when 0  # value1 is equal to value2
        result = (value1 == value2)
      when 1  # value1 is greater than or equal to value2
        result = (value1 >= value2)
      when 2  # value1 is less than or equal to value2
        result = (value1 <= value2)
      when 3  # value1 is greater than value2
        result = (value1 > value2)
      when 4  # value1 is less than value2
        result = (value1 < value2)
      when 5  # value1 is not equal to value2
        result = (value1 != value2)
      end
    when 2  # self switch
      if @event_id > 0
        key = [$game_map.map_id, @event_id, @parameters[1]]
        if @parameters[2] == 0
          result = ($game_self_switches[key] == true)
        else
          result = ($game_self_switches[key] != true)
   ;;     end
      end
    when 3  # timer
      if $game_system.timer_working
        sec = $game_system.timer / Graphics.frame_rate
        if @parameters[2] == 0
          result = (sec >= @parameters[1])
        else
          result = (sec <= @parameters[1])
        end
      end
    when 4  # actor
      actor = $game_actors[@parameters[1]]
      if actor != nil
        case @parameters[2]
        when 0  # in party
          result = ($game_party.actors.include?(actor))
        when 1  # name
          result = (actor.name == @parameters[3])
        when 2  # skill
          result = (actor.skill_learn?(@parameters[3]))
        when 3  # weapon
          result = (actor.weapon_id == @parameters[3])
        when 4  # armor
          result = (actor.armor1_id == @parameters[3] or
                    actor.armor2_id == @parameters[3] or
                    actor.armor3_id == @parameters[3] or
                    actor.armor4_id == @parameters[3])
        when 5  # state
          result = (actor.state?(@parameters[3]))
        end
      end
    when 5  # enemy
      enemy = $game_troop.enemies[@parameters[1]]
      if enemy != nil
        case @parameters[2]
        when 0  # appear
          result = (enemy.exist?)
        when 1  # state
          result = (enemy.state?(@parameters[3]))
        end
      end
    when 6  # character
      character = get_character(@parameters[1])
      if character != nil
        result = (character.direction == @parameters[2])
      end
    when 7  # gold
      if @parameters[2] == 0
        result = ($game_party.gold >= @parameters[1])
      else
        result = ($game_party.gold <= @parameters[1])
      end
    when 8  # item
      result = ($game_party.item_number(@parameters[1]) > 0)
    when 9  # weapon
      result = ($game_party.weapon_number(@parameters[1]) > 0)
    when 10  # armor
      result = ($game_party.armor_number(@parameters[1]) > 0)
    when 11  # button
      result = (Input.press?(@parameters[1]))
    when 12  # script
      result = eval(@parameters[1])
    end
    # Store determinant results in hash
    @branch[@list[@index].indent] = result
    # If determinant results are true
    if @branch[@list[@index].indent] == true
      # Delete branch data
      @branch.delete(@list[@index].indent)
      # Continue
      return true
    end
    # If it doesn't meet the conditions: command skip
    return command_skip
  end


The method is rather big, but don't worry, you will be guided through it. First isolate this section in your mind:

Spoiler: ShowHide
    when 4  # actor
      actor = $game_actors[@parameters[1]]
      if actor != nil
        case @parameters[2]
        when 0  # in party
          result = ($game_party.actors.include?(actor))
        when 1  # name
          result = (actor.name == @parameters[3])
        when 2  # skill
          result = (actor.skill_learn?(@parameters[3]))
        when 3  # weapon
          result = (actor.weapon_id == @parameters[3])
        when 4  # armor
          result = (actor.armor1_id == @parameters[3] or
                    actor.armor2_id == @parameters[3] or
                    actor.armor3_id == @parameters[3] or
                    actor.armor4_id == @parameters[3])
        when 5  # state
          result = (actor.state?(@parameters[3]))
        end
      end


Now concentrate on this part specifically:

Spoiler: ShowHide
          result = (actor.armor1_id == @parameters[3] or
                    actor.armor2_id == @parameters[3] or
                    actor.armor3_id == @parameters[3] or
                    actor.armor4_id == @parameters[3])


You might already see what you need to do. After your edit, this piece of code should look like:

Spoiler: ShowHide
          result = (actor.armor1_id == @parameters[3] or
                    actor.armor2_id == @parameters[3] or
                    actor.armor3_id == @parameters[3] or
                    actor.armor4_id == @parameters[3] or
                    actor.armor5_id == @parameters[3])


That's it. You're done. You have made all neccesary code edits that needed to be done to fully support another accessory slot. There is only one thing left that you need to consider. If you want to equip something to that slot using an event command, you won't be able to do so, because RMXP's editor doesn't support another equipment slot. This has to be done using a "Call Script" event command. You can simply use one of the two following calls:

Spoiler: ShowHide
$game_actors[ID].equip(NUMBER, ARMOR_ID)
$game_party.actors[POS].equip(NUMBER, ARMOR_ID)


Legend:

Spoiler: ShowHide

  • ID - ID of the actor in the database
  • POS - position of the actor in the party (STARTS FROM 0, NOT 1!)
  • ARMOR_ID - ID of the armor part in the database that should be equipped, use 0 to unequip it
  • NUMBER - the number of your additional slot, starting from 0 (for this example, it would be 5)


Keep in mind that this call is restrained by the same rules as the event command. In order to equip an accessory, the party must have at least one in possession!



8. Summary


Using an extra script just for another accessory slot which will render half of my other scripts faulty because of incompatibility? If you don't want to do that, this tutorial is what you are looking for! It teaches you how to add new equipment slots without messing up your game and other scripts. Keep in mind that this might not work for custom equipment systems and that this might not work with CMSes correctly. I suggest that you contact the maker of the CMS and ask him how to do the steps described in chapter 5 of this tutorial in his CMS instead of the default equipment scene.

Keep in mind that this applies to armor only, do not use it to add additional weapons, it will NOT work!

If you have any problems or think that this tutorial is missing something, please post, I have written this tutorial completely out of my head without testing.



9. Demo


This is a demo with working edits.
http://www.sendspace.com/file/xk2cin



10. Credits


Made by:

  • Blizzard


Requested by:

  • Aqua


Demo by:

  • Aqua
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Aqua

June 13, 2008, 02:01:49 pm #1 Last Edit: June 13, 2008, 02:34:57 pm by Aqua
OMG you finished!  Yay!!! *glomps*
Time to read it :)

Edit:  Yay!  It works :)  Thanks a ton!!!! *powers up*

Starrodkirby86

Congratulations Blizzard, you did this in so quick of time, that not even the power of brevity beaten you up and stole your lunch money. It seems like so much effort you put into this, yet I know you didn't take an extremely long time. Wow. Only thing I'm against is no screenshot, but that is so minor...KUDOS!

What's osu!? It's a rhythm game. Thought I should have a signature with a working rank. ;P It's now clickable!
Still Aqua's biggest fan (Or am I?).




Blizzard

June 13, 2008, 02:27:47 pm #3 Last Edit: June 13, 2008, 02:32:08 pm by Blizzard
What do you want? Screenshots of my open RMXP editor showing me editing the scripts? xD

EDIT: Wait, I have just the right thing. xD



There's the proof, it took me 1 hour and 20 minutes.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Starrodkirby86

Quote from: Blizzard on June 13, 2008, 02:27:47 pm
What do you want? Screenshots of my open RMXP editor showing me editing the scripts? xD
The final result mainly. It's just proof that it works, the process isn't needed to be known, heh. Though that's minor, I mean, no one really cares...right? I hope no one cares...:<

What's osu!? It's a rhythm game. Thought I should have a signature with a working rank. ;P It's now clickable!
Still Aqua's biggest fan (Or am I?).




Blizzard

Quote from: Blizzard on June 13, 2008, 02:00:03 pm
If you have any problems or think that this tutorial is missing something, please post, I have written this tutorial completely out of my head without testing.


:=
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Aqua

June 14, 2008, 10:37:45 am #6 Last Edit: June 14, 2008, 10:39:14 am by Aqua


I provided a screenie that you could use, Blizz :)
Only problem with this screenie is that it's a slight edit to the tutorial... =/
It still shows an extra slot though!

Blizzard

I could just put up a screeny of CP. I used this method to create the two extra accessory slots. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Starrodkirby86

June 15, 2008, 11:52:21 am #8 Last Edit: June 16, 2008, 11:35:47 am by Starrodkirby86
Quote from: Blizzard on June 13, 2008, 02:27:47 pm


Hey...I can't read that post on "Post a Picture of Yourself!"...Argh, stupid Dikura window...why can't I move--Oh right, it's a SCREENSHOT. Ah...I understand completely. Hey look, there's my window! *clicks* Why can't I open that too!? This is soooo making me angry right now...a little insane...

Though I think I know what post it is on Post a Picture...is it the one commenting how much MB that one image of me was?

And by the way, thanks Aqua for the final result screen, it looks better than your mock-up. Of course it does...it's the real thing! :3

What's osu!? It's a rhythm game. Thought I should have a signature with a working rank. ;P It's now clickable!
Still Aqua's biggest fan (Or am I?).




Sally

you acually expect for me to read all this? i will read it when i need more slots :P

Blizzard

I only expected Aqua to read it as she requested it. :P
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Sally

lol... could someone make a demo... :P becous ei could use this

Aqua

Okay Susys.  I made the demo.  It /should/ be correct... lol

And Blizz, you can link it...

http://www.sendspace.com/file/xk2cin

Sally


Sally

June 19, 2008, 10:37:09 pm #14 Last Edit: June 19, 2008, 10:42:55 pm by Susys
ok, i see you have a modd 7 diffrent scrips... can you make it so theres liek 5 accessories? and still have all the other things?

Edit:

blizzard, your a god, thank  you aqua :) i think ill use this...

Memor-X

ahhh, all the links to download the demo (Blizzards one and Aqua's one) are all dead, it says the file as been deleted, could someone look into this and get the file back cause i could use this, and also, with the new accessory slots, how do i lock them, you know, how you lokc the accessory slot when your editing the character in the database

Aqua


Punn

I pretty much use a script for multi slots, I'm too lazy to read, and do all that and I don't want to fuck up the main script files.

Aqua

Download the demo! :)

I named the modded main scripts so you can't possibly miss them.
Just copy and paste :)

Punn

No need to. I already got this feature similar to this. Although it can be useful for another project...