agneovo123
Official Terrarian
I had the idea, to make a stackable 'Bleeding' debuff.
The idea is as follows:
It starts out at 2 dmg 5 times a second, and with each additional stack the dmg increases by 2. Kind of like how the Daybreak works, except thie bleeding could be staced unlimitedly.
Now I have tried to make it work, but it just kept failing and failing, I would appreciate some help.
My current code:
GlobalNPC class: this is where I tried the stacking
The buff class:
GlobalVariables class: only using it as an external variable (CBS = Current Bleed Stacks)
And lastly I have a test sword with a 100% chance to inflict the debuff to test it.
I have tried commenting out certain parts of GlobalNPC, tried without the GlobalVariable CBS thing
tried to count the stacks within the buff class, nothing worked the way I wanted to.
The closest is the current code, which increses the DoT by 2 every time it ticks (I want it to increase every time I hit the target), and it is global so if I hit another enemy it doesn't start from 2, it starts from where it left off the last one. (I know the problem for this one is the global variable CBS, being you know: Global, but without it, it just wouldn't increase the stack damage).
Thanks in advance for any help.
Edit: I used the CODE feature
The idea is as follows:
It starts out at 2 dmg 5 times a second, and with each additional stack the dmg increases by 2. Kind of like how the Daybreak works, except thie bleeding could be staced unlimitedly.
Now I have tried to make it work, but it just kept failing and failing, I would appreciate some help.
My current code:
GlobalNPC class: this is where I tried the stacking
C#:
public class GlobalNPC : Terraria.ModLoader.GlobalNPC
{
public override bool InstancePerEntity => true;
public bool SBleed;
public int BleedStack;
public override void ResetEffects(NPC npc)
{
SBleed = false;
BleedStack = GlobalVariables.CBS;
//////GlobalVariables.CBS++;
}
public override void UpdateLifeRegen(NPC npc, ref int damage)
{
if (SBleed)
{
if (npc.lifeRegen > 0)
{
npc.lifeRegen = 0;
}
//////BleedStack = GlobalVariables.CBS;
GlobalVariables.CBS++;
npc.lifeRegen -= GlobalVariables.CBS*2 * 10;
if (damage < GlobalVariables.CBS*2)
{
damage = GlobalVariables.CBS*2;
}
}
}
}
The buff class:
C#:
public class SBleed : ModBuff
{
public override void SetDefaults()
{
DisplayName.SetDefault("Stackable Bleed");
Description.SetDefault("This bleed can stack (woah)");
}
public override void Update(NPC npc, ref int buffIndex)
{
npc.GetGlobalNPC<NPCs.GlobalNPC>().SBleed = true;
}
}
GlobalVariables class: only using it as an external variable (CBS = Current Bleed Stacks)
C#:
class GlobalVariables
{
public static int CBS = 1;
}
And lastly I have a test sword with a 100% chance to inflict the debuff to test it.
C#:
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
{
target.AddBuff(mod.BuffType("SBleed"), 180);
}
I have tried commenting out certain parts of GlobalNPC, tried without the GlobalVariable CBS thing
tried to count the stacks within the buff class, nothing worked the way I wanted to.
The closest is the current code, which increses the DoT by 2 every time it ticks (I want it to increase every time I hit the target), and it is global so if I hit another enemy it doesn't start from 2, it starts from where it left off the last one. (I know the problem for this one is the global variable CBS, being you know: Global, but without it, it just wouldn't increase the stack damage).
Thanks in advance for any help.
Edit: I used the CODE feature
Last edited: