Spreading States

Hey, ya'll!

Looking for some help with a move that will spread the dots on a target to all enemies.

So, if the target currently has poison, the move will cause all enemies to have poison. If the target has poison and is burned, the move will pass both to all enemies.

Any ideas on going about this? Is the skill already out there, and I'm just missing it?
Maybe there's an easier way, but this skill notetag seems to work with Yanfly's Skill Core plugin:
Code:
<Post-Damage Eval>
var spread = [4,5,6];
spread = target.states().filter(function(state) {
  return spread.indexOf(state.id) > -1;
});
if (spread.length > 0) {
  var group = target.friendsUnit().members();
  group.splice(target.index(), 1);
  while (spread.length > 0) {
    var state = spread.shift();
    group.forEach(function(targ) {
      targ.addState(state.id);
    });
  }
}
</Post-Damage Eval>
The var spread = [4,5,6] bit determines which state IDs will be affected (currently states 4, 5, and 6); edit this as appropriate. =)
Holy macaroni, this worked!! You are my favorite and I am facebooking you one millions dollars.

EDIT: It did work. It works to spread my states, but it also sort of instantly kills the enemy. Target still has HP and still shows on screen, but it's no longer targetable. When I use the skill on the only other enemy with full HP, the battle ends.
EDIT: It did work. It works to spread my states, but it also sort of instantly kills the enemy. Target still has HP and still shows on screen, but it's no longer targetable. When I use the skill on the only other enemy with full HP, the battle ends.
Oops, yes, confirmed! 👋 Remove the group.splice(target.index(), 1); line and see if that helps. 😅

It was only there in the first place because I wanted to avoid "spreading" the state to the target as well, but there's another way around that if that line is causing the problem. 😅
It's perfect! It does reset the dots on the target, but I'm 100% okay with that. I was considering that anyway. Thank you so much for your help!

Original thread: https://forums.rpgmakerweb.com/threads/spreading-states.92925/