TDW X Random Enemies Scope

TDW X Random Enemies Scope - v 1.00​
wrigty12​
 ​
Intro - Under a skill's scope, the only choices for a random enemy are 1-4 and are always the same. This plugin allows you to have a random, dynamic number of random enemies affected.

Features - 

- Expand your Skill scopes by having the ability to target more random enemies than allowed in the editor.

- Allow the number of random enemies struck by a Skill to be random, determined by a defined range.

How To Use - Simply download, place in your js file, and install! (Personally recommend placing it at the bottom.)

Parameters - None.

Notetags - 

[spoilers]

<random enemies: min max>

Where min and max are the minimum and maximum range for possible random 

enemies affected (Inclusive).

Place in a Skill note box.

Example: Placing the tag <random enemies: 5 7> in a Skill's note box will 

allow the skill to strike either 5, 6, or 7 random enemies each time used.

[/spoilers]

Future Plans - None.

Terms of Use - Free for commercial and non-commercial use. Feel free to credit: wrigty12 or Tyler Wright. (If you want to provide me with a copy of a game that uses this script, I would be happy to accept!)

Special Thanks - The structure for this plugin was inspired by Hime's Random Repeats plugin. Thank you for giving me a nice structure to follow!

Download - Link Here

Note - I am a beginner in the ways of making plug-ins and in JavaScript. If there is anything you see wrong, could be improved, or bugs you find, just let me know.
Hey there!
Quick question: Is ist possible to limit the scope, so that each enemy can only be hit once?


For example if a skill puts 2-3 random enemies to sleep, it would be wasteful to have one of them be affected twice.


Thanks for your answer and have a great day  🙂
@Quite.Toxick I believe you want exactly what I made this plugin to prevent. Originally I had this plugin by Kaimonkey (My forum request: Link ) but it made it so repeats only affect an enemy once each attack. If you cannot get it to work the way you want it to, I can add something similar to my plugin to fit your needs.


Thanks!
@wrigty12 Thank you for the response and the tip!


I tried the plugin by Kaimonkey but it didn't seem to have any effect.


That's probably because he wrote it before he knew that you're using Yanfly Battle Engine Core (as I do)?


If I select "1 random enemy" as scope and set the repeat to 4, the skill targets one enemy, plays the animation once and hits it four times with the effect.


What I am after is having four different enemies affected by the effect once, including the animation for each enemy.


If you could find the time to add such a feature to your plugin (which I assume is compatible with Yanfly's stuff) I would be more than grateful!  BD


Thanks!  🙂
Alright Ill look into it. I think I know of a method of making it work. Ill mess with it tonighg and post back if I succeed.


EDIT:


I couldn't get it to work with my plugin.


HOWEVER!! I did get the result you want using Yanfly's Target Control. Using the Lunatic Mode - Custom Target Eval tag, I did the following:


<Custom Target Eval>
var randomNumber = 5; //set this to be the number or formula for
//how many random enemies you want to be affected.
var options = [];
for (var n=0; n<foes.aliveMembers().length;n++){
options.push(n);
}
for (var i = 0; i < randomNumber; ++i) {
if (options.length != 0){
var indnumber = Math.randomInt(options.length);
var selected = options.splice(indnumber,1);
targets.push(foes.aliveMembers()[selected]);
}
}
</Custom Target Eval>


Just by editing the randomNumber value (either integer or a formula) it will only add an enemy once when selecting random targets.


If you want the same effect as my ranged random enemies, use the formula


Math.floor(Math.random() * (max - min + 1)) + min;


instead of the 5, where max and min are the max and min ranges.


Let me know if for some reason this doesn't work.
Oh, thanks a lot!


It works like a charm  BD


Sorry for the late reply, I didn't see you message because of the edit... didn't get a notification.  


Have a great day!

Original thread: https://forums.rpgmakerweb.com/threads/tdw-x-random-enemies-scope.54737/