69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
namespace CalamityMod.Projectiles.Summon
|
|
{
|
|
public class MK2RocketHoming : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Summon";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Main.projFrames[Projectile.type] = 6;
|
|
ProjectileID.Sets.MinionShot[Projectile.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 14;
|
|
Projectile.height = 14;
|
|
Projectile.extraUpdates = 1;
|
|
Projectile.tileCollide = false;
|
|
Projectile.friendly = true;
|
|
Projectile.minion = true;
|
|
Projectile.minionSlots = 0f;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 600;
|
|
Projectile.DamageType = DamageClass.Summon;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Player player = Main.player[Projectile.owner];
|
|
NPC potentialTarget = Projectile.Center.MinionHoming(1000f, player);
|
|
|
|
if (potentialTarget != null)
|
|
Projectile.velocity = (Projectile.velocity * 24f + Projectile.SafeDirectionTo(potentialTarget.Center) * 14f) / 25f;
|
|
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
|
Projectile.frameCounter++;
|
|
if (Projectile.frameCounter > 6)
|
|
{
|
|
Projectile.frame++;
|
|
Projectile.frameCounter = 0;
|
|
}
|
|
if (Projectile.frame >= Main.projFrames[Projectile.type])
|
|
{
|
|
Projectile.frame = 0;
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<Plague>(), 180);
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
if (Projectile.timeLeft > 599)
|
|
return false;
|
|
return true;
|
|
}
|
|
}
|
|
}
|