If you'd like, you can also use this plugin:
Code:
/*:
* @plugindesc Allows the user to add notetags to skills to indicate that, if the user has one state, the skill
* should apply another state to the target.
* @author Zevia
*
* @help In a skill, write the notetag: "<debuffer: x, y, z...>", where
* x, y, z, and any other variables are state IDs. The first number is the state
* the user needs in order to apply all the subsequent states to the target.
* For example, in a default project, <debuffer: 3, 4> in a skill's notetag would
* mean, "If the user has state ID 3 (Immortal), then the target receives state ID
* 4 (Poisoned)." <debuffer: 3, 4, 6, 8> would say, "If the user has state ID 3
* (Immortal), then the target receives state IDs 4 (Poisoned), 6 (Silence), and
* 8 (Confusion)".
*/
(function(module) {
'use strict';
module.Zevia = module.Zevia || {};
var DebufferState = module.Zevia.DebufferState = {};
DebufferState.evalDamageFormula = Game_Action.prototype.evalDamageFormula;
Game_Action.prototype.evalDamageFormula = function(target) {
var value = DebufferState.evalDamageFormula.call(this, target);
var debuffer = this.item().meta.debuffer;
if (!debuffer) { return value; }
var stateIds = debuffer.match(/\d+/g);
if (stateIds.length < 2) { return value; }
var buffId = parseInt(stateIds[0]);
if (isNaN(buffId)) { return value; }
if (this.subject().isStateAffected(buffId)) {
for (var i = 1; i < stateIds.length; i++) {
var stateId = parseInt(stateIds[i]);
if (isNaN(stateId)) { return value; }
target.addState(stateId);
}
}
return value;
};
})(window);
In the notetags of a skill, put
where x, y, z, etc. are state IDs. The first number is the state the user needs in order to apply all the other states to the target. For example, in a default project, if the Attack skill has the notetag
then if the user has State 3 (Immortal) and uses the Attack skill, the target will be afflicted with State 4 (Poisoned).
You can apply multiple states by just adding more numbers:
would mean, "If the user has State 3 (Immortal), then the target receives States 4 (Poisoned), 6 (Silence), and 8 (Confusion)".
If you misspell "debuffer" or include less than 2 numbers, then nothing should happen and the damage formula will be evaluated as normal.
Any action that does not call Game_Action.prototype.evalDamageFormula (for example, when an attack misses) will not call this extra logic. So if an attack misses, the state will not apply.
Here's some screenshots of an example:
Spoiler: Example Debuffer State With "Poison Fists"
State 11, Poison Fists:
Poison Fists skill that applies a buff:
Attack skill with the debuffer notetag:
Using the Attack skill without the Poison Fists buff:
Buffing with Poison Fists:
Attacking with the Poison Fists buff: