MZ Counter-attack when attacked with elemental skills

Looking for wizards! 🙂

I want certain potions to absorb and heal from elemental attacks. So you use the potion, it heals you, and then if you are ever attacked by fire for example, you heal a certain amount.

I want other potions to trigger a physical counter-attack when attacked with a specific element. So the potion heals you, and if you get attacked by fire, you counter attack.

I know that Counter attacks are triggered by physical attacks only? I have visustellah's plugin but can we create States that can apply both my ideas?
Well, the potion would activate a state. I guess you figured that much out, right? And make that state 0% vulnerable for fire.

Now we need to make characters inflicted by that state heal when attacked with fire... The only know how is to use javascript in the battle damage formule of the fire attacks. Use an if statement to see if the target has that state, if so, add HP to the target. Then do ; and then the damage formula.

I mean, this is not actually the engine reacting to the state, but you programming that healing into all skills that trigger it. The effect is the exact same for the player though. Fake it till you make it.

How to counter an element, I don't know.
And make that state 0% vulnerable for fire.
an easier method involves not doing that. with turans eval tags or visustella's battle core, you could give the state a tag to invert the fire damage taken into healing or replace the damage with a static healing amount. Whatever OP needs. the latter isnt affected by an element rate, but the former would require the state to not modify it unless its meant to also reduce the damage healed.

Im not familiar enough with MZ to be able to give a solution for the counter portion though. i dont think yanfly's counter control got ported in any way to MZ and a quick search doesnt bring up anything usable. maybe FOSSIL could work with it, and if it does you could give each state a counter based on their element, but otherwise i have nothing.

EDIT: If you just wanted to deal damage back at the attacker and not necessarily counter attack, the first 2 plugins could also let you do that.
I don't know about VisuStella, but I think triacontane's CounterExtend could do this:
A counter rule can be applied to a state etc with a notetag. These rules are defined in the plugin's parameters and include a list of counter skills, each with their own conditions (e.g. element ID).

I doubt it's compatible with VisuStella, and the help/params are all in Japanese, but it may be worth a try if no-one has a better suggestion~
I don't know about VisuStella, but I think triacontane's CounterExtend could do this:
A counter rule can be applied to a state etc with a notetag. These rules are defined in the plugin's parameters and include a list of counter skills, each with their own conditions (e.g. element ID).

I doubt it's compatible with VisuStella, and the help/params are all in Japanese, but it may be worth a try if no-one has a better suggestion~
even if this is an MV plugin ?
even if this is an MV plugin ?
The one I linked is an MZ plugin: it is in the mz_master branch, and has @target MZ in the header. It might also work in MV, I haven't tried. The older/MV version is here: link.

Please don't start duplicate threads. Moderators can move threads around; in future you can click the Report button on your post if you think your thread should be moved. 👋

I've moved this thread to JS Plugin Requests (from MZ Support). Thank you.

