Files
CalamityModPublic/NPCs/Providence/ProvSpawnHealer.cs
T

197 lines
8.1 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 ProvSpawnHealer : 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 = 0;
npc.width = 100;
npc.height = 80;
npc.defense = 35;
npc.Calamity().RevPlusDR(0.15f);
npc.lifeMax = 40000;
if (CalamityWorld.bossRushActive)
{
npc.lifeMax = CalamityWorld.death ? 500000 : 400000;
}
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.holyBossHealer = 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 = 107;
}
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;
}
}
if (npc.ai[0] == 0f)
{
Vector2 vector96 = new Vector2(npc.Center.X, npc.Center.Y);
float num784 = Main.npc[CalamityGlobalNPC.holyBoss].Center.X - vector96.X;
float num785 = Main.npc[CalamityGlobalNPC.holyBoss].Center.Y - vector96.Y;
float num786 = (float)Math.Sqrt((double)(num784 * num784 + num785 * num785));
if (num786 > 360f)
{
num786 = 8f / num786; //8f
num784 *= num786;
num785 *= num786;
npc.velocity.X = (npc.velocity.X * 15f + num784) / 16f;
npc.velocity.Y = (npc.velocity.Y * 15f + num785) / 16f;
return;
}
if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < 8f) //8f
{
npc.velocity.Y = npc.velocity.Y * 1.05f; //1.05f
npc.velocity.X = npc.velocity.X * 1.05f; //1.05f
}
if (Main.netMode != NetmodeID.MultiplayerClient && ((expertMode && Main.rand.NextBool(2000)) || Main.rand.NextBool(1000)))
{
npc.TargetClosest(true);
vector96 = new Vector2(npc.Center.X, npc.Center.Y);
num784 = player.Center.X - vector96.X;
num785 = player.Center.Y - vector96.Y;
num786 = (float)Math.Sqrt((double)(num784 * num784 + num785 * num785));
num786 = 24f / num786; //8f
npc.velocity.X = num784 * num786;
npc.velocity.Y = num785 * num786;
npc.ai[0] = 1f;
npc.netUpdate = true;
}
}
else
{
if (expertMode)
{
Vector2 value4 = player.Center - npc.Center;
value4.Normalize();
value4 *= 9f; //9f
npc.velocity = (npc.velocity * 99f + value4) / 99f; //100
}
Vector2 vector97 = new Vector2(npc.Center.X, npc.Center.Y);
float num787 = Main.npc[CalamityGlobalNPC.holyBoss].Center.X - vector97.X;
float num788 = Main.npc[CalamityGlobalNPC.holyBoss].Center.Y - vector97.Y;
float num789 = (float)Math.Sqrt((double)(num787 * num787 + num788 * num788));
if (num789 > 700f || npc.justHit)
{
npc.ai[0] = 0f;
}
}
}
public override bool CheckActive()
{
return false;
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
cooldownSlot = 1;
return true;
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(BuffID.OnFire, 600, 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/ProfanedGuardianBossH"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfanedGuardianBossGores/ProfanedGuardianBossH2"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfanedGuardianBossGores/ProfanedGuardianBossH3"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfanedGuardianBossGores/ProfanedGuardianBossH4"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfanedGuardianBossGores/ProfanedGuardianBossH5"), 1f);
for (int k = 0; k < 50; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 244, hitDirection, -1f, 0, default, 1f);
}
}
}
}
}