Files
CalamityModPublic/Projectiles/Boss/CalamitousExplosion.cs
T
2025-10-31 15:55:04 -04:00

95 lines
3.0 KiB
C#

using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Metaballs;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class CalamitousExplosion : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
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.Center);
Projectile.localAI[0] += 1f;
}
bool xflag = false;
bool yflag = false;
if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0])
{
xflag = true;
}
if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0])
{
xflag = true;
}
if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1])
{
yflag = true;
}
if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1])
{
yflag = true;
}
if (xflag && yflag)
{
Projectile.Kill();
}
float projTimer = 25f;
if (Projectile.ai[0] > 180f)
{
projTimer -= (Projectile.ai[0] - 180f) / 2f;
}
if (projTimer <= 0f)
{
projTimer = 0f;
Projectile.Kill();
}
projTimer *= 0.7f;
Projectile.ai[0] += 4f;
var p = CalamitasMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2CircularEdge(4, 4), 32f);
p.SizeScaling = 0.96f;
p = CalamitasMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2CircularEdge(3, 3), 40f);
p.SizeScaling = 0.96f;
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0)
return;
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 150);
}
}
}