117 lines
4.0 KiB
C#
117 lines
4.0 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.Dusts;
|
|
using System;
|
|
using System.IO;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
namespace CalamityMod.Projectiles.Boss
|
|
{
|
|
public class HellfireExplosion : ModProjectile
|
|
{
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Brimstone Hellfire Explosion");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 130;
|
|
Projectile.height = 130;
|
|
Projectile.hostile = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.penetrate = -1;
|
|
Projectile.timeLeft = 180;
|
|
CooldownSlot = ImmunityCooldownID.Bosses;
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(Projectile.localAI[0]);
|
|
}
|
|
|
|
public override void ReceiveExtraAI(BinaryReader reader)
|
|
{
|
|
Projectile.localAI[0] = reader.ReadSingle();
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, 0.75f, 0f, 0f);
|
|
if (Projectile.localAI[0] == 0f)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item20, Projectile.position);
|
|
Projectile.localAI[0] += 1f;
|
|
}
|
|
bool flag15 = false;
|
|
bool flag16 = false;
|
|
if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0])
|
|
{
|
|
flag15 = true;
|
|
}
|
|
if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0])
|
|
{
|
|
flag15 = true;
|
|
}
|
|
if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1])
|
|
{
|
|
flag16 = true;
|
|
}
|
|
if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1])
|
|
{
|
|
flag16 = true;
|
|
}
|
|
if (flag15 && flag16)
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
float num461 = 25f;
|
|
if (Projectile.ai[0] > 180f)
|
|
{
|
|
num461 -= (Projectile.ai[0] - 180f) / 2f;
|
|
}
|
|
if (num461 <= 0f)
|
|
{
|
|
num461 = 0f;
|
|
Projectile.Kill();
|
|
}
|
|
num461 *= 0.7f;
|
|
Projectile.ai[0] += 4f;
|
|
int num462 = 0;
|
|
while ((float)num462 < num461)
|
|
{
|
|
float num463 = (float)Main.rand.Next(-10, 11);
|
|
float num464 = (float)Main.rand.Next(-10, 11);
|
|
float num465 = (float)Main.rand.Next(3, 9);
|
|
float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464));
|
|
num466 = num465 / num466;
|
|
num463 *= num466;
|
|
num464 *= num466;
|
|
int num467 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f);
|
|
Main.dust[num467].noGravity = true;
|
|
Main.dust[num467].position.X = Projectile.Center.X;
|
|
Main.dust[num467].position.Y = Projectile.Center.Y;
|
|
Dust expr_149DF_cp_0 = Main.dust[num467];
|
|
expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11);
|
|
Dust expr_14A09_cp_0 = Main.dust[num467];
|
|
expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11);
|
|
Main.dust[num467].velocity.X = num463;
|
|
Main.dust[num467].velocity.Y = num464;
|
|
num462++;
|
|
}
|
|
}
|
|
|
|
public override void OnHitPlayer(Player target, int damage, bool crit)
|
|
{
|
|
if (damage <= 0)
|
|
return;
|
|
|
|
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300);
|
|
}
|
|
}
|
|
}
|