Files
CalamityModPublic/Buffs/DamageOverTime/VulnerabilityHex.cs
T
2026-07-05 18:56:15 +07:00

69 lines
2.7 KiB
C#

using CalamityMod.DataStructures;
using CalamityMod.Dusts;
using CalamityMod.NPCs;
using CalamityMod.Particles;
using CalamityMod.Systems.Collections;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Buffs.DamageOverTime
{
public class VulnerabilityHex : ModBuff
{
public static DebuffData debuffData = new DebuffData()
{
EnemyLostRegen = 2664, //4x tick size
HeatDebuffScaling = 1,
MinimumDamageTickSize = 666,
MultiplierDamageTickSize = 0
};
public const int CalamityDuration = 60;
public const int AflameDuration = 120;
public override void SetStaticDefaults()
{
Main.debuff[Type] = true;
Main.pvpBuff[Type] = true;
Main.buffNoSave[Type] = true;
BuffID.Sets.NurseCannotRemoveDebuff[Type] = true;
BuffID.Sets.LongerExpertDebuff[Type] = true;
CalamityBuffSets.DebuffDataset[Type] = debuffData;
}
public override void Update(Player player, ref int buffIndex) => player.Calamity().vHex = true;
public override void Update(NPC npc, ref int buffIndex)
{
CalamityGlobalNPC cgn = npc.Calamity();
//If this isn't here the drawcode gives an index out of bounds
if (npc.buffTime[buffIndex] > 1)
cgn.vulnerabilityHex = true;
// Set the remaining time of the fire drawer to be exactly right.
if (cgn.VulnerabilityHexFireDrawer != null)
cgn.VulnerabilityHexFireDrawer.SetLifetime = cgn.VulnerabilityHexFireDrawer.LocalTimer + npc.buffTime[buffIndex];
}
internal static void DrawEffects(PlayerDrawSet drawInfo)
{
Player Player = drawInfo.drawPlayer;
if (Main.rand.NextBool())
{
VoidSparkParticle spark2 = new VoidSparkParticle(Player.Calamity().RandomDebuffVisualSpot, new Vector2(0, Main.rand.NextFloat(-6f, -10f)), false, Main.rand.Next(18, 27), Main.rand.NextFloat(0.015f, 0.045f), Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.65f));
GeneralParticleHandler.SpawnParticle(spark2);
}
Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot, Main.rand.NextBool() ? 261 : (int)CalamityDusts.Brimstone);
dust.scale = Main.rand.NextFloat(0.4f, 0.5f);
dust.velocity = new Vector2(0, Main.rand.NextFloat(-0.5f, -2.5f)).RotatedByRandom(0.6f);
if (dust.type == 261)
dust.color = Color.Lerp(Color.Red, Color.Magenta, 0.65f);
}
}
}