158 lines
6.4 KiB
C#
158 lines
6.4 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.Dusts;
|
|
using CalamityMod.Events;
|
|
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
using Terraria.ID;
|
|
using Terraria.Audio;
|
|
using CalamityMod.NPCs.SupremeCalamitas;
|
|
using CalamityMod.NPCs;
|
|
|
|
namespace CalamityMod.Projectiles.Boss
|
|
{
|
|
public class SCalBrimstoneGigablast : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Boss";
|
|
public static readonly SoundStyle ImpactSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneGigablastImpact");
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Main.projFrames[Projectile.type] = 6;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.Calamity().DealsDefenseDamage = true;
|
|
Projectile.width = 50;
|
|
Projectile.height = 50;
|
|
Projectile.hostile = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 120;
|
|
Projectile.Opacity = 0f;
|
|
CooldownSlot = ImmunityCooldownID.Bosses;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.frameCounter++;
|
|
if (Projectile.frameCounter > 4)
|
|
{
|
|
Projectile.frame++;
|
|
Projectile.frameCounter = 0;
|
|
}
|
|
if (Projectile.frame > 5)
|
|
Projectile.frame = 0;
|
|
|
|
if (Projectile.ai[1] == 1f)
|
|
Projectile.Opacity = MathHelper.Clamp(Projectile.timeLeft / 60f, 0f, 1f);
|
|
else
|
|
Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - 60) / 60f), 0f, 1f);
|
|
|
|
Lighting.AddLight(Projectile.Center, 0.9f * Projectile.Opacity, 0f, 0f);
|
|
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
|
|
|
if (Projectile.localAI[0] == 0f)
|
|
{
|
|
Projectile.localAI[0] = 1f;
|
|
SoundEngine.PlaySound(SoundID.Item20, Projectile.Center);
|
|
}
|
|
|
|
int target = Player.FindClosest(Projectile.Center, 1, 1);
|
|
float projSpeed = Projectile.velocity.Length();
|
|
Vector2 playerVec = Main.player[target].Center - Projectile.Center;
|
|
playerVec.Normalize();
|
|
playerVec *= projSpeed;
|
|
Projectile.velocity = (Projectile.velocity * 24f + playerVec) / 25f;
|
|
Projectile.velocity.Normalize();
|
|
Projectile.velocity *= projSpeed;
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
|
|
int frameHeight = texture.Height / Main.projFrames[Projectile.type];
|
|
int drawStart = frameHeight * Projectile.frame;
|
|
lightColor.R = (byte)(255 * Projectile.Opacity);
|
|
|
|
if (CalamityGlobalNPC.SCal != -1)
|
|
{
|
|
if (Main.npc[CalamityGlobalNPC.SCal].active)
|
|
{
|
|
if (Main.npc[CalamityGlobalNPC.SCal].ModNPC<SupremeCalamitas>().cirrus)
|
|
lightColor.B = (byte)(255 * Projectile.Opacity);
|
|
}
|
|
}
|
|
|
|
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), Projectile.scale, SpriteEffects.None, 0);
|
|
return false;
|
|
}
|
|
|
|
public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f;
|
|
|
|
public override void OnHitPlayer(Player target, Player.HurtInfo info)
|
|
{
|
|
if (info.Damage <= 0 || Projectile.Opacity != 1f)
|
|
return;
|
|
|
|
target.AddBuff(ModContent.BuffType<VulnerabilityHex>(), 180, true);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
SoundEngine.PlaySound(ImpactSound, Projectile.Center);
|
|
|
|
// Difficulty modes
|
|
bool bossRush = BossRushEvent.BossRushActive;
|
|
bool death = CalamityWorld.death || bossRush;
|
|
bool revenge = CalamityWorld.revenge || bossRush;
|
|
bool expertMode = Main.expertMode || bossRush;
|
|
|
|
if (Projectile.ai[1] == 0f)
|
|
{
|
|
if (Projectile.owner == Main.myPlayer)
|
|
{
|
|
int totalProjectiles = bossRush ? 44 : death ? 36 : revenge ? 32 : expertMode ? 28 : 20;
|
|
float radians = MathHelper.TwoPi / totalProjectiles;
|
|
int type = ModContent.ProjectileType<BrimstoneBarrage>();
|
|
float velocity = 5f;
|
|
Vector2 spinningPoint = new Vector2(0f, -velocity);
|
|
for (int k = 0; k < totalProjectiles; k++)
|
|
{
|
|
Vector2 velocity2 = spinningPoint.RotatedBy(radians * k);
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, (int)Math.Round(Projectile.damage * 0.75), 0f, Projectile.owner, 0f, 1f);
|
|
}
|
|
}
|
|
}
|
|
|
|
int dustType = (int)CalamityDusts.Brimstone;
|
|
if (CalamityGlobalNPC.SCal != -1)
|
|
{
|
|
if (Main.npc[CalamityGlobalNPC.SCal].active)
|
|
{
|
|
if (Main.npc[CalamityGlobalNPC.SCal].ModNPC<SupremeCalamitas>().cirrus)
|
|
dustType = (int)CalamityDusts.PurpleCosmilite;
|
|
}
|
|
}
|
|
|
|
for (int j = 0; j < 2; j++)
|
|
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 1f);
|
|
|
|
for (int k = 0; k < 20; k++)
|
|
{
|
|
int redFire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1.5f);
|
|
Main.dust[redFire].noGravity = true;
|
|
Main.dust[redFire].velocity *= 3f;
|
|
redFire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 1f);
|
|
Main.dust[redFire].velocity *= 2f;
|
|
Main.dust[redFire].noGravity = true;
|
|
}
|
|
}
|
|
}
|
|
}
|