The plugin you suggested might be of great help but it's very hard to translate because it uses english and japanese, so I cannot just translate all of it in english only, the plugin dosen't work then
So only translate the header section? Google Translate gives me:
Spoiler: machine translation
JavaScript:
/*:
* @plugindesc Counterattack Extension Plugin
* @target MZ
* @url https://github.com/triacontane/RPGMakerMV/tree/mz_master/CounterExtend.js
* @base PluginCommonBase
* @author Triacontane
*
* @param CounterList
* @text Counterattack settings list
* @desc List of counterattack settings. Specify the identifier specified here from each memo field.
* @default []
* @type struct<COUNTER>[]
*
* @param ConsiderateRepeat
* @text Consider consecutive attacks
* @desc If enabled, you will only counterattack once for consecutive attacks or multiple actions by the opponent.
* @default false
* @type boolean
*
* @help CounterExtend.js
*
* Skills and items can be activated as a reaction (counterattack) to the opponent's actions.
* Counterattack settings can be set under a variety of conditions and settings.
* It works regardless of the "counterattack rate" feature that can be set by default.
*
* Please specify as follows in the memo field that has the feature (actor, job, weapon, armor, state, enemy character). If the battler has that feature, it will counterattack.
* For example, if you set it in the memo field of a state, the battler will counterattack when it is attacked by that state.
*
* <CounterExtend:aaa> # Counterattack with the counterattack setting that matches the identifier [aaa].
* <CounterExtend:aaa> # Same as above
* <CounterExtend:1> # Counterattack with the [1]th counterattack setting in the counterattack list.
* <CounterExtend:1> # Same as above
*
* Detailed counterattack settings can be entered from the plugin parameters.
* Unlike normal counterattacks, they are activated after the opponent's action is finished.
*
* When multiple counterattack tags are met at the same time, they are activated in the following order.
* State (in order of priority) > Actor, enemy character > Occupation > Equipment
*
* Skills and items entered in the memo field as follows can reduce the frequency of opponent counterattacks by the specified value.
* <CounterEvasion:100>
* <Counterattack avoidance:100>
*
* 〇Local variables that can be used in scripts
* subject -> Battler who counterattacks
* target -> Opponent battler
* triggerAction -> Action used by opponent battler
*
* 〇Variables that can be used in the calculation formula for counterattack skills
* a.lastHpDamage -> HP damage last taken by the counterattacker
*
* The base plugin "PluginCommonBase.js" is required to use this plugin.
* "PluginCommonBase.js" is stored in the following folder under the RPG Maker MZ installation folder.
* * dlc/BasicResources/plugins/official
*
*/

/*~struct~COUNTER:
*
* @param Id
* @text Identifier
* @desc An identifier that uniquely identifies the counter setting. Please specify the identifier specified here in each memo field.
* @default id
*
* @param SkillList
* @text Skill list
* @desc A list of skills and conditions that will be activated when counterattacking. If multiple conditions are met, the one at the top of the list will be executed.
* @default []
* @type struct<SKILL>[]
*
* @param Animation
* @text Animation
* @desc You can display an animation after executing a counterattack.
* @default 0
* @type animation
*
* @param Message
* @text Message
* @desc You can display a message after executing a counterattack.
* @default
*
* @param DefaultMessage
* @text Default message
* @desc If enabled, the default counterattack message will be displayed.
* @default false
* @type boolean
*
* @param CrossCounter
* @text Cross Counter
* @desc If enabled, counterattacks after receiving an attack.
* @default false
* @type boolean
*
* @param Interceptor
* @text Interceptor
* @desc If enabled, counterattacks before receiving an attack.
* @default false
* @type boolean
*
* @param CrossCounterCondition
* @parent CrossCounter
* @text Cross Counter Condition
* @desc Additional activation conditions specified when Cross Counter is enabled.
* @default 0
* @type select
* @option Always
* @value 0
* @option Only if the opponent's action hits
* @value 1
* @option Only if the opponent's action misses
* @value 2
*
* @param PayCounterCost
* @text Cost of counterattack
* @desc Sets whether counterattack consumes cost. If enabled, counterattack will not occur if the cost is insufficient.
* @default false
* @type boolean
*
* @param EraseState
* @text Cancel state
* @desc Automatically cancels the specified state after counterattack.
* @default 0
* @type state
*
* @param EraseStateCondition
* @parent EraseState
* @text Cancel state condition
* @desc Condition for canceling the state specified in Cancel state.
* @default 0
* @type select
* @option Always
* @value 0
* @option If failed
* @value 1
* @option If successful
* @value 2
*
*/

