Hi all, I could use some assistance. I'm trying to use state counters as a skill resource similar to TP but I'm running into some issues. If possible, for the Warrior state, I would like the counter to increase proportional to the damage the actor is dealing. This is the code I'm using:
This is working just as it should! If the enemy's HP is 200, and the warrior deals 63 damage, his counter is increasing by 32. If the enemy's HP is 2000, and the warrior deals 63 damage, his counter is increasing by 4.
I wanted to throw in a Math.min to ensure it always increase by at least 16
but now it only increases by 16, no matter how much damage I deal. I tried changing it to
and same thing, it's always defaulting to 16. Am I using Math.min wrong? Should I be setting a minimum another way?
Code:
<Custom Apply Effect>
user._warriorStacks = user._warriorStacks || 0;
var stacks = user._warriorStacks.clamp(0, 100);
user.setStateCounter(21, 'x' + stacks);
</Custom Apply Effect>
<Custom Remove Effect>
user._warriorStacks = 0;
var stacks = user._warriorStacks.clamp(0, 100);
user.setStateCounter(21, 'x' + stacks);
</Custom Remove Effect>
<Custom Establish Effect>
if (this.isPhysical() && value > 0) {
user._warriorStacks = user._warriorStacks || 0;
var stacks = user._warriorStacks.clamp(0, 100);
stacks += Math.ceil(value * 100 / target.mhp) * user.tcr;
stacks = stacks.clamp(0, 100);
user.setStateCounter(21, 'x' + stacks);
user._warriorStacks = stacks;
}
</Custom Establish Effect>
This is working just as it should! If the enemy's HP is 200, and the warrior deals 63 damage, his counter is increasing by 32. If the enemy's HP is 2000, and the warrior deals 63 damage, his counter is increasing by 4.
I wanted to throw in a Math.min to ensure it always increase by at least 16
Code:
stacks += Math.min(16, Math.ceil(value * 100 / target.mhp)) * user.tcr;
Code:
stacks += Math.min(16, value) * user.tcr;