Battle formula issues. Unsure if it's me, or plugins?

Hello, all!

I'm messing in areas I'm still learning. I was wondering if there was a kind soul here who can look at my formulas and educate me (gently) as to where I've gone wrong? I've got two skills that are frazzling my head.

Apologies if this isn't the right area to ask about this.

I've been using this thread as a reference: Damage Formulas 101 RPGMaker Forum

I've been working on combat generally following gameplay feedback. All spells/abilities were working fine until I introduced extra elements, states, and went about trying to be fancy with formulas.
A case of once again "I have a cool idea!" and being a bull in a china shop. ;_;
For reference, I am using Visustella plugins. A lot of them. I strongly suspect my formulas are the issue, though.

A lot of the stuff is working great. I've got fire spells that cause burning, water spells that remove burning but soak instead, etc.
I then focused on some of the melee classes I have.

Skill 1:
I made a 'sunder' skill.
Spoiler: Screenshot of Skill
[IMG]https://iili.io/JzOPQ2a.png[/IMG]
The description says it 'stacks' but the states below are made to give the illusion this is a stacked ability.
I created three states:
Sunder 1 (*85 defs)
Sunder 2 (*75 defs)
Sunder 3 (*65 defs)
Spoiler: Screenshot of state
[IMG]https://iili.io/JzOPZYJ.png[/IMG]
The idea would be that the ability checks for an applied state. if sunder 1 is present, remove it and add sunder 2, etc... it's in the formula below.
I didn't add any of the states to the "effects" area as I figured that would conflict with the formula?
This class is a tank class and uses def and atk stats to calculate damage, so that's not a typo 🙂 (some classes use a synergy of two stats in this way)

Formula:
Code:
if (b.isStateAffected(91)) b.removeState(91) b.addState(92);elseif (b.isStateAffected(92)) b.removeState(92) b.addState(93); elseif (b.isStateAffected(93) b.addState(93); else (b.adddState(91); end;(a.def * 2) + (a.atk * 2)
I feel the code before ';' is not working, as the attack element at the end does.

Skill 2:
This skill is supposed to deduct some MP and HP at the same.
I don't want to remove an MP percentage, I know this is possible using the effects bit. The skill would be too powerful versus such as boss fights where larger MP pools are used if I did it that way.

The Conviction skill:
Hit a target with a big sword. Hurt MP as well as HP.
Spoiler: Image of skill in db
[IMG]https://iili.io/Jze30e2.png[/IMG]

I found an older post with this formula, and even before trying to tweak it, it wasn't having the desired effect:
Code:
b.gainMP(-(a.mat + b.mdf * 0.5)); a.atk * 4 - b.def * 0.5;

This ability does 0 damage. Every enemy I've tested has MP, it's mind boggling.

Any tips/pointers? Or are the formulas okay and my problem is somewhere else?
If an error occurs when evaluating the formula, e.g. "gainMP is not a function", the result will be 0.
  1. Sunder: many problems, try this instead?

    if (b.isStateAffected(91)) { b.removeState(91); b.addState(92); } else if (b.isStateAffected(92)) { b.removeState(92); b.addState(93); } else if (b.isStateAffected(93)) b.addState(93); else b.addState(91); a.def * 2 + a.atk * 2

  2. Conviction: code is case-sensitive, try this instead?

    b.gainMp(-(a.mat + b.mdf * 0.5)); a.atk * 4 - b.def * 0.5
    Damage dealt will be dependent on the values of the subject & target param values (a.mat, b.mdf, a.atk, b.def).
Note for actors with Autobattle trait: by default the engine evaluates the formula of every available action on every eligible target to decide which one they should use. I think that'd allow the states/MP loss to be applied whenever an Autobattle actor considers using these skills on someone. Plugins might extend this logic to enemies.
Ah! To summarise where I'm going wrong...

For Sunder, basically a whole mess. I can see where you've made the changes, and I think I understand the brackets and semi-colon positioning, and that 'elseif' error I made.

Result is perfect:
Spoiler: Snips
[IMG]https://iili.io/JzkJxTP.png[/IMG]
[IMG]https://iili.io/JzkJnyB.png[/IMG]

Conviction... only difference I can see is I had a semi-colon at the end? Though I couldn't get this to work until I copy/pasted your code into the DB so I'd clearly borked something else up there.
Result: (I'll clean up the values/decimal in plugins)
Spoiler: Snip
[IMG]https://iili.io/Jzk2hp2.png[/IMG]

Thank-you so very much 🙂
Conviction... only difference I can see is I had a semi-colon at the end?
Conviction: code is case-sensitive

You just need to be much more attentive to detail when you're trying to type code. Everything from spaces between words to spelling and capitalization must be exactly correct.
Quite right!!
Even looking between the posts I didn't see the difference between MP and Mp.

I'm making myself another reference sheet, I'm going to put these on in big fonts and wear my old lady glasses so I get it right going forwards.
I'm just glad it was me that mucked up in the formulas, and not a plugin issue...

Original thread: https://forums.rpgmakerweb.com/threads/battle-formula-issues-unsure-if-its-me-or-plugins.163553/