I’ve bee working on a timed defense mechanic for my game. There would be an aspect of that system where the player would be able to counter the enemy with their own damage on a successful defense. There’s a small problem however:
I have been using Yanfly’s Action Sequences and have it set that the action effect is set to the user, which I think the damage calc is drawing from the enemy instead of the party. If ever I wanted to add effects that boost counter damage, this may not work.
Is there a way where I can add a second damage formula to account for this, or make some way to add the party’s own damage to this mechanic?
As I had already stated above, you would make the whole formula as a .js file and put it in as a plugin... it can have every formula in your entire game so you don't need a huge list of extra files.
Then, in the database you would simply put the command to call it.
for the 2 examples I provided it would be:
a.attack(a, b)
a.flame(a, b)
Whatever you define it as in the 1st line of each section, the word after 'Game_Battler.prototype.' is what you would use in the damage formula box.
As for your other question I never answered regarding action sequences, I don't really use those any more, but back when I did use them these custom formulas worked with them just the same as any other would have.
When writing it out as javascript you can't use the shortcuts used in the database...
Your v[id] needs to be written as $gameVariables.value(id), otherwise from that it should work for you 😀
and the way the formula works whomever is the check (a.isActor or a.isEnemy) just uses the top block of code, the other would use the bottom if you are allowing both actors and enemies access to the same skill.
As for how to make it work as a counter, I would assume you just call the same formula again when you want the counter to trigger and it (should) work as expected from the victim hitting back to the attacker. if you use math.randomInt(100) to make a chance roll, you can fine tune the odds of a counter attack.
Okay, I found out what I needed to do for this.
I just had to put the damage formula as an if-else condition, and have a variable that would change upon the successful counter, for instance:
v[x] ? b.atk * 4 - a.def * 2 : (a.atk * 4 - b.def * 2) / v[y]