YEP.82 – Counter Control

Yanfly Engine Plugins is a plugin library made for RPG Maker MV, a wonderful piece of software to help you make that role playing game of your dreams. You can find out more about RPG Maker MV here.

You can grab the plugin here:
English Dropbox
English Mirror

The default counterattack trait in RPG Maker MV doesn’t give many options for the developer. It’s a skill that flatout cancels out the physical skill of the attacker by evading it and then producing a normal attack from the counterattacker. This plugin will give you more control over how counters work in the sense that you can choose to have the counter connect first before allowing the counter skill to proc.


Introduction


This plugin requires YEP_BattleEngineCore. Make sure this plugin is located under YEP_BattleEngineCore in the plugin list.

If you are using Imported.YEP_X_BattleSysATB or Imported.YEP_X_BattleSysCTB, place this plugin under those plugins in the plugin list.

The default counterattack trait in RPG Maker MV doesn’t give many options for the developer. It’s a skill that flatout cancels out the physical skill of the attacker by evading it and then producing a normal attack from the counterattacker. This plugin will give you more control over how counters work in the sense that you can choose to have the counter connect first before allowing the counter skill to proc.


Instructions – How Advanced Counters Work


A counterattack is an action that serves as a reaction to an action used by an opposing battler unless the action is marked as able of being countered by allied members.

Now begins a clash between the attacker’s anti-counter stat (newly added) against the target’s counter stat plus any of the action’s modifiers. Once the finalized counter rate is decided, a random number check is made to see if the counter will pass. If it doesn’t, no counter will occur. If it does, the next step occurs.

The target will then generate a pool of skills it can use as counters. It will go in a priority list mentioned in the next section below. The battle system will then go through the pool of skills in order and select the first counter skill that meets all of the conditions required. If no skill is selected, no skill will be used as a counter. All skills have a mandatory requirement of being able to pay the skill’s cost and can use it.

Once the skill is selected, the counter skill is placed in the counter queue and waits for the current attacker’s turn to be over. Once over, the actions in the counter queue will begin. The counterattacker will perform counter actions without conflicting with their own turns. This process will repeat itself until the counter queue is emptied.

During the counter queue process, counter skills can trigger counter skills, too. For that reason, there is a maximum queue size determined by the plugin parameters. Once the queue count reaches this size, no more counter skills will be added to the counter queue.


Instructions – Counter Skill Priority List


When the pool of counter skills is being generated, they will be generated in the following order:

1. States – Highest Priority Notebox
2. States – Lowest Priority Notebox
3. Equipment – Weapons Notebox
4. Equipment – Armors Notebox
5. Actor – Current Class Notebox
6. Actor – Actor Notebox
7. Enemy – Enemy Notebox

The order of the pool of counter skills matter in that when going through the conditions of the counter skill to be used, the first counter skill whose condition is met will be the one used.


Notetags


You can use the following notetags to alter counters in your game. Each of these notetags will alter counters in a particular way.

Actor and Enemy Notetags:

<Default Counter: x>
<Default Counter: name>
Sets the default counter skill to x. If it is left as 0, then the counter skill will be RPG Maker MV’s default counter skill. If you are using the name of the skill, and there are multiple skills in the database with the same name, then priority will be given to the skill with the highest ID. *Note: Use 0 for x if you wish to add RPG Maker MV’s default counter.

Actor, Class, Enemy, Weapon, Armor, and State Notetags:

<Counter Skills: x>
<Counter Skills: x, x, x>
<Counter Skills: x to y>
This will add to the list of possible counter skills for the battler. If multiple skill ID’s are listed, then they’re all added. Priority will be given to the counter skills listed earlier.
*Note: Use 0 for x if you wish to add RPG Maker MV’s default counter.
*Note2: See the Counter List priority to see which skills will be given priority on the counter skill list.

<Counter Skill: name>
This will add the named skill to the list of possible counter skills for the battler. If there are multiple skills in the database with the same name, then priority will be given to the skill with the highest ID.
*Note: See the Counter List priority to see which skills will be given priority on the counter skill list.

