How to implement every possible Yanfly Tips & Tricks effect in MZ with VisuStella plugins

I've added the same values via a global passive state which has the following code:

So correct me if I'm wrong but this will count kills and defeats for each actor?
But then how can I make these stats appear somewhere in the vs menu? Like somewhere in the status page for instance?
They can be referenced the same way parameters can. So if you had say user.atk, you could do user._killCount instead.

@Dark_Ansem passives can do pretty much anything a normal state can, it's just that they're always active and aren't applied or removed (though they can be rendered inactive if they have a passive condition that isn't met)
@Trihan
Thanks, how would I do adding it to the biography?

Something like:

<Biography>
Kill stats: user._killCount / user._deathCount
</Biography>

and then in the status menu it would like eg:

Kill Stats: 15 / 1
How flexible can global passive states be?
@Trihan
Thanks, how would I do adding it to the biography?

Something like:

<Biography>
Kill stats: user._killCount / user._deathCount
</Biography>

and then in the status menu it would like eg:

Kill Stats: 15 / 1
Does the biography tag support JS?
It's the one from VS (ElementStatus core).
I'm not sure. It just says that text codes are allowed.
1644398610517.png


But maybe it's possible to use concatenation or something?
Hello,

I am trying to recreate Stockpile and Stockpile Swallow but they're missing from the list. Is it possible to implement them in MZ? If yes, could you add them to the list?
It's the one from VS (ElementStatus core).
I'm not sure. It just says that text codes are allowed.
In the documentation for that plugin, it says the contents are text, not code.

You would have to go to the places in the state where it increments user._killCount and instead add that to one of the gameVariables. You could then refer to that value via escape code in the biography.
In the documentation for that plugin, it says the contents are text, not code.

You would have to go to the places in the state where it increments user._killCount and instead add that to one of the gameVariables. You could then refer to that value via escape code in the biography.
How do I do that so that actor 1 has kills = variable 201, actor 2 variable 202 and so on.
How do I do that so that actor 1 has kills = variable 201, actor 2 variable 202 and so on.
Variable 201 - actor ID 1 = 200
Variable 202 - actor ID 2 = 200
so this is a good numbering scheme.

Therefore, every place that references user._killCount you replace with $gameVariables._data[user.actorId()+200]
Hello,

I am trying to recreate Stockpile and Stockpile Swallow but they're missing from the list. Is it possible to implement them in MZ? If yes, could you add them to the list?
I'm doing them in numerical order, so Stockpile effects are coming up.
Variable 201 - actor ID 1 = 200
Variable 202 - actor ID 2 = 200
so this is a good numbering scheme.

Therefore, every place that references user._killCount you replace with $gameVariables._data[user.actorId()+200]
Kill count is working fine however death count (when the actor dies) is not.

Here are the changes I made:


Code:
<JS Pre-Start Battle>

  $gameVariables._data[user.actorId()+600] = $gameVariables._data[user.actorId()+600] || 0;

  user._assistCount = user._assistCount || 0;

  $gameVariables._data[user.actorId()+610] = $gameVariables._data[user.actorId()+610] || 0;

</JS Pre-Start Battle>

<JS Post-Damage As User>

  if (target.hp <= 0) {

    $gameVariables._data[user.actorId()+600] = ($gameVariables._data[user.actorId()+600] || 0) + 1;

    // add assist for each other living party member

    $gameParty.battleMembers().forEach(member =>

      member !== user && member.hp > 0 ? member._assistCount = (member._assistCount || 0) + 1 : member

    );

  }

</JS Post-Damage As User>

<JS Post-Damage As Target>

  if (target.hp <= 0) {

    $gameVariables._data[user.actorId()+610] = ($gameVariables._data[user.actorId()+610] || 0) + 1;

  }

</JS Post-Damage As Target>

I also put that specific state as an actor global passive state. If I put it as a full global state, then each time an actor kills an enemy, they get a +1 death too.
You're using 600+ID for kills and 610+ID for deaths, yes?
Code:
$gameVariables._data[user.actorId()+610] = ($gameVariables._data[user.actorId()+610] || 0) + 1;
It's not the cause of your problem, but I'd take that out. You already have it in the Pre-Start Battle, so there's a 0% chance you could be getting to this code and the variable is uninitialized.

Just increment it.

It looks to me like you're using user when you should be using target.

Code:
$gameVariables._data[target.actorId()+610]++;
You're using 600+ID for kills and 610+ID for deaths, yes?
Correct.
As ATT_Turan said you have user where you should have target.
I recreated the attacks as per the forum post and I gave a generic enemy each attack, testing the attacks one by one and looking at their behavior. What happened was this:

