146 lines
6.7 KiB
C#
146 lines
6.7 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.Dusts;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class PristineFire : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Ranged";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
private int dust1 = (int)CalamityDusts.ProfanedFire;
|
|
private int dust2 = ModContent.DustType<HolyFireDust>();
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 6;
|
|
Projectile.height = 6;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.penetrate = 1;
|
|
Projectile.extraUpdates = 3;
|
|
Projectile.timeLeft = 120;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (Projectile.scale <= 1.5f)
|
|
{
|
|
Projectile.scale *= 1.01f;
|
|
}
|
|
Lighting.AddLight(Projectile.Center, 1f, 1f, 0.25f);
|
|
if (Projectile.timeLeft > 90)
|
|
{
|
|
Projectile.timeLeft = 120;
|
|
}
|
|
|
|
int dustTypeOnTimer = dust1;
|
|
|
|
Projectile.localAI[0] += 1f;
|
|
if (Projectile.localAI[0] > 5f)
|
|
{
|
|
for (int num447 = 0; num447 < 2; num447++)
|
|
{
|
|
Vector2 vector33 = Projectile.position;
|
|
vector33 -= Projectile.velocity * ((float)num447 * 0.25f);
|
|
Projectile.alpha = 255;
|
|
int num448 = Dust.NewDust(vector33, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f);
|
|
Main.dust[num448].noGravity = true;
|
|
Main.dust[num448].position = vector33;
|
|
Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f;
|
|
Main.dust[num448].velocity *= 0.2f;
|
|
Main.dust[num448].noLight = true;
|
|
Main.dust[num448].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f);
|
|
}
|
|
Projectile.ai[0] += 1f;
|
|
if (Projectile.ai[0] == 48f)
|
|
{
|
|
Projectile.ai[0] = 0f;
|
|
|
|
if (dustTypeOnTimer == dust1)
|
|
dustTypeOnTimer = dust2;
|
|
else
|
|
dustTypeOnTimer = dust1;
|
|
}
|
|
else
|
|
{
|
|
Vector2 value7 = new Vector2(5f, 10f);
|
|
|
|
for (int num41 = 0; num41 < 2; num41++)
|
|
{
|
|
int dustType = num41 == 0 ? dust1 : dust2;
|
|
Vector2 value8 = Vector2.UnitX * -12f;
|
|
value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7 * 1.5f;
|
|
int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f);
|
|
Main.dust[num42].scale = 0.75f;
|
|
Main.dust[num42].noGravity = true;
|
|
Main.dust[num42].position = Projectile.Center + value8;
|
|
Main.dust[num42].velocity = Projectile.velocity;
|
|
Main.dust[num42].noLight = true;
|
|
Main.dust[num42].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<HolyFlames>(), 240);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
int dustType = Utils.SelectRandom(Main.rand, new int[]
|
|
{
|
|
dust1,
|
|
dust2
|
|
});
|
|
int height = 50;
|
|
float num50 = 1.7f;
|
|
float num51 = 0.8f;
|
|
float num52 = 2f;
|
|
Vector2 value3 = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2();
|
|
Vector2 value4 = value3 * Projectile.velocity.Length() * (float)Projectile.MaxUpdates;
|
|
Projectile.position = Projectile.Center;
|
|
Projectile.width = Projectile.height = height;
|
|
Projectile.Center = Projectile.position;
|
|
Projectile.maxPenetrate = -1;
|
|
Projectile.penetrate = -1;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 10;
|
|
Projectile.Damage();
|
|
for (int num53 = 0; num53 < 40; num53++)
|
|
{
|
|
int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 200, default, num50);
|
|
Dust dust = Main.dust[num54];
|
|
dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f;
|
|
dust.noGravity = true;
|
|
dust.velocity *= 3f;
|
|
dust.velocity += value4 * Main.rand.NextFloat();
|
|
dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f);
|
|
num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, num51);
|
|
dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f;
|
|
dust.velocity *= 2f;
|
|
dust.noGravity = true;
|
|
dust.fadeIn = 1f;
|
|
dust.velocity += value4 * Main.rand.NextFloat();
|
|
dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f);
|
|
}
|
|
for (int num55 = 0; num55 < 20; num55++)
|
|
{
|
|
int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, num52);
|
|
Dust dust = Main.dust[num56];
|
|
dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f;
|
|
dust.noGravity = true;
|
|
dust.velocity *= 0.5f;
|
|
dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat());
|
|
dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f);
|
|
}
|
|
}
|
|
}
|
|
}
|