This script provides functionality for setting up “battle reactions”, which are actions that are automatically invoked in response to certain actions. A reaction is similar to a counter-attack, except instead of responding to any attack, it only responds to specific “reaction triggers” and responds with an appropriate “reaction response”.
For example, your actor might have a shield that casts “heal” on the wearer whenever the wearer is targeted by the “attack” skill. The reaction trigger is the “attack” skill, while the reaction response is to cast heal.
You can have multiple reactions occur simultaneously and all of them will be executed.
This script introduces the concept of “reaction objects”, which is basically
any object that supports reactions. Actors, Classes, Items, Skills, Weapons,
Armors, Enemies, and States all support reactions.
Reactions have two parts to them: the “Reaction Trigger” which activates the reaction, and the “Reaction Response” which is how the reaction will respond when it is triggered. The reaction trigger consists of a “Trigger Type” and a “Trigger ID”, while the reaction response consists of a “Reaction Type” and a “Reaction ID”.
The following reaction triggers are available:
- Skill Reactions Triggers – when targeted by a specific skill
- Skill Type Reaction Triggers – when targeted by a skill with a specific skill type
- Element Type Reaction Triggers – when targeted by a skill with a specific element type
The targets are determined by the scope of the skill. By default, if the scope is for opponents, then the target is the attacker. If the scope if for allies, then the target is the defender.
Place this script below Materials and above Main
The following lists the reaction triggers currently available and how to use them.
Skill Reaction Triggers
To create a reaction that responds to skills, note-tag any reaction object with
<skill reaction: skill_id react_id chance forced>
`skill_id` is the ID of the skill to react to `react_id` is the ID of the skill to use in response `chance` is the probability that it is used. 100 is always, while 0 is never. Decimals not supported. `forced` means it basically acts like a forced action (no MP/SP consumption)
The chance can be specified as a formula, with the following variables
available to use
a - react user (ie: the battler that will react) b - react target p - game party t - game troop v - game variables s - game switches
Note that you literally type in “forced” if you want the raction to be the
same as a “forced action”.
Skill Type Reactions Triggers
To create a reaction that responds to skill types, note-tag reaction objects
<stype reaction: stype_id react_id chance forced>
Where the stype_id can be looked up in the terms database.
When a skill with the specified skill type ID is used, the reaction will
Element Reaction Triggers
To create a reaction that responds to certain elements, note-tag any
reaction object with
<element reaction: element_id react_id chance forced>
Where the element_id can be looked up in the Terms database.
When a skill with the specified element is used, reaction will be triggered.
Note that this only considers the element of the skill, not features.
You can add conditions to your reactions. A reaction will only occur if the
reaction condition has been met.
Reaction conditions are specified as formulas. They can be any formula, and
use the same formula variables that are available to battle reactions.
To create a reaction condition, use the following note-tag
<reaction condition: id1,id2, ... > FORMULA </reaction condition>
The ID’s are important: they are the reactions that the condition applies to,
where each ID is separated by a comma.
Each reaction has a unique ID, in the order that they are written in your note
box. The first reaction is 1, the second reaction is 2, and so on. Refer to
the example to understand how reaction conditions can be used
Reactions can occur before or after an action is executed. By default, a
reaction occurs after, but you can set a reaction to occur when an action
has been declared, but before it hits.
So for example, if an enemy attacks you, you may react to this by putting up
a shield, effectively increasing your defense, before the attack lands.
To set a reaction to occur before an action hits, use the note-tag
<pre react: id1, id2, ... >
Where the ID’s are the reactions that you want to apply this setting to.
The following skill reaction responds to skill 1 with skill 12 with a chance of 50% and is treated as a forced action
<skill reaction: 1 12 50 forced>
To respond to any “Magic” skill (assuming skill type 2) with skill 14
<stype reaction: 2 14>
To respond to any “Fire” elemental skills (assuming element ID 3) with skill 54
<element reaction: 3 54>
Now suppose we have two reactions. The first is a skill reaction that reacts to
the attack skill (skill 1), and responds with a triple attack (skill 23).
The second is a skill type reaction that reacts to all “magic” skills (stype 2) with a heal spell (skill 51).
Both reactions will only occur if state 23 is applied.
You can begin by writing the reactions, and then write the reaction condition
<skill reaction: 1 23> <stype reaction: 2 51> <reaction condition: 1,2> a.state?(23) </reaction condition>
If you want the stype reaction to occur before the skill lands, you can simply
add the following to your note
<pre react: 2>