Eval Collection: Shuffle

Suffle Option Kostenlose Icons

(Requested here)  (Picture Source)

 

Shuffle is a skill that will take all the states that are currently on the battle field and randomly assign them to each battle participant. There are two rules to Shuffle:

  1. A battler cannot be given the same state that was taken from them.
  2. The duration of the states will carry over.

Requirements:

  • YEP_BuffsStatesCore.js
  • YEP_AutoPassiveStates.js
  • YEP_SkillCore.js

 

 

First you’ll want to create your Shuffle skill. Change its Scope to User.

Then you’ll have to use this notetag:


<After Eval>
// These arrays will store the collected states and their durations.
var states = [];
var statesDuration = [];
// Collect all states on the field
for (var i = 0; i < $gameTroop._enemies.length; i++) {
var enemy = $gameTroop._enemies[i];
// This array will contain all the states that were taken from this battler.
enemy._excludeShuffle = [];
if (enemy) {
for (j = 0; j < enemy.states().length; j++) {
var state = enemy.states()[j];
if (state && !enemy.isPassiveStateAffected(state.id)) {
states.push(state);
statesDuration[state.id] = enemy.stateTurns(state.id);
enemy._excludeShuffle.push(state.id);
enemy.removeState(state.id);
};
};
};
};

for (var i = 0; i < $gameParty.battleMembers().length; i++) {
var actor = $gameParty.battleMembers()[i];
// This array will contain all the states that were taken from this battler.
actor._excludeShuffle = [];
if (actor) {
for (j = 0; j < actor.states().length; j++) {
var state = actor.states()[j];
if (state && !actor.isPassiveStateAffected(state.id)) {
states.push(state);
statesDuration[state.id] = actor.stateTurns(state.id);
actor._excludeShuffle.push(state.id);
actor.removeState(state.id);
};
};
};
};

// This array will contain all the current battlers on the field.
var allBattlers = [];
for (var k = 0; k < $gameParty.battleMembers().length; k++) {
allBattlers.push($gameParty.battleMembers()[k]);
};
for (var l = 0; l < $gameTroop._enemies.length; l++) {
allBattlers.push($gameTroop._enemies[l]);
};

// This loop will assign the states

while (states.length > 0) {
var random = Math.floor(allBattlers.length * Math.random());
var randomState = Math.floor(states.length * Math.random());
if (allBattlers[random]._excludeShuffle.indexOf(states[randomState].id) === -1) {
allBattlers[random].addState(states[randomState].id);
allBattlers[random].setStateTurns(states[randomState].id, statesDuration[states[randomState].id]);
states.splice(randomState, 1);
} else {
continue;
};
};
</After Eval>

And that’s all. There’s nothing that you have to change in there, so you can just paste it and it will (or should) work.

 

Advertisements

Write a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s