Yanfly Target Core help

Hi, so I'm trying to make a skill similar to McCree's Fan the Hammer Skill in overwatch, where it uses all the rest of the bullets left in the clip to hit random enemies all at once.


I pretty much have everything but just need help having the Skill target a random number of foes based on how many bullets (Variable number) is left. 


For example, if theres 3 bullets left in the gun it selects 3 targets randomly.


I tried the <Custom Target Eval> but i dont really understand it and cant get it to work.
  I actually just made a skill based off that very thing yesterday.  Mcree's Fan the Hammer.


  What I did was use pieces of his Tips and Tricks for Chain Lightning, here.


I'm on my phone so I don't have exactly what I used, but where it says "various extra targets = 3", replace 3 with whatever contains how many bullets you have left.  For me, I was keeping track with state counters.


Edit:


<Custom Target Eval>


// Adds the selected target to the target list.


targets.push(target);


// Grab the group of alive foes as candidates.


var members = foes.aliveMembers();


// This is the number of extra targets to select with Chain Lightning.


var extraTargets = user._sureShot - 1;


// Loop the extra targets.


while (extraTargets--) {


// Grab a random foe from the alive foes.


var member = members[Math.floor(Math.random() * members.length)];


// Check to see if the member exists.


if (member) {


// Add the member to the group of targets.


targets.push(member);


}


}


</Custom Target Eval>


I removed the effects about removing targets already hit, and about lowering the damage.


 Replacing the bold part changes the amount of targets.
Dude it totally works! 


thank you so much kind sir. didnt even think about looking at that skill.


Into the special thanks for my game you go. 😛

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-target-core-help.67540/