Files
CalamityModPublic/Projectiles/Boss/ScavengerNuke.cs
T
tomat 67bceff6e7 Initial dotnet format pass.
This commit formats the entire codebase according to `dotnet format` and its limited understanding of our provided `.editorconfig`.
2024-02-28 21:49:50 -08:00

157 lines
6.4 KiB
C#

using System;
using CalamityMod.Events;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class ScavengerNuke : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
public static readonly SoundStyle ExplosionSound = new("CalamityMod/Sounds/Custom/Ravager/RavagerMissileExplosion");
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 5;
}
public override void SetDefaults()
{
Projectile.Calamity().DealsDefenseDamage = true;
Projectile.width = 44;
Projectile.height = 44;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = 1;
Projectile.alpha = 255;
Projectile.timeLeft = 600;
}
public override void AI()
{
bool bossRush = BossRushEvent.BossRushActive;
bool revenge = CalamityWorld.revenge || bossRush;
if (Projectile.timeLeft < 180)
Projectile.tileCollide = true;
Projectile.frameCounter++;
if (Projectile.frameCounter > 18)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 4)
Projectile.frame = 0;
Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2;
float inertia = bossRush ? 70f : revenge ? 90f : 110f;
float scaleFactor12 = bossRush ? 20f : revenge ? 16f : 12f;
if (Projectile.alpha > 0)
Projectile.alpha -= 10;
if (Projectile.alpha < 0)
Projectile.alpha = 0;
Lighting.AddLight(Projectile.Center, 1f, 0.7f, 0f);
int playerTracker = (int)Projectile.ai[0];
if (playerTracker >= 0 && Main.player[playerTracker].active && !Main.player[playerTracker].dead)
{
if (Projectile.Distance(Main.player[playerTracker].Center) > 320f)
{
Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[playerTracker].Center, Vector2.UnitY);
Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * scaleFactor12) / inertia;
}
}
else
{
if (Projectile.timeLeft > 30)
Projectile.timeLeft = 30;
if (Projectile.ai[0] != -1f)
{
Projectile.ai[0] = -1f;
Projectile.netUpdate = true;
}
}
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(ExplosionSound, Projectile.Center);
Projectile.position = Projectile.Center;
Projectile.width = Projectile.height = 160;
Projectile.position.X = Projectile.position.X - (Projectile.width / 2);
Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2);
Projectile.Damage();
for (int i = 0; i < 30; i++)
{
int nukeDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 2f);
Main.dust[nukeDust].velocity *= 3f;
if (Main.rand.NextBool())
{
Main.dust[nukeDust].scale = 0.5f;
Main.dust[nukeDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f;
}
}
for (int j = 0; j < 40; j++)
{
int nukeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 3f);
Main.dust[nukeDust2].noGravity = true;
Main.dust[nukeDust2].velocity *= 5f;
nukeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 2f);
Main.dust[nukeDust2].velocity *= 2f;
}
if (Main.netMode != NetmodeID.Server)
{
Vector2 goreSource = Projectile.Center;
int goreAmt = 3;
Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f);
for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++)
{
float velocityMult = 0.33f;
if (goreIndex < (goreAmt / 3))
{
velocityMult = 0.66f;
}
if (goreIndex >= (2 * goreAmt / 3))
{
velocityMult = 1f;
}
Mod mod = ModContent.GetInstance<CalamityMod>();
int type = Main.rand.Next(61, 64);
int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f);
Gore gore = Main.gore[smoke];
gore.velocity *= velocityMult;
gore.velocity.X += 1f;
gore.velocity.Y += 1f;
type = Main.rand.Next(61, 64);
smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f);
gore = Main.gore[smoke];
gore.velocity *= velocityMult;
gore.velocity.X -= 1f;
gore.velocity.Y += 1f;
type = Main.rand.Next(61, 64);
smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f);
gore = Main.gore[smoke];
gore.velocity *= velocityMult;
gore.velocity.X += 1f;
gore.velocity.Y -= 1f;
type = Main.rand.Next(61, 64);
smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f);
gore = Main.gore[smoke];
gore.velocity *= velocityMult;
gore.velocity.X -= 1f;
gore.velocity.Y -= 1f;
}
}
}
}
}