So the issue I'm having here is that based on a couple of variables I want the main character to use a specific move to apply statuses to themself, but for some reason that just does not work with only one move of the list, I can confirm that the variable is working properly in other cases where it's brought up so it's most likely the move or the code that is the problem, here is the code I'm using for you all to look over. Thanks for reading.
MZ Trying to figure out why only one move in an if statement won't work
RPG Maker MZ SupportWhich specific condition is actually giving you issues?
Your code is a bit hard to read so it's hard to keep track of what's going on.
Can you explain it a bit more simply?
Your code is a bit hard to read so it's hard to keep track of what's going on.
Can you explain it a bit more simply?
So the gimmick of one of the characters is that they can load different types of bullets to do different attacks, all of the other bullet types are triggering their specific attack to trigger correctly, except when there isn't a bullet. The code for there not being a bullet should theoretically work the same since the variable is just considered an "empty" bullet type.
First things first, you need to refactor that code because it's very messy and it's hurting my brain. (Sorry, it's just triggering my programming OCD brain).
If this still doesn't work then we'll have to investigate further.
What exactly is skill 236 in your database? Does it trigger normally when called from a different event? Does it have an animation?
EDIT: Also try adding `BattleManager.forceAction(subject)` when ammoType is empty.
JavaScript:
const subject = $gameActors.actor(1);
const ammoVarId = $gameVariables.value(11);
const ammoType = $gameVariables.value(ammoVarId);
const ammoActionMap = {
Bullet: 237,
Gunpowder: 238,
Blood: 239,
Acid: 240,
};
if (ammoType === "Empty") {
subject.forceAction(236, -2);
$gameMessage.add("Click");
this.setWaitMode("message");
} else if (ammoType in ammoActionMap) {
const skillId = ammoActionMap[ammoType];
subject.forceAction(skillId, -2);
BattleManager.forceAction(subject);
this.setWaitMode("action");
}
$gameVariables.setValue(ammoVarId, "Empty");
If this still doesn't work then we'll have to investigate further.
What exactly is skill 236 in your database? Does it trigger normally when called from a different event? Does it have an animation?
EDIT: Also try adding `BattleManager.forceAction(subject)` when ammoType is empty.
Thanks so much, it was indeed not having the BattleManager.forceAction(subject) line that caused the skill to not go off, thanks for the help and the refactoring!
Original thread: https://forums.rpgmakerweb.com/threads/trying-to-figure-out-why-only-one-move-in-an-if-statement-wont-work.177872/