How can I create a skill that buffs the user while also doing damage to enemies?

Hi all,

what the title says, I have trouble making it.

I found online, it should be possible with this formula:

a.addState(2);a.atk * 4 - b.def

Which didn't work but I need my skills to always do at least 1 damage, so it has to look like something like this:

a.addState(2);[35 + a.atk * 1.2 - b.def * 1, 1]max or [a.addState(2);35 + a.atk * 1.2 - b.def * 1, 1]max

But these cause a crash and error message.

Could anyone suggest something that could work?

Thanks in advance!
a.addState(2)
That is a JavaScript formula for MV or MZ. VXAce uses Ruby and so that bit of the formula should be:
a.add_state(2)
Try that and see if you still get a crash.
That is a JavaScript formula for MV or MZ. VXAce uses Ruby and so that bit of the formula should be:
a.add_state(2)
Try that and see if you still get a crash.
I used this and added it in various place in the formula, unfortunately it still crashed...
a.add_state(2);[35 + a.atk * 1.2 - b.def, 1].max
a.add_state(2);[35 + a.atk * 1.2 - b.def, 1].max
Thanks this works with states!

If I want to add an atk buff:
a.add_param(2);[35 + a.atk * 1.2 - b.def, 1].max isn't doing any damage, but neither do I get a crash.
Attack buffs are usually handled through states. It's the most straightforward way and easiest to debug. It also allows you to customise your buff exactly the way you want. For example, the default buff lasts 5 turns. You might only want it to last 3 turns.

Create a state; for this example we'll say it's state 67
a.add_state(67); damage formula
add_param is not a buff, but would permanently increase the parameter

one thing to keep in mind:
if a function works but does not return a valid number, then the engine will assume zero damage.
a crash will only happen if the formula itself contains errors.
That is what might happen here

I think you need more care to find out what the functions you found somewhere do before using them - above you tried functions for the wrong maker and wrong language and then a function that had different use.
Attack buffs are usually handled through states. It's the most straightforward way and easiest to debug. It also allows you to customise your buff exactly the way you want. For example, the default buff lasts 5 turns. You might only want it to last 3 turns.

Create a state; for this example we'll say it's state 67
a.add_state(67); damage formula
I did that instead, thank you very much!

@Andar you are right, I should have made sure it was for VXAce and not MV or MZ. But thanks for explaining the mechanics!

Also @everyone, I thought I said that in my first post but I didn't so with a minor delay: Happy New Year!😀

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-create-a-skill-that-buffs-the-user-while-also-doing-damage-to-enemies.174368/