Yanfly's Bide skill to target just one random enemy

ViviCJ

Prince of Parties
Member
Joined
Jun 4, 2016
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMMV
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>
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
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;
 

ViviCJ

Prince of Parties
Member
Joined
Jun 4, 2016
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMMV
You've done it one! Thank you so much!
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
You're very welcome!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,990
Members
137,562
Latest member
tamedeathman
Top