Files
CalamityModPublic/Projectiles/Boss/PhantomBlast2.cs
T

124 lines
5.0 KiB
C#

using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using System;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Boss
{
public class PhantomBlast2 : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
public override void SetDefaults()
{
Projectile.Calamity().DealsDefenseDamage = true;
Projectile.width = 18;
Projectile.height = 18;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.alpha = 255;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
CooldownSlot = ImmunityCooldownID.Bosses;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(Projectile.localAI[0]);
writer.Write(Projectile.localAI[1]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
Projectile.localAI[0] = reader.ReadSingle();
Projectile.localAI[1] = reader.ReadSingle();
}
public override void AI()
{
if (Projectile.ai[1] == 0f)
{
Projectile.ai[1] = 1f;
SoundEngine.PlaySound(SoundID.Item20, Projectile.Center);
}
Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2;
if (Projectile.velocity.Length() < 12f)
Projectile.velocity *= 1.01f;
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 9f)
{
Projectile.alpha -= 5;
if (Projectile.alpha < 30)
Projectile.alpha = 30;
}
Projectile.localAI[1] += 1f;
if (Projectile.localAI[1] == 24f)
{
Projectile.localAI[1] = 0f;
for (int l = 0; l < 12; l++)
{
Vector2 dustRotation = Vector2.UnitX * -Projectile.width / 2f;
dustRotation += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f);
dustRotation = dustRotation.RotatedBy(Projectile.rotation - MathHelper.PiOver2);
int phantomDust = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f);
Main.dust[phantomDust].scale = 1.1f;
Main.dust[phantomDust].noGravity = true;
Main.dust[phantomDust].position = Projectile.Center + dustRotation;
Main.dust[phantomDust].velocity = Projectile.velocity * 0.1f;
Main.dust[phantomDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[phantomDust].position) * 1.25f;
}
}
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(250, 100, 100, Projectile.alpha);
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item125, Projectile.Center);
Projectile.position.X = Projectile.position.X + (Projectile.width / 2);
Projectile.position.Y = Projectile.position.Y + (Projectile.height / 2);
Projectile.width = 50;
Projectile.height = 50;
Projectile.position.X = Projectile.position.X - (Projectile.width / 2);
Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2);
for (int i = 0; i < 3; i++)
{
int killGhostDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.2f);
Main.dust[killGhostDust].velocity *= 3f;
Main.dust[killGhostDust].noGravity = true;
if (Main.rand.NextBool())
{
Main.dust[killGhostDust].scale = 0.5f;
Main.dust[killGhostDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f;
}
}
for (int j = 0; j < 5; j++)
{
int killGhostDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.7f);
Main.dust[killGhostDust2].noGravity = true;
Main.dust[killGhostDust2].velocity *= 5f;
killGhostDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f);
Main.dust[killGhostDust2].velocity *= 2f;
}
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0)
return;
target.AddBuff(ModContent.BuffType<WhisperingDeath>(), 180);
}
}
}