Gw Temp

Menu

Tutorial - 'Trigger Happy Tutorial' by AzureFenrir

An item about RPGMaker 2000 posted on

Blurb

A short tutorial by Azure that shows how to make a trigger happy command, where you press a button as many times as possible to generate many attacks.

Body

Trigger Happy Tutorial

Hello, Azure is back!


For those who listened to the advice of most of the gaming population and never touched FFXII, Trigger Happy is a special command in the game II that only gunners can use. When trigger happy is used, you're asked to press the [ R ] key as many times as possible in a short period of time. Then, the gunner performs a number of (weaker) attacks equal to the number of times you pressed the [ R ] key. It works very well as a limit break.

Trigger Happy is acually an easy feature to implement in RM2K3, with the ability to use Key Input in battles (as a common event). As such, this will be a relatively short tutorial, although I'll try to make it as detailed as possible.

THINGS THAT YOU NEED TO KNOW:

Basic Experience With RM2K3 Commands
Experience With Battle Commands and Events
Basic Understanding of Switches
Basic Understanding of Variables
Key Input
Loops and Labels


Let's start off by making a new battle command called "Trigger." Since Trigger Happy only attacks one enemy, we have to give it an "Attack" archetype so that we can target with it. Give this command to the Gunner class (or whatever class you want):

Now, Since Trigger Happy is an attack archetype command, it will, by default, perform a regular attack when it's executed. Obviously, we must stop this from happening so we won't get another regular attack after our Trigger Happy command finished executing. To do this, creae a new condition called "Normal," make sure that it restricts all actions in battle ("No Action Allowed"), and have it last for only one turn. We will inflict this condition to prevent the hero from doing that extra attack.

We should now focus on the code. We know that, in order to do this, we need a battle event that detects whether "Gunner uses the "Trigger" command" and triggers certain commands. Unfortunately, Trigger Happy would require Key Input Processing, which is not available under Battle Commands, so we can't just stick it under a battle event.

The solution? Use a common event to handle the key input. So create a new common event, name it "Trigger Happy," and put the following code in it:

RPG Maker 2003 Code: Common Event Trigger Happy

<>Timer 1 Operation: Set, 0M 02S
<>Variable Operations: [####:TempPrevKey] Set, 0
<>Variable Operations: [####:TriggerCount] Set, 0
<>Timer 1 Operation: Start
<>Label: 1
<>Comment: Do Not Wait Until Key Press; Detect Decision Key (5))
<>Key Input Processing: [####:TempKeyVar]
<>Branch if: V[####:TempKeyVar] does not equal V[####:TempPrevKey]
<>Branch if: V[####:TempKeyVar] equals 5
<>Variable Operations: [####:TriggerCount] +, 1
<>Play SE: Shot
<>Flash Screen: (R31, G0, B0, V27), 0.5s (Wait)
: End
<>Branch if Timer1 is less than 0M 01S
<>Goto label: 2
: End
: End
<>Variable Operations: [####:TempPrevKey] Set, V[####:TempKeyVar]
<>Goto Label: 1
<>Label: 2
<>Timer 1 Operation: Stop


Let me explain this code. The common event first initializes Timer 1 to 2 seconds (which you can change to suit your game), which is how much time the user gets to press the Decision key and use rapid fire. The timer will be used to keep track of the passage of time, and will tell our event when time is up.

The next statement simply initializes two variables (specifically, the number of shots and the "Previous Key" variable) to zero. I'll explain the "Previous Key" vaiable later, so don't worry about it now. The code then starts Timer 1, and initializes the first label, which represents the start of this loop:

RPG Maker 2003 Code:

<>Label: 1
...
<>Goto Label: 1


In RM2K3, this is considered a "loop." The purpose of a loop is to repeat code over and over again until the loop ends. In our case, we want to repeat the "Key Input" code so we can get multiple presses of the "Decision" key.

Inside the loop, we first check whether the decision key is pressed. If it doesn't equal the variable "TempPrevKey"...wait a minute, what exactly is this "TempPrevKey", and why do we need it?

Well, let's take a close look at our code. We're checking how many times the user presses the Decision Key, and adding one to our "counter" every time they press it. However, what happens if the playe holds down the decision key? Well, the "Decision Key Pressed" will always turn out positive, so just by holding down the decision key, the player can get the maximum number of hits possible without even needing to push the key. This is obviously undesired.

We can solve this problem by storing the previous state of the decision key in the "TempPrevKey" variable. Thus, if the player holds down the decision key, the "Previous Key" variable will stay at five, and we can use a condition branch to prevent the counter incrementation from happening until the player releases the key and restores the TempPrevKey to zero. This is what the next two conditional branches do.

The commands inside these branch statements ae self-explainatory. If the decision key is pressed, they increment the "number of attacks" counter by one, and play special sound effects/flash the screen. Unfortunately, We can't show battle animations in a common event (due to layering problems), so a battle animation is inpossible to achieve. Finally, a branch statement detects whether the timer has run down to zero. If it has, then the two seconds is up, and we must go to label two, which stops the timer and ends the common event.

Now that we have a common event, we need to create a battle event that will do the rest of the work needed for Trigger Happy (like doing damage and showing the battle animation for the attack). So, create a new battle page, make its trigger "Hero [GunnerName uses the "Trigger" command", and put the following command into it:

RPG Maker 2003 Code: Battle Event "Hero [Gunner] uses the "Trigger" command"

<>Call Event: Trigger Happy
<>Variable Operations: [####:TempPrevKey] Set, Hero1 Attack
<>Variable Operations: [####:TempPrevKey] /, 8
<>Variable Operations: [####:TempPrevKey] *, V[####:TriggerCount]
<>Branch if Monster1 is the current target
<>Show Battle Animation: Trigger Happy, Monster1
<>Change HP: Monster1, Decrease V[####:TempPrevKey]
: End
<>Branch if Monster2 is the current target
<>Show Battle Animation: Trigger Happy, Monster2
<>Change HP: Monster2, Decrease V[####:TempPrevKey]
: End
<>Comment: Repeat for additional monsters
<>Change Condition: Gunner, Inflict Normal Condition


Most of this is self-explainatory. Basically, we call the trigger happy event, which, as we've seen before, stores the number of times the player presses the decision key in the "TriggerCount" variable. Then, we reuse "TempPrevKey" to store the total damage that we should do (which, in this case, is (Hero's Attack) / 8 damage per hit), and check which monster is being targetted. Finally, we show the animation on the appropriate monster, do our damage, and inflict the "Normal" condition that we've just created on the gunner to prevent him from attacking again (remember that "Trigger" is actually an attack archetype?).

That's really all that you need for a trigger happy system. I'm AzureFenrir, and this is the 10 o'clock GW Tutorials. Good night.

* Azure logs off as God kills another kitten *