/*=======================================NonRepeatRandom.js======================================= /*: * @plugindesc Non Repeating Random * @author Kaimonkey * @param True for all skills? * @desc Setting to true will mean that this plugin affects skills without the <norepeat> tag * @default false * * @help * ============================================================================ * Terms and Conditions * ============================================================================ * The plug in may only be used for NONCOMMERCIAL projects. If you wish to * use this plug in in a commercial product, please contact Kaimonkey for a * licience * * While reasonable effort will be made to fix any faults in the product, the * product comes "as is", and Kaimonkey is under no legal obligation to do so. * ============================================================================ * Intro * ============================================================================ * This script means that any skill with the repeat property, the scope of "one * random enemy", and the <norepeat> tag will never target the same enemy twice. * If not enough targets are avaiable the skill will target each enemy once. * */(function() { //Start Plugin var parameters = PluginManager.parameters('NonRepeatRandom'); var all_skills = String(parameters["True for all skills?"]) !== "false"; var _km_action_numTargets = Game_Action.prototype.numTargets; Game_Action.prototype.numTargets = function() { if(this.is_non_repeat()){ return this.item().repeats; } return _km_action_numTargets.call(this); }; Game_Action.prototype.is_non_repeat = function(){ return this.item().scope == 3 && (all_skills || this.item().note.includes("<norepeat>")); }; var _km_action_numRepeats = Game_Action.prototype.numRepeats; Game_Action.prototype.numRepeats = function() { if(this.is_non_repeat()){ return 1; } return _km_action_numRepeats.call(this); }; var _km_action_targetsForOpponents = Game_Action.prototype.targetsForOpponents; Game_Action.prototype.targetsForOpponents = function() { if(this.is_non_repeat()){ var members = shuffle(this.opponentsUnit().aliveMembers().clone()); var targets = []; for (var i = 0; i < this.numTargets(); i++) { if(members.length!=0) targets.push(members.pop()); else return targets; } return targets; } return _km_action_targetsForOpponents.call(this); }; function shuffle(o){ for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); return o; }})(); //Close Plugin