Switching Status Effects With Target

moldy

Veteran
Veteran
Joined
Nov 15, 2015
Messages
193
Reaction score
29
First Language
English
Primarily Uses
I'm trying to create a skill that transfers a target's current status effects to the user and vice versa. It only seems to work when the enemy currently has no statuses. I can't seem to figure out whats wrong. Here's my code:


var number = 0;
var player = []; // array to hold caster's current status IDs
var enemy = []; // array to hold target's current status IDs
var i = 0;


while (number < 150) { // add the current status IDs of enemy to an array
if (b.isStateAffected(number)) {
enemy[enemy.length] = number;
enemy.length += 1;
number += 1;
} else { number += 1; }
}



number = 0; // reset status ID starting point to zero



while (number < 150) {  // add the current status IDs of caster to an array
if (a.isStateAffected(number)) {
player[player.length] = number;
player.length += 1;
number += 1;
} else { number += 1; }
}



number = 0;



while (number < 150) { // clear all statuses from target
if (b.isStateAffected(number)) {
b.removeState(number);
number += 1;
} else { number += 1; }
}



number = 0;



while (number < 150) { // clear all statuses from player
if (a.isStateAffected(number)) {
a.removeState(number);
number += 1;
} else { number += 1; }
}



for (i = 0; i < enemy.length; i++) { // add enemy's previous statuses to player
a.addState(enemy);

}







for (i = 0; i < player.length; i++) { // add player's previous statuses to enemy


b.addState(player
);

}





 
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,714
First Language
English
Primarily Uses
RMMV
Are you saying you want to swap around the user's and the target's states?


enemy and player are arrays.  The addState method accepts one state, not an array.


However, why don't you just do something like this:

Code:
// save list of states away for later use
var aStates = a._states.splice(0);
var bStates = b._states.splice(0);

// clear states
a.clearStates();
b.clearStates();

// swap states
aStates.forEach(function(stateId) { b.addState(stateId); });
bStates.forEach(function(stateId) { a.addState(stateId); });
 

moldy

Veteran
Veteran
Joined
Nov 15, 2015
Messages
193
Reaction score
29
First Language
English
Primarily Uses
Are you saying you want to swap around the user's and the target's states?


enemy and player are arrays.  The addState method accepts one state, not an array.


However, why don't you just do something like this:



// save list of states away for later use
var aStates = a._states.splice(0);
var bStates = b._states.splice(0);

// clear states
a.clearStates();
b.clearStates();

// swap states
aStates.forEach(function(stateId) { b.addState(stateId); });
bStates.forEach(function(stateId) { a.addState(stateId); });


Thank you so much! :0


I'm bad at this lol.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,714
First Language
English
Primarily Uses
RMMV
Everyone always has more to learn :)   Don't feel bad.
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,381
Reaction score
8,537
First Language
English
Primarily Uses
RMMV
Moving this to JS Support, since that's where it should be but closing because it's solved. If you want it reopen, please just report it and state why.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top