Gw Temp

Menu

Tutorial - 'Trance Tutorial' by AzureFenrir

An item about RPGMaker 2000 posted on

Blurb

A tutorial that shows you how to make a FF9-styled Trance System.

Body

Trance Tutorial

Well, I'm kind of running short on time here (writing my tutorial), so I'll just get right to the tutorial without trying to think of (unfunny) witty descriptions.

THINGS THAT YOU NEED TO KNOW:

Experience With and Knowledge of RM2K Commands
Basics of Switches
Knowledge of Variables
Fork/Conditional Statements
Familiarity with the Timing of Battle Events


Trance is a classic system in Final Fantasy 9 that is similar to a limit break, except for the fact that Trance is not an attack. Rather, it is a condition that your characters enter once their "Trance" bars are fully filled up by enemy attacks. Once the "Trance" condition occurs, the character in question gains a boost in many stats, and will usually gain a new special ability, as well (such as X-Magic).

Once the character achieves trance, the trance bar will slowly decrease as he/she begins to take turns. Once the bar hits zzero, trance is cancelled, and the character must wait for his/her bar to fill up again. The trance bar also decreases to zero when a hero dies.

We will start off by making the background of the trance system.


Implementing the Trance System

Before we start, create a new switch called "BattleStart". Now, flip to the "Monster Group" page and create a new monster group. Put a few instances of the newly monster into this monster group. This tutorial will only work with this monster group for now - you can always copy the battle pages into other monster groups when you need to.



Done? OK. First of all, we need a internal trance variable so that we can maintain a tally of a hero's trance bar and determine if it's filled, right? So, before we do anything, create a new variable and call it "Hero1Trance." Repeat this process for every hero in your game.

However, the trance bar is increased by the amount of damage that a monster does relative to the hero's max HP, right? So, every time the monster attacks, we must find the amount of damage that the attack has done. A good way to do this is to compare the hero's HP with his HP from last turn. If the Hero's current HP is smaller, then we can subtract the hero's HP with his HP from last turn, and that would be our damage. So, we need to create a few new variables to store the heros' HPs, right? We'll call these variables "Hero1PrevHP", "Hero2PrevHP", etc. We will also create new variables to show whether the heros are already in Trance mode. I will call these switches "Hero1Trance", "Hero2Trance", etc. Feel free to replace "Heron" with your own hero' names.

We are ignoring damage done by other methods, such as poison, when using this method, but it should still work fairly well for our purposes.

First, set the trigger of the premade battle event to "Turn Elapsed [0]" so that it will run before a battle has started. Have this event set every hero's "HeronPrevHP" variable to their current HPs, and turn on the "BattleStart" switch.

Now, create a new battle event in our new monster group. This battle event will increment the heros' trance bars every time an enemy attacks, so we'll make its trigger "Switch [####:BattleStart] ON" to ensure that the code will run after every monster action (We used Switch for a reason - I'll explain why we didn't use "Turn Elapsed [1x]" later).

Put the following code inside the event:

