MV YEP Taunt and Random Scope

Hello, everyone! Today's inquiry regards Yanfly's Taunt Core! http://www.yanfly.moe/wiki/Taunt_(YEP). It's a relatively simple question, but I'm not positive the answer will be as intuitive, huh.

Basically, the gist of the Taunt Core is that it forces skills of certain types to ignore TGR and absolutely target an entity with the Taunt tag, no matter what. Somehow I never noticed this until well over a year after using the tag, but skills with the "x Random Enemies" scope seem to ignore this, and simply target entities regardless of their Taunt status. Considering Taunt is a major game mechanic in my game, having this random element that ignores Taunt is really frustrating, and I'm not exactly keen on removing all "X Random Enemies" skills, either, so I was hoping there might be some way to edit the JS to account for this. Of course, it's also possible I missed some other factor affecting this, so I've included my plugin list in case there's some conflict I've not noticed (although testing this with a blank project yielded the same results).


Thanks a ton, huh!
1612071098093.png

1612071117143.png

1612071133780.png


1612071155030.png
im not that familiar with the taunt plugin, but i believe some override others... specially the enemy AI plugin with others relative with targeting.

what i would do in your place is try to add a custom rule that would check if possible targets have a state indicating taunt. if im correct, you want the battlers taunting to be magnets. if so, try this code instead of the < x random > notetag
JavaScript:
<Custom Target Eval>
   var tauntCount = 0; //set a counter in order check if any of them have taunt*
   //* = to check it, in this example, taunt comes with a state. the state just needs to be present
   //be sure to add a state along with taunt in order for this to work.
   //lets check if any of the members have the said state. if so, add 1 to the counter.
   // replace STATEidHERE bellow with the number of the states id.
   //getting the target alive friends list:
   for(var i = 0; i < target.friendsUnit().aliveMembers(); ++i){
      var member = target.friendsUnit().aliveMembers()[i];
      if(member.isStateAffected(STATEidHERE)){tauntCount++;}
   }
   //now, if the counter is > than zero, someone has taunt and should be the target
   //if not, X lucky targets will suffer the skills effect. define the X times bellow.
   var skillTargets = X;
   if(tauntCount > 0){
      var members; //the random members list
      for(var i = 0; i < target.friendsUnit().aliveMembers(); ++i){
         var member = target.friendsUnit().aliveMembers()[i];
         if(member.isStateAffected(STATEidHERE)){members.push(member);}
      }
      //distribute the X effects to those tauting
      while(skillTargets--){
         var member = members[Math.floor(Math.random() * members.length)];
         if(member){targets.push(member);}
      }
   }
   else{
      var members = target.friendsUnit().aliveMembers();
      while(skillTargets--){
      var member = members[Math.floor(Math.random() * members.length)];
         if(member){
            targets.push(member);
            //if you dont want the same target being hit twice, uncomment next line.
            //members.splice(indexOf(member,1));
         }
      }
   }
</Custom Target Eval>

man... those were serious lines... double check for missing comas, brackets and other stuff... im not that great of a coder and i coded direct in the text box with a weird (to me) auto complete. i hope it helps.

code got long, but i tried to make things easy to understand to unexperienced coders... such as me =)

Original thread: https://forums.rpgmakerweb.com/threads/yep-taunt-and-random-scope.132869/