/*:
* @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
*
*/