MZ Can't manage to create a functional Stacking System

Greetings! First time posting in this forum so please forgive me for any failures in terms of conduct or terminology.

So! I've been wanting to make a fangame for the Project Moon game series. But one specific hurdle always comes up, adding a stacking effects system. In Project Moon games (Specifically Ruina and Limbus), effects exist that stack on those who have them. Using burn as an example (As it's one of the simpler effects) "Burn is a status effect that deals bonus fixed damage to the afflicted unit. At the end of a turn, the unit with Burn will take fixed damage equal to Burn Potency, and the Burn Count will be reduced by 1."

Another aspect that I can't find out how to manage is making the stacks have two separate aspects. Which are potency and count. The count is how much of the effect is on the enemy, and the potency is how much it'll damage the carrier when the criteria are met. When the count hits 0, the effect goes away. This second aspect isn't one I NEED, but I would LIKE to have for the system.

The effect stacks vary on what they do: burn does damage at the end of the turn equal to potency, bleed does damage upon the afflicted attempting an attack equal to potency, and rupture does damage upon the afflicted being hit equal to potency. Though the issue I am getting stuck on is simply adding stacks, I've looked through many guides and they never actually worked. Plus, most of them do have one flaw that I don't care for. In the Project Moon games, the stacks can go up to 99 (Unless specified) every single stack guide I've found requires each stack to be a seperate status.

Apologies if this question has already been answered, and if the wording is confusing. My question is simply this: How can I add a Stacking effect System to MV that can go up to 99? (If possible: Also adding a potency count) I am fine with using Plugins as long as they're free.
How can I add a Stacking effect System to MV that can go up to 99
this is the MZ section and im unsure of if you actually mean MV or MZ, but in the case of either you could get it done with either Yanfly's buffs and states core for MV or Visustella's battle core for MZ.

You'd have to use the JS notetags, but it'd allow you to apply states, keep a stack property that you can manipulate however you need, and has timing notetags to run your damage effects and have them use the stack property to calculate the damage.

Theres a yanfly tips and tricks entry that does most of what you need in MV.
Itll be slightly different for MZ, but Trihan has an adaptation already made
this is the MZ section and im unsure of if you actually mean MV or MZ, but in the case of either you could get it done with either Yanfly's buffs and states core for MV or Visustella's battle core for MZ.

You'd have to use the JS notetags, but it'd allow you to apply states, keep a stack property that you can manipulate however you need, and has timing notetags to run your damage effects and have them use the stack property to calculate the damage.

Theres a yanfly tips and tricks entry that does most of what you need in MV.
Itll be slightly different for MZ, but Trihan has an adaptation already made
Originally I was using MV, though a day or two ago I managed to purchase MZ. So that's what I'm using for the project. Sorry if that wasn't clear, just went off how the files seem to label it as RMMZ rather than simply MZ.

Though, anyways. I have tried to find a way to download Visustella. But I cannot find a way to access the plugins outside of the wave 8 pack (100 dollars) or the Sample Game Project. I am assuming the issue is coming from me not thinking clearly though, as I bet the plugins will come with the sample game project.

Thanks! I'll give it a try and get back to you
Though, anyways. I have tried to find a way to download Visustella. But I cannot find a way to access the plugins outside of the wave 8 pack (100 dollars) or the Sample Game Project
Youre meant to grab the sample project. it contains up-to-date versions of all their freely available plugins.
Youre meant to grab the sample project. it contains up-to-date versions of all their freely available plugins.
Alright! So the stacking system is working, now the only issue is getting two of the basic effects from Project Moon working with it. Though I assume I should make a seperate post for that.

Thanks for the help, Robro!
Though I assume I should make a seperate post for that.
Eh, theyre related enough to benefit from being the same thread IMO. by the other two, I take it you mean rupture and bleed not being end of turn like burn?

you'd just need to use a different timing notetag for each. sounds like <JS Post-Damage as Target> for rupture and <JS Post-Start Action> for bleed. Im not sure if youll need to have to add a call to force a damage popup from them, but most of the code otherwise would be the same. You'd likely just need to add a few more conditions depending to limit what actions/damage triggers those effects
Eh, theyre related enough to benefit from being the same thread IMO. by the other two, I take it you mean rupture and bleed not being end of turn like burn?

