Files
CalamityModPublic/NPCs/Providence/ProvSpawnDefense.cs
T

168 lines
6.4 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.Providence
{
public class ProvSpawnDefense : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("A Profaned Guardian");
Main.npcFrameCount[npc.type] = 6;
}
public override void SetDefaults()
{
npc.npcSlots = 1f;
npc.aiStyle = -1;
npc.damage = 100;
npc.width = 100;
npc.height = 80;
npc.defense = 50;
npc.Calamity().RevPlusDR(0.4f);
npc.lifeMax = 25000;
if (CalamityWorld.bossRushActive)
{
npc.lifeMax = CalamityWorld.death ? 360000 : 300000;
}
double HPBoost = (double)Config.BossHealthPercentageBoost * 0.01;
npc.lifeMax += (int)((double)npc.lifeMax * HPBoost);
npc.knockBackResist = 0f;
npc.noGravity = true;
npc.noTileCollide = true;
aiType = -1;
for (int k = 0; k < npc.buffImmune.Length; k++)
{
npc.buffImmune[k] = true;
}
npc.buffImmune[BuffID.Ichor] = false;
npc.buffImmune[BuffID.CursedInferno] = false;
npc.buffImmune[ModContent.BuffType<AbyssalFlames>()] = false;
npc.buffImmune[ModContent.BuffType<ArmorCrunch>()] = false;
npc.buffImmune[ModContent.BuffType<DemonFlames>()] = false;
npc.buffImmune[ModContent.BuffType<GodSlayerInferno>()] = false;
npc.buffImmune[ModContent.BuffType<Nightwither>()] = false;
npc.buffImmune[ModContent.BuffType<Shred>()] = false;
npc.buffImmune[ModContent.BuffType<WhisperingDeath>()] = false;
npc.buffImmune[ModContent.BuffType<SilvaStun>()] = false;
npc.HitSound = SoundID.NPCHit52;
npc.DeathSound = SoundID.NPCDeath55;
}
public override void FindFrame(int frameHeight)
{
npc.frameCounter += 0.15f;
npc.frameCounter %= Main.npcFrameCount[npc.type];
int frame = (int)npc.frameCounter;
npc.frame.Y = frame * frameHeight;
}
public override void AI()
{
CalamityGlobalNPC.holyBossDefender = npc.whoAmI;
bool expertMode = Main.expertMode;
Vector2 vectorCenter = npc.Center;
Player player = Main.player[npc.target];
npc.TargetClosest(false);
if (!Main.npc[CalamityGlobalNPC.holyBoss].active)
{
npc.active = false;
npc.netUpdate = true;
return;
}
npc.dontTakeDamage = Main.npc[CalamityGlobalNPC.holyBoss].dontTakeDamage;
if (Math.Sign(npc.velocity.X) != 0)
{
npc.spriteDirection = -Math.Sign(npc.velocity.X);
}
npc.spriteDirection = Math.Sign(npc.velocity.X);
int num1009 = (npc.ai[0] == 0f) ? 1 : 2;
int num1010 = (npc.ai[0] == 0f) ? 60 : 80;
for (int num1011 = 0; num1011 < 2; num1011++)
{
if (Main.rand.Next(3) < num1009)
{
int dustType = Main.rand.Next(2);
if (dustType == 0)
{
dustType = 244;
}
else
{
dustType = 160;
}
int num1012 = Dust.NewDust(npc.Center - new Vector2((float)num1010), num1010 * 2, num1010 * 2, dustType, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 0.5f);
Main.dust[num1012].noGravity = true;
Main.dust[num1012].velocity *= 0.2f;
Main.dust[num1012].fadeIn = 1f;
}
}
npc.TargetClosest(true);
float num1372 = 9f;
Vector2 vector167 = new Vector2(npc.Center.X + (float)(npc.direction * 20), npc.Center.Y + 6f);
float num1373 = player.position.X + (float)player.width * 0.5f - vector167.X;
float num1374 = player.Center.Y - vector167.Y;
float num1375 = (float)Math.Sqrt((double)(num1373 * num1373 + num1374 * num1374));
float num1376 = num1372 / num1375;
num1373 *= num1376;
num1374 *= num1376;
npc.ai[1] -= 1f;
if (num1375 < 200f || npc.ai[1] > 0f)
{
if (num1375 < 200f)
{
npc.ai[1] = 20f;
}
return;
}
npc.velocity.X = (npc.velocity.X * 50f + num1373) / 51f;
npc.velocity.Y = (npc.velocity.Y * 50f + num1374) / 51f;
if (num1375 < 350f)
{
npc.velocity.X = (npc.velocity.X * 10f + num1373) / 11f;
npc.velocity.Y = (npc.velocity.Y * 10f + num1374) / 11f;
}
if (num1375 < 300f)
{
npc.velocity.X = (npc.velocity.X * 7f + num1373) / 8f;
npc.velocity.Y = (npc.velocity.Y * 7f + num1374) / 8f;
}
}
public override bool CheckActive()
{
return false;
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
cooldownSlot = 1;
return true;
}
public override void HitEffect(int hitDirection, double damage)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 244, hitDirection, -1f, 0, default, 1f);
}
if (npc.life <= 0)
{
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfanedGuardianBossGores/ProfanedGuardianBossT"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfanedGuardianBossGores/ProfanedGuardianBossT2"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfanedGuardianBossGores/ProfanedGuardianBossT3"), 1f);
for (int k = 0; k < 30; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 244, hitDirection, -1f, 0, default, 1f);
}
}
}
}
}