TAA_SubstituteSkills (v1.0.0)

TAA_SubstituteSkills - v1.0.0
Created by taaspider

Terms of Use
Any plugins developed by taaspider are free for use for both commercial and noncommercial RPG Maker games, unless specified otherwise. Just remember to credit "taaspider".

Redistribution of parts or the whole of taaspider plugins is forbidden (which also includes reposting), unless it comes from the official website (linked within the post). You are allowed to edit and change the plugin code for your own use, but you're definitely not allowed to sell or reuse any part of the code as your own. Although not required to use my plugins, a free copy of your game would be nice!

Introduction

This plugin provides more control over the substitute effect. The engine default allows only for a substitute character to cover for all its allies at the same time for all types of attacks, and only when they are at low health. With TAA_SubstituteSkill you can create more specific and flexible substitutions, like covering for a single ally with no health limitations, having different substitutes for each skill type, or even covering for an enemy unit.

Main Features
  • Create substitute skills for each skill types independently;
  • Allow substitution skills to work on as many targets as you want, from one to all allies at the same time, or even covering for enemies;
  • Supports multiple substitutes at the same time, one for each skill type (so you can have a Knight cover for normal and special skills, and a Mage cover for magic attacks);
  • Allow for substitutions to cover (or not) from ally skills as well;
  • Create skills that ignores substitutes and force its way to the original target;

Screenshots

Spoiler
Couldn't think of a nice way to show much of the plugin features with images, but here's a gif not showing much anyway 😛
View attachment 169532

How to Use

WARNING: This plugin requires RPG Maker MV 1.5.0 or above! Please make sure your RPG Maker MV software is up to date before using this plugin. You don't need any specific version if you're using MZ.