CODE: BATTLE EVENT
<>Call Common Event: TranceTest
Trigger: Switch [####:BattleStart] ON


<>Branch if Switch[####:Hero1Trance] is ON
    <>
: End
<>Variable Operation [####:Hero1PrevHP] Set, Hero1 HP
<>Comment: Repeat this for all heros.


What does this code do? Well, it calls a common event called TranceTest, then it detects if a hero is already in trance mode, and if he is, does nothing (we'll be inserting more code here later). After that, it sets the hero's PrevHP variable to their current HP, and proceeds to the next hero. Fair enough, but what is TranceTest?

Well, that is a new common event that we will now create. Put the following code inside this new common event:

CODE: COMMON EVENT TranceTest


COMMENT: REPEAT FOR EVERY HERO!!!


What does this do? Well, first, we have a branch statement that checks whether the hero is already IN trance mode. If he/she is, then the common event does nothing (for the hero, that is). If not, then the code proceeds to increment the hero's trance bar appropriately.

Next, the code sets a temporary...whoopsie, we forgot to declare that variable! So, quickly create a new variable called "Temporary", and use it in this code. Basically, the variable operations store the hero's previous HP in the "Temporary" variable, and subtracts it by the hero's current HP.

After that, the next Branch statement checks whether this "Temporary" is 0 or less. If it is, then the hero hasn't taken damage, and nothing happens to the trance bar. Then, the code checks whether the hero is dead, and if he isn't, then the trance bar incrementing code is free to execute.

The next three variable operations then finds the percentage of the hero's HP that he/she had lost. This percentage is then added to the trance bar to "increment it." Then, we check whether the hero has a "full" trance bar using this:

<>Branch if Var[####:Hero1Trance] is 100 or more

So what happens if the hero does have a full trance bar? Well, first of all, we reset the bar to 100 (since trance bars never go over 100). Then, we store the character's equipment, change classes, and replace the equipment.

So why are we changing classes? Well, when characters get a full trance bar, they will usually gain new abilities, and will look slightly different than normal. Thus, by changing to a new (functionally identical) class, we can accomplish all of this relatively easily. Of course, since changing classes causes your character to be unequipped, we have to store a character's equipment, and reequip them after the class change is done.

Finally, we increase the hero's stats (in this case, increase Agility by 100) and set the switch "Hero1Trance" to ON, indicating that Hero1 is already in Trance mode. We then repeat this for every hero.

That was easy enough, but what about getting characters out of trance? Well, we can accomplish that in our next section:


Making the Trance Temporary

Just like in making the trance system, we will now make another common event that will handle when the trance ends. So, go to the common events tab and create a new common event called Hero1TranceEnd. Put the following code in there:

CODE: COMMON EVENT Hero1TranceEnd



Of course, you must make a new common event for each hero. This event is simple - it simply strips the hero of his trance status, puts him back into his original class, and removes his bonuses. It also resets his Trance switch and variable.

Now, we will modify our "Trigger: Switch [####:BattleStart] ON" battle event a little bit:

CODE: BATTLE EVENT
Trigger: Switch [####:BattleStart] ON



COMMENT: REPEAT FOR EVERY HERO!!!


So, we added some code to our "Hero1Trance is ON" branch. The code will detect whether a new variable "Hero1AfterTurn" is ON (make sure you create this new variable), and if it is, then we subtract the hero's Trance bar by 20 (to make the trance bar decrease by 20% every turn). Then, if the trance bar is empty, we call "Hero1TranceEnd" to remove his trance. Easy enough, right...but what's the "Hero1AfterTurn" switch?

Well, recall that this event runs EVERY TURN. Thus, we need a way to detect whether the tranced hero has just taken a turn (since only then does the trance bar decrease), or if it's another hero/enemy. So, create a new battle event page [b]for each hero[/b], as follows:

CODE: BATTLE EVENT
Trigger: [Hero1] has taken [1x] turns


<>Switch Operation [####:Hero1AfterTurn] - ON Set
COMMENT: MAKE A NEW PAGE FOR EVERY HERO!!!


So, this battle event turns ON the Hero1After switch, and the "Switch [####:BattleStart] ON" checks this variable and decrements the trance bar if it's ON. It then sets this variable to OFF. So, why bother putting the actual trance barcode in the "Switch [####:BattleStart] ON" event? Why not just cram it into this event?

Well, what happens when you cram it into this code? Since "[Hero] has taken [X] turns" events execute BEFORE the actual contents of a turn (the actual attack, the actual spell animation, etc.) is executed, the hero will lose his trance prematurely during his fifth tranced turn, even though he should still have 20% of his bar left.

To solve this problem, we put it in the switch-triggered event. Since these events run AFTER the battle animations and damage bits have been executed, they will eliminate this problem. This is also the reason we used "Switch [####:BattleStart] ON" as the trigger for our trance detection battle event instead of "Turn Elapsed [1x]".

Now, test your system. If you followed everything in my tutorial correctly, then you should have a working trance system!