- Joined
- Apr 18, 2013
- Messages
- 1,226
- Reaction score
- 603
- First Language
- English
- Primarily Uses
- RMMV
I have created a state that adds a damage shield to the actor based on their luk stat. It works as is. The problem I'm having is coming up with a way to make the state stack. Currently, when the state is reapplied, it just resets the state counter to the original formula of Math.floor(user.luk * 2)
Technically this is okay, it is what I originally wanted. However, if possible I'd like to make it so that the state counter will add itself to whatever the current value is. So lets say the actors luk stat is 20, the state is applied and the actor will receive a damage shield of 40 = luk * 2. Lets say the actor takes 5 damage, so the state counter (the damage shield) is reduced to 35. If I reapply the state to the actor the next turn, the state counter returns to 40 (= luk * 2). Instead what I would like to happen is the state counter change to 75 (the original 35 plus another 40 based on the formula of Math.floor(user.luk * 2)).
Below is the states note tag box contents
I've been trying to figure this out for a day or so and I'm stumped. Hopefully someone can help me, thanks in advance.
Technically this is okay, it is what I originally wanted. However, if possible I'd like to make it so that the state counter will add itself to whatever the current value is. So lets say the actors luk stat is 20, the state is applied and the actor will receive a damage shield of 40 = luk * 2. Lets say the actor takes 5 damage, so the state counter (the damage shield) is reduced to 35. If I reapply the state to the actor the next turn, the state counter returns to 40 (= luk * 2). Instead what I would like to happen is the state counter change to 75 (the original 35 plus another 40 based on the formula of Math.floor(user.luk * 2)).
Below is the states note tag box contents
Code:
<Custom Apply Effect>
// The number of damage before the shield wears off.
user._Protect = Math.floor(target.luk * 2);
// Set the state counter to display damage shield amount left.
user.setStateCounter(stateId, user._Protect);
</Custom Apply Effect>
<Custom Remove Effect>
// Remove the damage needed to expire the shield.
user._Protect = undefined;
// Reset the state counter.
user.setStateCounter(stateId, 0);
</Custom Remove Effect>
<Custom React Effect>
// Check if the action deals HP damage.
if (this.isHpEffect() && value > 0) {
// Play an animation on the target.
target.startAnimation(53);
// Calculate the amount of HP to reduce.
var reduce = Math.min(value, target._Protect);
// Reduce that from the value.
value -= reduce;
// Reduce that value from the shield amount.
target._Protect -= reduce;
// Set the state counter to reflect the new damage shield amount left
target.setStateCounter(stateId, target._Protect);
// Create a text to display.
var text = "<CENTER>" + target.name() + "'s protection aura blocks " + reduce + " damage."
// Set the wait time.
var wait = 90;
// Display the text.
BattleManager.addText(text, wait);
}
// Check if the damage shield is exhausted
if (target._Protect <= 0) {
// Then remove the state.
target.removeState(stateId);
}
</Custom React Effect>

