How to create a Regen/Poison status like the ones in Slay The Spire?

Hey everyone! I want to create a Regen/Poison status effect like the one in Slay The Spire. The way it works in that game is that when you say inflict Poison on an enemy, the poison does damage depending on the number inflicted. So say you play a card that inflicts 5 Poison to an enemy. On their next turn, the enemy takes 5 poison damage and the count decreases by 1. Now on the next turn, they'll take 4 damage and the state decreases by 1 again. This continues until the state runs out or you keep adding the poison effect to the enemy. This works the same for Regen but for healing. Here's a video of Poison in effect.



I'm using most of Yanfly's plugins if that helps.
Yanfly's BuffStates Core plugin can do that and in your basic poison state in note field paste this:

Code:
<Custom Regenerate Effect>
var dmg = $gameVariables.value(x); replace with your specific var
target.gainHp(-Math.floor(target.mhp - dmg));
target.startAnimation(44);
$gameVariables.setValue(x, $gameVariables.value(x) - y); //set 'y' to amount how much you want to decrease damage
</Custom Regenerate Effect>

and don't forget to reset variable to it's default value after battle.
@Soulrender I tried it, but I get this error.
You may have forgotten to replace the x and y with actual numbers? That error is basically saying "could not open the console to show you the actual error". Possible causes: your plugin(s) and/or project's core scripts are outdated. In case you're interested, you can find details on updating your project's core scripts to match your editor version here (don't forget the backup stage!):
https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-v1-6-1-stable-release.96715/

For your question...I just tested with these Buffs & States Core notetags on a poison state and it seemed to work out OK:
Code:
<Reapply Add Turns>

<Custom Regenerate Effect>
var dmg = user.stateTurns(stateId);
user.startAnimation(59);
user.gainHp(-dmg);
</Custom Regenerate Effect>
Replace 59 with the ID of the animation you want to play on damage (or remove the line entirely if you like). Set the state to remove on Turn End, duration 1~1. Then you can use multiple "Add State" traits (or a <State X Turns: +Y> notetag) to add however much poison you like! The turns should add due to the <Reapply Add Turns> tag; damage is equal to turns remaining. 😤

For a catalyst-like effect (multiply poison), you could do something like this:
Code:
<Custom State 12 Turns>
turn *= 2;
</Custom State 12 Turns>
Just replace 12 with the ID of your poison state. Also, note that the tag here must be "Custom State X Turns": there's an error in the documentation (thanks to Sagittarius1 for pointing that out years ago). 😅
@caethyril Yeah I filled out the required bits, my plugins and project are all up to date, tried it with your code and I tried it with the Moogle X traits plugin turned off. Same results.
show us a screenshot of your plugin manager with all plugins.

it might be an incompatibility between two plugins, and we need to see the entire list to check for that.
@Andar Here you go.

I've moved this thread to Plug-In Support. Thank you.

Wow that's a lot of plugins! OK, couple of notes:
  • YEP_EnhancedTP is way down at the bottom rather than among the Yanfly plugins, is there a reason for that? 😅

  • Press F8 during play to open the console (may not work if you haven't correctly updated your project, in that case try F12 and switch to the Console tab). If there's any red text there (errors), a screenshot may help.

  • Have you tried turning off the Progressive States and Overriding States plugins by Himeworks? Just because those look relevant. Remember to save your project after making Plugin Manager changes else those changes will not be reflected during test.
Otherwise I think my only other suggestion, assuming you really have correctly updated your project files (including the libs folder, people often forget that), is to turn off a batch of plugins, save, test, and repeat to try to isolate any possible conflicts. 😔 Hopefully someone has a better idea!
@caethyril Yeah I was waiting to get closer to a demo build before clearing out everything that I don't use (And some of them I'm too scared to remove because I forgot what code is where and don't want to break anything). After looking through the console I saw that it was the Yanfly sample plugin that was causing the in battle error so i removed that, but instead of crashing when it's time to deduct HP, it doesn't do anything at all. Turning off the Hime plugins didn't change anything there. Here's a pic of the state I have:

EDIT: @caethyril I want to say that your code worked! I must have been placing something wrong in it when I first copied it into the notebox. Thank you again so much for your help!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-create-a-regen-poison-status-like-the-ones-in-slay-the-spire.116314/