Yanfly stockpile spit up 5 stacks instead of 3

I tried to increase the number of stockpiles to five but it ends in syntax error.

this is the inital code
Code:
<Damage Formula>
// Check if the stockpile damage hasn't already been calculated
if (!this._stockpileDmg) {
  // Default the user's stockpile stacks to 1
  a._stockpile = a._stockpile || 1;
  // If the stockpile stack is 1
  if (a._stockpile === 1) {
    // Use this formula
    this._stockpileDmg = a.atk * 4;
  // If the stockpile stack is 2
  } else if (a._stockpile === 2) {
    // Use this formula
    this._stockpileDmg = a.atk * 8;
  // Otherwise if it's more
  } else {
    // Use this formula
    this._stockpileDmg = a.atk * 16;
  }
}
// Set the damage equal to the calculated damage
value = this._stockpileDmg;
</Damage Formula>

<Custom Requirement>
// Default the user's stockpile stacks to 0
user._stockpile = user._stockpile || 0;
// If the user is at 0 stacks
if (user._stockpile <= 0) {
  // The skill will be disabled
  value = false;
}
</Custom Requirement>

<After Eval>
// Remove the stockpile state
user.removeState(312);
</After Eval>




this is what I tried to do:
Code:
<Damage Formula>
// Check if the stockpile damage hasn't already been calculated
if (!this._stockpileDmg) {
  // Default the user's stockpile stacks to 1
  a._stockpile = a._stockpile || 1;
  // If the stockpile stack is 1
  if (a._stockpile === 1) {
    // Use this formula
    this._stockpileDmg = 20;
  // If the stockpile stack is 2
  } else if (a._stockpile === 2) {
    // Use this formula
    this._stockpileDmg = 40;
// If the stockpile stack is 3
  if (a._stockpile === 3) {
    // Use this formula
    this._stockpileDmg = 60;
// If the stockpile stack is 4
  if (a._stockpile === 4) {
    // Use this formula
    this._stockpileDmg = 80;
  // Otherwise if it's more
  } else {
    // Use this formula
    this._stockpileDmg = 100;
  }
}
// Set the damage equal to the calculated damage
value = this._stockpileDmg;
</Damage Formula>

<Custom Requirement>
// Default the user's stockpile stacks to 0
user._stockpile = user._stockpile || 0;
// If the user is at 0 stacks
if (user._stockpile <= 0) {
  // The skill will be disabled
  value = false;
}
</Custom Requirement>

<After Eval>
// Remove the stockpile state
user.removeState(91);
</After Eval>
My guess from looking up Yanfly's Stockpile code is this:

Code:
<Custom Apply Effect>
// Default the stockpile stacks to 0.
user._stockpile = user._stockpile || 0;
// Increase the stockpile stack by 1
user._stockpile += 1;
// Cap the stockpile stack at 3
user._stockpile = Math.min(user._stockpile, 3);
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._stockpile);
</Custom Apply Effect>

Or more importantly this line.

Code:
// Cap the stockpile stack at 3
user._stockpile = Math.min(user._stockpile, 3);

You want to change that 3 to a 5.

Edit:

Sorry I looked at your code a little more carefully (the way it is formatted here is terrible on the eyes).

Code:
if (!this._stockpileDmg)
{
      // Default the user's stockpile stacks to 1
      a._stockpile = a._stockpile || 1;
      // If the stockpile stack is 1
      if (a._stockpile === 1)
      {
        // Use this formula
        this._stockpileDmg = 20;
       // If the stockpile stack is 2
       }
    else if (a._stockpile === 2)
    {
        // Use this formula
        this._stockpileDmg = 40;
        // If the stockpile stack is 3
          if (a._stockpile === 3)
          {
            // Use this formula
            this._stockpileDmg = 60;
            // If the stockpile stack is 4
              if (a._stockpile === 4)
              {
                // Use this formula
                this._stockpileDmg = 80;
                // Otherwise if it's more
              }
              else
              {
                // Use this formula
                this._stockpileDmg = 100;
              }
           }

I made the code a little bit easier to read now. As you can see, not only are you missing braces, you are nesting the newer conditions in the else if, which is not what you want.
You're a lifesaver! Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-stockpile-spit-up-5-stacks-instead-of-3.88801/