January 21, 2009:
-Added the script that allows for the equips to immediately take effect in the menu.
This tutorial is for an alternate Class Changing and Class Skill learning system to go along with a Class Changing Armor piece(Armor/Shield/Helmet/Accessory) or Weapon, through pretty much pure eventing, for one character. I made this due to a massive flaw in XP's basic class changing and class skill learning system, where, if you learn a skill in one class, and change to another class that would also give you a skill at that level, you wouldn't learn it, and never would.
The one thing that should be noted is that there's a couple of little, bitty, pieces of script that are going to have to be added. BUT, I will be giving you the coding and telling you in as much detail as I possibly can, where to put it. So fear not!
Now then, on to the tutorial.
STEP 1:
Select a common event in the Common Events tab of the Database. Set it's Trigger to Parallel and select a Condition switch to start it.
STEP 2:
Now, in the common event, add a Conditional Branch for each equip that will change your character's class. The setting for the branches, under tab 2, is Actor, where you select the character (who, for this tutorial's code areas, will be called Bob,) the game is checking for the equip on, and then select either Armor or Weapon depending on which you are going use to change your character's class (For the sake of this tutorial, it will be accessories). You should also have Set handling when conditions do not apply, checked. After creating each Conditional Branch, you should start the next Conditional Branch in the previous branch's Else area. Let's take a look at a simplified version as it would appear in XP using only 4 accessories (Accessory 1, Accessory 2, Accessory 3, and Accessory 4).
The "-" symbols before the "@>"s should be ignored and are only used in place of spaces.
@>Conditional Branch: [Bob] is [Accessory 1] equipped
--@>
-:-Else
--@>Conditional Branch: [Bob] is [Accessory 2] equipped
----@>
---:-Else
----@>Conditional Branch: [Bob] is [Accessory 3] equipped
------@>
-----:-Else
------@>Conditional Branch: [Bob] is [Accessory 4] equipped
--------@>
-------:-Else
--------@>
-------:-Branch End
------@>
-----:-Branch End
----@>
---:-Branch End
--@>
-:-Branch End
@>
This, combined with the common event running parallel, makes the game constantly check your character's equipment for the class changing armor or weapon.
STEP 3:
Now, between the line stating the Conditional Branches condition and it's Else line, insert (press the "enter" key, or double click) the Change Actor Class... event command, under the 3 tab. Select the Actor and the Class you want them to change to. Do this for each branch. And after the last branch's Else, insert a class change that will change you're character's class to none (which is also added under the class tab). Let's look at what it would look like now, with each accessory changing to a different class (Class A, Class B, Class C, and Class D, and the None class).
@>Conditional Branch: [Bob] is [Accessory 1] equipped
--@>Change Actor Class: [Bob], [Class A]
--@>
-:-Else
--@>Conditional Branch: [Bob] is [Accessory 2] equipped
----@>Change Actor Class: [Bob], [Class B]
----@>
---:-Else
----@>Conditional Branch: [Bob] is [Accessory 3] equipped
------@>Change Actor Class: [Bob], [Class C]
------@>
-----:-Else
------@>Conditional Branch: [Bob] is [Accessory 4] equipped
--------@>Change Actor Class: [Bob], [Class D]
--------@>
-------:-Else
--------@>Change Actor Class: [Bob], [None]
--------@>
-------:-Branch End
------@>
-----:-Branch End
----@>
---:-Branch End
--@>
-:-Branch End
@>
With the Change Actor Class... commands in there now, anytime you change your equipment to a different armor or weapon, the game will automatically change your class, or, if you don't have a class changing armor or weapon, will tell you you have no class.
STEP 4:
All right, the class changing parts are done. Now for the skills.
First, right click on the first conditional branch, or just double click it, and insert a Control Variables... event command under the 1 tab.
You'll only need one variable, but change which one if neccessary(for this tutorial the variable will be called Level, and will be the first variable). Leave the Operation at Set. Change the Operand to Actor and after selecting the actor change it to Level. This will make the variable permanantly equal to the actor's level. Now the event
@>Control Variables:[0001:Level] = [Bob]'s Level
@>Conditional Branch: [Bob] is [Accessory 1] equipped
--@>Change Actor Class: [Bob], [Class A]
--@>
-:-Else
--@>Conditional Branch: [Bob] is [Accessory 2] equipped
----@>Change Actor Class: [Bob], [Class B]
----@>
---:-Else
----@>Conditional Branch: [Bob] is [Accessory 3] equipped
------@>Change Actor Class: [Bob], [Class C]
------@>
-----:-Else
------@>Conditional Branch: [Bob] is [Accessory 4] equipped
--------@>Change Actor Class: [Bob], [Class D]
--------@>
-------:-Else
--------@>Change Actor Class: [Bob], [None]
--------@>
-------:-Branch End
------@>
-----:-Branch End
----@>
---:-Branch End
--@>
-:-Branch End
@>
STEP 5:
Now, in each conditional branch, in the space right after the Change Actor Class commands, add another Conditional Branch, but for this one, go to the 1 tab and select the Variable option. Select the variable that has your character's level stored in it, then, under that, select the Greater than or Equal to option from the drop down menu, and under that, select the Constant, and enter a number equal to what level you want the character to learn a skill at. This should be lowest level he learns a skill at.
Now, immediately under the conditional branch line, insert a Change Skills... event command under the 3 tab. Select the Actor, Set the Operation to Learn, and select the Skill you want to learn.
Then immediately following the Change Skills... command, insert another condition branch for the next skill, this time setting the Constant to a higher number. And repeat this for each class, and each skill.
Here the sample using 2 skills for each class (A Skill 1, A Skill 2 ~ D Skill1, Skill 2).
@>Control Variables:[0001:Level] = [Bob]'s Level
@>Conditional Branch: [Bob] is [Accessory 1] equipped
--@>Change Actor Class: [Bob], [Class A]
--@>Conditional Branch: Variable [0001:Level] >= 2
----@>Change Skills: [Bob], + [A Skill 1]
----@>Conditional Branch: Variable [0001:Level] >= 4
------@>Change Skills: [Bob], + [A Skill 2]
------@>
-----:-Else
------@>
-----:-Branch End
----@>
---:-Else
----@>
---:-Branch End
--@>
-:-Else
--@>Conditional Branch: [Bob] is [Accessory 2] equipped
----@>Change Actor Class: [Bob], [Class B]
----@>Conditional Branch: Variable [0001:Level] >= 3
------@>Change Skills: [Bob], + [B Skill 1]
------@>Conditional Branch: Variable [0001:Level] >= 5
--------@>Change Skills: [Bob], + [B Skill 2]
--------@>
-------:-Else
--------@>
-------:-Branch End
------@>
-----:-Else
------@>
-----:-Branch End
----@>
---:-Else
----@>Conditional Branch: [Bob] is [Accessory 3] equipped
------@>Change Actor Class: [Bob], [Class C]
------@>Conditional Branch: Variable [0001:Level] >= 1
--------@>Change Skills: [Bob], + [C Skill 1]
--------@>Conditional Branch: Variable [0001:Level] >= 8
----------@>Change Skills: [Bob], + [C Skill 2]
----------@>
---------:-Else
----------@>
---------:-Branch End
--------@>
-------:-Else
--------@>
-------:-Branch End
--------@>
-----:-Else
------@>Conditional Branch: [Bob] is [Accessory 4] equipped
--------@>Change Actor Class: [Bob], [Class D]
--------@>Conditional Branch: Variable [0001:Level] >= 7
----------@>Change Skills: [Bob], + [D Skill 1]
----------@>Conditional Branch: Variable [0001:Level] >= 9
------------@>Change Skills: [Bob], + [D Skill 2]
------------@>
-----------:-Else
------------@>
-----------:-Branch End
----------@>
---------:-Else
----------@>
---------:-Branch End
--------@>
-------:-Else
--------@>Change Actor Class: [Bob], [None]
--------@>
-------:-Branch End
------@>
-----:-Branch End
----@>
---:-Branch End
--@>
-:-Branch End
@>
Now the game will give you skills based on your level.
In tha case of this code, while Bob is Class A, he'll know A Skill 1 if he's at least level 2, and A Skill 2 if he's at least level 4. Or while Class D, He'll know D Skill 1 if he's at least level 7, and D Skill 2 if he's at least level 9.
And he'll keep any skill he's learned no matter his class.
Or...
STEP 6:
Now, you could very easily stop after step 5 and let your character use all the skills. Or, you can make it so the character can only use a set of skills if he's currently that class. To do this, between the conditional branches and the control variable command that sets the variable to your character's level, we add a Change Skills... for each skill the character can learn, only we set them to forget it.
Now the event would look like this:
@>Control Variables:[0001:Level] = [Bob]'s Level
@>Change Skills: [Bob], - [A Skill 1]
@>Change Skills: [Bob], - [A Skill 2]
@>Change Skills: [Bob], - [B Skill 1]
@>Change Skills: [Bob], - [B Skill 2]
@>Change Skills: [Bob], - [C Skill 1]
@>Change Skills: [Bob], - [C Skill 2]
@>Change Skills: [Bob], - [D Skill 1]
@>Change Skills: [Bob], - [D Skill 2]
@>Conditional Branch: [Bob] is [Accessory 1] equipped
--@>Change Actor Class: [Bob], [Class A]
--@>Conditional Branch: Variable [0001:Level] >= 2
----@>Change Skills: [Bob], + [A Skill 1]
----@>Conditional Branch: Variable [0001:Level] >= 4
------@>Change Skills: [Bob], + [A Skill 2]
------@>
-----:-Else
------@>
-----:-Branch End
----@>
---:-Else
----@>
---:-Branch End
--@>
-:-Else
--@>Conditional Branch: [Bob] is [Accessory 2] equipped
----@>Change Actor Class: [Bob], [Class B]
----@>Conditional Branch: Variable [0001:Level] >= 3
------@>Change Skills: [Bob], + [B Skill 1]
------@>Conditional Branch: Variable [0001:Level] >= 5
--------@>Change Skills: [Bob], + [B Skill 2]
--------@>
-------:-Else
--------@>
-------:-Branch End
------@>
-----:-Else
------@>
-----:-Branch End
----@>
---:-Else
----@>Conditional Branch: [Bob] is [Accessory 3] equipped
------@>Change Actor Class: [Bob], [Class C]
------@>Conditional Branch: Variable [0001:Level] >= 1
--------@>Change Skills: [Bob], + [C Skill 1]
--------@>Conditional Branch: Variable [0001:Level] >= 8
----------@>Change Skills: [Bob], + [C Skill 2]
----------@>
---------:-Else
----------@>
---------:-Branch End
--------@>
-------:-Else
--------@>
-------:-Branch End
--------@>
-----:-Else
------@>Conditional Branch: [Bob] is [Accessory 4] equipped
--------@>Change Actor Class: [Bob], [Class D]
--------@>Conditional Branch: Variable [0001:Level] >= 7
----------@>Change Skills: [Bob], + [D Skill 1]
----------@>Conditional Branch: Variable [0001:Level] >= 9
------------@>Change Skills: [Bob], + [D Skill 2]
------------@>
-----------:-Else
------------@>
-----------:-Branch End
----------@>
---------:-Else
----------@>
---------:-Branch End
--------@>
-------:-Else
--------@>Change Actor Class: [Bob], [None]
--------@>
-------:-Branch End
------@>
-----:-Branch End
----@>
---:-Branch End
--@>
-:-Branch End
@>
I'm pretty sure there's an easier way to make the character forget all those skills using a small script, but unfortunately I don't know how. If you do, though, please let me know.
STEP 7:
All right, now it's time to add the few lines of script that will make this whole thing work without having to exit the menu in the game.
First, open up the main Script Editor (the button next to the musical note). You're going to see a rather large list of scripts on the left side, and a lot of confusing looking stuff in the bigger area on the right, but pay no mind to it for right now. In the list of scripts on the left, scroll down until you find a script called Scene_Equip. Click on it once to highlight it and cause it's scripting to appear in the area on the right.
There will be a section of it that should be immediately visible that is in green text (green text areas are known as comments, which are ignored by the game when it starts, they're there for us so we know where we are in the script) called # * Main Processing, which is preceded and followed by a lot of - marks. Under this section is another sub-section labeled # Set cursor position. Click the beginning of the line, right next to the 39 on the line of numbers to the left, and press Enter to create a blank line. Now, copy and past (or manually enter if you want) the following into this blank line.
# Common Events Activator
@common_events = {}
for i in 1...$data_common_events.size
@common_events[i] = Game_CommonEvent.new(i)
end
It should appear almost exactly like that in the window there (the colors will be a bit off). If it doesn't you might want to make sure you got it all, or got it all right. Now position the text entering cursor (the little blinking black bar) at the beginning of the first line, and press the Tab key twice. Do so on all the other lines we just added, only press it three times for the fourth. This makes the script much neater, which will be a must if you ever start scripting yourself.
With that done, the area before and after the little script add-on we just made should look something like:
Quote:
# Associate help window
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
# Common Events Activator
@common_events = {}
for i in 1...$data_common_events.size
@common_events = Game_CommonEvent.new(i)
end
# Set cursor position
@right_window.index = @equip_index
refresh
Only with a lot more colors. But you should get the idea.
STEP 8:
All right, that bit's done with, now you have one more small section of coding to add.
Scroll down the script until you find another section called # * Frame Update, and find the sub-section with the comment # If right window is active: call update_right. Now, go one line above to where it says refresh, and create a new line above it. Add the following code to the new line:
#Common Event
$game_system.map_interpreter.update
common = []
common += @common_events[9].list
$game_system.map_interpreter.setup(common, 0)
Once again, coloring will differ, but that's about how it should look when it's been added.
All right, now, this is very, very, very important. You see that 9 between the two brackets? That is where we need to put the number of the common event in the common event list that contains all our wonderful eventing. You don't need to add the zeros that come before the number, but you can if you want. For the sake of this tutorial, let's just say that the common event we used is common event 1. Now do what we did with the other section and Tab them over so they're lines up with the rest of the script. The areas before and after the little section of script should look like this:
Quote:
# Update windows
@left_window.update
@right_window.update
@item_window.update
#Common Event
$game_system.map_interpreter.update
common = []
common += @common_events[001].list
$game_system.map_interpreter.setup(common, 0)
refresh
# If right window is active: call update_right
if @right_window.active
update_right
return
end
@left_window.update
@right_window.update
@item_window.update
#Common Event
$game_system.map_interpreter.update
common = []
common += @common_events[001].list
$game_system.map_interpreter.setup(common, 0)
refresh
# If right window is active: call update_right
if @right_window.active
update_right
return
end
But once again, it will have a lot more color.
Congratulations! Now, when you go into the menu in your game and put on a piece of class changing equipment, it will immediately take effect. Go ahead and try it if you want. When you exit out of the equip screen, you'll see that your class will have been changed.
AFTERWORDS:
Now, here's a couple of ideas on how to use this whole thing.
You don't have to use the bits of scripting if you really don't want to. You could also very easily use a normal event (attached to a dresser or something) to change your Equips without having to go into the menu.
Or by deleting the change class commands, you could very easily use this to make weapons and armor give your characters special skills while they're equipped.
I'm sure there are several other ways this can be used, so go ahead and play with it a bit.
I hope this tutorial has helped you in one way or another. If you were confused by some part of this tutorial, please let me know so I can clarify it for you and future readers. Or if there's some part of my eventing that's redundant, or I just plain don't need to do, let me know about that as well.
Special thanks and credits for the scripting goes to GubiD of the Creation Asylum forums, who may not have directly helped me, but created a script for running Common Events in custom menus, which I managed to pick apart and get the important bits to add on to the default menu script.