I'm trying to program a skill that has a 50% chance to apply debuffs to either your enemy or yourself. I'm somewhat familiar with javascript and wrote up a simple if x = 1 do this, or if it's = to 2 do that, but I keep getting the above error. It changes from a to b every once in a while, so at least the if statement works, but the rest of it just breaks down. Can anyone help me out? I've attached a picture of the code for reference.
Reference Error: a is not defined
RPG Maker MV Supporta and b are only valid in the context of damage formula and maybe plugins. They mean nothing in a common event.
Also get rid of the == 0 in the top line. That is setting x to a true/false value. Technically, true equates to 1 (or anything other than 0) but if you're comparing x == 1 then you shouldn't be setting x to a boolean.
Also get rid of the == 0 in the top line. That is setting x to a true/false value. Technically, true equates to 1 (or anything other than 0) but if you're comparing x == 1 then you shouldn't be setting x to a boolean.
In that case, how can I go about applying a state through a common event?
Yeah, that whole thing should just be in the damage formula of the skill.
It doesn't affect your code working, but your x variable is pointless - especially since you only use it once, you can just say
It doesn't affect your code working, but your x variable is pointless - especially since you only use it once, you can just say
Code:
if (Math.floor(Math.random()*2)==0)
{
...
}
else
{
...
}
Original thread: https://forums.rpgmakerweb.com/threads/reference-error-a-is-not-defined.141333/