170 lines
7.6 KiB
C#
170 lines
7.6 KiB
C#
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Boss
|
|
{
|
|
public class FlareBomb : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Flare Bomb");
|
|
Main.projFrames[projectile.type] = 4;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 30;
|
|
projectile.height = 30;
|
|
projectile.hostile = true;
|
|
projectile.scale = 1.5f;
|
|
projectile.ignoreWater = true;
|
|
projectile.penetrate = 1;
|
|
projectile.alpha = 50;
|
|
projectile.timeLeft = 600;
|
|
cooldownSlot = 1;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive;
|
|
projectile.frameCounter++;
|
|
if (projectile.frameCounter > 4)
|
|
{
|
|
projectile.frame++;
|
|
projectile.frameCounter = 0;
|
|
}
|
|
if (projectile.frame > 3)
|
|
{
|
|
projectile.frame = 0;
|
|
}
|
|
Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f);
|
|
float num953 = revenge ? 110f : 100f; //100
|
|
float scaleFactor12 = revenge ? 27f : 25f; //5
|
|
float num954 = 40f;
|
|
if (projectile.timeLeft > 30 && projectile.alpha > 0)
|
|
{
|
|
projectile.alpha -= 25;
|
|
}
|
|
if (projectile.timeLeft > 30 && projectile.alpha < 128 && Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
|
{
|
|
projectile.alpha = 128;
|
|
}
|
|
if (projectile.alpha < 0)
|
|
{
|
|
projectile.alpha = 0;
|
|
}
|
|
projectile.frameCounter++;
|
|
if (projectile.frameCounter > 4)
|
|
{
|
|
projectile.frame++;
|
|
projectile.frameCounter = 0;
|
|
}
|
|
if (projectile.frame > 3)
|
|
{
|
|
projectile.frame = 0;
|
|
}
|
|
int num959 = (int)projectile.ai[0];
|
|
if (num959 >= 0 && Main.player[num959].active && !Main.player[num959].dead)
|
|
{
|
|
if (projectile.Distance(Main.player[num959].Center) > num954)
|
|
{
|
|
Vector2 vector102 = projectile.DirectionTo(Main.player[num959].Center);
|
|
if (vector102.HasNaNs())
|
|
{
|
|
vector102 = Vector2.UnitY;
|
|
}
|
|
projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (projectile.ai[0] != -1f)
|
|
{
|
|
projectile.ai[0] = -1f;
|
|
projectile.netUpdate = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override Color? GetAlpha(Color lightColor)
|
|
{
|
|
return new Color(255, Main.DiscoG, 53, projectile.alpha);
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
Texture2D texture2D13 = Main.projectileTexture[projectile.type];
|
|
int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
|
|
int y6 = num214 * projectile.frame;
|
|
Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, SpriteEffects.None, 0f);
|
|
return false;
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14);
|
|
projectile.position = projectile.Center;
|
|
projectile.width = projectile.height = 48;
|
|
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
|
|
projectile.Damage();
|
|
for (int num621 = 0; num621 < 5; 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 < 8; 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 < 3; 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;
|
|
}
|
|
}
|
|
}
|
|
}
|