First of, download the plugin here. You can also test the plugin using my sample demo project. It was built with MV, but you can open it with MZ as well (just open the game.rmmzproject file and you're good to go).

Spoiler: Substitution States
Substitution is configured by creating specific states, that when applied to a character turns the user who applies it its substitute for as long as that state is active.

States have the following settings:
  • Type: This determines which skill type will be covered by the substitute. You can specify a comma separated list of types using their names or engine indexes. For example, the engine default types Magic and Special. You can use their names as configured in the editor, or use their index according to their order: Magic is 1 and Special is 2. If you want the state to allow for normal attacks substitution just specify Normal or index 0. You can also specify all skill types by setting to "all" or -1. See some examples in the States Note Tags section.
    This is the only obligatory parameter.
  • Friendly Fire: This determines if the substitute will cover the target in case they're being hit by their allies. For example, if this is set to true and a healer issues a healing skill to the target, the substitute we'll be healed instead. If false, the substitution will not occur.
    If not set, the default global parameter is used (which you can configure through the Plugin Manager).
  • Condition: This determines on which conditions the substitution can occur. For example, only allow the substitute to take over damage if the target's HP is below 50%, or if the target's health is greater than the substitute.
    If not set, the default global parameter is used (which you can configure through the Plugin Manager).
A character can have multiple substitution states at the same time, but only one state will be active for each skill type. For example, if state A covers for Magic, and state B covers for all (and A was inflicted after B ), than the character will be substituted by whoever inflicted A if it is hit by a magic skill, while whoever inflicted B will cover for anything else.

Spoiler: Plugin Parameters
There are just two parameters, which sets the default values for Friendly Fire and Condition:
  • Substitute Friendly Fire
    • If set to true, substitutes will also cover for any allies issued abilities as long as substitution conditions are met. If false, only enemy attacks are substituted. You can overwrite this config using States Note Tags.
  • Substitute Condition
    • This sets a default condition to allow an applied substitution to happen. For example, only if the target HP is lower than the substitute HP, or the target health is below 50%, and so on.
      This is an eval clause, and the following special objects can be used:
      • a: access the attacker parameters like hp, mp, etc.
      • b: access the original target parameters;
      • c: access the substitute parameters;
      • v[n]: access the value from variable number n;
      • s[n]: access the value (true or false) from switch number n;
Just remember that this condition must return true or false. If it is evaluated to anything other than that the condition will always fail. You can leave this parameter blank to have if you want default condition to always pass.

Spoiler: State Note Tags
State note tags are used to create substitute states and customize default settings. The only mandatory tag is "type", which specifies which skill types are affected by the substitution:
<TAA_SSK: type:type1,type2,...,typeN>​
type is a comma separated list of skill types. You can use skill type names as they appear in the editor, or use their index. Here's some examples:
<TAA_SSK: type:normal,Special>​
This tag enables the substitution for both normal and Special skills. Magic skills are not affected. One important thing to note though, is that despite "normal" being case INSENSITIVE, any other skill types are case SENSITIVE, and they should be written exactly as they are set in the editor System tab.

<TAA_SSK: type:0,2>​
Assuming the engine default config, this tag has the exact same meaning as the first one. The 0 index represent normal attacks, while 2 is the Special skill type index.​

<TAA_SSK: type:all>​
<TAA_SSK: type:-1>​
Both this tags render the same result: a substitution for all skill types.​

To include a custom Friendly Fire or Condition settings, add the "friendFire" and "condition" clauses to your tag, and separate each clause with a ';':
<TAA_SSK: type:all; friendFire:true; condition:eval clause>​
friendFire must be either "true" or "false", while condition is an eval clause. As long as the type clause is present, you can add one or both of the others as you like, just be sure to keep the proper order (first type, then friendFire and last condition).

The following codes can be used inside a condition clause:
  • a: access the attacker parameters like hp, mp, etc.
  • b: access the original target parameters;
  • c: access the substitute parameters;
  • v[n]: access the value from variable number n;
  • s[n]: access the value (true or false) from switch number n;

Here's a few examples:
<TAA_SSK: type:1; condition: b.hp < b.mhp/2 >​
This denotes a substitution for skill type 1 that only takes effect when the target's HP is below 50%.​

<TAA_SSK: type:Normal; friendFire:false; condition: c.hp > b.hp >​
This creates a state that allows substitution to normal attacks, won't allow substitution for ally issued skills and only takes place when the substitute's HP is higher than the targets.​

<TAA_SSK: type:Magic; friendFire:true>​
This state will allow substitutions only for magical attacks, and will also work against ally's moves.​

State tags can also span multiple lines when inside the proper tags:
<TAA_SSK>​
type:type1,type2,...,typeN​
friendFire:true|false​
condition:eval clause​
</TAA_SSK>​

Here's how the three examples above would look like in a multi line format:
<TAA_SSK>​
type:1​
condition: b.hp < b.mhp / 2​
</TAA_SSK>​
​
<TAA_SSK>​
type:Normal​
friendFire:false​
condition: c.hp > b.hp​
</TAA_SSK>​
​
<TAA_SSK>​
type:Magic​
friendFire:true​
</TAA_SSK>​

Spoiler: Skill Note Tags
Skill note tags are way simpler, as their only setting is how likely the skill is to ignore the substitution and hit the actual target:
<TAA_SSK: N >​
where N is a number between 0 and 100, being 0 always hit the substitute, and 100 always bypass him and hit the original target.

Spoiler: Script Calls
$gameSystem.sskIsFriendlyFireAllowed()
Returns true if the global default friendly fire setting is enable, otherwise false.​

$gameSystem.sskEnableFriendlyFire()
Enables the global default friendly fire setting.​

$gameSystem.sskDisableFriendlyFire()
Disables the global default friendly fire setting.​

$gameSystem.sskResetFriendlyFire()
Resets the global default friendly fire setting to its original value.​

$gameSystem.sskCondition()
Returns the current global default substitution condition.​

$gameSystem.sskUpdateCondition(newCondition)
Sets the global default substitution condition to newCondition.​

$gameSystem.sskResetCondition()
Resets the global default substitution condition to its original value.​

Spoiler: Plugin Commands
Substitute FriendFire enable
Substitute FriendFire disable
Substitute FriendFire reset
Enable, disable or reset global default friendly fire setting.​

Substitute Condition Set newCondition
Updates the global default substitution condition to newCondition​

Substitute Condition Reset
Resets the global default substitution condition to its original value.​

Spoiler: CHANGE LOG
  • Version 1.0.0:
    • Fixed a bug for when a single state covers for more than one skill type;
    • Fixed a bug which would always have a substitute cover for friendly skills (unless a ignore tag was set);
    • Fixed a minor bug that could cause a substitute to cover for himself if he substitutes a target for a substitution skill issued by himself;
  • Version 0.9.0:
    • Beta release;
Tried to make this work onmz but I can't seem to be able to, Turned off all other plugins, saved the project. Tried giving teh state teh subsitute tag (it doesn't matter if it has it or not) Created an enemy that only does regular attacks and a state with the substitution tag normal. I didn't mess with the settings so the condition should always pass. But my substituter's allies kept getting hurt.

