Help With Yanfly Lunatic Skill Custom Requirement (States As Resource)

SefirosuKuraodo

Veteran
Veteran
Joined
Apr 7, 2015
Messages
66
Reaction score
20
First Language
English
Primarily Uses
N/A
So I'm wondering if anyone can help me out with something I'm attempting to do here, and point out what I'm doing wrong... It's a bit complicated, so I'll try and give as much detail as I possibly can without this becoming word soup :p

I have a class that allows the user create Shadow Clones of themselves.

Example: User casts "Phantom Zone", and three separate states are applied (Phantom1, Phantom2, & Phantom3), each one a shadow clone that appears behind them and mimics their movements. That's working fine.
- The class has certain skills that are only usable when the user is afflicted by at least one of those three states is afflicted, and will 'Cost' one of these states (but not all of them.)
- If the user has one of these three states applied (or all of them) then I want the Custom Requirement/Execution to check and see if User has Phantom1 State = if yes, skill shows up as usable. If Skill is used, State is removed.
-If User does not have Phantom1 State, then check and see if User has Phantom2 State =if yes, skill shows up as usable. If Skill is used, State is removed.
-If User does not have Phantom2 State, then check and see if User has Phantom3 State = if yes, skill shows up as usable. If Skill is used, State is removed.

If anyone has a method for accomplishing this, I would greatly appreciate the help!

I've tinkered and tried a few different methods, but I can't seem to get the Custom Requirement to work. I get Syntax Errors and the skill shows up as usable regardless of whether the states have been applied or not. When I open up the skill menu. Here's how the Skill is currently set up:

<Custom Requirement>

if (user.isStateAffected(139)) {

value = true;

} else {

if (user.isStateAffected(140)) {

value = true;

} else {

if (user.isStateAffected(141)) {

value = true;

} else {

value = false;

}

</Custom Requirement>



<Custom Execution>

// Check if the user is affected by Phantom3 State.

if (user.isStateAffected(141)) {

// Remove the state from the user.

user.removeState(141);

// Check if the user is affected by Phantom2 State.

} else if (user.isStateAffected(140)) {

// Remove the state from the user.

user.removeState(140);

// Check if the user is affected by Phantom1 State.

} else if (user.isStateAffected(139)) {

// Remove the state from the user.

user.removeState(139);

}

</Custom Execution>
 

kirbwarrior

Veteran
Veteran
Joined
Nov 13, 2014
Messages
732
Reaction score
418
First Language
English
Primarily Uses
N/A
I'm a little tired, but it doesn't look like you have any "end"s in there. Also, since you are using Yanfly's plugins, look into his Buffs&States Core. It lets you stack states. It doesn't look like your Phantom States do anything different, so you could turn it into a number of the same state instead.
 

SefirosuKuraodo

Veteran
Veteran
Joined
Apr 7, 2015
Messages
66
Reaction score
20
First Language
English
Primarily Uses
N/A
I'm a little tired, but it doesn't look like you have any "end"s in there. Also, since you are using Yanfly's plugins, look into his Buffs&States Core. It lets you stack states. It doesn't look like your Phantom States do anything different, so you could turn it into a number of the same state instead.
Thanks for replying. I guess my only confusion on Yanfly's B&S Core was that I couldn't seem to find a stacking mechanic in the engine for States, just buffs. All I could seem to find for states was to add the amount of turns/ticks to the current amount when reapplying, but not a true stack - but I'm probably just overlooking it when it's right in front of me :p

I did want to say that I stumbled upon a solution, though, since the Custom Execution section is working as intended. Basically since I have it set up to take stack 3 first if available, then 2, THEN 1, all I needed the Custom Requirement section to check for was whether State 1 was applied or not, since it would always be the last stack taken anyway. That way it didn't matter if States 3 and 2 were available :p - I was just overthinking the whole thing lol. Thank you, Kirbywarrior, for your help! ^_^
 

kirbwarrior

Veteran
Veteran
Joined
Nov 13, 2014
Messages
732
Reaction score
418
First Language
English
Primarily Uses
N/A
Your welcome! Glad you noticed your overthinking, I do it all the time.

Also, the stacking states thing might be in State Categories. I tend to conflate those. If not, you can instead have the state have 3 "turns" to it, but the stat just refreshes the turn count up 1 each turn, then the skill decreases the turn count itself to actually make it go down. It's unnecessarily complicated, but it can work.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
This is where you made your syntax errors btw.

Did you notice the difference between your Custom execution and Custom requirement?
I will point out the difference.
In custom execution you use
if (stuff) {
}else if (stuff) {
}else if (stuff) {
}else (stuff) {
}
In custom requirement you use
if (stuff) {
}else {
if (stuff) {
}else {
if (stuff){
}else {
}
The thing is, your custom execution has one if else statement thanks to the else if. Your custom requirement has multiple if else statements, even though you could just use else if the same way you did in Custom requirement.
So where is the syntax error?
In your curly brackets. Count how many curly brackets are there that close if else statements. There is only one. And you need one for each if else statement, so three in total.
if (stuff) {
}else {
if (stuff) {
}else {
if (stuff){
}else {
}
}
}
would have been the correct syntax. But then again, using else if and therefore making it one if else statement would have been completely fine.
 

zarroc407

Veteran
Veteran
Joined
Jun 20, 2013
Messages
104
Reaction score
16
First Language
english
@SefirosuKuraodo You could give this code a try I tested it and it seemed to work the way you described what you wanted it to

<Custom Requirement>
// Checks if user has phantom state 1, 2, or 3 if they have one the skill is usable
if (user.isStateAffected(139) || user.isStateAffected(140) || user.isStateAffected(141)) {
value = true;
} else {
value = false;
}
</Custom Requirement>


<Custom Execution>
// If the user is affected by phantom state 1 it is removed
if (user.isStateAffected(139)) {
user.removeState(139);
// If the user is affected by phantom state 2 but not phantom state 1 phantom state 2 is removed
} else if (user.isStateAffected(140) && ! user.isStateAffected(139)) {
user.removeState(140);
// If the user is affected by phantom state 2 but not phantom state 1 or 2 phantom state 3 is removed
} else if (user.isStateAffected(141) && ! user.isStateAffected(140) && ! user.isStateAffected(139)) {
user.removeState(141);
}
</Custom Execution>
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games? And, if so, would any of you be interested in a short, proof of concept type non-euclidian puzzle game?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,232
Members
137,607
Latest member
Maddo
Top