Files
CalamityModPublic/Projectiles/Magic/BloodBeam.cs
T
2026-04-16 04:46:51 -05:00

74 lines
2.6 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class BloodBeam : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public override void SetDefaults()
{
Projectile.width = 12;
Projectile.height = 12;
Projectile.friendly = true;
Projectile.tileCollide = false;
Projectile.DamageType = DamageClass.Magic;
Projectile.penetrate = 2;
Projectile.extraUpdates = 3;
Projectile.timeLeft = 120;
Projectile.usesIDStaticNPCImmunity = true;
Projectile.idStaticNPCHitCooldown = 10;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0.35f, 0f, 0f);
if (Projectile.position.Y > Main.player[Projectile.owner].position.Y - 160f)
{
Projectile.tileCollide = true;
}
if (Projectile.ai[0] > 7f)
{
float scalar = 1f;
if (Projectile.ai[0] == 8f)
{
scalar = 0.25f;
}
else if (Projectile.ai[0] == 9f)
{
scalar = 0.5f;
}
else if (Projectile.ai[0] == 10f)
{
scalar = 0.75f;
}
Projectile.ai[0] += 1f;
int dustType = DustID.Blood;
int blood = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f);
Dust dust = Main.dust[blood];
if (Main.rand.NextBool(3))
{
dust.noGravity = true;
dust.scale *= 2f;
dust.velocity.X *= 2f;
dust.velocity.Y *= 2f;
}
dust.velocity.X *= 1.2f;
dust.velocity.Y *= 1.2f;
dust.scale *= scalar;
}
else
{
Projectile.ai[0] += 1f;
}
Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BurningBlood>(), 120);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BurningBlood>(), 120);
}
}