<Counter Total: +x>
<Counter Total: -x>
Alters the number of times the battler can counter by x. This is the amount of times the battler can counter until the battler’s turn comes up at which, the number of times is reset.

<Target Counter: x%>
When this battler attacks an opponent target, this will cause the target counter rate to be altered by x% rate. If a target has 10% CNT, then a notetag of 50% will cause the counter rate to become 5%.

<Target Counter: +x%>
<Target Counter: -x%>
When this battler attacks an opponent target, this will cause the target counter rate to increase or decrease by x%. If a target has 10% CNT, then a notetag of +50% will cause the counter rate to become +60%.

<Evade Counter>
This will change all counter skills used by the related battler to become evade counters regardless of their default nature. However, if the battler is affected by a trait that is <Hit Counter>, then priority will be given to the <Hit Counter> trait instead.

<Hit Counter>
This will change all counter skills used by the related battler to become hit counters regardless of their default nature. If the battler is also affected by <Evade Counter>, this effect will take priority.

Skill and Item Notetags:

<Ally Counter>
Makes this action able to proc counter skills by allied members.

<Ally Cannot Counter>
Makes this action unable to proc counter skills by allied members.

<Cannot Counter>
Causes this action to be un-counterable. This means that it will always return a 0% counterattack possibility.

<Counter Rate: x%>
This will cause this action to proc a counter from the target by x% rate. This means if the target has a 10% chance to counter and this notetag is 50%, then the target will have a 5% chance to counter.

<Counter Rate: +x%>
<Counter Rate: -x%>
This will cause this action to proc a counter from the target by an additive x%. This means if the target has a 10% chance to counter and this notetag is +50%, then the target has a 60% chance to counter.

Skill Notetags:

<Evade Counter>
If this skill is being used as the counter skill, the battler will evade the current action and then counter.

<Hit Counter>
If this skill is being used as the counter skill, the battler will take the hit against the current action and then counter.

<Counter Name: text>
This changes the displayed name of the skill when used as a counter skill to ‘text’.

<Counter Icon: x>
This changes the displayed icon of the skill when used as a counter skill to x icon.


Notetags – Counter Conditions


When making your counter skills, you can have those counter skills respond only to specific conditions. If all conditions are met, the counter skill will occur. If a single condition isn’t met, that counter skill will then be skipped and the next one will be checked. To add counter conditions, use the following notetags:

Skill Notetags:

<Counter Condition>
condition
condition
</Counter Condition>
Replace the ‘condition’ text in between the notetags with the listed in the conditions list below to best fit what you want.

— Example —

<Counter Condition>
physical hit
single target
</Counter Condition>
This skill will only be used as a counter skill if the current action is a physical hit that’s single target.


Counter Condition List


Here is a list of all the counter conditions that come with this plugin that you can use. Keep in mind that all of the counter conditions must be met before a counter will take effect. If even a single counter condition fails to be met, the counter skill will not proc.


ATTACKER param eval
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Replace ‘param’ with ‘level’, ‘maxhp’, ‘hp’, ‘maxmp’, ‘mp’, ‘atk’, ‘def’, ‘mat’, ‘mdf’, ‘agi’, or ‘luk’. This will run a check against the attacker’s parameter. If the check returns ‘true’, the counter condition is met. If it returns ‘false’, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Attacker level > 50
Attacker hp <= attacker.mhp0.50
Attacker atk > defender.def


CERTAIN HIT
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is a certain hit, the counter condition is met. If it isn’t, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Certain Hit


COUNTER HIT
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is a counter skill, the counter condition is met. If it isn’t, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Counter Hit


DEFENDER param eval
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Replace ‘param’ with ‘level’, ‘maxhp’, ‘hp’, ‘maxmp’, ‘mp’, ‘atk’, ‘def’, ‘mat’, ‘mdf’, ‘agi’, or ‘luk’. This will run a check against the defender’s parameter. If the check returns ‘true’, the counter condition is met. If it returns ‘false’, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Defender level > 50
Defender hp <= defender.mhp0.50
Defender atk > attacker.def


