177 lines
6.2 KiB
C#
177 lines
6.2 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
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 = 180;
|
|
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);
|
|
|
|
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;
|
|
}
|
|
|
|
if (projectile.timeLeft > 135 && projectile.ai[1] == 1f)
|
|
return;
|
|
|
|
float num953 = revenge ? 110f : 100f;
|
|
float num954 = 40f;
|
|
float scaleFactor12 = revenge ? 50f : 40f;
|
|
|
|
if (projectile.ai[1] == 1f)
|
|
{
|
|
num953 *= 0.7f;
|
|
scaleFactor12 *= 0.7f;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
if (projectile.timeLeft < 60 || projectile.ai[1] == 1f)
|
|
return;
|
|
|
|
float num1247 = 0.5f;
|
|
for (int num1248 = 0; num1248 < Main.maxProjectiles; num1248++)
|
|
{
|
|
if (Main.projectile[num1248].active)
|
|
{
|
|
if (num1248 != projectile.whoAmI && Main.projectile[num1248].type == projectile.type)
|
|
{
|
|
if (Vector2.Distance(projectile.Center, Main.projectile[num1248].Center) < 24f)
|
|
{
|
|
if (projectile.position.X < Main.projectile[num1248].position.X)
|
|
projectile.velocity.X -= num1247;
|
|
else
|
|
projectile.velocity.X += num1247;
|
|
|
|
if (projectile.position.Y < Main.projectile[num1248].position.Y)
|
|
projectile.velocity.Y -= num1247;
|
|
else
|
|
projectile.velocity.Y += num1247;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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(SoundID.Item14, projectile.position);
|
|
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 < 3; num621++)
|
|
{
|
|
int num622 = Dust.NewDust(projectile.position, 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 < 5; num623++)
|
|
{
|
|
int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f);
|
|
Main.dust[num624].noGravity = true;
|
|
Main.dust[num624].velocity *= 5f;
|
|
num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num624].velocity *= 2f;
|
|
}
|
|
CalamityUtils.ExplosionGores(projectile.Center, 3);
|
|
}
|
|
|
|
public override void OnHitPlayer(Player target, int damage, bool crit)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<LethalLavaBurn>(), 180);
|
|
}
|
|
|
|
public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit)
|
|
{
|
|
target.Calamity().lastProjectileHit = projectile;
|
|
}
|
|
}
|
|
}
|