Conditional branch skill

Hi everyone, I'm just starting out using conditional branches, this skill being my first, and this is what I'm trying to do.

I want to add a state to the player (it gives anyone one specific element of their choosing and applies it to the player). If the opponent is of a opposite element, say I'm fire and they're earth, then there is a 1% chance, per shot, to instant kill them.

I'd like the state to last for 3 turns and within that time, ANY attack the user does has a chance to kill the enemy by 1% chance.

How would I set this up?
Hello and welcome! Please make sure to use the template as a guide when asking questions, it helps a lot in preventing back-and-forth to find out what you need exactly:


With that out of the way... are you using any plugins? What you describe can be done through common events (I think) and some scripting, but just checking as there might be an easier way depending on what you are already using.
Hello and welcome! Please make sure to use the template as a guide when asking questions, it helps a lot in preventing back-and-forth to find out what you need exactly:


With that out of the way... are you using any plugins? What you describe can be done through common events (I think) and some scripting, but just checking as there might be an easier way depending on what you are already using.
I have quite a few. Some of the standard battle core ones, and gameplay ones like this one. Is there a specific one you're looking for?
I have quite a few. Some of the standard battle core ones, and gameplay ones like this one. Is there a specific one you're looking for?
Just show a picture of your plugin list. Far easier to do that than to have others guessing.
I'm just starting out using conditional branches, this skill being my first,
OK, let's clear up a few things.

the conditional branch is an event command, not a skill. All regular skills will always have a more or less fixed result without any options.

That said, there are several different ways around that limitation. One way is to use a common event that is called by the skill, but that (while being the simplest way) has a number of limitations, and you'll need plugins to work around some of those limitations.
For example by default all common events called by skills are processed at the end of the battleturn unless you have a plugin with action sequences to tell the engine when else to process the common event.
But there are several plugins providing action sequences, and you can only use one of them - which means the above mentioned screenshot of your plugin manager is easier than us listing one or two dozen possible plugins.

one specific element of their choosing
Then you can't use conditional branches but need to use show choices - a conditional branch can only select between two options and most games have more than two elements.
I tried to send it from the first message, but it said the file was too big. I changed this format of the picture and it works now.
Assuming you're using Windows, you can just hit Win+Shift+S to take a screenshot. This will be much more compact and also maximize readability.

In any case, judging from your plugins, can we assume that you are familiar with action sequences? In that case you should be able to create a common event that does checks the state of the target using BattleManager._target.isStateAffected(N) and if yes checks for the attack element of the user using BattleManager._subject.attackElements() ... or so I thought. It seems to return 1 no matter what the attack is. Let me check what's going on.
Assuming you're using Windows, you can just hit Win+Shift+S to take a screenshot. This will be much more compact and also maximize readability.

In any case, judging from your plugins, can we assume that you are familiar with action sequences? In that case you should be able to create a common event that does checks the state of the target using BattleManager._target.isStateAffected(N) and if yes checks for the attack element of the user using BattleManager._subject.attackElements() ... or so I thought. It seems to return 1 no matter what the attack is. Let me check what's going on.
Yes, this is Windows, and the quality of the picture sucks, but I had to take it real quick before getting back to dad duties, otherwise you're right a screenshot would've been better, next time. Also thanks in advance for the help, as I'm fair at common events, like 4/10, but don't think I'd have been able to figure this out with any level of expedience.
Assuming you're using Windows, you can just hit Win+Shift+S to take a screenshot. This will be much more compact and also maximize readability.

In any case, judging from your plugins, can we assume that you are familiar with action sequences? In that case you should be able to create a common event that does checks the state of the target using BattleManager._target.isStateAffected(N) and if yes checks for the attack element of the user using BattleManager._subject.attackElements() ... or so I thought. It seems to return 1 no matter what the attack is. Let me check what's going on.
Were you able to figure out what was going wrong?
Were you able to figure out what was going wrong?
Yes... but at the same time I came to the realization that it's gonna be too wonky anyway. So... after consulting with some Jedi Masters behind the scenes... let's check on some mechanics.

