Yanfly's Bide skill to target just one random enemy

Hi all!

Was wondering if anyone could help me edit this skill yanfly made replicating pokemon's bide ability.

Currently it attacks all enemies but I'd like it to just hit one random enemy.

If anyone can help, I'd hugely appreciate it!

Thank you


http://yanfly.moe/2016/04/16/tips-tricks-bide-pokemon-rpg-maker-mv/


<Custom Apply Effect>

// Upon applying Bide, set the Bide damage to 0.

user._bide = 0;

</Custom Apply Effect>



<Custom Respond Effect>

// Check if the target took any HP damage.

if (target.result().hpDamage > 0) {

// If the target did, raise the Bide damage by the HP damage taken.

target._bide += target.result().hpDamage;

}

</Custom Respond Effect>



<Custom Remove Effect>

// Check if the party is in battle.

if ($gameParty.inBattle()) {

// Play animation 97 on the user.

user.startAnimation(97);

// Calculate the damage. The damage dealt is equal to 2x Bide damage.

var damage = Math.ceil(user._bide * 2);

// Get the group of alive enemies.

var enemies = user.opponentsUnit().aliveMembers();

// Loop through each of the enemies.

for (var i = 0; i < enemies.length; ++i) {

// Get the enemy.

var enemy = enemies;

// Play animation 107 on the enemy.

enemy.startAnimation(107);

// Make the enemy take damage.

enemy.gainHp(-damage);

// Prompt the enemy's damage popup.

enemy.startDamagePopup();

// Clear the results of the enemy taking damage.

enemy.clearResult();

// Check if the enemy is dead.

if (enemy.isDead()) {

// If the enemy is dead, make it collapse.

enemy.performCollapse();

}

}

// Reset the Bide damage value.

user._bide = 0;



} // Check if the party is in battle.

</Custom Remove Effect>
Here's a partial copy of the code - what you need to do is delete anything I marked in orange (make sure to also get the curly brace } near the end!), and add anything I wrote in green. I think this will work, though I haven't tested it.

// Loop through each of the enemies.

for (var i = 0; i < enemies.length; ++i) {

// Get the enemy.

var enemy = enemies
;

// Get a random enemy.

var enemy = enemies[Math.floor(Math.random() * enemies.length)]

// Play animation 107 on the enemy.

enemy.startAnimation(107);

// Make the enemy take damage.

enemy.gainHp(-damage);

// Prompt the enemy's damage popup.

enemy.startDamagePopup();

// Clear the results of the enemy taking damage.

enemy.clearResult();

// Check if the enemy is dead.

if (enemy.isDead()) {

// If the enemy is dead, make it collapse.

enemy.performCollapse();

}

}

// Reset the Bide damage value.

user._bide = 0;
You've done it one! Thank you so much!
You're very welcome!

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-bide-skill-to-target-just-one-random-enemy.75507/