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:
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.
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:
@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:
@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:
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:
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:
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":
- 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:
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:
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.
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:
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:
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:
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:
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.
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
Again, change it to:
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.
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:
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:
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:
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.
unless equippable?($data_armors[@armor4_id])
equip(4, 0)
end
Add another section and do the appropriate edits. It should look like this afterwards:
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".
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:
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:
- $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.
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:
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:
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:
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:
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:
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:
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:
@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.
- @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:
@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:
@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:
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:
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:
@right_window = Window_EquipRight.new(@actor)
Below that line add this one:
@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:
@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:
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:
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:
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:
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:
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:
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:
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:
$game_actors[ID].equip(NUMBER, ARMOR_ID)
$game_party.actors[POS].equip(NUMBER, ARMOR_ID)
Legend:
- 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:
Requested by:
Demo by: