Dealing Increased Damage with Multiple States

Hi I'm working on a game where I'm trying to have a single skill deal different damage based on whether the target is poisoned, bleeding, or both. My plugins that I'm working with include yanfly's damage core, yanfly's buff states core, and yanfly's battle engine core. Note that these are not all of the plugins in use they are just the ones I thought would be applicable for this situation. The current note tag I have been working on trying to figure this problem out is this so far:

<damage formula>
if (target.isStateAffected(28))
if (target.isStateAffected(4))
{
value = a.atk * 50
} else
if (target.isStateAffected(28))
{
value = a.atk * 30
} else
if (target.isStateAffected(4))
{
value = a.atk * 15
} else
{
value = a.atk * 5
}
</damage formula>

With the note tag above it currently deals damage only when the target is bleeding(28) or bleeding(28) and poisoned(4), but it does not have the base attack(which should be the a.atk * 5) or deal damage when the target is poisoned(4). Any help would be greatly appreciated as I am not very good with the programming part of this yet. Still learning so if its not possible to do then that's ok too just feels like something that should be.
Are you using Yanfly's plugins? Do you have the State Category one? This plugin can help you solve this in a very easy way. If you have it, I think I can help you a bit.
Are you using Yanfly's plugins? Do you have the State Category one? This plugin can help you solve this in a very easy way. If you have it, I think I can help you a bit.
I am using a lot of yanfly's plugins, but until you mentioned it I didn't realize there was a states categories one. I have it installed now, but I'm still not quite sure how to get the effect I want using it.
I don't see how the states categories would benefit you, as you have different calculations for each state. The problem is in your incorrect JavaScript syntax. In fact, I'm having a hard time figuring out exactly what you're going for, because your if/else conditionals and the braces are so inconsistently formatted that I'm not sure what your intended logic is.

Any time you're putting code into a forum post, you should always use the code tag (the </> icon) so that it preserves your indents and brackets. I think JamesRyan would probably have seen your problem straight off if it were more visually obvious.

So here's what I think you want, with provided comments - if any of it isn't what you meant, just change that part.
Code:
<damage formula>
if (target.isStateAffected(28)) // If target is bleeding
{
    if (target.isStateAffected(4)) // If target is bleeding AND poisoned
        value = a.atk * 50;
    else // Target is JUST bleeding
        value=a.atk*30;
}
else if (target.isStateAffected(4)) // If target is JUST poisoned
    value = a.atk * 15;

else // Target has neither harmful status
    value = a.atk * 5;
</damage formula>
I don't see how the states categories would benefit you, as you have different calculations for each state. The problem is in your incorrect JavaScript syntax. In fact, I'm having a hard time figuring out exactly what you're going for, because your if/else conditionals and the braces are so inconsistently formatted that I'm not sure what your intended logic is.

Any time you're putting code into a forum post, you should always use the code tag (the </> icon) so that it preserves your indents and brackets. I think JamesRyan would probably have seen your problem straight off if it were more visually obvious.

So here's what I think you want, with provided comments - if any of it isn't what you meant, just change that part.
Code:
<damage formula>
if (target.isStateAffected(28)) // If target is bleeding
{
    if (target.isStateAffected(4)) // If target is bleeding AND poisoned
        value = a.atk * 50;
    else // Target is JUST bleeding
        value=a.atk*30;
}
else if (target.isStateAffected(4)) // If target is JUST poisoned
    value = a.atk * 15;

else // Target has neither harmful status
    value = a.atk * 5;
</damage formula>
Thank you very much this did exactly what I was aiming for. As you can tell I am no code writer. I've been self teaching with videos and forums as best as I can, but I still, obliviously, have a long way to go. That being said I am still interested to hear what the idea with the states category plugin was and if it would work better.
That being said I am still interested to hear what the idea with the states category plugin was and if it would work better.
As I said, I can't see how it would help. Perhaps JamesRyan had something clever in mind that's not occurring to me, but the only thing the categories would do is let you tag your poison and bleed with, say, a "debuff" category.

Then you'd replace the three conditionals in your code with a switch statement for the count of how many debuff states the target has on them, and calculate your multiplier based off of that.

The code would be about the same size, you'd have to add the notetags to the states, and you'd have an extra plugin that you might not need to use for anything else. ¯\_(ツ)_/¯
As I said, I can't see how it would help. Perhaps JamesRyan had something clever in mind that's not occurring to me, but the only thing the categories would do is let you tag your poison and bleed with, say, a "debuff" category.

Then you'd replace the three conditionals in your code with a switch statement for the count of how many debuff states the target has on them, and calculate your multiplier based off of that.

The code would be about the same size, you'd have to add the notetags to the states, and you'd have an extra plugin that you might not need to use for anything else. ¯\_(ツ)_/¯
Ah ok thank you.
I'm not sure if my idea fits yours, but what I am thinking is to make use of the number of states that affected your characters based on their categories. For example, each state of the category "Poison" will increase your damage by 5, and each of the category "Slow" will increase your damage by 10. So if you are affected by 3 states categorized into "Poison" and 2 states categorized into "Slow", your damage will increase by 3*5 + 2*10. That will be faster than checking each state.
I'm not sure if my idea fits yours, but what I am thinking is to make use of the number of states that affected your characters based on their categories. For example, each state of the category "Poison" will increase your damage by 5, and each of the category "Slow" will increase your damage by 10. So if you are affected by 3 states categorized into "Poison" and 2 states categorized into "Slow", your damage will increase by 3*5 + 2*10. That will be faster than checking each state.
Ok I think I understand what you're meaning. I'm not nearly finished with this game yet so maybe I'll try that on a different set of abilities. Just would have to figure out the damage formulas I'm sure. Thanks for all your help and your time. It is greatly appreciated.

Original thread: https://forums.rpgmakerweb.com/threads/dealing-increased-damage-with-multiple-states.141007/