Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

In need of assistance with checking an actor for multiple states at once.

Nystrai

Villager
Xy$
0.00
Hi!

ive been creating some pretty cool things for my game. but ive hit a snag with my JS (which im admittedly still learning)

ive attempted to google references for how to accomplish my goal but the syntax im using, while not causing a crash on its own is not exactly doing what I would like it to do.

My lead character has different transformation states that can be used during battle. these execute and work properly. the issue that I am having is with the death state. when the character hits 0hp and dies. Im trying to drop all states and revert.

Im attempting to do this with the death state but I only want it to work on actor one. otherwise I want the code to do nothing and just work as vanilla intended.

im hoping someone a lot smarter than me with some JS skills can see and point out my error. it feels like it should be easier than this. without having to do a ton of else statements. im attempting to check if actor 1 has any state 188 though 196.
if he does. then I want to have those states removed and have their appearance restored to normal.

in short its not working. (if you need more information please tell me)


I will mention that this is using yanfly's buffs and states core with custom apply and remove effects.

in the beginning I attempted to check for multiple states using || as an OR... or so I thought.
but it doesn't seem to be checking at all. if I remove that check . it does work. but it freaks out tries to run the code anytime any actor dies.

I greatly appreciate any advice and I will add your name to the game credits, multiple people if needed.

thank you so much if you even looked at this.


JavaScript:
<Custom Apply Effect>
//only excecute if lead character is under the influence of states 188 though 196.
if ($gameActors.actor(1).isStateAffected(188 || 189 || 190 || 191 || 192 || 193 || 194 || 195 || 196 )) {

this.removeState(196)
this.removeState(195)
this.removeState(194)
this.removeState(193)
this.removeState(192)
this.removeState(191)
this.removeState(190)
this.removeState(189)
this.removeState(188)
// Retrieve archived settings.
var charName = user._prevCharName;
var charIndex = user._prevCharIndex;
var faceName = user._prevFaceName;
var faceIndex = user._prevFaceIndex;
var battlerName = user._prevBattlerName;
// Changes the character image to the archived setting.
user.setCharacterImage(charName, charIndex);
// Changes the face image to the archived setting.
user.setFaceImage(faceName, faceIndex);
// Changes the battler image from the archived setting.
user.setBattlerImage(battlerName);
// Clear archived data.
user._priorityCharacterName = undefined;
user._priorityCharacterIndex = undefined;
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
user._priorityFaceName = undefined;
user._priorityFaceIndex = undefined;
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
user._priorityBattlerName = undefined;
// Play an animation on the target.
target.startAnimation(159);
$gameScreen.startFlash([255, 255, 255, 255], 20);
user._prevBattlerName = undefined;
// Refreshes the user's appearance.
user.refresh();

//Or else do nothing.
} else {}
</Custom Apply Effect>
 
Top