/*~struct~SKILL:
*
* @param Id
* @text Identifier
* @desc An identifier to make it easier to identify parameters when viewed in a list. Not referenced by the plugin.
* @default
*
* @param SkillId
* @text Counterattack skill
* @desc The skill that is activated when counterattacking. If 0 is specified, counterattacks with a normal attack.
* @type skill
* @default 0
*
* @param ItemId
* @text Counterattack item
* @desc The item to be used when counterattacking. You can specify either the skill or this. If both are specified, the item takes priority.
* @type item
* @default 0
*
* @param Reflection
* @text Skill reflection
* @desc If enabled, counterattacks using the skill used by the opponent.
* @type boolean
* @default false
*
* @param IdCondition
* @text Counterattack condition (skill ID)
* @desc If specified, counterattacks only against skills of a specific hit type.
* @type skill
* @default 0
*
* @param HitTypeCondition
* @text Counterattack condition (hit type)
* @desc If specified, counterattacks only against skills of a specific hit type.
* @type select
* @default 0
* @option Not specified
* @value 0
* @option Physical attack
* @value 1
* @option Magic attack
* @value 2
*
* @param SkillTypeCondition
* @text Counterattack condition (skill type)
* @desc If specified, counterattack will only occur against skills of a specific skill type.
* @type number
*
* @param ElementCondition
* @text Counterattack condition (attribute)
* @desc If specified, counterattack will only occur against skills of a specific attribute (the value of "Type" -> "Attribute" in the database).
* @type number
* @default 0
*
* @param WeakCondition
* @text Counterattack condition (weakness)
* @desc If specified, counterattack will only occur if the skill received is a weakness or resistance.
* @type select
* @default 0
* @option None
* @value 0
* @option Weakness
* @value 1
* @option Resistance
* @value 2
*
* @param SwitchCondition
* @text Counterattack condition (switch)
* @desc If specified, counterattack will only occur if the switch is ON.
* @type switch
* @default 0
*
* @param Subject
* @text Counterattack condition (user)
* @desc If specified, counterattack will only occur if the user is a specific battler.
* @type select
* @default opponentsUnit
* @option Opponent unit
* @value opponentsUnit
* @option Allied unit (including self)
* @value friendsUnit
* @option Allied unit (excluding self)
* @value friendsUnitWithoutUser
* @option Self
* @value user
* @option Everyone
* @value all
*
* @param MemoTagCondition
* @text Counterattack condition (memo tag)
* @desc If specified, counterattack will only occur against skills and battlers (including weapons and armor) with the specified tag written in the memo field.
* @default
*
* @param ScriptCondition
* @text Counterattack condition (script)
* @desc If specified, counterattack will only occur if the script evaluation result is valid.
* @type combo
* @default
* @option subject.mpRate() <= 0.5; // If your MP is below 50%
* @option triggerAction.calcElementRate(subject) > 1.0; // If it is a weak attribute
*
* @param Frequency
* @text Counterattack frequency
* @desc The frequency (probability) of a counterattack. Specifying 100 will ensure a counterattack.
* @type number
* @default 100
* @min 0
* @max 100
*
* @param FrequencyTag
* @text Counterattack frequency tag
* @desc All values obtained from the specified tag (e.g. <CounterFrequency:100>) are added to the "counterattack frequency" to determine the counterattack frequency.
* @default CounterFrequency
*
* @param ConditionReverse
* @text Reverse counterattack condition
* @desc When enabled, a counterattack will occur if the counterattack condition is not met.
* @type boolean
* @default false
*
*/
I haven't proof-read that, but you can try just replacing the JP plugin header with the translated one.
thanks, I'll give it a try, if you ever come across an idea to have potions heal you when you get attacked by a specific element, please let me know, I've tried with states and common events and none work and I have no idea why.

the counter attack works, one problem solved, I just might be able to activate a self heal when attacked by a specific element, working on it
edit : Ok , I was able to complete what I set out to do with this plugin, you saved my life. thank you Caethyril
Nice! 😤

Just to add to the other suggestions: I noticed VisuStella's Elements & Status Menu Core has an <Element Absorb: X> notetag that can be used on states. That might be a neater solution than a "counter-heal"? It's a common idea so there are probably other plugins that can do something similar, e.g. "absorb element" or "invert damage".
It's certainly an idea I used in MV with Yanfly's plugin. My game centers around crafting, so I want to make elemental armors absorb a part of the damage. I figure enemies are more interesting if they absorb your attacks than if you do theirs but that's just my opinion 😉
I figure enemies are more interesting if they absorb your attacks than if you do theirs but that's just my opinion 😉
I generally feel like that type of thing should be available to both the player and enemies. If they can absorb elements and you can't, I'm calling bull.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/counter-attack-when-attacked-with-elemental-skills.172986/