ELEMENT: x
ELEMENT: name
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target has element X attached to it, the counter condition is met. If it isn’t, the counter condition isn’t met. Replace ‘x’ with the element ID or the element name in the database system tab. If multiple elements share the same name, priority will be given to the element with the highest ID.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Element: 4
Element: Fire
Element: Ice


EVAL: code
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
For those with JavaScript experience, you can use the above line to perform an eval check to see if the conditions are met for the counter skill. If the eval check returns ‘true’, the condition is met. If it returns ‘false’, the condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Eval: attacker.name() === ‘Harold’
Eval: defender.hpRate() <= 0.50


ITEM: x
ITEM: name
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current aciton used against the target is item x, the counter condition is met. If it isn’t, the counter condition isn’t met. Replace ‘x’ with the item ID. If you choose to use the item name, and your database has multiple items with the same name, priority will be given to the item with the highest ID.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Item: 30
Item: Bomb


MAGICAL HIT
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is a magical hit, the counter condition is met. If it isn’t, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Magical Hit


MULTI TARGET
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is a multi target action, the counter condition is met. If it isn’t, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Multi Target


NOT CERTAIN HIT
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is NOT certain hit, the counter condition is met. If it is, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Not Certain Hit


NOT COUNTER HIT
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is NOT a counter skill, the counter condition is met. If it is, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Not Counter Hit


NOT ELEMENT: x
NOT ELEMENT: name
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target has element X attached to it, the counter condition is NOT met. If it isn’t, the counter condition is met. Replace ‘x’ with the element ID or the element name in the database system tab. If multiple elements share the same name, priority will be given to the element with the highest ID.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Not Element: 4
Not Element: Fire
Not Element: Ice


NOT ITEM: x
NOT ITEM: name
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current aciton used against the target is NOT item x, the counter condition is met. If it is, the counter condition isn’t met. Replace ‘x’ with the item ID. If you choose to use the item name, and your database has multiple items with the same name, priority will be given to the item with the highest ID.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Not Item: 30
Not Item: Bomb


NOT MAGICAL HIT
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is NOT a magical hit, the counter condition is met. If it is, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Not Magical Hit


NOT PHYSICAL HIT
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is NOT a physical hit, the counter condition is met. If it is, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Not Physical Hit


NOT SKILL: x
NOT SKILL: name
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current aciton used against the target is NOT skill x, the counter condition is met. If it is, the counter condition isn’t met. Replace ‘x’ with the skill ID. If you choose to use the skill name, and your database has multiple skills with the same name, priority will be given to the skill with the highest ID.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Not Skill: 50
Not Skill: Firaga


NOT STYPE: x
NOT STYPE: name
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is NOT a skill and skill type x, the counter condition is met. If it isn’t the counter condition isn’t met. Replace ‘x’ with the Skill Type ID. If you choose to use the skill type name and your database has multiple skill types with the same name, priority will be given to the skill type with the highest ID.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Not Stype: 1
Not Stype: Magic


PHYSICAL HIT
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is a physical hit, the counter condition is met. If it isn’t, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Physical Hit


RANDOM: x%
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
This will run a random check. There is a x% chance that this counter check will pass. If it passes, the counter condition is met. If it doesn’t, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Random: 30%


SINGLE TARGET
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is a single target action, the counter condition is met. If it isn’t, the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Single Target


SKILL: x
SKILL: name
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current aciton used against the target is skill x, the counter condition is met. If it isn’t, the counter condition isn’t met. Replace ‘x’ with the skill ID. If you choose to use the skill name, and your database has multiple skills with the same name, priority will be given to the skill with the highest ID.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Skill: 50
Skill: Firaga


STYPE: x
STYPE: name
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If the current action used against the target is a skill and skill type x, the counter condition is met. If it isn’t the counter condition isn’t met. Replace ‘x’ with the Skill Type ID. If you choose to use the skill type name and your database has multiple skill types with the same name, priority will be given to the skill type with the highest ID.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Stype: 1
Stype: Magic


SWITCH x OFF
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If switch x is OFF (false) prior to the current action being used against the target, the counter condition is met. If it is ON (true), the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Switch 10 Off


