88 lines
3.5 KiB
C#
88 lines
3.5 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.Dusts;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class SputterCometBig : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Ranged";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 8;
|
|
Projectile.height = 8;
|
|
Projectile.aiStyle = ProjAIStyleID.Arrow;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 600;
|
|
Projectile.extraUpdates = 1;
|
|
AIType = ProjectileID.Bullet;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, 0.3f, 0.5f, 0.1f);
|
|
if (Main.rand.NextBool(3))
|
|
{
|
|
int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, ModContent.DustType<AstralOrange>(), 0f, 0f, 0, default, 0.5f);
|
|
Main.dust[num137].alpha = Projectile.alpha;
|
|
Main.dust[num137].velocity *= 0f;
|
|
Main.dust[num137].noGravity = true;
|
|
}
|
|
if (Projectile.soundDelay == 0)
|
|
{
|
|
Projectile.soundDelay = 20 + Main.rand.Next(40);
|
|
if (Main.rand.NextBool(5))
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item9, Projectile.position);
|
|
}
|
|
}
|
|
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 150f, 12f, 20f);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
|
|
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.Item93, Projectile.position);
|
|
if (Projectile.owner == Main.myPlayer)
|
|
{
|
|
int flash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType<Flash>(), (int)((double)Projectile.damage * 0.5), 0f, Projectile.owner, 0f, 0f);
|
|
Main.projectile[flash].usesLocalNPCImmunity = true;
|
|
Main.projectile[flash].localNPCHitCooldown = 10;
|
|
}
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, ModContent.DustType<AstralOrange>(), Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
if (Main.netMode != NetmodeID.Server)
|
|
{
|
|
for (int num480 = 0; num480 < 3; num480++)
|
|
{
|
|
Gore.NewGore(Projectile.GetSource_Death(), Projectile.position, new Vector2(Projectile.velocity.X * 0.05f, Projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|