No Idea why this switch wont flip.

To make a long story short, I have a combo system in my game which increases a variable by 1 for each time you land a hit. The way I have it registering if the attack landed or not is by flipping a switch on whenever the attack hits via the damage formula:

Code:
$gameSwitches.setValue(9, true); $gameSwitches.setValue(10, true); $gameSwitches.setValue(21, true); if (a.isStateAffected(13)) + (a.atk * 2.5 - b.def * 1); else (a.atk * 1.1 - b.def * 1)

(the combo switch is switch 9, the other switches don't matter for this specific issue unless I'm wrong)

I also have a common event attached to the attack which detects if the switch is turned on and increases the Combo variable by 1. With that I can do a bunch of other things within the Troop events like increase the combo meter graphic I have. I had a whole system in place which worked up until about an hour ago. I didn't touch anything, the most I did was copy and paste the above code into a new attack I was working on, which shouldn't do anything.

My problem is that the switches no longer trigger. Like I said, they did a couple hours ago, but when I went to test my new attack, the switch simply wouldn't trigger. It wasn't just with the new attack either, I went back to the other attack's which worked fine before and now, for some reason they just aren't triggering. I'm completely stumped. I have legitimately no Idea why the switches will not trigger from the formula. While setting up and testing my system, the switches were extremely finicky and it confused me then, but I managed to get it working up until now.

This is quite the dilemma and I would really appreciate some help figuring this out. Its very integral to my game to get this working, which is why I'm so frustrated at how finicky this is being. Thanks guys.

1715586515796.png

1715586475013.png
have you perhaps added a plugin without configuring it?

the main reason why we always tell to configure all plugins as soon as they are added is that some plugins require variables or switches to be assigned to them, and the default chosen by the programmer is more often than not a switch or variable already in use.
so the plugin needs to be pointed to which switches and variables it can use, or thing like you describe will happen if a plugin takes control of a switch or variable.

other than that, search with the event searcher for the switch to make sure it isn't used in any other event.

and what did you do/work on in that hour? because that info might point to where things could have gone wrong
Code:
$gameSwitches.setValue(9, true); $gameSwitches.setValue(10, true); $gameSwitches.setValue(21, true); if (a.isStateAffected(13)) + (a.atk * 2.5 - b.def * 1); else (a.atk * 1.1 - b.def * 1)
You have an error: the plus sign after isStateAffected() should not be there. Any errors in will return 0 without error reporting since it is using the try/catch error method in the evalDamageFormula() function.

Try this:
JavaScript:
const s = $gameSwitches; [9, 10, 21].forEach(id => s.setValue(id, true)); a.isStateAffected(13) ? a.atk * 2.5 - b.def : a.atk * 1.1 - b.def
Try this:
JavaScript:
const s = $gameSwitches; [9, 10, 21].forEach(id => s.setValue(id, true); a.isStateAffected(13) ? a.atk * 2.5 - b.def : a.atk * 1.1 - b.def
you have an error in the condition that with with a missing bracks:
JavaScript:
const s = $gameSwitches; [9, 10, 21].forEach(id => s.setValue(id, true)); a.isStateAffected(13) ? a.atk * 2.5 - b.def : a.atk * 1.1 - b.def
this is the fix version that should work.
you have an error in the condition that with with a missing bracks:
JavaScript:
const s = $gameSwitches; [9, 10, 21].forEach(id => s.setValue(id, true)); a.isStateAffected(13) ? a.atk * 2.5 - b.def : a.atk * 1.1 - b.def
this is the fix version that should work.
Haha just fixed it too lol. Thanks ninja shadow dragon master

If there is one thing I miss... it will be and always be the close parenthesis. One of many.
Without plugins MV only supports queuing one common event at a time, so your skill will only queue the last event (HandAxeCheck).

You have an error: the plus sign after isStateAffected() should not be there.
No. It's in the single-line if statement result (not its condition), and + is a valid unary operator:
It's unnecessary here, but harmless.
have you perhaps added a plugin without configuring it?
write plugins is not easy. I just write the plugins like this.. base on TS common event
Spoiler: image like above
index.php

click here to download the script
for learning only

the script kinda long, but it can used to learn how to make plugins

and perhaps in the end, TS can make the newer version like this
version 1 perhaps
Without plugins MV only supports queuing one common event at a time, so your skill will only queue the last event (HandAxeCheck).


No, + is a valid unary operator:
It's unnecessary here, but harmless.
Cool - the more you know. Thanks for the reference!
Without plugins MV only supports queuing one common event at a time, so your skill will only queue the last event (HandAxeCheck).


No. It's in the single-line if statement result (not its condition), and + is a valid unary operator:
It's unnecessary here, but harmless.
Yeah, that seems to be it. I removed the Hand axe check and it worked. That really complicates things, I guess I could just add all the attack checks into 1 common event and see if that works. Thanks for the replies guys, I seriously thought it was the switch call bc it was being finicky before.

Yeah, I just added all the common events into one event and it seems to be running alright. So future reference I guess, you can only call one common event per attack.

you have an error in the condition that with with a missing bracks:
JavaScript:
const s = $gameSwitches; [9, 10, 21].forEach(id => s.setValue(id, true)); a.isStateAffected(13) ? a.atk * 2.5 - b.def : a.atk * 1.1 - b.def
this is the fix version that should work.
Thanks for tidying up my formula, ill test this and make adjustments if needed. Don't know too much abt javascript so im pretty sloppy.
Thanks for tidying up my formula, ill test this and make adjustments if needed. Don't know too much abt javascript so im pretty sloppy.
I making you the plugins. hope this work like you wanted
click here to download the script
the plugin
Yeah, that seems to be it. I removed the Hand axe check and it worked.
A plugin like Himeworks Common Event Queue might help:
I making you the plugins. hope this work like you wanted
click here to download the script
Just a small thing to point out - it's correct usage to set switches to true or false, rather than 0 like you have on line 92.

It's very unlikely to cause a problem anyplace, as the value() getter function automatically converts it to boolean, but it's better practice on your part to set it to the correct type of value in the first place.

It's theoretically possible that someone would be directly accessing the _data array and utilizing strict equality in which case the check would fail.

Original thread: https://forums.rpgmakerweb.com/threads/no-idea-why-this-switch-wont-flip.168634/