Custom Skill with random effects not activating properly.

Hello, I came here to ask for some help with a custom skill I am trying to make, as I am not the best at programming.
The skill is supposed to inflict one enemy with one status effect chosen from 4 provided ones. I have gotten it to partially work, but during test battles this keeps happening:
Actor uses the skill on enemy
"It had no effect"
the enemy attacks
And then an effect is applied after all as the enemy gains a status effect (though also sometimes no status effect is applied at all, which is another issue)

Here are what the skill and the common event I use for it looks like, any suggestions where things might be wrong is appreciated. I also tried to switch targets around in the change enemy status between the entire troop or one of the ? listed below that option, didn't help, though.

Screenshot 2023-02-21 110116.jpg


Screenshot 2023-02-21 110144.jpg
your problem is that the common event is processed independently of the skill - and nothing in the default engine can change that.

One solution would be to use action sequences to tell the engine when to use the common event and to override the no effect message.
But I don't know how that works with MZ/Visustella
Beyond what @Andar indicated above, I am also confused by your Common Event.

You have a control Variable randomly selecting a number from 1-4, but then your Conditional Branches are confusing with what looks like 4 other Variables and nested Conditional Branches that don’t need to be nested.

I would have just expected 4 Conditional Branches that check the value of the Random Variable without any Else Branches or nesting.

If Variable # = 1 then apply whatever state.

If Variable # = 2 then apply a different state.

ETC.

But I could be looking at this completely wrong.
I am also confused by your Common Event...But I could be looking at this completely wrong.
You're not wrong, the logic is incorrect 😉

@GenoTaurus The reason you're getting all these "nothing happened" messages is because for some reason you're setting four variables to random values, then only checking for one value on each.

Following your conditional branches, you will only see something happen if:
Poison1 = 1 (2-4 nothing happens)
Silence2 = 2 (1, 3-4 nothing happens)
Blind3 = 3 (1-2, 4 nothing happens)
Confusion4 = 4 (1-3 nothing happens)

So there's a 75% chance that none of the code in your event will execute. What you want, I think, is to use one variable like Zombie said so that there is a 100% chance for something to happen.

It doesn't matter whether you use Else and nest the Conditionals or not, but using one variable is the logical way to go.
The reason you're getting all these "nothing happened" messages is because for some reason you're setting four variables to random values, then only checking for one value on each.
While the logic OP is using is definitely wrong like you say, I'm pretty sure the messages they're getting is because of what Andar said. The common event is independent of the skill, so even if the logic was correct, that message would still appear as the skill doesn't actually have any effects of its own.

@GenoTaurus Once you fix your common event up, as is mentioned in the posts above mine, have your skill add a blank state to the enemies to ensure you don't get the "there was no effect" message and add a command to remove that state in your conditional branch.
I'm pretty sure the messages they're getting is because of what Andar said...have your skill add a blank state
Good call.
While the logic OP is using is definitely wrong like you say, I'm pretty sure the messages they're getting is because of what Andar said. The common event is independent of the skill, so even if the logic was correct, that message would still appear as the skill doesn't actually have any effects of its own.

@GenoTaurus Once you fix your common event up, as is mentioned in the posts above mine, have your skill add a blank state to the enemies to ensure you don't get the "there was no effect" message and add a command to remove that state in your conditional branch.
Could you elaborate a bit on that "add a blank state and later remove it" suggestion? From what I understood this should be a cleaner version which should hopefully remove some of the unwanted no effect chances, but where to go from there?
Screenshot 2023-02-21 180601.jpg
If you loosen your expectations, you can do this in a much easier fashion!

In the skill itself, just make state rate: Poison 25%, state rate: Silence 25%, etc. Sure, the enemy might get more than one status, or none at all, but in my experience with a similar ability, it rarely fails to inflict at least one.

Though you'll want to make sure the success rate is 100% on cast and not 95%, unless you really want a good chance of the spell doing nothing.

(Edited for clarification)
Could you elaborate a bit on that "add a blank state and later remove it" suggestion?
Screenshot 2023-02-21 124424.jpg
Screenshot 2023-02-21 124522.jpg

From what I understood this should be a cleaner version which should hopefully remove some of the unwanted no effect chances
...no? You've fundamentally not changed the logic of your event. You only took them out of the nested Else branches.

You are still using four variables and looking at one value of each. The only thing you've accomplished is allowing all four states to potentially apply at the same time.

Going by your original post, this is not what you want to happen. If so, did you read my prior post, #4?

If this is what you want to happen, then there's zero reason for an event and you can simply add the states normally as Imperial_Steele said.
his should be a cleaner version
it still contains the logic error.

you need to use ONE variable, not four like you're using.

control variable 'state attached' = random 1..4 if state attached = 1 apply poison if state attached = 2 apply silence if state attached = 3 apply blind if state attached = 4 apply confusion
it still contains the logic error.

you need to use ONE variable, not four like you're using.

control variable 'state attached' = random 1..4 if state attached = 1 apply poison if state attached = 2 apply silence if state attached = 3 apply blind if state attached = 4 apply confusion
Ooooh now I get it, thank you! Like I mentioned, I am not really experienced in this type of stuff its all just a bit of me trying things out for a little part time project.
View attachment 253910
View attachment 253911


...no? You've fundamentally not changed the logic of your event. You only took them out of the nested Else branches.

You are still using four variables and looking at one value of each. The only thing you've accomplished is allowing all four states to potentially apply at the same time.

Going by your original post, this is not what you want to happen. If so, did you read my prior post, #4?

If this is what you want to happen, then there's zero reason for an event and you can simply add the states normally as Imperial_Steele said.
So the blank state is simply one I add to the skill which I then remove per the code? And I did read the prior post, I just didn't understand it apparently, sorry.
So the blank state is simply one I add to the skill which I then remove per the code? And I did read the prior post, I just didn't understand it apparently, sorry.
That's exactly right. It's only used to give the skill something to do to avoid it telling the player that there was no effect.

Original thread: https://forums.rpgmakerweb.com/threads/custom-skill-with-random-effects-not-activating-properly.155164/