1608304604866.png


1608304641501.png
Tried to make this work onmz but I can't seem to be able to, Turned off all other plugins, saved the project. Tried giving teh state teh subsitute tag (it doesn't matter if it has it or not) Created an enemy that only does regular attacks and a state with the substitution tag normal. I didn't mess with the settings so the condition should always pass. But my substituter's allies kept getting hurt.

View attachment 171848

View attachment 171849

I just tried it in my sandbox project, and it does work. But reading your comment I wasn't sure of two things:
  1. How are you applying the substitution state?
  2. Are you applying the state to the substitute, or his allies (who should be covered)?
The substitution states are meant to be applied to the target you want to cover by having your substitute use a skill to apply the substitution state on them. So, taking your image as an example, if Rose is supposed to be the substitute, she must apply the state to her allies. Is that how you were testing?

Also, I'm assuming that when you say "Created an enemy that only does regular attacks" you mean the default Attack skill, which has the Skill Type set as "None". When you set substitutions for normal attacks, it will only work for skills with Skill Type set as None.
1608404674573.png


Spoiler
In my tests Reid issued a skill to apply the substitute state to the whole party. That makes him have the state icon as well (I may fix that in the future), but he is actually the tanker.
1608405213734.png
Ahh that explains it, I thought the state was to be applied to the character who substitutes not to the ones who are to be subtituted.
So, if I create a skill that affects all alies would the subsituttion work just fine even though the substituter is also affected by the state? (i guess i could make the substitute character immune to the status effect just to be sure)
Also dumb questions:
1- The only character to substitute will be the one who applied substitute to their allies right?
2- What happens if two characters use a substitute skill?

Thanks a lot for the reply. I was already looking for ways to code this by myself with my extremely meager knowledge of javascript. :LZYdizzy:
Ahh that explains it, I thought the state was to be applied to the character who substitutes not to the ones who are to be subtituted.
So, if I create a skill that affects all alies would the subsituttion work just fine even though the substituter is also affected by the state? (i guess i could make the substitute character immune to the status effect just to be sure)
Also dumb questions:
1- The only character to substitute will be the one who applied substitute to their allies right?
2- What happens if two characters use a substitute skill?

Thanks a lot for the reply. I was already looking for ways to code this by myself with my extremely meager knowledge of javascript. :LZYdizzy:

Glad to help!
The plugin actually inverts the engine's default setup (the engine default substitution is applied to the substitute, while my plugin applies to those who are going to be substituted), so I can understand the confusion! 🙂

The substituter being affected by the state won't change a thing, as the plugin prevents a character from covering for himself. You don't need to worry about that. I'll probably change the code in future versions to prevent a character from applying the state to himself.