Leech seed worked as intended, Toxic would heal the player at a constant rate as opposed to how its supposed to behave, and Bide would fire off once before making the enemy invincible (I gave it 200 HP and after Bide's attack that enemy soaked up more than 200 HP in damage).
I tested out the Toxic state on a player character by using a test item, and it worked as intended on my end.
Spoiler: Custom DoT Formula (state)
JavaScript:
<JS HP Slip Damage>
  damage = origin.mat * 0.5;
</JS HP Slip Damage>

<JS Pre-Regenerate>
  $gameTemp.requestAnimation([target], 12);
</JS Pre-Regenerate>

Spoiler: Kyrie Eleison (state)
JavaScript:
<JS On Add State>
  user._kyrieHits = 10;
  user._kyrieHP = Math.floor(user.mhp * 0.3);
  user.setStateDisplay(state.id, user._kyrieHP);
</JS On Add State>

<JS On Erase State>
  delete user._kyrieHits;
  delete user._kyrieHP;
</JS On Erase State>

<JS Pre-Damage As Target>
  if (this.isHpEffect() && value > 0) {
    $gameTemp.requestAnimation([target], 53);
    const reduce = Math.min(value, target._kyrieHP);
    value -= reduce;
    target._kyrieHP -= reduce;
    target._kyrieHits--;
    target.setStateDisplay(state.id, target._kyrieHP);
    const text = "<CENTER>" + target.name() + "'s shield blocks " + reduce + " damage and has " + target._kyrieHits + (target._kyrieHits !== 1 ? " hits" : " hit")+ " left.";
    const logWindow = SceneManager._scene._logWindow;
    logWindow._lines.push(text);
    logWindow.refresh();
  }
  if (target._kyrieHP <= 0 || target._kyrieHits <= 0) {
    target.removeState(state.id);
  }
</JS Pre-Damage As Target>

Spoiler: Enfire/blizzard/thunder/etc (state)
JavaScript:
<JS Post-Damage As User>
  if (this.isHpEffect() && this.isAttack() && this.isPhysical()) {
    target.startDamagePopup();
    const elementId = 2;
    const baseDamage = 20;
    const damage = Math.ceil(target.elementRate(elementId) * baseDamage);
    $gameTemp.requestAnimation([target], 66);
    target.gainHp(-damage);
    target.startDamagePopup();
  }
</JS Post-Damage As User>

Replace 2 with the ID of the element related to the buff.

Spoiler: Map Linked Battle Effects (state)
JavaScript:
<JS Passive Condition>
  condition = true;
  if (BattleManager.isBattleTest()) {
    condition = false;
  } else if ($gameMap && $gameParty.inBattle()) {
    const activeMaps = [];
    activeMaps.push(1);
    const terrainTags = [];
    //terrainTags.push(1);
    const regionIds = [];
    //regionIds.push(1);
    if (activeMaps.length > 0) {
      if (!activeMaps.contains($gameMap.mapId())) {
        condition = false;
      }
    }
    if (terrainTags.length > 0) {
      if (!terrainTags.contains($gamePlayer.terrainTag())) {
        condition = false;
      }
    }
    if (regionIds.length > 0) {
      if (!regionIds.contains($gamePlayer.regionId())) {
        condition = false;
      }
    }
  } else {
    condition = false;
  }
</JS Passive Condition>

Add whatever maps, terrain tags and region IDs you wish and comment/uncomment those lines as needed.

Spoiler: Absorb Ailments (skill)
JavaScript:
<JS Pre-Apply>
  if (!this._absorbedAllStates) {
    this._absorbedAllStates = true;
    this._absorbHeal = 0;
    const heal = user.mdf;
    const group = user.friendsUnit().aliveMembers();
    for (let i = 0; i < group.length; ++i) {
      const member = group[i];
      if (member && member !== user) {
        const category = 'Ailment';
        const states = member.states();
        for (let j = 0; j < states.length; ++j) {
          const state = states.shift();
          const id = state.id;
          if (state.categories.includes(category.toUpperCase())) {
            const turns = member.stateTurns(id);
            member.removeState(id);
            user.addState(id);
            user.setStateTurns(id, turns);
            this._absorbHeal += heal;
          }
        }
      }
    }
  }
</JS Pre-Apply>

This requires that any applicable states are assigned a category of "Ailment". Feel free to change the category as required if you want it to affect a different kind of state.

Spoiler: Negative Ions (state)
JavaScript:
<JS Post-Damage As Target>
  const elements = this.elements();
  const lightningId = 4;
  if (elements.contains(lightningId) && value > 0) {
    let damage = Math.ceil(value * 0.5);
    const group = target.friendsUnit().aliveMembers();
    group.splice(group.indexOf(target), 1);
    const member = group[Math.randomInt(group.length)];
    if (member) {
      target.removeState(state.id);
      damage = Math.ceil(damage * member.elementRate(lightningId));
      $gameTemp.requestAnimation([member], 76);
      member.gainHp(-damage);
      member.startDamagePopup();
    }
  }
</JS Post-Damage As Target>

Replace 4 with the ID of your lightning element, or customise it for a different element if you wish.

Spoiler: Chaotic Energies (state)
JavaScript:
<JS Pre-Damage As User>
  const validTypes = [];
  validTypes.push(1, 2);
  if (this.isHpEffect() && this.isMagical() && this.isSkill() && value > 0 && validTypes.contains(this.item().stypeId)) {
    const bonus = Math.random() * 0.24;
    value += Math.ceil(value * bonus);
  }
</JS Pre-Damage As User>

<JS Pre-Damage As Target>
  if (this.isHpEffect() && value > 0) {
    const bonus = Math.random() * 0.05;
    value -= Math.ceil(value * bonus);
  }
</JS Pre-Damage As Target>

Add/remove whatever skill types you wish to the validTypes array.

Spoiler: Aura of Ebon Destruction (states)
Ebon Aura state:
JavaScript:
<JS On Add State>
  $gameParty.members().forEach(member => member.addState(193));
</JS On Add State>

<JS On Erase State>
  const origins = $gameParty.members().filter(member => member.hasState(state.id));
  if (origins.length === 0) $gameParty.members().forEach(member => member.removeState(193));
</JS On Erase State>

Replace 193 with the ID of your Ebon Aura Effect state.

Ebon Aura Effect state:
JavaScript:
<JS Pre-Damage As User>
  if (this.isHpEffect() && value > 0) {
    const bonusRate = 0.2;
    value += Math.ceil(value * bonusRate);
    if (target.result().critical) {
      value += 200;
    }
    $gameTemp.requestAnimation([target], 2);
  }
</JS Pre-Damage As User>

Spoiler: Berserker Power (state)
JavaScript:
<JS Pre-Damage As User>
  if (this.isPhysical() && this.isHpEffect() && value > 0) {
    value *= 2 - user.hpRate();
    value += (user.mhp - user.hp) * 0.5;
    value = Math.ceil(value);
  }
</JS Pre-Damage As User>

Spoiler: Lightning Rod (states)
Lightning Rod state:
JavaScript:
<JS On Add State>
  $gameParty.members().forEach(member => member.addState(200));
  $gameTroop.members().forEach(member => member.addState(199));
</JS On Add State>

<JS On Erase State>
  $gameParty.members().forEach(member => member.removeState(200));
  $gameTroop.members().forEach(member => member.removeState(199));
</JS On Erase State>

<JS Pre-Damage As Target>
  if (this.isHpEffect() && value > 0) {
    const lightningId = 4;
    const elements = this.elements();
    if (elements.contains(lightningId)) {
      value = 0;
      const paramId = 4;
      const turns = 5;
      target.addBuff(paramId, turns);
      $gameTemp.requestAnimation([target], 51);
    }
  }
</JS Pre-Damage As Target>

Replace 199 with the ID of your Rod Foes state and 200 with the ID of your Rod Allies state.

Rod Foes state:
JavaScript:
<Bypass Taunt>
<JS Pre-Start Action>
  if (this.isForOpponent()) {
    const lightningId = 4;
    const lightningRod = 198;
    const elements = this.elements();
    if (elements.contains(lightningId)) {
      const pool = user.opponentsUnit().aliveMembers().filter(member => member.isStateAffected(lightningRod));
      if (pool.length > 0) {
        const rod = pool[Math.randomInt(pool.length)];
        this.setTarget(rod.index());
console.log(this._targetIndex);
      }
    }
  }
</JS Pre-Start Action>

Replace 198 with the ID of your Lightning Rod state.

Rod Allies state:
This state only needs to exist, there's no code for it.

Spoiler: White Wind (skill)
Damage formula: this._healAmount ??= a.hp; this._healAmount

Spoiler: Chaos Bolt (skill)
JavaScript:
<Always Critical>

<JS Critical Damage>
  multiplier = 1 + user.cri;
</JS Critical Damage>

Spoiler: One Time Half MP Cost (state)
JavaScript:
<JS Pre-Damage As User>
  if (this.isSkill() && user.skillMpCost(this.item()) > 0) {
    user.removeState(state.id);
  }
</JS Pre-Damage As User>

The half MP cost is just done via normal trait.

Spoiler: Trueshot Aura
Trueshot Origin state:
JavaScript:
<JS On Add State>
  $gameParty.members().forEach(member => member.addState(202));
</JS On Add State>

<JS On Erase State>
  $gameParty.members().forEach(member => member.removeState(202));
</JS On Erase State>

Replace 202 with the ID of your Trueshot Aura state.

Trueshot Aura state:
JavaScript:
<JS Pre-Damage As User>
  if (user.isActor()) {
    const rangedTypes = [];
    rangedTypes.push(7, 8, 9);
    const weapon = user.weapons()[0];
    if (weapon && this.isAttack()) {
      if (rangedTypes.contains(weapon.wtypeId)) {
        value += Math.ceil(value * 0.3);
      }
    }
  }
</JS Pre-Damage As User>

Replace the push values in rangedTypes with a comma-separated list of your ranged weapon type IDs.

Spoiler: Arcane Curse (state)
JavaScript:
<Reapply Rules: Add>

<JS Post-Start Action>
  if (action.isMagical()) {
    const turns = user.stateTurns(state.id) + 4;
    user.setStateTurns(state.id, turns);
  }
</JS Post-Start Action>

Spoiler: Gehenna
Gehenna Origin state:
JavaScript:
<JS On Add State>
  $gameParty.members().forEach(member => member.addState(197));
</JS On Add State>

<JS On Erase State>
  $gameParty.members().forEach(member => member.removeState(197));
</JS On Erase State>

Replace 197 with the ID of your Gehenna Aura state.

Gehenna Aura state:
JavaScript:
<JS Pre-Damage As Target>
  if (this.isMagical() && this.isHpEffect() && value > 0) {
    const reduction = Math.floor(value * 0.1);
    value -= reduction;
    target.gainHp(reduction);
  }
</JS Pre-Damage As Target>

Spoiler: Weapon Mastery Passive (state)
JavaScript:
<JS Passive Condition>
  const weapons = user.weapons();
  const swords = 2;
  condition = false;
  for (let i = 0; i < weapons.length; ++i) {
    const weapon = weapons[i];
    if (weapon && weapon.wtypeId === swords) {
      condition = true;
      break;
    }
  }
</JS Passive Condition>

Spoiler: Cauterize (state)
Passive:
JavaScript:
<JS Post-Start Battle>
  const reraise = 159;
  user.addState(159);
  user._cauteriseCooldown = 0;
</JS Post-Start Battle>

<JS Pre-Regenerate>
  user._cauteriseCooldown ??= 0;
  if (user._cauteriseCooldown > 0) {
    user._cauteriseCooldown--;
    if (user._cauteriseCooldown <= 0) {
      const reraise = 159;
      user.addState(reraise);
    }
  }
</JS Pre-Regenerate>

Replace 159 with the ID of your Cauterize Reraise state.

Reraise:
JavaScript:
<No Death Clear>

<JS Post-Apply As Target>
  if (target.hp <= 0 || target.isDead()) {
    $gameTemp.requestAnimation([target], 49);
    const rate = 0.35;
    const heal = Math.floor(target.mhp * rate);
    target.removeState(state.id);
    target.gainHp(heal);
    target.startDamagePopup();
    const burningState = 160;
    target.addState(burningState);
    target._cauteriseCooldown = 10;
  }
</JS Post-Apply As Target>

Replace 160 with the ID of your Cauterize Burning state.

Burning:
JavaScript:
<JS Pre-Regenerate>
  $gameTemp.requestAnimation([user], 13);
</JS Pre-Regenerate>

HP loss and additional agility effects are handled via traits. You could use the Visual State Effects plugin for this as well if you wanted.

Spoiler: Collect & Inject Ailments (skill)
Collect:
JavaScript:
<JS Pre-Apply>
  const category = 'AILMENT';
  const states = target.states();
  for (let i = 0; i < states.length; ++i) {
    const state = states[i];
    if (state && state.categories.contains(category)) {
      user._collectedAilment = state.id;
      target.removeState(state.id);
      const text = '<CENTER>\\c[6]' + user.name() + '\\c[0] collects \\c[4]' + state.name + '\\c[0] ailment!';
      const logWindow = SceneManager._scene._logWindow;
      logWindow._lines.push(text);
      break;
    }
  }
</JS Pre-Apply>

Inject:
JavaScript:
<JS Skill Enable>
  user._collectedAilment ??= 0;
  enabled = user._collectedAilment > 0;
</JS Skill Enable>

<JS Pre-Apply>
  const stateId = user._collectedAilment;
  target.addState(stateId);
  user._collectedAilment = 0;
</JS Pre-Apply>

Spoiler: Truthseeker (state)
JavaScript:
<JS Passive Condition>
  condition = false;
  if ($gameParty.inBattle()) {
    if (user.isActor()) {
      const swordTypeId = 2;
      const weapons = user.weapons();
      for (let i = 0; i < weapons.length; ++i) {
        const weapon = weapons[i];
        if (weapon && weapon.wtypeId === swordTypeId) {
          condition = true;
        }
      }
    }
  }
</JS Passive Condition>

<JS Pre-Damage As User>
  if (this.isHpEffect() && value > 0) {
    const bonus = Math.ceil(value * 0.4);
    value += bonus;
  }
</JS Pre-Damage As User>

Spoiler: Aura of Sacrifice
Protector Origin state:
JavaScript:
<JS On Add State>
  $gameParty.members().filter(member => member !== target).forEach(member => member.addState(195));
</JS On Add State>

<JS On Erase State>
  $gameParty.members().filter(member => member !== target).forEach(member => member.removeState(195));
</JS On Erase State>

Replace 195 with the ID of your Protector Aura state.

Protector Aura state:
JavaScript:
<JS Pre-Damage As Target>
  if (this.isHpEffect() && value > 0 && origin.isAlive()) {
    const reduction = Math.ceil(0.50 * value);
    value = 0;
    origin.gainHp(-reduction);
    $gameTemp.requestAnimation([origin], 2);
    origin.startDamagePopup();
    origin.clearResult();
  }
</JS Pre-Damage As Target>

Spoiler: Magnet
This effect can't be adapted as Row Formations isn't available in MZ.

Spoiler: Subjugate (skill/state)
JavaScript:
<JS Pre-Damage>
  value = Math.min(value, 9999);
</JS Pre-Damage>

<JS Post-Damage>
  const turns = 4;
  user.addBuff(3, turns);
  user.addBuff(5, turns);
  if (value > 0) {
    user.gainHp(value);
    user.startDamagePopup();
  }
  if (target.hp > 0) {
    const drainStateId = 162;
    target.addDebuff(3, turns);
    target.addDebuff(5, turns);
    target.addState(drainStateId);
    target._subjugateDamage ??= 0;
    target._subjugateDamage += value;
  }
</JS Post-Damage>

Replace 162 with the ID of your Subjugate Drain state:

HTML:
<JS Pre-Regenerate>
  user._subjugateDamage ??= 0;
  if (user.isAlive() && user._subjugateDamage > 0) {
    const turns = Math.max(1, user.stateTurns(state.id));
    const damage = Math.ceil(user._subjugateDamage / turns);
    user._subjugateDamage -= damage;
    user.gainHp(-damage);
    $gameTemp.requestAnimation([user], 4);
    user.startDamagePopup();
    if (origin !== user && origin.isAlive()) {
      origin.gainHp(damage);
      $gameTemp.requestAnimation([origin], 46);
      origin.startDamagePopup();
    }
  }
</JS Pre-Regenerate>

<JS On Erase State>
  delete target._subjugateDamage;
</JS On Erase State>

Spoiler: Shades of Black (skill)
JavaScript:
<JS Post-Apply>
  const tier1skills = [];
  tier1skills.push(99, 107, 115, 123, 129, 135, 141, 147);
  tier1skills.push(103, 111, 119, 126, 132, 138, 144, 150);
  const tier2skills = [];
  tier2skills.push(100, 108, 116, 124, 130, 136, 142, 148);
  tier2skills.push(104, 112, 120, 127, 133, 139, 145, 151);
  let skillId = 0;
  if (Math.random() < 0.88) {
    skillId = tier1skills[Math.randomInt(tier1skills.length)];
  } else {
    skillId = tier2skills[Math.randomInt(tier2skills.length)];
  }
  user.forceAction(skillId, target.index());
</JS Post-Apply>

The IDs I've placed in the tier1skills and tier2skills arrays map to the default set of elemental spells. Replace as needed.

Spoiler: Overheat (state)
JavaScript:
<Element Absorb: Fire>

<JS Pre-Damage As Target>
  if (this.isHpEffect()) {
    const fireElementId = 2;
    const elements = this.elements();
    if (elements.contains(fireElementId)) {
      target.addBuff(0, 10);
    }
  }
</JS Pre-Damage As Target>

<JS Post-Damage As Target>
  if (target.hp >= target.paramBase(0) * 2) {
    const damage = target.hp;
    $gameTemp.requestAnimation([target], 107);
    const fireElementId = 2;
    const members = BattleManager.allBattleMembers();
    for (let i = 0; i < members.length; ++i) {
      const member = members[i];
      if (member) {
        if (member.getAbsorbedElements().includes(fireElementId)) {
          member.gainHp(damage * member.elementRate(fireElementId));
        } else {
          member.gainHp(-damage * member.elementRate(fireElementId));
        }
        member.startDamagePopup();
      }
    }
    target.setHp(0);
    target.removeImmortal();
  }
</JS Post-Damage As Target>

Replace 2 with the ID of your fire element, or customise it to happen with a different one.

Spoiler: Curada (state)
JavaScript:
<JS On Add State>
  target._stockHeal ??= 0;
  target._stockHeal += 2000;
  target.setStateDisplay(state.id, target._stockHeal);
</JS On Add State>

<JS On Erase State>
  delete target._stockHeal;
</JS On Erase State>

<JS Pre-Regenerate>
  user._stockHeal ??= 0;
  if (user.isAlive() && user.hpRate() < 1) {
    const missingHp = Math.min(user.mhp - user.hp, user._stockHeal);
    user._stockHeal -= missingHp;
    user.setStateDisplay(state.id, user._stockHeal);
    user.gainHp(missingHp);
    user.startDamagePopup();
  }
  if (user._stockHeal <= 0) {
    user.removeState(state.id);
  }
</JS Pre-Regenerate>

<JS Post-Apply As Target>
  target._stockHeal ??= 0;
  if (target.isAlive() && target.hpRate() < 1) {
    target.startDamagePopup();
    const missingHp = Math.min(target.mhp - target.hp, target._stockHeal);
    target._stockHeal -= missingHp;
    target.setStateDisplay(state.id, target._stockHeal);
    target.gainHp(missingHp);
    target.startDamagePopup();
  }
  if (target._stockHeal <= 0) {
    target.removeState(state.id);
  }
</JS Post-Apply As Target>

Spoiler: Holy Knight's Pride (state)
JavaScript:
<JS Passive Condition>
  condition = $gameParty.inBattle();
</JS Passive Condition>

<JS Pre-Damage As User>
  if (this.isSkill() && this.isHpEffect() && value > 0) {
    const skillType = 5;
    if (this.item().stypeId === skillType) {
      const bonus = Math.ceil(value * 0.3);
      value += bonus;
    }
  }
</JS Pre-Damage As User>

Replace 5 with the skill type you wish to confer a bonus to for the battler with this passive.

Spoiler: Fire Aura (state)
JavaScript:
<JS On Add State>
  const threshold = Math.ceil(target.mhp * 0.1);
  target.setStateDisplay(state.id, threshold);
  let text = '<CENTER>\\c[4]' + state.name + '\\c[0] blocks damage under \\c[4]' + threshold + '\\c[0]!';
  const logWindow = SceneManager._scene._logWindow;
  logWindow._lines.push(text);
  logWindow.refresh();
  const pierceElements = [2, 3];
  let elementNames = '';
  while (pierceElements.length > 0) {
    const elementId = pierceElements.shift();
    elementNames += '\\c[4]' + $dataSystem.elements[elementId] + '\\c[0]';
    if (pierceElements.length > 0) {
      elementNames += ', ';
    }
  };
  text = '<CENTER>Deal more than \\c[4]' + threshold +  '\\c[0] damage or ' + elementNames + ' damage to break the barrier!';
  logWindow._lines.push(text);
  logWindow.refresh();
</JS On Add State>

<JS Pre-Regenerate>
  const threshold = Math.ceil(target.mhp * 0.1);
  target.setStateDisplay(state.id, threshold);
</JS Pre-Regenerate>

<JS Pre-Damage As Target>
  if (this.isHpEffect() && value > 0) {
    const logWindow = SceneManager._scene._logWindow;
    const pierceElements = [2, 3];
    const threshold = Math.ceil(target.mhp * 0.1);
    const elements = this.elements();
    let pierced = value > threshold;
    let elementNames = '';
    if (!pierced) {
      while (pierceElements.length > 0) {
        const elementId = pierceElements.shift();
        if (elements.contains(elementId)) {
          pierced = true;
        }
        elementNames += '\\c[4]' + $dataSystem.elements[elementId] + '\\c[0]';
        if (pierceElements > 0) {
          elementNames += ', ';
        }
      }
    }
    let text = '<CENTER>\\c[4]' + state.name + '\\c[0]';
    if (pierced) {
      target.removeState(state.id);
      text += ' has been pierced!';
      logWindow._lines.push(text);
      logWindow.refresh();
    } else {
      value = 0;
      $gameTemp.requestAnimation([target], 53);
      text += ' blocks damage under \\c[4]' + threshold + '\\c[0]!';
      logWindow._lines.push(text);
      logWindow.refresh();
      text = '<CENTER>Deal more than \\c[4]' + threshold + '\\c[0] damage or ' + elementNames + ' damage to break barrier!';
      logWindow._lines.push(text);
      logWindow.refresh();
    }
  }
</JS Pre-Damage As Target>

Replace pierceElements with whichever element IDs will break through the shield.

Spoiler: Greater Undead (state)
Note that the healing reversal part of this can also be achieved now via the Life State Effects plugin, and it's less useful than it was in MV since VS plugins don't provide the ability to switch between enemy and ally targeting.

JavaScript:
<JS Passive Condition>
  condition = !user._undeadDeath;
</JS Passive Condition>

<JS Pre-Damage As Target>
  if (this.isHpRecover()) {
    value = Math.abs(value);
  }
</JS Pre-Damage As Target>

<JS Post-Damage As Target>
  if (target.hp <= 0) {
    const elements = this.elements();
    const killingElements = [2];
    let killed = false;
    while (killingElements.length > 0) {
      const elementId = killingElements.shift();
      if (elements.contains(elementId)) {
        killed = true;
      }
    }
    if (killed) {
      target._undeadDeath = true;
      target.refresh();
    } else {
      target.setHp(1);
    }
  }
</JS Post-Damage As Target>

Replace the 2 in killingElements with a comma-separated list of elements that will kill an undead enemy.

Spoiler: Attunement (state)
JavaScript:
<JS Pre-Damage As User>
  if (this.isHpEffect() && value > 0) {
    const elements = this.elements();
    for (let i = 0; i < elements.length; ++i) {
      const elementId = elements[i];
      if (target.elementRate(elementId) > 1) {
        const rate = 1.3;
        value = Math.ceil(value * rate);
        break;
      }
    }
  }
</JS Pre-Damage As User>

Spoiler: Death Nova
<No Death Clear>

The effect itself will be added to the Dead state inside a <JS On Add State> notetag:

JavaScript:
const deathNovaId = 169;
  if (target.isDead() && target.isStateAffected(deathNovaId)) {
    const poisonId = 4;
    const caster = target.getStateOrigin(deathNovaId);
    const damage = caster.mat * 6;
    const foes = target.opponentsUnit().aliveMembers();
    for (let i = 0; i < foes.length; ++i) {
      const foe = foes[i];
      if (foe) {
        foe.gainHp(-damage);
        foe.addState(poisonId);
        foe.startDamagePopup();
      }
    }
    $gameTemp.requestAnimation([target], 109);
    target.removeState(deathNovaId);
  }

Replace 169 with the ID of the Death Nova state and 4 with the ID of your Poison state.

Spoiler: Courage of the Colossus (state)
This effect requires the Anti Damage Barriers plugin.

JavaScript:
<JS Pre-Apply As User>
  this._targetStatesCount = 0;
  if (target) {
    const states = target.states();
    for (let i = 0; i < states.length; ++i) {
      const checkState = states[i];
      if (checkState && checkState.categories.contains('AILMENT')) {
        this._targetStatesCount++;
      }
    }
  }
</JS Pre-Apply As User>

<JS Post-Apply As User>
  this._targetStatesCount ??= 0;
  let statesCount = 0;
  if (target) {
    const states = target.states();
    for (let i = 0; i < states.length; ++i) {
      const checkState = states[i];
      if (checkState && checkState.categories.contains('AILMENT')) {
        statesCount++;
      }
    }
  }
  if (!this._gainedCourageBarrier && (statesCount > this._targetStatesCount)) {
    this._gainedCourageBarrier = true;
    let barrier = user.level * 10;
    barrier += Math.ceil(user.mhp * 0.07) * user.opponentsUnit().aliveMembers().length;
    barrier += user.getStateDisplay(171) || 0;
    user._courageBarrier = barrier;
    user.addState(171);
  }
</JS Post-Apply As User>

Replace 171 with the ID of your Courage Barrier state:

JavaScript:
<All Absorb Barrier: user._courageBarrier || 0>

Spoiler: Enemy Thieves Remade (skill)
This effect will work as-is with no plugins needed besides Battle Core, but to be able to steal stolen items back you will also need the Steal Items plugin.

JavaScript:
<JS Post-Apply>
if (user.isEnemy()) {
  const successRate = 0.50;
  if (Math.random() < successRate) {
    const items = [];
    const total = $gameParty.items().length;
    for (let i = 0; i < total; ++i) {
      const currentItem = $gameParty.items()[i];
      if (currentItem.itypeId !== 2) {
        items.push(currentItem);
      }
    }
    if (items.length > 0) {
      const random = Math.floor(Math.random() * items.length);
      const currentItem = items[random];
      $gameParty.loseItem(currentItem, 1);
      let text = user.name() + ' stole ' + currentItem.name + ' from the party!';
      SoundManager.playEquip();
      const stealableItem = {
        type: 'ITEM',
        id: currentItem.id,
        rate: 0.50,
        isStolen: false,
        isDrop: false
      }
      user._stealableItems.push(stealableItem);
    }
  } else {
    let text = user.name() + ' failed to steal an item!';
    SoundManager.playBuzzer();
  }
  text = '<CENTER>' + text;
  const logWindow = SceneManager._scene._logWindow;
  logWindow.addStealText(text);
}
</JS Post-Apply>

Spoiler: Linken's Ring (armor)
JavaScript:
<JS Pre-Regenerate>
  user._linkenCooldown ??= 0;
  user._linkenCooldown = Math.ceil(user._linkenCooldown - 1, 0);
</JS Pre-Regenerate>

<JS Pre-Apply As Target>
  target._linkenCooldown ??= 0;
  if (target._linkenCooldown <= 0) {
    if (this.item() && DataManager.isSkill(this.item()) && this.isForOpponent()) {
      const blockedtypes = [1];
      blockedtypes.push(1);
      const blockedskills = [];
      blockedskills.push();
      if (blockedtypes.contains(this.item().stypeId) || blockedskills.contains(this.item().id)) {
        this._formerItemSuccessRate = this.item().successRate;
        this.item().successRate = 0;
        $gameTemp.requestAnimation ([target], 53)
        target._linkenCooldown = 10;
      }
    }
  }
</JS Pre-Apply As Target>

<JS Post-Apply As Target>
  if (this._formerItemSuccessRate !== undefined) {
    this.item().successRate = this._formerItemSuccessRate;
  }
</JS Post-Apply As Target>

Spoiler: Gravity (skill)
Damage formula: let damage = 0; if (b.hasStateCategory('boss')) { damage = a.mat * 6; } else { damage = b.hp * 0.5; } damage

Spoiler: Main Character Game Over (troop event)
This effect works exactly the same way as the original YEP one and requires no changes.

Spoiler: Perfection of the Maestro
I haven't converted this one yet but it would follow the same Origin/Aura state pattern I've developed for other effects that used the Passive Aura Effects plugin before.

Spoiler: Convert (skill)
JavaScript:
<JS Pre-Apply>
  const hp = target.hp;
  const mp = target.mp;
  target.setHp(mp);
  target.setMp(hp);
</JS Pre-Apply>

Spoiler: Bubble Wrap (states)
JavaScript:
<JS Pre-Start Battle>
  var bubbleWrapId = 174;
  user.addState(bubbleWrapId);
  user._bubbleWrapCooldown = 0;
</JS Pre-Start Battle>

<JS Pre-Regenerate>
  user._bubbleWrapCooldown ??= 0;
  if (user._bubbleWrapCooldown > 0) {
    user._bubbleWrapCooldown -= 1;
    if (user._bubbleWrapCooldown <= 0) {
      var bubbleWrapId = 174;
      $gameTemp.requestAnimation ([user], 82);
      user.addState(bubbleWrapId);
    }
  }
</JS Pre-Regenerate>

Replace 174 with the ID of your Bubble Wrap state:

JavaScript:
<JS Pre-Damage As Target>
  if (this.isHpEffect() && value > 0) {
    var elements = this.elements();
    var lightningElementId = 4;
    if (!elements.contains(lightningElementId)) {
      value = 0;
    }
    $gameTemp.requestAnimation ([target], 4);
    target.removeState(state.id);
  }
</JS Pre-Damage As Target>

<JS On Erase State>
  target._bubbleWrapCooldown = 3;
</JS On Erase State>

Spoiler: Death (skill)
JavaScript:
<Custom Cost Text>
  \fs[20]\c[23]All MP\c[0]\fr
</Custom Cost Text>

<JS Skill Enable>
  enabled = user.mp > 0;
</JS Skill Enable>

<JS Pre-Damage>
  if (!target.hasStateCategory('Boss')) {
    value = 0;
    target.result().hpAffected = false;
  }
</JS Pre-Damage>

<JS Post-Damage>
  if (!target.hasStateCategory('boss')) {
    target.result().hpAffected = false;
    const deathStateId = target.deathStateId();
    let chance = user.mpRate();
    chance *= target.stateRate(deathStateId);
    if (Math.random() < chance) {
      if (target.isImmortal()) {
        target.removeImmortal();
      }
      target.addState(deathStateId);
    } else {
      target.result().missed = true;
    }
  }
</JS Post-Damage>

<JS Post-Apply>
  user.setMp(0);
</JS Post-Apply>
I tested out the Toxic state on a player character by using a test item, and it worked as intended on my end.
I think it could just be me and I'll do more testing when I get around to it.
Thanks x1000 for doing these @Trihan. This is definitely something I really missed about MV.
Much thanks to you my friend!
Okay, let's finish this.

Spoiler: Confusion (state)
JavaScript:
<JS Pre-Start Action>
  var confuseRate = 0.50;
  if (Math.random() < confuseRate) {
    var confusionSkill = 358;
    $gameTemp.requestAnimation ([user], 63);
    action.setSkill(confusionSkill);
  }
</JS Pre-Start Action>

Replace 358 with the ID of your confusion self-attack skill, which will just be a damaging skill with "the user" as the scope.

Spoiler: Skill Cost Mastery (skill)
JavaScript:
<JS MP Cost>
  user._timesUsedSkill ??= {};
  user._timesUsedSkill[skill.id] ??= 0;
  const times = user._timesUsedSkill[skill.id];
  const extraCost = Math.max(8 - times, 0) * 2;
  cost += Math.ceil(extraCost);
</JS MP Cost>

<JS Post-Damage>
  user._timesUsedSkill ??= {};
  user._timesUsedSkill[skill.id] ??= 0;
  user._timesUsedSkill[skill.id] += 1;
</JS Post-Damage>

Spoiler: Circle of Radiant Glory (skill/state)
This effect requires the tier 3 Skill Cooldowns plugin.

Skill note:
JavaScript:
<JS Skill Enable>
  if (user.isStateAffected(176)) {
    enabled = false;
  }
</JS Skill Enable>

Replace 176 with the ID of your CoRG state:

JavaScript:
<No Death Clear>

<JS On Add State>
  target._radiantGloryDeadTurns = 0;
  target._radiantGloryMp = Math.ceil(user.mp / 4);
  user.gainMp(-target._radiantGloryMp);
  user.startDamagePopup();
</JS On Add State>

<JS On Erase State>
  delete target._radiantGloryDeadTurns;
  delete target._radiantGloryMp;
</JS On Erase State>

<JS Pre-End Turn>
if (user.isDead()) {
  user._radiantGloryDeadTurns ??= 0;
  user._radiantGloryDeadTurns += 1;
  if (user._radiantGloryDeadTurns >= 2) {
    user._radiantGloryMp ??= 1;
    user.gainHp(user._radiantGloryMp * 4);
    user.startDamagePopup();
    $gameTemp.requestAnimation([user], 49);
    user.removeState(state.id);
    var skillId = 360;
    var turns = 10;
    origin.setCooldown(skillId, turns);
  }
}
</JS Pre-End Turn>

Replace 360 with the ID of your CoRG skill.

Spoiler: Critical Vulnerability (state)
(edit: this one isn't working as intended. Will review)

Spoiler: Beast Boost (state)
JavaScript:
<JS Post-Damage As User>
if (!this._beastBoostApplied && (target.isDead() || target.hp <= 0)) {
  this._beastBoostApplied = true;
  var boostParam = 2;
  for (var i = 3; i < 8; ++i) {
    if (user.param(i) > user.param(boostParam)) {
      boostParam = i;
    }
  }
  var turns = 5;
  user.addBuff(boostParam, turns);
  $gameTemp.requestAnimation([user], 51);
}
</JS Post-Damage As User>

Spoiler: Cup of Life (state)
JavaScript:
<JS Post-Damage As User>
  const hpdiff = target.mhp - target.hp;
  if (this.isHpEffect() && target.isAlive() && value < 0 && (Math.abs(value) > hpdiff)) {
    const difference = Math.abs(value) - hpdiff;
    value = -hpdiff;
    user.gainHp(difference);
    user.startDamagePopup();
    $gameTemp.requestAnimation([user], 46);
  }
</JS Post-Damage As User>

Spoiler: Black Resonance (state)
JavaScript:
<JS Post-Damage As User>
  if (this.isSkill() && this.isMagical() && this.isHpEffect() && value > 0) {
    const skillTypes = [];
    skillTypes.push(1);
    if (skillTypes.contains(this.item().stypeId)) {
      let count = 0;
      const allies = user.friendsUnit().aliveMembers();
      while (allies.length > 0) {
        ally = allies.shift();
        if (ally && ally.isStateAffected(state.id) && ally !== user) {
          count += 1;
        }
      }
      const multiplier = 1.00;
      if (count <= 0) {
        multiplier = 1.00;
      } else if (count === 1) {
        multiplier = 1.10;
      } else if (count === 2) {
        multiplier = 1.15;
      } else {
        multiplier = 1.20;
      }
      value *= multiplier;
      value = Math.ceil(value);
    }
  }
</JS Post-Damage As User>

Spoiler: Daring Padawan (state)
JavaScript:
<JS Pre-Start Battle>
// Insert the ID's of the states you want to add as bonus states applied at the start of battle
var padawanStates = [15, 16, 17];
// Loop through each of those bonus states
for (var i = 0; i < padawanStates.length; ++i) {
  // Get currently looped state
  var bonusState = padawanStates[i];
  // Add the state to the user
  user.addState(bonusState);
}
</JS Pre-Start Battle>

<JS Pre-Damage As Target>
// Check if the effect dealt HP damage and is a critical hit
if (this.isHpEffect() && value > 0 && target.result().critical) {
  // Get the padawan states
  var padawanStates = [15, 16, 17];
  // Make an empty pool of states
  var currentStates = [];
  // Loop through each of the padawan states
  for (var i = 0; i < padawanStates.length; ++i) {
    // Get the currently looped state
    var bonusState = padawanStates[i];
    // Check if the target is affected by that state
    if (target.isStateAffected(bonusState)) {
      // If it is, add it to the pool of states
      currentStates.push(bonusState);
    }
  }
  // Check if the pool of states isn't empty
  if (currentStates.length > 0) {
    // Get a random state from that pool
    var removedState = currentStates[Math.floor(Math.random() * currentStates.length)];
    // Remove the random state
    target.removeState(removedState);
  }
}
</JS Pre-Damage As Target>

<JS Post-Damage As User>
// Check if the regained states flag is off and if the target is dead or has 0 HP
if (!this._regainPadawanStates && (target.isDead() || target.hp <= 0)) {
  // Get the padawan states
  var padawanStates = [15, 16, 17];
  // Loop through each of the states
  for (var i = 0; i < padawanStates.length; ++i) {
    // Get the currently looped state
    var bonusState = padawanStates[i];
    // Add the state to the user
    user.addState(bonusState);
  }
  // Set the flag to regain the states to true
  this._regainPadawanStates = true;
}
</JS Post-Damage As User>

Note that there are a few techniques you can use to make this code more efficient since MZ supports ES6, but I didn't bother with them for this.

Spoiler: Entrust (skill)
JavaScript:
<JS Skill Enable>
  enabled = user.tp >= 1;
</JS Skill Enable>

<JS Post-Apply>
  target.setTp(user.tp);
  user.setTp(0);
</JS Post-Apply>

Spoiler: Exertion Rune (state)
JavaScript:
<JS Pre-Start Battle>
// Start the exertion modifier at 0.20 at the start of battle
user._exertionMultiplier = 0.20;
// Set the text to be displayed for the state
var text = '+' + Math.floor(user._exertionMultiplier * 100) + '%'
// Set the state counter to display the text
user.setStateDisplay(state.id, text);
</JS Pre-Start Battle>

<JS Post-Damage As User>
// Check if the action dealt magical HPdamage
if (this.isMagical() && this.isHpEffect() && value > 0) {
  // Default the exertion multiplier to 0.20
  user._exertionMultiplier = user._exertionMultiplier || 0.20;
  // Increase the damage by the exertion multiplier
  value += Math.floor(value * user._exertionMultiplier);
}
</JS Post-Damage As User>

<JS Pre-Regenerate>
// Default the exertion multiplier to 0.20
user._exertionMultiplier = user._exertionMultiplier || 0.20;
// Increase the exertion multiplier by 0.20, but cap it between 0.20 and 1.20
user._exertionMultiplier = (user._exertionMultiplier + 0.20).clamp(0.20, 1.20);
// Set the text to be displayed for thestate
var text = '+' + Math.floor(user._exertionMultiplier * 100) + '%'
// Set the state counter to display the text
user.setStateDisplay(state.id, text);
</JS Pre-Regenerate>

Spoiler: Subdue, Then Strike (state)
JavaScript:
<JS Pre-End Turn>
// Check if the user wasn't hit during the turn
if (!user._subdueStruck) {
  // Play an animation
  $gameTemp.requestAnimation([user], 2);
  // The number of turns for the buffs
  var turns = 3;
  // Check if the user has an AGI buff
  if (user.isBuffAffected(6)) {
    // Add an ATK buff
    user.addBuff(2, turns);
    // Add an AGI buff
    user.addBuff(6, turns);
  } else {
    // Add an AGI buff
    user.addBuff(6, turns);
  }
}
// Reset the user struck flag
user._subdueStruck = false;
</JS Pre-End Turn>

<JS Pre-Damage As Targe>
// Check if the target took HP damage from the action
if (target.result() && target.result().hpDamage > 0) {
  // Enable a flag to indicate the user has been struck
  target._subdueStruck = true;
}
</JS Pre-Damage As Targe>

Spoiler: Restart State Turns (skill)
JavaScript:
<JS Post-Apply>
// Get the target's current states
var states = target.states();
// Set the category to check to 'enchant'
var category = 'enchant';
category = category.toUpperCase();
// Loop through each of the states
for (var i = 0; i < states.length; ++i) {
  // Get the currently looped state
  var thisState = states[i];
  // Check if the state exists and is party of the matching category
  if (thisState && thisState.categories.contains(category)) {
    // Reset the state turn count
    target.resetStateCounts(thisState.id);
  }
}
</JS Post-Apply>

Spoiler: Stormflurry (state)
JavaScript:
<JS Post-Damage As User>
// Create empty pools for skills and skipp types.
var skills = [];
var skillTypes = [];
// Insert the skills this passive can be used with.
skills.push(1, 99, 235, 236, 237);
// Insert the skill types this passive can be used with.
skillTypes.push(18);
// Check if the action is a skill, the skill pool contain the skill or if the skill type pool contains the skill's type
if (this.isSkill() && (skills.contains(this.item().id)) || skillTypes.contains(this.item().stypeId)) {
  // Check if the target exists and has suffered HP damage
  if (target && target.result() && target.result().hpDamage > 0) {
    // Make a copy of the target's original action results
    var originalResult = JsonEx.makeDeepCopy(target._result);
    // Clear those results
    target.clearResult();
    // Calculate the extra damage
    var extraDmg = Math.ceil(0.40 * originalResult.hpDamage);
    // Calculate the success rate to deal extra damage
    var successRate = 0.20;
    // Make the number of times struck
    var struck = 0;
    // Set the maximum number of times the action can be struck
    var maxHits = 5;
    // Make a loop
    for (;;) {
      // Check if the target is alive and the action has passed the success rate
      if (target.isAlive() && Math.random() < successRate) {
        // Increase the number of times struck by 1
        struck += 1;
        // Make the target receive damage
        target.gainHp(-extraDmg);
        // Show the damage popup
        target.startDamagePopup();
        // Check if the target is dead
        if (target.isDead()) {
          // Make the target collapse
          target.performCollapse();
        }
        // Clear the target's results
        target.clearResult();
        // Check if the number of times struck has hit the maximum
        if (struck >= maxHits) {
          // If it did, break the loop
          break;
        }
      // If the extra damage success rate fails
      } else {
        // Then break the loop
        break;
      }
    }
    // If the number of times struck is greater than 0
    if (struck > 0) {
      // Then play an animation on the target
     $gameTemp.requestAnimation ([target], 5);
    }
    // Revert the target's results back to its original results
    target._result = originalResult;
  }
}
</JS Post-Damage As User>

Spoiler: Damage Dispersion (state)
JavaScript:
<JS Pre-Damage As Target>
// Check if this dealt HP damage
if (this.isHpEffect() && value > 0) {
  // Get the target's alive allies
  var group = target.friendsUnit().aliveMembers();
  // Calculate the damage to be dispersed
  var rate = 0.15;
  // Reduce it by 15% per member other than the user
  rate = Math.min(rate, 1 / Math.max(1, group.length - 1));
  // Round the damage down
  var dmg = Math.floor(value * rate);
  // Loop through each member
  for (var i = 0; i < group.length; ++i) {
    // Get the currently looped member
    var member = group[i];
    // Check if the member exists and isn't the target
    if (member && member !== target) {
      // Lower the damage dealt to the target by the reduced amount
      value -= dmg;
      // Play an animation on the looped member
      $gameTemp.requestAnimation([member], 2);
      // Make the member lose HP
      member.gainHp(-dmg);
      // Play a damage popup
      member.startDamagePopup();
      // Check if the member is dead
      if (member.isDead()) {
        // If it is, make the member collapse
        member.performCollapse();
      }
      // Clear the member's results
      member.clearResult();
    }
  }
  // Make sure the damage amount reduced cannot go below 0
  value = Math.max(value, 0);
}
</JS Pre-Damage As Target>

Spoiler: Illness (state)
JavaScript:
<JS Pre-Regenerate>
// The rate to get a debuff instead of an ailment
var debuffChance = 0.25;
// If debuff chance succeeds
if (Math.random() < debuffChance) {
  var allowedParams = [];
  // Insert Param ID's you want to randomly add here:
  allowedParams.push(2, 3, 4, 5, 6, 7);
  // Get a random debuff from the pool
  var id = allowedParams[Math.floor(Math.random() * allowedParams.length)];
  // The number of turns for that debuff
  var turns = 5;
  // Add the debuff to the target
  target.addDebuff(id, turns);
  // Play an animation on the target
  $gameTemp.requestAnimation([target], 54);
// If the debuff chance fails
} else {
  // Make a pool for ailments
  var allowedStates = [];
  // Insert states you want to randomly add here:
  allowedStates.push(21, 22, 26, 27);
  allowedStates.push(31, 36, 37, 38);
  allowedStates.push(41, 42, 43, 46);
  allowedStates.push(51, 56, 57, 58);
  allowedStates.push(60, 61, 66, 67);
  // Loop through each of the ailments
  while (allowedStates.length > 0) {
    // Get a random state from the pool
    var id = allowedStates[Math.floor(Math.random() * allowedStates.length)];
    // Remove the state from the pool
    allowedStates.splice(allowedStates.indexOf(id), 1);
    // Check if the target isn't affected by it
    if (!target.isStateAffected(id)) {
      // Add the state to that target
      target.addState(id);
      // Play an animation
      $gameTemp.requestAnimation([target], 55);
      // Stop the loop
      break;
    }
  }
}
</JS Pre-Regenerate>

Spoiler: Moody (state)
JavaScript:
<JS Pre-Regenerate>
// This is the number of turns the buffs and debuffs will last
var turns = 5;
// Create a pool for the parameters that can be changed
var allowedParams = [];
// Insert Param ID's you want to randomly add here:
allowedParams.push(2, 3, 4, 5, 6, 7);
// Make a copy of the pool
var result = allowedParams.slice();
// Initialize the parameter ID
var paramId;
// Loop through each of the copied pool's parameters
while (result.length > 0) {
  // Get a randomly looped parameter
  paramId = result[Math.floor(Math.random() * result.length)];
  // Remove it from the copied pool
  result.splice(result.indexOf(paramId), 1);
  // Check if the user isn't at max buffs for that stat
  if (!user.isMaxBuffAffected(paramId)) {
    // Buff the user twice for that stat
    user.addBuff(paramId, turns);
    user.addBuff(paramId, turns);
    // Break the loop
    break;
  }
}
// Make a copy of the pool again
var result = allowedParams.slice();
// Check if the previously initialized parameter has a value
if (paramId !== undefined) {
  // Get the index of the parameter
  var index = result.indexOf(paramId);
  // If it is 0 or greater
  if (index > -1) {
    // Then remove it from the pool
    result.splice(index, 1);
  }
}
// Loop through the copied pool once more
while (result.length > 0) {
  // Get a randomly looped parameter
  paramId = result[Math.floor(Math.random() * result.length)];
  // Remove the looped parameter from the pool
  result = result.splice(result.indexOf(paramId), 1);
  // Check if the user isn't at max debuffs for that parameter
  if (!user.isMaxDebuffAffected(paramId)) {
    // Then add a debuff to that parameter
    user.addDebuff(paramId, turns);
    // Break the loop
    break;
  }
}
</JS Pre-Regenerate>

Spoiler: Stockpile (skill/state)
Stockpile state:
JavaScript:
<JS On Add State>
// Default the stockpile stacks to 0.
target._stockpile = target._stockpile || 0;
// Increase the stockpile stack by 1
target._stockpile += 1;
// Cap the stockpile stack at 3
target._stockpile = Math.min(target._stockpile, 3);
// Update the state counter for the stockpile stack
target.setStateDisplay(state.id, target._stockpile);
</JS On Add State>

<JS On Erase State>
// Set the user's stockpile stack to 0
target._stockpile = 0;
// Update the state counter for the stockpile stack
target.setStateDisplay(state.id, target._stockpile);
</JS On Erase State>

Stockpile Swallow:
Damage formula - if (!this._stockpileHeal) { a._stockpile ??= 1; this._stockpileHeal = a.mhp * (a._stockpile * 0.25); } this._stockpileHeal

Notebox:
JavaScript:
<JS Skill Enable>
// Default the user's stockpile to 0 stacks
user._stockpile = user._stockpile || 0;
// Check if the stockpile stack is 0
if (user._stockpile <= 0) {
  // Set it to false
  enabled = false;
}
</JS Skill Enable>

<JS Post-Apply>
// Remove the stockpile state from the user after being used
user.removeState(188);
</JS Post-Apply>

Replace 188 with the ID of your Stockpile state.

Stockpile Spitup:
Damage formula - if (!this._stockpileDmg) { a._stockpile ??= 1; if (a._stockpile === 1) { this._stockpileDmg = a.atk * 4; } else if (a._stockpile === 2) { this._stockpileDmg = a.atk * 8; } else { this._stockpileDmg = a.atk * 16; } } this._stockpileDmg

Notebox:

JavaScript:
<JS Skill Enable>
// Default the user's stockpile stacks to 0
  user._stockpile = user._stockpile || 0;
// If the user is at 0 stacks
  if (user._stockpile <= 0) {
  // The skill will be disabled
    enabled = false;
  }
</JS Skill Enable>

<JS Post-Apply>
// Remove the stockpile state
   user.removeState(188);
</JS Post-Apply>

Spoiler: Iteration Skill Damage (skill/state)
Skill damage formula - var total = user._totalSpellsCasted || 0; var bonusMultiplier = total * 0.5; user.mat * (1 + bonusMultiplier);

State note:
JavaScript:
<JS Pre-Start Battle>
// At the start of battle reset the number of casts
user._totalSpellsCasted = 0;
</JS Pre-start Battle>

<JS Pre-Start Action>
// Default the amount of spells casted to 0
user._totalSpellsCasted = user._totalSpellsCasted || 0;
// Get the user's current action
// Check if it is a skill and magical
if (action.isSkill() && action.isMagical()) {
  // Increase the total number of spells casted by 1
  user._totalSpellsCasted += 1;
}
</JS Pre-Start Action>

Spoiler: Minion Barrier (state)
JavaScript:
<JS Passive Condition>
// The passive effect will only be true if there's more than 1 member on the field
condition = user.friendsUnit().aliveMembers().length > 1;
</JS Passive Condition>

<JS Pre-Damage As Target>
// Check if this dealt HP damage
if (this.isHpEffect() && value > 0) {
  // Get the current group of alive allies
  var allies = target.friendsUnit().aliveMembers();
  // Calculate the amount of damage dealt spread across the allies
  var dmg = Math.ceil(value / Math.max(1, allies.length - 1));
  // Check if the number of allies is greater than 0
  if (allies.length - 1 > 0) {
    // If it is, reduce the direct damage to 0
    value = 0;
  }
  // Loop through each of the allies
  for (var i = 0; i < allies.length; ++i) {
    // Get the currently looped ally
    var ally = allies[i];
    // Check if the ally exists and isn't the target
    if (ally && ally !== target) {
      // Make the ally take damage
      ally.gainHp(-dmg);
      // Show the damage popup
      ally.startDamagePopup();
      // Display an animation on that ally
      $gameTemp.requestAnimation([ally], 12)
      // If the ally is dead
      if (ally.isDead()) {
        // Then make the ally collapse
        ally.performCollapse();
      }
      // Clear the ally's results
      ally.clearResult();
    }
  }
}
</JS Pre-Damage As Target>

Spoiler: Imperial Highblade Shock (skill)
Formula - let damage = 0; if (this._calculatedBaseDmg) { damage = this._calculatedBaseDmg; } else { var totalEnemies = target.friendsUnit().aliveMembers().length; if (totalEnemies === 1) { this._calculatedBaseDmg = user.atk * 16; } else if (totalEnemies === 2) { this._calculatedBaseDmg = user.atk * 8; } else if (totalEnemies === 3) { this._calculatedBaseDmg = user.atk * 4; } else { this._calculatedBaseDmg = user.atk * 2; } } damage = this._calculatedBaseDmg; damage

Note:

// Use multiple elements
<Multiple Elements: 6, 13>
// Set the damage rule to the highest multiplier
<Multi-Element Rule: Highest>

Spoiler: Erratic Deflector (state)
JavaScript:
<JS Pre-Damage As Target>
// Check if this action deals HP damage
if (this.isHpEffect() && value > 0) {
  // The success rate of the deflector
  var successRate = 1.0;
  // Check if the success rate passed
  if (Math.random() < successRate) {
    // Get the target's alive allies
    var allies = target.friendsUnit().aliveMembers();
    // Check if the ally count is more than 1
    if (allies.length > 1) {
      // Remove the target from the allies
      allies.splice(allies.indexOf(target), 1);
      // Set the maximum amount of total targets
      var max = Math.min(allies.length, 4);
      // Set the minimum amount of total targets
      var min = 1;
      // Get a random number between them
      var totalTargets = Math.floor(Math.random() * (max - min + 1) + min);
      // Loop the amount
      while (allies.length > totalTargets) {
        // Remove random allies from the pool
        allies.splice(Math.floor(Math.random() * allies.length), 1);
      }
      // Calculate the redirected damage
      var redirectedDamage = Math.min(value, Math.max(target.def * 4, target.mdf * 4));
      redirectedDamage = Math.ceil(redirectedDamage / totalTargets);
      // Reduce the value of the damage
      value = value - redirectedDamage;
      // Loop through the remaining allies
      while (allies.length > 0) {
        // Get the currently looped ally
        var member = allies.shift();
        // Check if the ally exists
        if (member) {
          // Make that member take damage
          member.gainHp(-redirectedDamage);
          // Display a popup
          member.startDamagePopup();
          // Show an animation
          $gameTemp.requestAnimation ([member], 2);
          // Check if the member is dead
          if (member.isDead()) {
            // Collapse the member
            member.performCollapse();
          }
          // Clear the member's results
          member.clearResult();
        }
      }
    }
  }
}
</JS Pre-Damage As Target>

And that concludes the topic! As always, let me know if you have any difficulties implementing any of these and I'll do what I can do help.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-implement-every-possible-yanfly-tips-tricks-effect-in-mz-with-visustella-plugins.143816/