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:
OMG you finished! Yay!!! *glomps*
Time to read it :)
Edit: Yay! It works :) Thanks a ton!!!! *powers up*
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 do you want? Screenshots of my open RMXP editor showing me editing the scripts? xD
EDIT: Wait, I have just the right thing. xD
(http://img505.imageshack.us/img505/5681/snap956lm9.th.png) (http://img505.imageshack.us/img505/5681/snap956lm9.png)
There's the proof, it took me 1 hour and 20 minutes.
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...:<
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.
:=
(http://img501.imageshack.us/img501/1740/extraslotscreeniecf4.th.png) (http://img501.imageshack.us/my.php?image=extraslotscreeniecf4.png)
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!
I could just put up a screeny of CP. I used this method to create the two extra accessory slots. xD
Quote from: Blizzard on June 13, 2008, 02:27:47 pm
(http://img505.imageshack.us/img505/5681/snap956lm9.th.png) (http://img505.imageshack.us/img505/5681/snap956lm9.png)
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
you acually expect for me to read all this? i will read it when i need more slots :P
I only expected Aqua to read it as she requested it. :P
lol... could someone make a demo... :P becous ei could use this
Okay Susys. I made the demo. It /should/ be correct... lol
And Blizz, you can link it...
http://www.sendspace.com/file/xk2cin (http://www.sendspace.com/file/xk2cin)
thanks DLS now...
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...
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
http://www.mediafire.com/?dnesjbv9f9u (http://www.mediafire.com/?dnesjbv9f9u)
Hope this one lasts...
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.
Download the demo! :)
I named the modded main scripts so you can't possibly miss them.
Just copy and paste :)
No need to. I already got this feature similar to this. Although it can be useful for another project...
could someone add a demo for download that has stormtronics CSM fixed up to have these fixed up in it
I would love to utilize something like this in game creation, but after following the instructions to the button... it spits out an error on test that claims:
Script 'Scene_Equip' line 98: NoMethodError occured.
undefined method ` active' for nil:NilClass
Which, line 98 just so happens to be:
97 # If right window is active
98 if @right_window.active
99 # Erase parameters for after equipment change
100 @left_window.set_new_parameters(nil, nil, nil, nil)
101 end
As a person that can barely grasp x and y locations in the script, this makes zero sense to me. :( Perhaps...a little help?
I think you have an extra nil in there...
Here's what mine is
# If right window is active
if @right_window.active
# Erase parameters for after equipment change
@left_window.set_new_parameters(nil, nil, nil)
end
scripting is so powerful!
yet one simple thing is keeping it from running altogether.
It pops up with an identical error message.
The problem goes unchanged, even after fixing it as you suggested, with the 'nils'.
What in the world does it even mean?
nil means non-existent.
I hotlinked it... >.< (http://starrodkirby86.web44.net/AquaTesting/ExtraArmorSlot_by_Blizzard_Demo_by_Aqua.zip)
Here's the demo I had before, just on a site that Star and I co-own. Open it up and paste the scripts in there over yours and it should be fine.
OK, I'm clearly not getting some things here.
1. The new slot appears with no name in game. How do I change this?
2. How do I create a new weapon/armor for this slot?
:???:
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(5, 32 * 4, 92, 32, $data_system.words.armor4)
self.contents.draw_text(6, 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)
draw_item_name(@data[5], 92, 32 * 5)
end
That could should have shown the name for the new slot... You sure you did that part right?
As for #2... do you mean a new weapon/armor type? As in... one which cannot be equipped in a different slot? Because this tutorial was made so that you can equip an
extra armor from existing types like accessories.
Quote from: Aqua on October 19, 2008, 07:32:53 pm
As for #2... do you mean a new weapon/armor type? As in... one which cannot be equipped in a different slot? Because this tutorial was made so that you can equip an extra armor from existing types like accessories.
Oh. x_x
Nevermind, then. :P
If you want a custom equipment system, I suggest Guillaume777's Multi-Slot Equip. I made most of my scripts affecting equipment work with that one.
Ok first things first this script is the best.
But I followed the instructions step by step and it's all in place but when I go into the menu this happened...
(http://i487.photobucket.com/albums/rr231/Exile322/th_Addedarmorslotproblem.png) (http://s487.photobucket.com/albums/rr231/Exile322/?action=view¤t=Addedarmorslotproblem.png)
I don't know how to fix it so can someone help me. I want to see the name of the new slot, see what's in it, and make the left and right equip screens bigger.
There was a mistake at the beginning of step 5. I fixed it.
Quote from: Aqua on June 14, 2008, 10:37:45 am
(http://img501.imageshack.us/img501/1740/extraslotscreeniecf4.th.png) (http://img501.imageshack.us/my.php?image=extraslotscreeniecf4.png)
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!
Ok how do i change the size of the right window so that it looks like this :???: :???:
Quote from: Blizzard on October 20, 2008, 05:54:04 am
If you want a custom equipment system, I suggest Guillaume777's Multi-Slot Equip. I made most of my scripts affecting equipment work with that one.
Hi can someone give me the script for Guillaume777's Multi slot equip coz I can't find it anywhere. :???:
Researching, seems DerVVulfman made another wonderful script, but since he left, he removed it from RMXP.org (Chances are). Fortunately, House Slasher, one of his new homes, is still up and running successfully and I found the script.
http://houseslasher.com/index.php?showtopic=51
Enjoy.
Could this be used to add more weapon slots for BABS?
I'm basing a VX script off of this... I mostly finsihed it but there's a bug with the word end... I've never made my own complete script so I'm seeking help :( I'm gonna post a topic for help here on CP
I don't mean to necro, but I was just wondering something. If I made an Equip Window from scratch, would it be possible to make 5 accessory slots without any other edits, or would I still have to change some values in other scripts? PS. I don't need anything else to work aside from accessories.
Edit: A better explaination of what I want to do. I want to store the accessories in all four slots, no more shields or armours etc.
I believe you should be fine. The equip slots for Shields and stuff is just an ID value that the game uses to call $data_armors to get its stats. It's not like RMXP has the "two-handed = no shield" rule either, so you're all good.
I've seen it done before anyways :P
Alright, so I'm gonna go ahead and ask what may turn out to be a reaallly dumb question.. I have this set up, and it works perfect, minus one thing. When viewing character 1, it shows the equipment on the character, and, all of the equipment, on the characters under it... (this is in reference to the status screen). When I switch to character 2 (pet rat) it only shows the equipment that the pet is wearing. After that, I took a look at character 3 (she gets added later in the game), and it has the same result as character 1, and shows the items equipped on the pet...
Any thoughts on what be causing this? I have several other scripts, but if someone could give me a hint into what might be causing the issues, I might be able to look into trying to fix it =p
Using:
Blizz stat distro
Tons
Arcanes Alternate Battle Results Window (this in theory shouldn't cause the issue, since it really doesn't even touch the equipment)
My Game_Actor rewrite (this shouldn't cause an issue though, since it just modifies the actor experience on level up)
My guess is that in your menu system, when it's calling Scene_Equip, it's not starting at 0 like it's supposed to. 0 = first party member, 1 = second party member, etc...
Check Scene_Equip and make sure you didn't change anything on the initialization part and check Scene_Menu and look for where it's calling Scene_Equip.
Nope, everything is proper in that sense. Also, would it not be the Window_Status script in this case?
I think I need some pictures to understand what's really going on.
Can do =p
Character 1 stat screen: https://dl.dropboxusercontent.com/u/25886192/character%201.png
Character 2 stat screen: https://dl.dropboxusercontent.com/u/25886192/character%202.png
Character 3 stat screen: https://dl.dropboxusercontent.com/u/25886192/character%203.png
Ohhhhh okay. Now I see what you meant. It's probably one of your windows then.
And what does your Window_Status look like?
Window_Status is the standard default script, and then the extra armor has a modded version, looks like this:
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_Status < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
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)
#Dual Wep Show
draw_item_name($data_weapons[@actor.armor1_id], 320 + 16, 240)
#-------------
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
def dummy
self.contents.font.color = system_color
draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
#Dual Wep Show
draw_item_name($data_weapons[@actor.armor1_id], 320 + 16, 240)
#-------------
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
end
draw_item_name($data_weapons[@actor.armor1_id], 320 + 16, 240)
#-------------
draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 240)
Uh, how did you not see this? :???:
You're drawing the weapon and armor of the same ID as the first armor slot. I take it Wooden Shield and Claw have the same ID.
:facepalm:
...I have no idea how I didn't think to look at that. I noticed the dual weapon thing before, but figured it probably had nothing to do with what I was using it for, because I wasn't allowing dual weapons...
Thank you for pointing that out though, that did the trick!