RPG Maker Forums

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

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>
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.

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top