Files
CalamityModPublic/Projectiles/Melee/AstralScytheProjectile.cs
T

88 lines
2.9 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Melee
{
public class AstralScytheProjectile : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/Enemy/MantisRing";
private int tileCounter = 5;
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 3;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 72;
Projectile.height = 30;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Melee;
Projectile.timeLeft = 300;
Projectile.penetrate = 8;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 7;
Projectile.tileCollide = false;
}
public override void AI()
{
if (tileCounter > 0)
tileCounter--;
if (tileCounter <= 0)
Projectile.tileCollide = true;
Projectile.velocity *= 1.03f;
Projectile.frameCounter++;
if (Projectile.frameCounter > 4)
{
Projectile.frame++;
Projectile.frameCounter = 0;
if (Projectile.frame > 2)
{
Projectile.frame = 0;
}
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 240);
}
public override void Kill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item1, Projectile.Center);
for (int i = 0; i < 60; i++)
{
float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f);
Vector2 angleVec = angle.ToRotationVector2();
float distance = Main.rand.NextFloat(14f, 36f);
Vector2 off = angleVec * distance;
off.Y *= (float)Projectile.height / Projectile.width;
Vector2 pos = Projectile.Center + off;
Dust d = Dust.NewDustPerfect(pos, ModContent.DustType<AstralBlue>(), angleVec * Main.rand.NextFloat(2f, 4f));
d.customData = true;
}
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
}
}