206 lines
7.8 KiB
C#
206 lines
7.8 KiB
C#
using CalamityMod.Dusts;
|
|
using CalamityMod.Events;
|
|
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using System.IO;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.NPCs.Providence
|
|
{
|
|
[AutoloadBossHead]
|
|
public class ProvSpawnHealer : ModNPC
|
|
{
|
|
private bool start = true;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("A Profaned Guardian");
|
|
Main.npcFrameCount[npc.type] = 6;
|
|
NPCID.Sets.TrailingMode[npc.type] = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
npc.npcSlots = 1f;
|
|
npc.aiStyle = -1;
|
|
npc.damage = 20;
|
|
npc.width = 100;
|
|
npc.height = 80;
|
|
npc.defense = 30;
|
|
npc.DR_NERD(0.2f);
|
|
npc.lifeMax = 15000;
|
|
if (BossRushEvent.BossRushActive)
|
|
{
|
|
npc.lifeMax = 20000;
|
|
}
|
|
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
|
|
npc.lifeMax += (int)(npc.lifeMax * HPBoost);
|
|
npc.knockBackResist = 0f;
|
|
npc.noGravity = true;
|
|
npc.noTileCollide = true;
|
|
aiType = -1;
|
|
npc.HitSound = SoundID.NPCHit52;
|
|
npc.DeathSound = SoundID.NPCDeath55;
|
|
npc.Calamity().VulnerableToHeat = false;
|
|
npc.Calamity().VulnerableToCold = true;
|
|
npc.Calamity().VulnerableToSickness = false;
|
|
npc.Calamity().VulnerableToWater = true;
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(npc.dontTakeDamage);
|
|
}
|
|
|
|
public override void ReceiveExtraAI(BinaryReader reader)
|
|
{
|
|
npc.dontTakeDamage = reader.ReadBoolean();
|
|
}
|
|
|
|
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()
|
|
{
|
|
// Setting this in SetDefaults will disable expert mode scaling, so put it here instead
|
|
npc.damage = 0;
|
|
|
|
CalamityGlobalNPC.holyBossHealer = npc.whoAmI;
|
|
|
|
if (CalamityGlobalNPC.holyBoss < 0 || !Main.npc[CalamityGlobalNPC.holyBoss].active)
|
|
{
|
|
npc.active = false;
|
|
npc.netUpdate = true;
|
|
return;
|
|
}
|
|
|
|
npc.dontTakeDamage = Main.npc[CalamityGlobalNPC.holyBoss].dontTakeDamage;
|
|
|
|
NPC parent = Main.npc[CalamityGlobalNPC.holyBoss];
|
|
if (start)
|
|
{
|
|
for (int d = 0; d < 30; d++)
|
|
Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f);
|
|
|
|
npc.ai[1] = npc.ai[0];
|
|
start = false;
|
|
}
|
|
|
|
float playerLocation = npc.Center.X - Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center.X;
|
|
npc.direction = playerLocation < 0 ? 1 : -1;
|
|
npc.spriteDirection = npc.direction;
|
|
|
|
double deg = npc.ai[1];
|
|
double rad = deg * (Math.PI / 180);
|
|
double dist = 400;
|
|
npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2;
|
|
npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2;
|
|
npc.ai[1] += 1f;
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
SpriteEffects spriteEffects = SpriteEffects.None;
|
|
if (npc.spriteDirection == 1)
|
|
spriteEffects = SpriteEffects.FlipHorizontally;
|
|
|
|
Texture2D texture2D15 = Main.npcTexture[npc.type];
|
|
Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow2");
|
|
Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2));
|
|
Color color36 = Color.White;
|
|
float amount9 = 0.5f;
|
|
int num153 = 5;
|
|
|
|
if (CalamityConfig.Instance.Afterimages)
|
|
{
|
|
for (int num155 = 1; num155 < num153; num155 += 2)
|
|
{
|
|
Color color38 = lightColor;
|
|
color38 = Color.Lerp(color38, color36, amount9);
|
|
color38 = npc.GetAlpha(color38);
|
|
color38 *= (float)(num153 - num155) / 15f;
|
|
Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition;
|
|
vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f;
|
|
vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY);
|
|
spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f);
|
|
}
|
|
}
|
|
|
|
Vector2 vector43 = npc.Center - Main.screenPosition;
|
|
vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f;
|
|
vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY);
|
|
spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f);
|
|
|
|
texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow");
|
|
Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f);
|
|
Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f);
|
|
|
|
if (CalamityConfig.Instance.Afterimages)
|
|
{
|
|
for (int num163 = 1; num163 < num153; num163++)
|
|
{
|
|
Color color41 = color37;
|
|
color41 = Color.Lerp(color41, color36, amount9);
|
|
color41 = npc.GetAlpha(color41);
|
|
color41 *= (float)(num153 - num163) / 15f;
|
|
Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition;
|
|
vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f;
|
|
vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY);
|
|
spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f);
|
|
|
|
Color color43 = color42;
|
|
color43 = Color.Lerp(color43, color36, amount9);
|
|
color43 = npc.GetAlpha(color43);
|
|
color43 *= (float)(num153 - num163) / 15f;
|
|
spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f);
|
|
}
|
|
}
|
|
|
|
spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f);
|
|
|
|
spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f);
|
|
|
|
return false;
|
|
}
|
|
|
|
public override void NPCLoot()
|
|
{
|
|
if (!CalamityWorld.malice && !CalamityWorld.revenge)
|
|
{
|
|
int heartAmt = Main.rand.Next(3) + 3;
|
|
for (int i = 0; i < heartAmt; i++)
|
|
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart);
|
|
}
|
|
}
|
|
|
|
public override bool CheckActive() => false;
|
|
|
|
public override void HitEffect(int hitDirection, double damage)
|
|
{
|
|
for (int k = 0; k < 3; k++)
|
|
Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 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, (int)CalamityDusts.ProfanedFire, hitDirection, -1f, 0, default, 1f);
|
|
}
|
|
}
|
|
}
|
|
}
|