Skill damage Formulas removing and adding states

Hello, everyone, I am very new to RPG Maker and am currently working on my first game. One problem I am having is I want a class that works like this:


Skill A applies Buff A to the user and removes Buff C.


Skill B applies Buff B to the user and removes Buff A


Skill C applies Buff C to the user and removes Buff B.


Buff A increases the damage of Skill B


Buff B increases the damage of Skill C


Buff C increases the damage of Skill A


I believe I am very close to getting it, but I just can't figure out how to. When I use a.add_state(37); a.state?(39)? a.atk * 4 : a.atk * 1 - b.def * 2;  a.remove_state(39)  it applies the buff and removes the other buff correctly, but the damage is null. I can get it to work when I remove the last part, making it a.add_state(37); a.state?(39)? a.atk * 4 : a.atk * 1 - b.def * 2;  That applies the buff and accurately increases the damage if the required buff is up, the problem is the buff I want removed isn't.  Does anyone know how I can create a formula that achieves what I am after?


This is my first time on the forums, and I am not sure if I posted this is the right place, I looked through the forums and this is the closest I think. Sorry if if's not.
The damage is always the last processed number of the damage formula - you need to reorder the commands in a way that the damage number is the last part.


If the conditions are too difficult for that, you can make a temporary variable holding the damage result and place that at the end
As Andar mentioned, you need the damage to be the last thing that's evaluated.  Of course, if you put the remove state, the conditional will result in "false" every time!  We can fix that by storing the damage in a local variable and then calling it a moment later:


c = (a.state?(39) ? a.atk * 4 : a.atk * 1 - b.def * 2); a.add_state(37); a.remove_state(39); c


I think that should work.


By the way, this is not the right subforum to post such a question - post in the appropriate "Help" subforum instead (each Maker has its own Help subforum here).  Game Mechanics Design is for discussing qualitative design topics like "would this type of battle system be fun" or "how do I balance my game's economy".  Don't worry though - tons of people make that mistake.

Original thread: https://forums.rpgmakerweb.com/threads/skill-damage-formulas-removing-and-adding-states.55506/