Files
CalamityModPublic/Projectiles/Melee/BrimlanceHellfireExplosion.cs
T
2024-04-04 04:22:36 +07:00

102 lines
3.7 KiB
C#

using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class BrimlanceHellfireExplosion : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 130;
Projectile.height = 130;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = 3;
Projectile.timeLeft = 30;
Projectile.DamageType = DamageClass.Melee;
Projectile.usesIDStaticNPCImmunity = true;
Projectile.idStaticNPCHitCooldown = 30;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.75f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f);
if (Projectile.localAI[0] == 0f)
{
SoundEngine.PlaySound(SoundID.Item20, Projectile.position);
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;
int timerCounter = 0;
while ((float)timerCounter < projTimer)
{
float rand1 = (float)Main.rand.Next(-10, 11);
float rand2 = (float)Main.rand.Next(-10, 11);
float rand3 = (float)Main.rand.Next(3, 9);
float randAdjuster = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2));
randAdjuster = rand3 / randAdjuster;
rand1 *= randAdjuster;
rand2 *= randAdjuster;
int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f);
Dust dust = Main.dust[brimDust];
dust.noGravity = true;
dust.position.X = Projectile.Center.X;
dust.position.Y = Projectile.Center.Y;
dust.position.X += (float)Main.rand.Next(-10, 11);
dust.position.Y += (float)Main.rand.Next(-10, 11);
dust.velocity.X = rand1;
dust.velocity.Y = rand2;
timerCounter++;
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 240);
}
}
}