you'd just need to use a different timing notetag for each. sounds like <JS Post-Damage as Target> for rupture and <JS Post-Start Action> for bleed. Im not sure if youll need to have to add a call to force a damage popup from them, but most of the code otherwise would be the same. You'd likely just need to add a few more conditions depending to limit what actions/damage triggers those effects
Alright! So <JS Post-Start Action> works for Bleed, while for some reason Rupture isn't working with <JS Post-Damage as Target>. I did also try <JS Post-Damage as User> and that also didn't work. Perhaps I am missing something in the code?

The working Bleed Code
Code:
<JS On Add State>
  target.Bleed ??= 0;
  target.Bleed++;
</JS On Add State>

<JS On Erase State>
  delete target.Bleed;
</JS On Erase State>

<JS Pre-Regenerate>
  target.Burn ??= 0;
  const stacks = Math.min(5, target.Bleed);
  const damage = stacks * 1;
  $gameTemp.requestAnimation([target], 2);
  target.gainHp(-damage);
</JS Pre-Regenerate>

The non-working Rupture code

Code:
<JS On Add State>
  target.Rupture ??= 0;
  target.Rupture++;
</JS On Add State>

<JS On Erase State>
  delete target.Rupture;
</JS On Erase State>

<JS Post-Damage as Target>
  target.Rupture ??= 0;
  const stacks = Math.min(5, target.Rupture);
  const damage = stacks * 1;
  $gameTemp.requestAnimation([target], 2);
  target.gainHp(-damage);
<JS Post-Damage as Target>
for some reason Rupture isn't working with <JS Post-Damage as Target>. I did also try <JS Post-Damage as User> and that also didn't work. Perhaps I am missing something in the code?
yeah, that right there might be the popup thing i mentioned. Im uncertain off the top of my head if VS handled that aspect differently and the code looks correct at a glance (although conditions should be added. right now, healing "hits" would also trigger it). Can you confirm no extra damage was dealt? dont rely on the popups. set your testing skill to do a flat amount of damage and check the battler's hp before and after the hit.

if they are taking extra damage then you'd just need a target.startDamagePopup() after the damage is dealt to show it. otherwise, i'd have to look closer at the code and try it out later.
yeah, that right there might be the popup thing i mentioned. Im uncertain off the top of my head if VS handled that aspect differently and the code looks correct at a glance (although conditions should be added. right now, healing "hits" would also trigger it). Can you confirm no extra damage was dealt? dont rely on the popups. set your testing skill to do a flat amount of damage and check the battler's hp before and after the hit.

if they are taking extra damage then you'd just need a target.startDamagePopup() after the damage is dealt to show it. otherwise, i'd have to look closer at the code and try it out later.
So! 1. TURNS OUT I MIXED UP BURN AND BLEED'S CODE, MEANING BLEED ACTUALLY ALSO AIN'T WORKING. and 2. Tried to set the damage to a solid amount and it still didn't (Set it to 30 per stack, the enemies I'm testing with it have 30 health). Burn so far is the only one working as intended.
so, testing what you currently have, rupture works. things to note, you didnt have the / in the closing tag for it, I forgot that <JS On Add State> was from the skill and states core and not the battle core (so if you dont have it, add it), and It does do one of popup things i expected it to do.

try this for rupture. keep the other notetags
Code:
<JS Post-Damage as Target>
  if (this.isDamage() && value > 0){
    var result = JsonEx.makeDeepCopy(target._result);
    target.clearResult();

    target.Rupture ??= 0;
    const stacks = Math.min(5, target.Rupture);
    const damage = stacks * 1;
    $gameTemp.requestAnimation([target], 2);
    target.gainHp(-damage);
    target.startDamagePopup();

    target.clearResult();
    target._result = result;
  }

</JS Post-Damage as Target>
it should only trigger when an action does damage, and should show a separate popup for this effect doing damage.

For bleed, im just following the conventions you used for rupture, but try this alongside your other tags:
Code:
<JS Post-Start Action>
  target.Bleed ??= 0;
  const stacks = Math.min(5, target.Bleed);
  const damage = stacks * 1;
  $gameTemp.requestAnimation([target], 2);
  target.gainHp(-damage);
  target.startDamagePopup();
</JS Post-Start Action>

Also make sure to save your project any time you adjust notetags between tests
so, testing what you currently have, rupture works. things to note, you didnt have the / in the closing tag for it, I forgot that <JS On Add State> was from the skill and states core and not the battle core (so if you dont have it, add it), and It does do one of popup things i expected it to do.