Your questions are actually not dumb, as I asked that myself as I was coding hehe
Yes, the character to substitute will be the one who applied the substitution state on allies (or enemies). If a second character use a substitute skill, then a few scenarios can occur:
  • If friendly fire is not allowed (which means the substitute will cover for ally skills), and target characters have an active substitution, and another character uses a skill to apply another substitution state (assuming the skill type is covered by the applied substitution state), then the first substitute (and not the actual target) will have the second substitution applied;
  • If, on the other hand, friendly fire is allowed (which means the substitute won't cover for ally skills) and the second character tries to place a state that covers the same skill type, then the second character will replace the first as substitute;
  • If the first substitution skill covers a specific skill type (let's say, normal, for example), and the second covers a different skill type (like Magic), then normal attacks will be covered by the first substitute, and magic attacks by the second;
It's a bit tricky to explain, so let me know if what I wrote is too confusing! 😛
Got it, thanks a lot! 🙂
TAA_SubstituteSkills - v1.0.0
Created by taaspider

Terms of Use
Any plugins developed by taaspider are free for use for both commercial and noncommercial RPG Maker games, unless specified otherwise. Just remember to credit "taaspider".

Redistribution of parts or the whole of taaspider plugins is forbidden (which also includes reposting), unless it comes from the official website (linked within the post). You are allowed to edit and change the plugin code for your own use, but you're definitely not allowed to sell or reuse any part of the code as your own. Although not required to use my plugins, a free copy of your game would be nice!

Introduction

This plugin provides more control over the substitute effect. The engine default allows only for a substitute character to cover for all its allies at the same time for all types of attacks, and only when they are at low health. With TAA_SubstituteSkill you can create more specific and flexible substitutions, like covering for a single ally with no health limitations, having different substitutes for each skill type, or even covering for an enemy unit.

Main Features
  • Create substitute skills for each skill types independently;
  • Allow substitution skills to work on as many targets as you want, from one to all allies at the same time, or even covering for enemies;
  • Supports multiple substitutes at the same time, one for each skill type (so you can have a Knight cover for normal and special skills, and a Mage cover for magic attacks);
  • Allow for substitutions to cover (or not) from ally skills as well;
  • Create skills that ignores substitutes and force its way to the original target;

Screenshots

Spoiler
Couldn't think of a nice way to show much of the plugin features with images, but here's a gif not showing much anyway 😛
View attachment 169532

How to Use

WARNING: This plugin requires RPG Maker MV 1.5.0 or above! Please make sure your RPG Maker MV software is up to date before using this plugin. You don't need any specific version if you're using MZ.

First of, download the plugin here. You can also test the plugin using my sample demo project. It was built with MV, but you can open it with MZ as well (just open the game.rmmzproject file and you're good to go).

Spoiler: Substitution States
Substitution is configured by creating specific states, that when applied to a character turns the user who applies it its substitute for as long as that state is active.

States have the following settings:
  • Type: This determines which skill type will be covered by the substitute. You can specify a comma separated list of types using their names or engine indexes. For example, the engine default types Magic and Special. You can use their names as configured in the editor, or use their index according to their order: Magic is 1 and Special is 2. If you want the state to allow for normal attacks substitution just specify Normal or index 0. You can also specify all skill types by setting to "all" or -1. See some examples in the States Note Tags section.
    This is the only obligatory parameter.
  • Friendly Fire: This determines if the substitute will cover the target in case they're being hit by their allies. For example, if this is set to true and a healer issues a healing skill to the target, the substitute we'll be healed instead. If false, the substitution will not occur.
    If not set, the default global parameter is used (which you can configure through the Plugin Manager).
  • Condition: This determines on which conditions the substitution can occur. For example, only allow the substitute to take over damage if the target's HP is below 50%, or if the target's health is greater than the substitute.
    If not set, the default global parameter is used (which you can configure through the Plugin Manager).
A character can have multiple substitution states at the same time, but only one state will be active for each skill type. For example, if state A covers for Magic, and state B covers for all (and A was inflicted after B ), than the character will be substituted by whoever inflicted A if it is hit by a magic skill, while whoever inflicted B will cover for anything else.

Spoiler: Plugin Parameters
There are just two parameters, which sets the default values for Friendly Fire and Condition:
  • Substitute Friendly Fire
    • If set to true, substitutes will also cover for any allies issued abilities as long as substitution conditions are met. If false, only enemy attacks are substituted. You can overwrite this config using States Note Tags.
  • Substitute Condition
    • This sets a default condition to allow an applied substitution to happen. For example, only if the target HP is lower than the substitute HP, or the target health is below 50%, and so on.
      This is an eval clause, and the following special objects can be used:
      • a: access the attacker parameters like hp, mp, etc.
      • b: access the original target parameters;
      • c: access the substitute parameters;
      • v[n]: access the value from variable number n;
      • s[n]: access the value (true or false) from switch number n;
Just remember that this condition must return true or false. If it is evaluated to anything other than that the condition will always fail. You can leave this parameter blank to have if you want default condition to always pass.

Spoiler: State Note Tags
State note tags are used to create substitute states and customize default settings. The only mandatory tag is "type", which specifies which skill types are affected by the substitution:
<TAA_SSK: type:type1,type2,...,typeN>​
type is a comma separated list of skill types. You can use skill type names as they appear in the editor, or use their index. Here's some examples:
<TAA_SSK: type:normal,Special>​
This tag enables the substitution for both normal and Special skills. Magic skills are not affected. One important thing to note though, is that despite "normal" being case INSENSITIVE, any other skill types are case SENSITIVE, and they should be written exactly as they are set in the editor System tab.

<TAA_SSK: type:0,2>​
Assuming the engine default config, this tag has the exact same meaning as the first one. The 0 index represent normal attacks, while 2 is the Special skill type index.​

<TAA_SSK: type:all>​
<TAA_SSK: type:-1>​
Both this tags render the same result: a substitution for all skill types.​

To include a custom Friendly Fire or Condition settings, add the "friendFire" and "condition" clauses to your tag, and separate each clause with a ';':
<TAA_SSK: type:all; friendFire:true; condition:eval clause>​
friendFire must be either "true" or "false", while condition is an eval clause. As long as the type clause is present, you can add one or both of the others as you like, just be sure to keep the proper order (first type, then friendFire and last condition).

The following codes can be used inside a condition clause:
  • a: access the attacker parameters like hp, mp, etc.
  • b: access the original target parameters;
  • c: access the substitute parameters;
  • v[n]: access the value from variable number n;
  • s[n]: access the value (true or false) from switch number n;

Here's a few examples:
<TAA_SSK: type:1; condition: b.hp < b.mhp/2 >​
This denotes a substitution for skill type 1 that only takes effect when the target's HP is below 50%.​

<TAA_SSK: type:Normal; friendFire:false; condition: c.hp > b.hp >​
This creates a state that allows substitution to normal attacks, won't allow substitution for ally issued skills and only takes place when the substitute's HP is higher than the targets.​

<TAA_SSK: type:Magic; friendFire:true>​
This state will allow substitutions only for magical attacks, and will also work against ally's moves.​

State tags can also span multiple lines when inside the proper tags:
<TAA_SSK>​
type:type1,type2,...,typeN​
friendFire:true|false​
condition:eval clause​
</TAA_SSK>​

Here's how the three examples above would look like in a multi line format:
<TAA_SSK>​
type:1​
condition: b.hp < b.mhp / 2​
</TAA_SSK>​
​
<TAA_SSK>​
type:Normal​
friendFire:false​
condition: c.hp > b.hp​
</TAA_SSK>​
​
<TAA_SSK>​
type:Magic​
friendFire:true​
</TAA_SSK>​

Spoiler: Skill Note Tags
Skill note tags are way simpler, as their only setting is how likely the skill is to ignore the substitution and hit the actual target:
<TAA_SSK: N >​
where N is a number between 0 and 100, being 0 always hit the substitute, and 100 always bypass him and hit the original target.

Spoiler: Script Calls
$gameSystem.sskIsFriendlyFireAllowed()
Returns true if the global default friendly fire setting is enable, otherwise false.​

$gameSystem.sskEnableFriendlyFire()
Enables the global default friendly fire setting.​

$gameSystem.sskDisableFriendlyFire()
Disables the global default friendly fire setting.​

$gameSystem.sskResetFriendlyFire()
Resets the global default friendly fire setting to its original value.​

$gameSystem.sskCondition()
Returns the current global default substitution condition.​

$gameSystem.sskUpdateCondition(newCondition)
Sets the global default substitution condition to newCondition.​

$gameSystem.sskResetCondition()
Resets the global default substitution condition to its original value.​

Spoiler: Plugin Commands
Substitute FriendFire enable
Substitute FriendFire disable
Substitute FriendFire reset
Enable, disable or reset global default friendly fire setting.​

Substitute Condition Set newCondition
Updates the global default substitution condition to newCondition​

Substitute Condition Reset
Resets the global default substitution condition to its original value.​

Spoiler: CHANGE LOG
  • Version 1.0.0:
    • Fixed a bug for when a single state covers for more than one skill type;
    • Fixed a bug which would always have a substitute cover for friendly skills (unless a ignore tag was set);
    • Fixed a minor bug that could cause a substitute to cover for himself if he substitutes a target for a substitution skill issued by himself;
  • Version 0.9.0:
    • Beta release;

First of all, I think I love you. This is (I think) exactly what I need.
Secondly, I don't really know what I'm doing, and most of this didn't make sense to me, so I hope you don't mind my asking this. My game will have four characters, and I want to be able to make the tank substitute for the mage only when they are physical attacks, and only, or mostly, the mage.
Is that possible with your plugin?

Thank you so much for this plugin! I'll be donating after pay day lol 😀
First of all, I think I love you. This is (I think) exactly what I need.
Secondly, I don't really know what I'm doing, and most of this didn't make sense to me, so I hope you don't mind my asking this. My game will have four characters, and I want to be able to make the tank substitute for the mage only when they are physical attacks, and only, or mostly, the mage.
Is that possible with your plugin?

Thank you so much for this plugin! I'll be donating after pay day lol 😀

Glad you liked it! 🙂

I believe you can do that with the plugin, yes.

You can define what can be covered by skill type. So if you have a skill type for physical attacks (like the default, Special) and another for magical attacks (Magic), you can setup a substitute state to cover for normal and Special attacks only.

As for the skill affecting only the mage, there's nothing in the plugin to restrict who can be covered (well, you can cover an enemy if you want to 🙂 ). You can, however, make so that every other class (but the mages) are immune to the substitute status by adding a state resist trait. That won't prevent your player from trying to apply it to other classes, but it will prevent it from working 😛
Awesome Plugin, very useful if you want to make a charackter that has a tank role.
You can create bodyguard skills and such, to cover your other teammates or make enemies do the same. Which opens more tactical moves within a battle.
Just what I needed, works like a charm 😛

Edit: I just thought about something, I don't believe charms work so maybe I should stop using that phrase xD
Hello! I was trying this in MZ, but have been having a strange result.

I just wanted the substitute to work for all types and any HP when the state is applied, and this works flawlessly! On the other hand, when in combat, I keep getting this crash when an enemy attacks one of my characters, before damage numbers pop up (even when state hasn't been applied yet):

1666122034681.png


I am also using Visustella Core plugins, so I don't know if that might have something to do with it?

This is how my substitue state is set up:
1666122144190.png
I am also using Visustella Core plugins, so I don't know if that might have something to do with it?
Well...does the error still happen if you turn them off? 😉

I don't know about your parameters, but the notetag appears to be correct. The error is weird, it reads more like a typo in code than a conflict. I can't think of a data structure this would be checking that has a member variable just called l, and I don't see anything when I search the plugin code.

Testing with the plugin by itself is probably the best first step.
D'oh I should have done that first, hah....

Though I'm getting the strange result that even with no other plugins and only this one, I still get that crash. But only on my testing save. If I start over, nothing. So I suppose there's something somewhere saved that breaks things...

So I think I should really just start over and hopefully the problem won't come back. For now, I will assume problem is solved!
But only on my testing save. If I start over, nothing. So I suppose there's something somewhere saved that breaks things...
As a rule, any time you add plugins or modify settings, you need to start a new test play.
Yeah I was way too fast on the trigger there. Thanks for the quick reply though!
You guys were too fast for me, I've only just seen your posts now hehehe
Glad everything worked out! 🙂
I've got an interesting issue! Overall, the plugin works great. However, I believe my issue might have to do with using Visustella Battle Core used with this plugin. Using the TPB.

When the defending actor jumps in front of the ally to take the damage when the ally is still waiting for their command input (this motion comes from the VBC I think), the protected ally moves back to make space for the defender to jump in front, but does not move forward to their original 'home' position until an command has been selected. So if the protected ally keeps getting attacked while awaiting a command, they essentially keep moving backwards until they're "pushed" out of the screen.

Perhaps this could be posted in a Visustella Battle Core thread, but I'm not sure.

Anyways, if anyone knows what's up, that would be great! In the meantime I'm perusing through the plugin to see if I can see anything myself.

Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/taa_substituteskills-v1-0-0.130519/