MV Stacking REGEN and keeping it between combat.

So im toying with the idea of having a REGEN state that heals more for each stack.

REGEN as a basic effect heals for 10% max hp per round + users.mat X (# of stacks minus 1). Lasts 3 rounds.
Casting REGEN skill will add 1 stack for 3 rounds. ==> 10% recovery x 3 rounds
Casting another instance of REGEN skill will add the same effect ==> 10% recovery + (( 2 stacks - 1 ) x user.mat) x 3 rounds

I want to have other skills and items that can extend the duration 3 ==> 6 rounds or simply add stacks of REGEN but not duration. Example an amulet that always lets the user start with 5 stacks of REGEN.

Additionally out of combat every 20 steps the user will be healed and 1 round will be removed.

Code:
<Custom Battle Effect>
user._stackingRegen = user._stackingRegen || 1;
user.setStateCounter(50, user._stackingRegen);
</Custom Battle Effect>

<Custom Apply Effect>
user._stackingRegen = user._stackingRegen || 1;
user._stackingRegen += 1;
user.setStateCounter(50, user._stackingRegen);
</Custom Apply Effect>

<Custom Regenerate Effect>
  var regenstacks = ((user.mhp * .1) + ((user._stackingRegen - 1) * user.mat)));
  var regen = Math.floor(regenstacks);
  user.gainHp(regen);
  user.startDamagePopup();
  user.clearResult();
</Custom Regenerate Effect>

<Custom Remove Effect>
user._stackingRegen = 0;
user.setStateCounter(50, user._stackingRegen);
</Custom Remove Effect>

Heres what I have for the State, I also have no idea how to get the footsteps to work.

Original thread: https://forums.rpgmakerweb.com/threads/stacking-regen-and-keeping-it-between-combat.126313/