HELP with a Yanfly skill requirement function

Magusalfador

Veteran
Veteran
Joined
Jun 15, 2014
Messages
232
Reaction score
39
First Language
English Spanish
Primarily Uses
There is a skill custom requirement plug in, if the eval comes true, the skill is usable, otherwise will not.
Someone helped me with this in the past:

Code:
if ($gameTroop.aliveMembers().some(function(member) { return member.isStateAffected(22) })) {
    value = false;
  } else {
    value = true;
  }
This checks if someone in the enemy troop has the state 22.

Now, what I need is a code that checks if all alive game Party members have state X, lets say 172.

So if all party members have the state 172, the skill is unusable, otherwise, is usable.

Thanks!
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,657
Reaction score
1,110
First Language
EN
Primarily Uses
RMMV
Short answer: swap $gameTroop for $gameParty, replace some with every, and change the state ID as appropriate~
JavaScript:
if ($gameParty.aliveMembers().every(function(member) { return member.isStateAffected(172); })) {
  value = false;
} else {
  value = true;
}
:kaothx:

Explanation: your example uses Array.some to check if at least one element of the array meets the given criteria. For your question, you want Array.every, which checks if all elements of the array meet the given criteria. In case you're interested, you can find a whole list of functions usable with arrays here (scroll down a bit or check the sidebar on the left):
 

Magusalfador

Veteran
Veteran
Joined
Jun 15, 2014
Messages
232
Reaction score
39
First Language
English Spanish
Primarily Uses
Damn, I swear I tried that and didnt worked...so thats why I asked for help...let me double check that and see where I coded that wrong.

Thakyou!!!

EDIT: Yup, that works...don´t know what was wrong when I tried it.
Thanks again.
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

The nick "Toeuia" that I'm using comes from a, idk, you okay the chess game while chit chatting them. The first two are students. Then you know, finally, the champion, and then the champion's sensei. I played like this so many times until suddenly there's another chess master. Very naive but super smart. After he lost, he kinda advised me not to give up on chest. Because the next one was never seen beaten. Touya.
I'm currently playing Ara Fell - I can see why it's had generally good reviews. The exploration aspect is pretty strong and the writing is passable.

The game auto-saves and offers an option to turn back just before each major combat, and immediately brings the player back to the last position saved when there's a TPK. Convenient at the very least.
This is Krizzirk Toeuia Aeslan, I'm picking up transmission. Draftwingeds on, duty on, exhaust ready. 310 Immulicationsers approaching. I'll take the cake and----hold it!!! My Cosvere Radar detected 3001 of them!!
11 hours of programming... Only to add two more zoom levels.
Well, that's what happens when you decide between minimap and zoom too late.

It's my cute little ghost~

Forum statistics

Threads
99,374
Messages
964,608
Members
130,989
Latest member
FerdiPanther
Top