try this for rupture. keep the other notetags
Code:
<JS Post-Damage as Target>
  if (this.isDamage() && value > 0){
    var result = JsonEx.makeDeepCopy(target._result);
    target.clearResult();

    target.Rupture ??= 0;
    const stacks = Math.min(5, target.Rupture);
    const damage = stacks * 1;
    $gameTemp.requestAnimation([target], 2);
    target.gainHp(-damage);
    target.startDamagePopup();

    target.clearResult();
    target._result = result;
  }

</JS Post-Damage as Target>
it should only trigger when a skill does damage, and should show a separate popup for this effect doing damage.

For bleed, im just following the conventions you used for rupture, but try this alongside your other tags:
Code:
<JS Post-Start Action>
  target.Bleed ??= 0;
  const stacks = Math.min(5, target.Bleed);
  const damage = stacks * 1;
  $gameTemp.requestAnimation([target], 2);
  target.gainHp(-damage);
  target.startDamagePopup();
</JS Post-Start Action>

Also make sure to save your project any time you adjust notetags between tests
Alright! So Bleed works as intended! Though Rupture is activating as it's applied, rather than from seperate attacks. Though I am worried I am bothering you a bit much about this.

Just the last thing in relation to the stack system I wish to add. In Project Moon's games, at the end of a turn all stacks lose one unless specified otherwise. Trying to add that myself, but I am finding that it'll be difficult to make it so that a stack is lost, and make it so if stacks hit zero to make the state be removed.

Thanks for all your help by the way!
Though Rupture is activating as it's applied, rather than from seperate attacks.
I am not certain what you mean by this. do you mean that the skill that applies this is triggering it on the same use? or that skills that add rupture in general shouldnt be able to trigger rupture?

Just the last thing in relation to the stack system I wish to add. In Project Moon's games, at the end of a turn all stacks lose one unless specified otherwise. Trying to add that myself, but I am finding that it'll be difficult to make it so that a stack is lost, and make it so if stacks hit zero to make the state be removed.
Try this and change the stack name as needed. no need to put in an actual value for state.id
Code:
<JS Post-End Turn>
target.Rupture--;

if (target.Rupture <= 0)
  target.removeState(state.id);
</JS Post-End Turn>
I am not certain what you mean by this. do you mean that the skill that applies this is triggering it on the same use? or that skills that add rupture in general shouldnt be able to trigger rupture?
It is honestly hard to describe now that I realize it. The attack that adds rupture shouldn't activate the rupture it adds, so if there is already rupture stacks it works as intended. But if the attacks is applying the first stacks? It shouldn't prompt the activation of the effect. Though, I feel that it'll be fine honestly.

Code:
<JS Post-End Turn>
target.Rupture--;

if (target.Rupture <= 0)
  target.removeState(state.id);
</JS Post-End Turn>
Added the code and it caused an error 'SyntaxError - missing ( after argument list' Added the code exactly. only adding the state ID with rupture.
Code:
<JS On Add State>
  target.Rupture ??= 0;
  target.Rupture++;
</JS On Add State>

<JS On Erase State>
  delete target.Rupture;
</JS On Erase State>

<JS Post-Damage as Target>
  if (this.isDamage() && value > 0){
    var result = JsonEx.makeDeepCopy(target._result);
    target.clearResult();

    target.Rupture ??= 0;
    const stacks = Math.min(5, target.Rupture);
    const damage = stacks * 1;
    $gameTemp.requestAnimation([target], 2);
    target.gainHp(-damage);
    target.startDamagePopup();

    target.clearResult();
    target._result = result;
  }

</JS Post-Damage as Target>

<JS Post-End Turn>
target.Rupture--;

if (target.Rupture <= 0)
  target.removeState(state.4);
</JS Post-End Turn>

EDIT: Alright, so turns out the adding of the number to the remove state somehow messed it up! Thanks!
It is honestly hard to describe now that I realize it. The attack that adds rupture shouldn't activate the rupture it adds, so if there is already rupture stacks it works as intended. But if the attacks is applying the first stacks? It shouldn't prompt the activation of the effect. Though, I feel that it'll be fine honestly.
how exactly is the action applying rupture? if its a method that happens post damage execution like an add state skill effect from the database, the first use shouldnt be able trigger the effect. if its also a visustella notetag, then there are timings that would apply before damage execution and make its own rupture application trigger from its own damage

Alright, so turns out the adding of the number to the remove state somehow messed it up! Thanks!
yeah, thats partially why i said theres no need to put a value in for state.id. the plugin already has a state variable for the state triggering the current effect thats being run. you can get the id of the state at any time using state.id. You could put the number in manually, but then youll have to remember to update it if you ever move it

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/cant-manage-to-create-a-functional-stacking-system.183665/