SWITCH x ON
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
If switch x is ON (ftrue) prior to the current action being used against the target, the counter condition is met. If it is OFF (false), the counter condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Switch 10 On


VARIABLE x eval
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
This runs an eval check against variable x. If the eval check returns ‘true’ the condition is met. If it returns ‘false’ then the condition isn’t met.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Example: Variable 15 >= 15
Variable 16 <= 20
Variable 17 === $gameParty.aliveMembers().length


Lunatic Mode – Custom Counter Skills


For those with JavaScript proficiency, you can use the following Lunatic Mode notetags to give a dynamic set of skills granted for counter usage.

Actor, Class, Enemy, Weapon, Armor, and State Notetags:

<Custom Counter Skills>
if (user.name() === ‘Harold’) {
skills.push(50, 51, 52);
} else if (user.name() === ‘Therese’) {
skills.push(53, 54, 55);
} else if (user.name() === ‘Marsha’) {
skills.push(56, 57, 58);
} else if (user.name() === ‘Lucius’) {
skills.push(59, 60, 61);
}
</Custom Counter Skills>
The ‘skills’ variable is an array that will contain all the counter skills that will be added to the list of potential skills the battler can counter actions with provided that their requirements are met.


Lunatic Mode – Custom Counter Total


For those with JavaScript proficiency, you can use the following Lunatic Mode notetags to give a dynamic counter total bonus:

Actor, Class, Enemy, Weapon, Armor, and State Notetags:

<Custom Counter Total>
value = user.level;
<Custom Counter Total>
The ‘value’ variable is the total amount of counters is increased or decreased by. If the total counter value reaches 0 or less than 0 for the battler, the battler is unable to use counter skills.


Lunatic Mode – Custom Target Counter Rate


For those with JavaScript proficiency, you can use the following Lunatic Mode notetags to make the attacker’s traits alter the target’s CNT rate.

Actor, Class, Enemy, Weapon, Armor, and State Notetags:

<Custom Target Counter Rate>
rate -= user.hpRate();
</Custom Target Counter Rate>
The ‘rate’ variable is the final rate used to determine the counter rate the target has. It is already given the value calculated from the target’s CNT value. This is calculated before the skill’s custom counter rate.


Lunatic Mode – Custom Counter Rates


For those with JavaScript proficiency, you can use the following Lunatic Mode notetags to give skills a dynamic chance for the target to counter.

Skill and Item Notetags:

<Custom Counter Rate>
rate += target.hpRate();
</Custom Counter Rate>
The ‘rate’ variable is the final rate used to determine the counter rate the target has. It is already given the value calculated from the target’s CNT value plus any additional counter rate modifiers from the skill. This is calculated after the attacker’s custom target counter rate.


Lunatic Mode – Custom Counter Condition


For those with JavaScript proficiency, you can use the following Luantic Mode notetags to give counter skills a custom counter condition. While you can do the same with an Eval condition, this notetag is for those who prefer to take control over everything at once.

Skill Notetags:

<Custom Counter Condition>
if (attacker.name() === ‘Harold’) {
condition = true;
} else if (defender.name() === ‘Therese’) {
condition = true;
} else {
condition = false;
}
</Custom Counter Condition>
The ‘condition’ variable determines whether or not the counter skill will pass or fail. If the ‘condition’ variable returns ‘true’, the condition is met. If the ‘condition’ variable returns ‘false’, the condition fails to be met. Once the condition is met, the rest of the <Counter Condition> conditions will be checked.


Happy RPG Making!


 

 

 

 

 

 

Happy RPG Making!


These plugins and Tips & Tricks ideas are made possible thanks to our creative patrons on Patreon! The majority of our Tips & Tricks, Plugins, and Lunatic Pack ideas are placed within the Patreon-exclusive Sample Project for quick and easy access! If you'd like to make a Plugin Suggestion, Yanfly's Patreon-based Suggestion Box a visit here:


If you have any bugs to report, visit the following link:


If you have any questions about Action Sequences, visit the following link:



Thank you!