Files
CalamityModPublic/Projectiles/Melee/StormRulerProj.cs
T
2026-06-12 09:56:59 -07:00

80 lines
2.6 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class StormRulerProj : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 8;
ProjectileID.Sets.TrailingMode[Type] = 0;
}
public override void SetDefaults()
{
Projectile.width = Projectile.height = 28;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Melee;
Projectile.penetrate = 1;
Projectile.alpha = 255;
Projectile.timeLeft = 600;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0f, 0.25f, 0.25f);
if (Projectile.localAI[0] == 0f)
{
Projectile.scale -= 0.02f;
Projectile.alpha += 30;
if (Projectile.alpha >= 250)
{
Projectile.alpha = 255;
Projectile.localAI[0] = 1f;
}
}
else if (Projectile.localAI[0] == 1f)
{
Projectile.scale += 0.02f;
Projectile.alpha -= 30;
if (Projectile.alpha <= 0)
{
Projectile.alpha = 0;
Projectile.localAI[0] = 0f;
}
}
Projectile.rotation = Projectile.velocity.ToRotation();
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<WindChilled>(), 180);
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
target.AddBuff(ModContent.BuffType<WindChilled>(), 180);
}
public override void OnKill(int timeLeft)
{
if (Projectile.owner == Main.myPlayer)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType<StormMark>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f);
}
}
public override bool PreDraw(ref Color lightColor)
{
if (Projectile.timeLeft > 595)
return false;
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
return false;
}
}
}