RMMV Inability to apply the same state on consecutive turns using JS

Joined
Jul 8, 2021
Messages
8
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hi all. This bothersome issue has graduated from the "JavaScript questions that don't deserve their own thread" topic. My game has a skill (among several others) that deals damage to one target, then applies a state to all allies that lasts for the remainder of the turn. To that end, the skill uses "1 Enemy" as its scope and applies the ally state through JS. The code is as follows (I'm using Yanfly's Skill Core):

JavaScript:
<After Eval>
var group = user.friendsUnit().aliveMembers();
    for (var i = 0; i < group.length; ++i) {
      var member = group[i];
        member.addState(81);
}
</After Eval>

The state applies as expected unless I use the skill again on the next turn, immediately after the state elapses. If this happens, the state does not apply to anybody. On the turn after this, if the skill is used again, the state applies as normal.

I am not really sure what's causing the issue. I initially believed it was an issue with the Turn End auto-removal timing - the issue does not arise when using Action End, and as far as I can tell the only time this happens is when attempting to apply the same state using JS the turn after the initial state ends. The state can be re-applied if a different skill applies the state to the target through the game engine as opposed to JS. ATT_Turan believes it is an issue with Yanfly's Skill Core, so I've played around with that a bit (e.g. changing the note tags) to no avail.

