178 lines
9.0 KiB
C#
178 lines
9.0 KiB
C#
using CalamityMod.Projectiles.Typeless;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class Nuke : ModProjectile
|
|
{
|
|
public int flarePowderTimer = 12;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Nuke");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 14;
|
|
projectile.height = 14;
|
|
projectile.friendly = true;
|
|
projectile.penetrate = 1;
|
|
projectile.timeLeft = 125;
|
|
projectile.ranged = true;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
flarePowderTimer--;
|
|
if (flarePowderTimer <= 0)
|
|
{
|
|
if (projectile.owner == Main.myPlayer)
|
|
{
|
|
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType<DragonDust>(), (int)((double)projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f);
|
|
}
|
|
flarePowderTimer = 12;
|
|
}
|
|
if (projectile.owner == Main.myPlayer && projectile.timeLeft <= 3)
|
|
{
|
|
projectile.tileCollide = false;
|
|
projectile.ai[1] = 0f;
|
|
projectile.alpha = 255;
|
|
projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
|
|
projectile.width = 1000;
|
|
projectile.height = 1000;
|
|
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
|
|
projectile.knockBack = 30f;
|
|
}
|
|
else
|
|
{
|
|
if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f)
|
|
{
|
|
for (int num246 = 0; num246 < 4; num246++)
|
|
{
|
|
float num247 = 0f;
|
|
float num248 = 0f;
|
|
if (num246 == 1)
|
|
{
|
|
num247 = projectile.velocity.X * 0.5f;
|
|
num248 = projectile.velocity.Y * 0.5f;
|
|
}
|
|
int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 1f);
|
|
Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f;
|
|
Main.dust[num249].velocity *= 0.2f;
|
|
Main.dust[num249].noGravity = true;
|
|
num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f);
|
|
Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f;
|
|
Main.dust[num249].velocity *= 0.05f;
|
|
}
|
|
}
|
|
}
|
|
float num472 = projectile.Center.X;
|
|
float num473 = projectile.Center.Y;
|
|
float num474 = 600f;
|
|
bool flag17 = false;
|
|
for (int num475 = 0; num475 < 200; num475++)
|
|
{
|
|
if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1))
|
|
{
|
|
float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
|
|
float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
|
|
float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477);
|
|
if (num478 < num474)
|
|
{
|
|
num474 = num478;
|
|
num472 = num476;
|
|
num473 = num477;
|
|
flag17 = true;
|
|
}
|
|
}
|
|
}
|
|
if (flag17)
|
|
{
|
|
float num483 = 24f;
|
|
Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
|
|
float num484 = num472 - vector35.X;
|
|
float num485 = num473 - vector35.Y;
|
|
float num486 = (float)Math.Sqrt((double)(num484 * num484 + num485 * num485));
|
|
num486 = num483 / num486;
|
|
num484 *= num486;
|
|
num485 *= num486;
|
|
projectile.velocity.X = (projectile.velocity.X * 20f + num484) / 21f;
|
|
projectile.velocity.Y = (projectile.velocity.Y * 20f + num485) / 21f;
|
|
}
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
projectile.position = projectile.Center;
|
|
projectile.width = projectile.height = 192;
|
|
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
|
|
projectile.maxPenetrate = -1;
|
|
projectile.penetrate = -1;
|
|
projectile.usesLocalNPCImmunity = true;
|
|
projectile.localNPCHitCooldown = 10;
|
|
projectile.Damage();
|
|
Main.PlaySound(2, (int)projectile.Center.X, (int)projectile.Center.Y, 14);
|
|
for (int num621 = 0; num621 < 40; num621++)
|
|
{
|
|
int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num622].velocity *= 3f;
|
|
if (Main.rand.NextBool(2))
|
|
{
|
|
Main.dust[num622].scale = 0.5f;
|
|
Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
|
|
}
|
|
}
|
|
for (int num623 = 0; num623 < 60; num623++)
|
|
{
|
|
int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f);
|
|
Main.dust[num624].noGravity = true;
|
|
Main.dust[num624].velocity *= 5f;
|
|
num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num624].velocity *= 2f;
|
|
}
|
|
for (int num625 = 0; num625 < 10; num625++)
|
|
{
|
|
float scaleFactor10 = 0.33f;
|
|
if (num625 == 1)
|
|
{
|
|
scaleFactor10 = 0.66f;
|
|
}
|
|
if (num625 == 2)
|
|
{
|
|
scaleFactor10 = 1f;
|
|
}
|
|
int num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f);
|
|
Main.gore[num626].velocity *= scaleFactor10;
|
|
Gore expr_13AB6_cp_0 = Main.gore[num626];
|
|
expr_13AB6_cp_0.velocity.X += 1f;
|
|
Gore expr_13AD6_cp_0 = Main.gore[num626];
|
|
expr_13AD6_cp_0.velocity.Y += 1f;
|
|
num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f);
|
|
Main.gore[num626].velocity *= scaleFactor10;
|
|
Gore expr_13B79_cp_0 = Main.gore[num626];
|
|
expr_13B79_cp_0.velocity.X -= 1f;
|
|
Gore expr_13B99_cp_0 = Main.gore[num626];
|
|
expr_13B99_cp_0.velocity.Y += 1f;
|
|
num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f);
|
|
Main.gore[num626].velocity *= scaleFactor10;
|
|
Gore expr_13C3C_cp_0 = Main.gore[num626];
|
|
expr_13C3C_cp_0.velocity.X += 1f;
|
|
Gore expr_13C5C_cp_0 = Main.gore[num626];
|
|
expr_13C5C_cp_0.velocity.Y -= 1f;
|
|
num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f);
|
|
Main.gore[num626].velocity *= scaleFactor10;
|
|
Gore expr_13CFF_cp_0 = Main.gore[num626];
|
|
expr_13CFF_cp_0.velocity.X -= 1f;
|
|
Gore expr_13D1F_cp_0 = Main.gore[num626];
|
|
expr_13D1F_cp_0.velocity.Y -= 1f;
|
|
}
|
|
}
|
|
}
|
|
}
|