For the attackers element, you basically want to have a state that says "I AM FIRE" or something (iow just a state to flag that doesn't really do anything)? And the element of the target is likewise a state? Or is it the element rate that you want to look at for the target?

If it's just a state on the target you could probably do something like the below in a state notetag.

From Battle Core
JavaScript:
<JS Pre-Damage as User>
if (target.isStateAffected(N) && Math.randomInt(100) < 1)    value = target.hp;
</JS Pre-Damage as User>

If it's the target's element rate you want to look at, something like:
JavaScript:
<JS Pre-Damage as User>
if (target.elementRate(N) > 1 && Math.randomInt(100) < 1)    value = target.hp;
</JS Pre-Damage as User>

Naturally this will snuff your allies too if they are of the specified element (like when you try to heal someone), so you would have to put in some logic to prevent that.
Yes... but at the same time I came to the realization that it's gonna be too wonky anyway. So... after consulting with some Jedi Masters behind the scenes... let's check on some mechanics.

For the attackers element, you basically want to have a state that says "I AM FIRE" or something (iow just a state to flag that doesn't really do anything)? And the element of the target is likewise a state? Or is it the element rate that you want to look at for the target?

If it's just a state on the target you could probably do something like the below in a state notetag.

From Battle Core
JavaScript:
<JS Pre-Damage as User>
if (target.isStateAffected(N) && Math.randomInt(100) < 1)    value = target.hp;
</JS Pre-Damage as User>

If it's the target's element rate you want to look at, something like:
JavaScript:
<JS Pre-Damage as User>
if (target.elementRate(N) > 1 && Math.randomInt(100) < 1)    value = target.hp;
</JS Pre-Damage as User>

Naturally this will snuff your allies too if they are of the specified element (like when you try to heal someone), so you would have to put in some logic to prevent that.
Fortunately the character using it is just an archer type so shouldn't be healing too much, however if it makes it easier for you I can just change the system to make it so the character does that insta kill if the target is under the influence of an effect (say, on fire). However, if you've ironed out the kinks I'll GLADLY take it. I hope to one day be able to do this myself, but until then I greatly appreciate the help.

Yes... but at the same time I came to the realization that it's gonna be too wonky anyway. So... after consulting with some Jedi Masters behind the scenes... let's check on some mechanics.

For the attackers element, you basically want to have a state that says "I AM FIRE" or something (iow just a state to flag that doesn't really do anything)? And the element of the target is likewise a state? Or is it the element rate that you want to look at for the target?

If it's just a state on the target you could probably do something like the below in a state notetag.

From Battle Core
JavaScript:
<JS Pre-Damage as User>
if (target.isStateAffected(N) && Math.randomInt(100) < 1)    value = target.hp;
</JS Pre-Damage as User>

If it's the target's element rate you want to look at, something like:
JavaScript:
<JS Pre-Damage as User>
if (target.elementRate(N) > 1 && Math.randomInt(100) < 1)    value = target.hp;
</JS Pre-Damage as User>

Naturally this will snuff your allies too if they are of the specified element (like when you try to heal someone), so you would have to put in some logic to prevent that.
Just to make sure I'm reading this right, in the second one I replace element rate with the specified element of the thing to check for, but what do I switch out if I say want to increase the chance to insta kill? Is the 1 after math random int?
Is the 1 after math random int?
Yes. Math.randomInt is a RM-unique function that is defined in RMMZ_core, as follows:

JavaScript:
Math.randomInt = function(max) {
    return Math.floor(max * Math.random());
};

You can review the original Math.random() function here:
Yes. Math.randomInt is a RM-unique function that is defined in RMMZ_core, as follows:

JavaScript:
Math.randomInt = function(max) {
    return Math.floor(max * Math.random());
};

You can review the original Math.random() function here:
Thanks for the help, and sorry for asking so many questions (my coding is rusty, and in rpg maker it's basically non existent at the moment).

<JS Pre-Damage as User>
if (target.isStateAffected(N) && Math.randomInt(100) < 1) value = target.hp;
</JS Pre-Damage as User>

These are the variables I change?

And I need to make states for all elements, independently, that I want to attach this to?
These are the variables I change?

And I need to make states for all elements, independently, that I want to attach this to?
Yes and yes. N is the state ID (a number) and 1 is (in this case) equal to the percentage chance the enemy will be snuffed.
Yes and yes. N is the state ID (a number) and 1 is (in this case) equal to the percentage chance the enemy will be snuffed.
Perfect. The only thing I'm still confused on is, if I use this in the note tag of the new stats, what do I add to that character's ability to make it it also checks for that?
Yes and yes. N is the state ID (a number) and 1 is (in this case) equal to the percentage chance the enemy will be snuffed.
I've been breaking my brain trying to figure this out and it doesn't seem to work. I don't know what I'm doing wrong. I've made a state and put this code in it. I've also put it in the fire status, and the burn status and nothing has helped. Were you able to get it to work? If so what did you do, outside of what I did, that helped?
I've been breaking my brain trying to figure this out and it doesn't seem to work.
I'd need a little more context so please do share screenshots of the state and the skills that apply the state. Please do try to follow the template!

I'd need a little more context so please do share screenshots of the state and the skills that apply the state. Please do try to follow the template!

The picture on the left is trying to apply it to the created state "I am Fire", and the picture on the right is applying the same latter code for applied state. I cranked the 1 integer up to 100 to see if it works first, then will revert it back to 1% once I'm sure it does.
As per the documentation, the <JS Pre-Damage as User> does not work as a skill note tag. You'd want to use <JS Pre-Damage> for skills.

In any case, let's check what we're doing here. Is my understanding correct that you want:

1. target acquires "I am Fire" state
2. target is attacked by Firecrit
3. target has a chance of dying

In that case, I think that either
a. the "I am Fire" state should have a <JS Pre-Damage as Target> note tag and not the "as user" variant
b. the "Firecrit" skill should have a <JS Pre-Damage> note tag

Also, and this may be because of the way the code is truncated in the screenshot, but I can't see the code that actually OHKO's the target. Could you double check if that is in place?

Original thread: https://forums.rpgmakerweb.com/threads/conditional-branch-skill.179866/