I know this may be a silly question... But, is there a command like user.addState(x); but capable of affecting all enemies in battle??
How can I add and remove state to all enemies with a javascript command?
RPG Maker MV SupportThis should do it - $gameTroop refers to the current troop and the aliveMembers method on it returns all the enemies in the troop that don't have the death state applied.
If you're using an older version of MV that doesn't support ES6:
JavaScript:
// Replace x with the state Id you want to add
$gameTroop.aliveMembers().forEach(enemy => enemy.addState(x));
If you're using an older version of MV that doesn't support ES6:
JavaScript:
$gameTroop.aliveMembers().forEach(function(member) {
member.addState(x);
});
Thank you very much, it worked! 😤
Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-add-and-remove-state-to-all-enemies-with-a-javascript-command.166992/