Files
CalamityModPublic/Projectiles/Ranged/EnhancedNanoRoundProj.cs
T

91 lines
3.2 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class EnhancedNanoRoundProj : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 4;
Projectile.height = 4;
Projectile.aiStyle = ProjAIStyleID.Arrow;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Ranged;
Projectile.penetrate = 1;
Projectile.timeLeft = 600;
Projectile.extraUpdates = 3;
AIType = ProjectileID.Bullet;
Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0f, 0.25f, 0.25f);
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 4f)
{
if (Main.rand.NextBool(3))
{
int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 229, 0f, 0f, 0, default, 0.5f);
Main.dust[num137].alpha = Projectile.alpha;
Main.dust[num137].velocity *= 0f;
Main.dust[num137].noGravity = true;
}
}
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor);
return false;
}
// This projectile is always fullbright.
public override Color? GetAlpha(Color lightColor)
{
return new Color(1f, 1f, 1f, 0f);
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(BuffID.Confused, 300);
if (target.life <= 0)
{
if (Projectile.owner == Main.myPlayer)
{
for (int i = 0; i < 2; i++)
{
Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<Nanomachine>(), (int)(Projectile.damage * 0.3), 0f, Projectile.owner, 0f, 0f);
}
}
}
}
public override void Kill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item93, Projectile.position);
int num212 = Main.rand.Next(5, 10);
for (int num213 = 0; num213 < num212; num213++)
{
int num214 = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 229, 0f, 0f, 100, default, 2f);
Main.dust[num214].velocity *= 2f;
Main.dust[num214].noGravity = true;
}
}
}
}