At his suggestion I also tried adding member._stateTurns[81] = 0 to the After Eval. With this line, the state disappears if an actor is attacked (not 100% what I'm looking for but that's not really a problem), and that allows me to successfully reapply the state to that actor by reusing the skill on the next turn. However, reusing the skill still won't apply the state to any other actors that were not attacked, as if the state is not properly refreshing like it does when an actor gets attacked (it does also successfully apply to the actor that used/is using the skill, which I guess is because by that point there's been one whole turn since the initial usage of the skill). Turning off the Turn End auto-removal causes the state to not be removed at all, even though the addition to the After Eval sets the turns to zero (I assume that it doesn't check turn count if there is no auto-removal parameter). Forcing a removal through e.g. user.removeState in the state's note field is not effective.

Manually checking the actors for the state via the console reveals that they are all unaffected by the state after the initial turn elapses, regardless of whether or not they were attacked on the previous turn. Even though the value returns as "false," the state still does not re-apply to anyone except the user and, if applicable, the character(s) that were attacked on the previous turn.

These are the state's settings; they're fairly simple:
sowing.png

Turning off the Turn End auto-removal causes the state to not be removed at all, even though the addition to the After Eval sets the turns to zero (I assume that it doesn't check turn count if there is no auto-removal parameter). Forcing a removal through e.g. user.removeState in the state's note field is not effective.

I am curious if this is because of a quirk in the baseline programming; the only insight I've been able to find on this is a thread from 2014 where a VXA user was having a similar issue.

There are a couple of workarounds I can slap together for this, so the problem isn't dire, but none of them are exactly ideal. It seemed like something that would have a simple solution but this is proving to not be the case. At this point I mostly just want to know more about the underlying problem that is causing this; if it is solvable while retaining the intended functionality of the skill, that would be really great.

Thank you!
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,717
Reaction score
1,601
First Language
English
Primarily Uses
RMMV
Something I'm confused by - you say that with the state at 0 turns, it is removed if an actor is attacked. Is it also correctly removed from everyone else at the end of the turn?
Manually checking the actors for the state via the console reveals that they are all unaffected by the state after the initial turn elapses...Even though the value returns as "false," the state still does not re-apply to anyone except the user and, if applicable, the character(s) that were attacked on the previous turn.
That's the weird bit that seems contradictory. The only thing that should cause adding a state to fail (aside from being resistant to it) is already having it, or being inside an action that just removed that state.

Just to verify, does the skill act the same way when you turn off all plugins except the Skill Core? Ditto in a new project?

If I get some time this evening, I'll see if I can reproduce the effect.
 
Joined
Jul 8, 2021
Messages
8
Reaction score
1
First Language
English
Primarily Uses
RMMV
Something I'm confused by - you say that with the state at 0 turns, it is removed if an actor is attacked. Is it also correctly removed from everyone else at the end of the turn?

Yes. The console returns a false value for all of the actors when I check if they are affected by the state, regardless of whether or not they were attacked. Even then, though, the state applies inconsistently.

At your request I tried turning off all the other plugins except Skill Core and the issue does NOT occur. The skill works as intended even without the member._stateTurns[81] = 0 line. I'm trying it now while disabling certain individual plugins that might potentially cause conflict (e.g. Buffs and States Core), but haven't found anything yet.

Here are my plugins:

plugins 1.png
plugins 2.png

I know the list is a little messy but they should be in the correct order.

EDIT: After some experimentation, I've discovered that the responsible plugin is Yanfly's Battle Engine Core. Disabling it allows the skill to work as intended. It's pretty important for the project so I can't just toss it; I'm playing around with some of the plugin's functions, but haven't had any luck yet (the Turn Start note tag seemed promising but I haven't gotten it to do what I need).
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,717
Reaction score
1,601
First Language
English
Primarily Uses
RMMV
EDIT: After some experimentation, I've discovered that the responsible plugin is Yanfly's Battle Engine Core. Disabling it allows the skill to work as intended.
So just to be clear, having only the Skill Core and Battle Engine Core active in your project results in the bug? Which battle system are you using?
 
Last edited:
Joined
Jul 8, 2021
Messages
8
Reaction score
1
First Language
English
Primarily Uses
RMMV
So just to be clear, having only the Skill Core and Battle Engine Core active in your project results in the bug? Which battle system are you using?
That's correct. I'm using the default turn-based battle system.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,717
Reaction score
1,601
First Language
English
Primarily Uses
RMMV
So, I can't reproduce your bug. I started a new project, added just those two plugins, created your skill and the notetag exactly as you have them (with your original setting of turn end 1-1). I did not include any of the state notetags, as I didn't install those plugins.

It all behaves exactly as expected, I use the skill and everyone gets the state. It disappears at the end of the turn. Next turn I use it again, everyone gets it.

So I don't know what to tell you...something is not right on your end. Double-check again that you have the current version of those plugins, that your MV project is updated to at least 1.6.1 (current version is 1.6.2, you can check by opening your Game.rpgproject in a text editor), they're in the right place in the plugin manager list...
 
Joined
Jul 8, 2021
Messages
8
Reaction score
1
First Language
English
Primarily Uses
RMMV
So strange!! I am still running into the bug even after creating a new project and adding no other plugins but the two in question. All of the versions are the most recent ones and the plugins are in the right order.

I'm giving the skills in question a one-turn cooldown. Simple enough. At a certain point it just becomes about the principle of the thing, you know?

I really appreciate you taking the time to look into this.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,717
Reaction score
1,601
First Language
English
Primarily Uses
RMMV
That's bizarre. It might be worth reinstalling MV, making another fresh project and trying it...I have no clue what could be making it work differently on your computer.

Good luck.
 

Latest Threads

Latest Profile Posts

Surprising nobody, it turns out "next Friday" for the next Jump into Javascript has become "possibly Sunday if you're lucky" XD
Folks, if anyone sends you a message inviting you to add their API to your game, please report them. We don't want people spamming our members asking them to add stuff to their games for their own (or others') benefit. We've updated the forum rules to confirm this.
I'm listening to iiluminaughtii talking about the secrets behind shady businesses and scams. Meanwhile I'm writing a fanfic about Sephiroth from FF7, one specifically for my stepmom. I'll get to give it to her, too, because my boss said I could take the holidays off! Dec. 22-27 I will be in Orlando, and maybe Fort Myers too, visiting my dad and stepmom!
Of course, I bought a handful of games on the Steam Black Friday sale. Will I try them? Will I complete any? Who knows...
I don't really have any neat updates today about how I screwed up programming... But if you want to observe the intensenes of me programming, then you can check out my stream :)

Forum statistics

Threads
117,013
Messages
1,103,807
Members
152,910
Latest member
Mr_Popo
Top