Polterghast only enrages on surface

This commit is contained in:
SheerExpanse committed 2019-07-13 22:46:07 -04:00
1 parent 7b18ad4b16
commit 91fae83f1a
3 files changed
+1607 -1606

No files matched your search

+310 -310
View File
@@ -1,310 +1,310 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Localization;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Projectiles;
using CalamityMod.World;
namespace CalamityMod.NPCs.Polterghast
{
public class PolterPhantom : ModNPC
{
private int despawnTimer = 600;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Polterghast");
Main.npcFrameCount[npc.type] = 4;
}
public override void SetDefaults()
{
npc.damage = 210;
npc.width = 90;
npc.height = 120;
npc.defense = 0;
npc.lifeMax = CalamityWorld.revenge ? 150000 : 130000;
if (CalamityWorld.death)
{
npc.lifeMax = 225000;
}
if (CalamityWorld.bossRushActive)
{
npc.lifeMax = CalamityWorld.death ? 1100000 : 900000;
}
double HPBoost = (double)Config.BossHealthPercentageBoost * 0.01;
npc.lifeMax += (int)((double)npc.lifeMax * HPBoost);
npc.knockBackResist = 0f;
npc.aiStyle = -1; //new
aiType = -1; //new
npc.alpha = 255;
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[mod.BuffType("AbyssalFlames")] = false;
npc.buffImmune[mod.BuffType("DemonFlames")] = false;
npc.buffImmune[mod.BuffType("GodSlayerInferno")] = false;
npc.buffImmune[mod.BuffType("Nightwither")] = false;
npc.buffImmune[mod.BuffType("Shred")] = false;
npc.noGravity = true;
npc.noTileCollide = true;
npc.netAlways = true;
npc.canGhostHeal = false;
npc.HitSound = SoundID.NPCHit36;
npc.DeathSound = SoundID.NPCDeath39;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(despawnTimer);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
despawnTimer = reader.ReadInt32();
}
public override void AI()
{
CalamityGlobalNPC.ghostBossClone = npc.whoAmI;
npc.alpha -= 5;
if (npc.alpha < 50)
{
npc.alpha = 50;
}
if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active)
{
npc.active = false;
npc.netUpdate = true;
return;
}
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.5f, 0.25f, 0.75f);
npc.TargetClosest(true);
Vector2 vector = npc.Center;
if (Vector2.Distance(Main.player[npc.target].Center, vector) > 6000f)
{
npc.active = false;
}
bool speedBoost1 = false;
bool despawnBoost = false;
if (npc.timeLeft < 1500)
{
npc.timeLeft = 1500;
}
bool revenge = (CalamityWorld.revenge || CalamityWorld.bossRushActive);
bool expertMode = (Main.expertMode || CalamityWorld.bossRushActive);
int[] array2 = new int[4];
float num730 = 0f;
float num731 = 0f;
int num732 = 0;
int num;
for (int num733 = 0; num733 < 200; num733 = num + 1)
{
if (Main.npc[num733].active && Main.npc[num733].type == mod.NPCType("PolterghastHook"))
{
num730 += Main.npc[num733].Center.X;
num731 += Main.npc[num733].Center.Y;
array2[num732] = num733;
num732++;
if (num732 > 3)
break;
}
num = num733;
}
num730 /= (float)num732;
num731 /= (float)num732;
float num734 = 3f;
float num735 = 0.03f;
if (!Main.player[npc.target].ZoneDungeon)
{
despawnTimer--;
if (despawnTimer <= 0)
despawnBoost = true;
speedBoost1 = true;
num734 += 8f;
num735 = 0.15f;
}
else
{
despawnTimer = 600;
}
if (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] < 300f)
{
num734 = 18f;
num735 = 0.12f;
}
if (expertMode)
{
num734 += revenge ? 1.5f : 1f;
num734 *= revenge ? 1.25f : 1.1f;
num735 += revenge ? 0.015f : 0.01f;
num735 *= revenge ? 1.2f : 1.1f;
}
Vector2 vector91 = new Vector2(num730, num731);
float num736 = Main.player[npc.target].Center.X - vector91.X;
float num737 = Main.player[npc.target].Center.Y - vector91.Y;
if (despawnBoost)
{
num737 *= -1f;
num736 *= -1f;
num734 += 8f;
}
float num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737));
int num739 = 500;
if (speedBoost1)
{
num739 += 500;
}
if (expertMode)
{
num739 += 150;
}
if (num738 >= (float)num739)
{
num738 = (float)num739 / num738;
num736 *= num738;
num737 *= num738;
}
num730 += num736;
num731 += num737;
vector91 = new Vector2(vector.X, vector.Y);
num736 = num730 - vector91.X;
num737 = num731 - vector91.Y;
num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737));
if (num738 < num734)
{
num736 = npc.velocity.X;
num737 = npc.velocity.Y;
}
else
{
num738 = num734 / num738;
num736 *= num738;
num737 *= num738;
}
if (npc.velocity.X < num736)
{
npc.velocity.X = npc.velocity.X + num735;
if (npc.velocity.X < 0f && num736 > 0f)
{
npc.velocity.X = npc.velocity.X + num735 * 2f;
}
}
else if (npc.velocity.X > num736)
{
npc.velocity.X = npc.velocity.X - num735;
if (npc.velocity.X > 0f && num736 < 0f)
{
npc.velocity.X = npc.velocity.X - num735 * 2f;
}
}
if (npc.velocity.Y < num737)
{
npc.velocity.Y = npc.velocity.Y + num735;
if (npc.velocity.Y < 0f && num737 > 0f)
{
npc.velocity.Y = npc.velocity.Y + num735 * 2f;
}
}
else if (npc.velocity.Y > num737)
{
npc.velocity.Y = npc.velocity.Y - num735;
if (npc.velocity.Y > 0f && num737 < 0f)
{
npc.velocity.Y = npc.velocity.Y - num735 * 2f;
}
}
Vector2 vector92 = new Vector2(vector.X, vector.Y);
float num740 = Main.player[npc.target].Center.X - vector92.X;
float num741 = Main.player[npc.target].Center.Y - vector92.Y;
npc.rotation = (float)Math.Atan2((double)num741, (double)num740) + 1.57f;
if (speedBoost1)
{
npc.defense = 400;
npc.damage = 1200;
}
else
{
npc.damage = expertMode ? 336 : 210;
npc.defense = 0;
}
}
public override Color? GetAlpha(Color drawColor)
{
return new Color(200, 150, 255, npc.alpha);
}
public override void FindFrame(int frameHeight)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 6.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y + frameHeight;
}
if (npc.frame.Y > frameHeight * 3)
{
npc.frame.Y = 0;
}
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
if (CalamityWorld.revenge)
player.AddBuff(mod.BuffType("Horror"), 180, true);
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
cooldownSlot = 1;
return true;
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale);
npc.damage = (int)(npc.damage * 0.8f);
}
public override void HitEffect(int hitDirection, double damage)
{
Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default(Color), 1f);
if (npc.life <= 0)
{
npc.position.X = npc.position.X + (float)(npc.width / 2);
npc.position.Y = npc.position.Y + (float)(npc.height / 2);
npc.width = 90;
npc.height = 90;
npc.position.X = npc.position.X - (float)(npc.width / 2);
npc.position.Y = npc.position.Y - (float)(npc.height / 2);
for (int num621 = 0; num621 < 10; num621++)
{
int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 60, 0f, 0f, 100, default(Color), 2f);
Main.dust[num622].velocity *= 3f;
if (Main.rand.Next(2) == 0)
{
Main.dust[num622].scale = 0.5f;
Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
}
}
for (int num623 = 0; num623 < 60; num623++)
{
int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default(Color), 3f);
Main.dust[num624].noGravity = true;
Main.dust[num624].velocity *= 5f;
num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default(Color), 2f);
Main.dust[num624].velocity *= 2f;
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Localization;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Projectiles;
using CalamityMod.World;
namespace CalamityMod.NPCs.Polterghast
{
public class PolterPhantom : ModNPC
{
private int despawnTimer = 600;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Polterghast");
Main.npcFrameCount[npc.type] = 4;
}
public override void SetDefaults()
{
npc.damage = 210;
npc.width = 90;
npc.height = 120;
npc.defense = 0;
npc.lifeMax = CalamityWorld.revenge ? 150000 : 130000;
if (CalamityWorld.death)
{
npc.lifeMax = 225000;
}
if (CalamityWorld.bossRushActive)
{
npc.lifeMax = CalamityWorld.death ? 1100000 : 900000;
}
double HPBoost = (double)Config.BossHealthPercentageBoost * 0.01;
npc.lifeMax += (int)((double)npc.lifeMax * HPBoost);
npc.knockBackResist = 0f;
npc.aiStyle = -1; //new
aiType = -1; //new
npc.alpha = 255;
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[mod.BuffType("AbyssalFlames")] = false;
npc.buffImmune[mod.BuffType("DemonFlames")] = false;
npc.buffImmune[mod.BuffType("GodSlayerInferno")] = false;
npc.buffImmune[mod.BuffType("Nightwither")] = false;
npc.buffImmune[mod.BuffType("Shred")] = false;
npc.noGravity = true;
npc.noTileCollide = true;
npc.netAlways = true;
npc.canGhostHeal = false;
npc.HitSound = SoundID.NPCHit36;
npc.DeathSound = SoundID.NPCDeath39;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(despawnTimer);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
despawnTimer = reader.ReadInt32();
}
public override void AI()
{
CalamityGlobalNPC.ghostBossClone = npc.whoAmI;
npc.alpha -= 5;
if (npc.alpha < 50)
{
npc.alpha = 50;
}
if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active)
{
npc.active = false;
npc.netUpdate = true;
return;
}
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.5f, 0.25f, 0.75f);
npc.TargetClosest(true);
Vector2 vector = npc.Center;
if (Vector2.Distance(Main.player[npc.target].Center, vector) > 6000f)
{
npc.active = false;
}
bool speedBoost1 = false;
bool despawnBoost = false;
if (npc.timeLeft < 1500)
{
npc.timeLeft = 1500;
}
bool revenge = (CalamityWorld.revenge || CalamityWorld.bossRushActive);
bool expertMode = (Main.expertMode || CalamityWorld.bossRushActive);
int[] array2 = new int[4];
float num730 = 0f;
float num731 = 0f;
int num732 = 0;
int num;
for (int num733 = 0; num733 < 200; num733 = num + 1)
{
if (Main.npc[num733].active && Main.npc[num733].type == mod.NPCType("PolterghastHook"))
{
num730 += Main.npc[num733].Center.X;
num731 += Main.npc[num733].Center.Y;
array2[num732] = num733;
num732++;
if (num732 > 3)
break;
}
num = num733;
}
num730 /= (float)num732;
num731 /= (float)num732;
float num734 = 3f;
float num735 = 0.03f;
if (!Main.player[npc.target].ZoneDungeon && !CalamityWorld.bossRushActive && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)
{
despawnTimer--;
if (despawnTimer <= 0)
despawnBoost = true;
speedBoost1 = true;
num734 += 8f;
num735 = 0.15f;
}
else
{
despawnTimer = 600;
}
if (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] < 300f)
{
num734 = 18f;
num735 = 0.12f;
}
if (expertMode)
{
num734 += revenge ? 1.5f : 1f;
num734 *= revenge ? 1.25f : 1.1f;
num735 += revenge ? 0.015f : 0.01f;
num735 *= revenge ? 1.2f : 1.1f;
}
Vector2 vector91 = new Vector2(num730, num731);
float num736 = Main.player[npc.target].Center.X - vector91.X;
float num737 = Main.player[npc.target].Center.Y - vector91.Y;
if (despawnBoost)
{
num737 *= -1f;
num736 *= -1f;
num734 += 8f;
}
float num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737));
int num739 = 500;
if (speedBoost1)
{
num739 += 500;
}
if (expertMode)
{
num739 += 150;
}
if (num738 >= (float)num739)
{
num738 = (float)num739 / num738;
num736 *= num738;
num737 *= num738;
}
num730 += num736;
num731 += num737;
vector91 = new Vector2(vector.X, vector.Y);
num736 = num730 - vector91.X;
num737 = num731 - vector91.Y;
num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737));
if (num738 < num734)
{
num736 = npc.velocity.X;
num737 = npc.velocity.Y;
}
else
{
num738 = num734 / num738;
num736 *= num738;
num737 *= num738;
}
if (npc.velocity.X < num736)
{
npc.velocity.X = npc.velocity.X + num735;
if (npc.velocity.X < 0f && num736 > 0f)
{
npc.velocity.X = npc.velocity.X + num735 * 2f;
}
}
else if (npc.velocity.X > num736)
{
npc.velocity.X = npc.velocity.X - num735;
if (npc.velocity.X > 0f && num736 < 0f)
{
npc.velocity.X = npc.velocity.X - num735 * 2f;
}
}
if (npc.velocity.Y < num737)
{
npc.velocity.Y = npc.velocity.Y + num735;
if (npc.velocity.Y < 0f && num737 > 0f)
{
npc.velocity.Y = npc.velocity.Y + num735 * 2f;
}
}
else if (npc.velocity.Y > num737)
{
npc.velocity.Y = npc.velocity.Y - num735;
if (npc.velocity.Y > 0f && num737 < 0f)
{
npc.velocity.Y = npc.velocity.Y - num735 * 2f;
}
}
Vector2 vector92 = new Vector2(vector.X, vector.Y);
float num740 = Main.player[npc.target].Center.X - vector92.X;
float num741 = Main.player[npc.target].Center.Y - vector92.Y;
npc.rotation = (float)Math.Atan2((double)num741, (double)num740) + 1.57f;
if (speedBoost1)
{
npc.defense = 400;
npc.damage = 1200;
}
else
{
npc.damage = expertMode ? 336 : 210;
npc.defense = 0;
}
}
public override Color? GetAlpha(Color drawColor)
{
return new Color(200, 150, 255, npc.alpha);
}
public override void FindFrame(int frameHeight)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 6.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y + frameHeight;
}
if (npc.frame.Y > frameHeight * 3)
{
npc.frame.Y = 0;
}
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
if (CalamityWorld.revenge)
player.AddBuff(mod.BuffType("Horror"), 180, true);
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
cooldownSlot = 1;
return true;
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale);
npc.damage = (int)(npc.damage * 0.8f);
}
public override void HitEffect(int hitDirection, double damage)
{
Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default(Color), 1f);
if (npc.life <= 0)
{
npc.position.X = npc.position.X + (float)(npc.width / 2);
npc.position.Y = npc.position.Y + (float)(npc.height / 2);
npc.width = 90;
npc.height = 90;
npc.position.X = npc.position.X - (float)(npc.width / 2);
npc.position.Y = npc.position.Y - (float)(npc.height / 2);
for (int num621 = 0; num621 < 10; num621++)
{
int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 60, 0f, 0f, 100, default(Color), 2f);
Main.dust[num622].velocity *= 3f;
if (Main.rand.Next(2) == 0)
{
Main.dust[num622].scale = 0.5f;
Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
}
}
for (int num623 = 0; num623 < 60; num623++)
{
int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default(Color), 3f);
Main.dust[num624].noGravity = true;
Main.dust[num624].velocity *= 5f;
num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default(Color), 2f);
Main.dust[num624].velocity *= 2f;
}
}
}
}
}
File diff suppressed because it is too large. Load diff
+485 -484
View File
@@ -1,484 +1,485 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Projectiles;
using CalamityMod.World;
namespace CalamityMod.NPCs.Polterghast
{
public class PolterghastHook : ModNPC
{
private int despawnTimer = 300;
private bool phase2 = false;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Polterghast Hook");
Main.npcFrameCount[npc.type] = 2;
}
public override void SetDefaults()
{
npc.aiStyle = -1;
aiType = -1;
npc.damage = 120;
npc.width = 40; //324
npc.height = 40; //216
npc.defense = 50;
npc.lifeMax = CalamityWorld.revenge ? 60000 : 50000;
if (CalamityWorld.death)
{
npc.lifeMax = 100000;
}
npc.dontTakeDamage = true;
npc.noGravity = true;
npc.noTileCollide = true;
for (int k = 0; k < npc.buffImmune.Length; k++)
{
npc.buffImmune[k] = true;
}
npc.HitSound = SoundID.NPCHit34;
npc.DeathSound = SoundID.NPCDeath39;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(phase2);
writer.Write(despawnTimer);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
phase2 = reader.ReadBoolean();
despawnTimer = reader.ReadInt32();
}
public override void AI()
{
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.3f, 1f, 1f);
bool expertMode = Main.expertMode;
bool revenge = CalamityWorld.revenge;
bool speedBoost1 = false;
bool despawnBoost = false;
if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active)
{
npc.active = false;
npc.netUpdate = true;
return;
}
if (CalamityGlobalNPC.ghostBoss != -1 && !Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].ZoneDungeon && !CalamityWorld.bossRushActive)
{
despawnTimer--;
if (despawnTimer <= 0) { despawnBoost = true; }
npc.localAI[0] -= 6f;
speedBoost1 = true;
}
else { despawnTimer = 300; }
if ((double)Main.npc[CalamityGlobalNPC.ghostBoss].life <= (double)Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax * 0.75)
{
if (!phase2)
{
npc.damage = 0;
phase2 = true;
}
npc.TargetClosest(true);
if (Main.netMode == 1)
{
if (npc.ai[0] == 0f)
{
npc.ai[0] = (float)((int)(npc.Center.X / 16f));
}
if (npc.ai[1] == 0f)
{
npc.ai[1] = (float)((int)(npc.Center.X / 16f));
}
}
if (Main.netMode != 1)
{
if (npc.ai[0] == 0f || npc.ai[1] == 0f)
{
npc.localAI[0] = 0f;
}
npc.localAI[0] -= 5f;
if (speedBoost1)
{
npc.localAI[0] -= 10f;
}
if (!despawnBoost && npc.localAI[0] <= 0f && npc.ai[0] != 0f)
{
int num;
for (int num763 = 0; num763 < 200; num763 = num + 1)
{
if (num763 != npc.whoAmI && Main.npc[num763].active && Main.npc[num763].type == npc.type && (Main.npc[num763].velocity.X != 0f || Main.npc[num763].velocity.Y != 0f))
{
npc.localAI[0] = (float)Main.rand.Next(60, 300);
}
num = num763;
}
}
if (npc.localAI[0] <= 0f)
{
npc.localAI[0] = (float)Main.rand.Next(300, 600);
bool flag50 = false;
int num764 = 0;
while (!flag50 && num764 <= 1000)
{
num764++;
int num765 = (int)(Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.X / 16f);
int num766 = (int)(Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.Y / 16f);
if (npc.ai[0] == 0f)
{
num765 = (int)((Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.X + Main.npc[CalamityGlobalNPC.ghostBoss].Center.X) / 32f);
num766 = (int)((Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.Y + Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y) / 32f);
}
if (despawnBoost)
{
num765 = (int)Main.npc[CalamityGlobalNPC.ghostBoss].position.X / 16;
num766 = (int)(Main.npc[CalamityGlobalNPC.ghostBoss].position.Y + 400f) / 16;
}
int num767 = 20;
num767 += (int)(100f * ((float)num764 / 1000f));
int num768 = num765 + Main.rand.Next(-num767, num767 + 1);
int num769 = num766 + Main.rand.Next(-num767, num767 + 1);
try
{
if (WorldGen.SolidTile(num768, num769) || (Main.tile[num768, num769].wall > 0 && (num764 > 500 || Main.npc[CalamityGlobalNPC.ghostBoss].life < Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax / 2)))
{
flag50 = true;
npc.ai[0] = (float)num768;
npc.ai[1] = (float)num769;
npc.netUpdate = true;
}
}
catch
{
}
}
}
}
if (npc.ai[0] > 0f && npc.ai[1] > 0f)
{
float num772 = 8f;
if (expertMode)
{
num772 += 1f;
}
if (speedBoost1)
{
num772 *= 2f;
}
if (despawnBoost)
{
num772 *= 2f;
}
Vector2 vector95 = new Vector2(npc.Center.X, npc.Center.Y);
float num773 = npc.ai[0] * 16f - 8f - vector95.X;
float num774 = npc.ai[1] * 16f - 8f - vector95.Y;
float num775 = (float)Math.Sqrt((double)(num773 * num773 + num774 * num774));
if (num775 < 12f + num772)
{
npc.velocity.X = num773;
npc.velocity.Y = num774;
}
else
{
num775 = num772 / num775;
npc.velocity.X = num773 * num775;
npc.velocity.Y = num774 * num775;
}
}
Vector2 vector102 = new Vector2(npc.Center.X, npc.Center.Y);
float num818 = Main.player[npc.target].Center.X - vector102.X;
float num819 = Main.player[npc.target].Center.Y - vector102.Y;
float num820 = (float)Math.Sqrt((double)(num818 * num818 + num819 * num819));
float num821 = 10f;
num820 = num821 / num820;
num818 *= num820;
num819 *= num820;
npc.rotation = (float)Math.Atan2((double)num819, (double)num818) + 1.57f;
Vector2 vector17 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num147 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector17.X;
float num148 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector17.Y;
float num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148));
num149 = 4f / num149;
num147 *= num149;
num148 *= num149;
vector17 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
num147 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector17.X;
num148 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector17.Y;
num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148));
if (num149 > 1200f)
{
npc.ai[2] = 0f;
npc.ai[3] = 0f;
return;
}
npc.ai[2] += 1f;
if (npc.ai[3] == 0f)
{
if (npc.ai[2] > 120f)
{
npc.ai[2] = 0f;
npc.ai[3] = 1f;
npc.netUpdate = true;
}
}
else
{
if (npc.ai[2] > 40f)
{
npc.ai[3] = 0f;
}
if (Main.netMode != 1 && npc.ai[2] == 20f)
{
float num151 = 5f;
int num152 = 60;
int num153 = mod.ProjectileType("PhantomHookShot");
num149 = num151 / num149;
num147 *= num149;
num148 *= num149;
int num154 = Projectile.NewProjectile(vector17.X, vector17.Y, num147, num148, num153, num152, 0f, Main.myPlayer, 0f, 0f);
}
}
return;
}
if (Main.netMode == 1)
{
if (npc.ai[0] == 0f)
{
npc.ai[0] = (float)((int)(npc.Center.X / 16f));
}
if (npc.ai[1] == 0f)
{
npc.ai[1] = (float)((int)(npc.Center.X / 16f));
}
}
if (Main.netMode != 1)
{
if (npc.ai[0] == 0f || npc.ai[1] == 0f)
{
npc.localAI[0] = 0f;
}
npc.localAI[0] -= 5f;
if (speedBoost1)
{
npc.localAI[0] -= 10f;
}
if (!despawnBoost && npc.localAI[0] <= 0f && npc.ai[0] != 0f)
{
int num;
for (int num763 = 0; num763 < 200; num763 = num + 1)
{
if (num763 != npc.whoAmI && Main.npc[num763].active && Main.npc[num763].type == npc.type && (Main.npc[num763].velocity.X != 0f || Main.npc[num763].velocity.Y != 0f))
{
npc.localAI[0] = (float)Main.rand.Next(60, 300);
}
num = num763;
}
}
if (npc.localAI[0] <= 0f)
{
npc.localAI[0] = (float)Main.rand.Next(300, 600);
bool flag50 = false;
int num764 = 0;
while (!flag50 && num764 <= 1000)
{
num764++;
int num765 = (int)(Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.X / 16f);
int num766 = (int)(Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.Y / 16f);
if (npc.ai[0] == 0f)
{
num765 = (int)((Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.X + Main.npc[CalamityGlobalNPC.ghostBoss].Center.X) / 32f);
num766 = (int)((Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.Y + Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y) / 32f);
}
if (despawnBoost)
{
num765 = (int)Main.npc[CalamityGlobalNPC.ghostBoss].position.X / 16;
num766 = (int)(Main.npc[CalamityGlobalNPC.ghostBoss].position.Y + 400f) / 16;
}
int num767 = 20;
num767 += (int)(100f * ((float)num764 / 1000f));
int num768 = num765 + Main.rand.Next(-num767, num767 + 1);
int num769 = num766 + Main.rand.Next(-num767, num767 + 1);
try
{
if (WorldGen.SolidTile(num768, num769) || (Main.tile[num768, num769].wall > 0 && (num764 > 500 || Main.npc[CalamityGlobalNPC.ghostBoss].life < Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax / 2)))
{
flag50 = true;
npc.ai[0] = (float)num768;
npc.ai[1] = (float)num769;
npc.netUpdate = true;
}
}
catch
{
}
}
}
}
if (npc.ai[0] > 0f && npc.ai[1] > 0f)
{
float num772 = 11f;
if (expertMode)
{
num772 += 1f;
}
if (speedBoost1)
{
num772 *= 2f;
}
if (despawnBoost)
{
num772 *= 2f;
}
Vector2 vector95 = new Vector2(npc.Center.X, npc.Center.Y);
float num773 = npc.ai[0] * 16f - 8f - vector95.X;
float num774 = npc.ai[1] * 16f - 8f - vector95.Y;
float num775 = (float)Math.Sqrt((double)(num773 * num773 + num774 * num774));
if (num775 < 12f + num772)
{
npc.velocity.X = num773;
npc.velocity.Y = num774;
}
else
{
num775 = num772 / num775;
npc.velocity.X = num773 * num775;
npc.velocity.Y = num774 * num775;
}
Vector2 vector96 = new Vector2(npc.Center.X, npc.Center.Y);
float num776 = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - vector96.X;
float num777 = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - vector96.Y;
npc.rotation = (float)Math.Atan2((double)num777, (double)num776) - 1.57f;
}
}
public override void FindFrame(int frameHeight)
{
if (phase2)
{
if (npc.ai[3] == 0f)
{
if (npc.frame.Y < 1)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 4.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y + frameHeight;
}
}
}
else if (npc.frame.Y > 0)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 4.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y - frameHeight;
}
}
return;
}
if (npc.velocity.X == 0f && npc.velocity.Y == 0f)
{
if (npc.frame.Y < 1)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 4.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y + frameHeight;
}
}
}
else if (npc.frame.Y > 0)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 4.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y - frameHeight;
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
{
if (Main.npc[CalamityGlobalNPC.ghostBoss].active && !phase2)
{
Vector2 center = new Vector2(npc.Center.X, npc.Center.Y);
float bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X;
float bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y;
float rotation2 = (float)Math.Atan2((double)bossCenterY, (double)bossCenterX) - 1.57f;
bool draw = true;
while (draw)
{
int chainWidth = 20; //16 24
int chainHeight = 52; //32 16
float num10 = (float)Math.Sqrt((double)(bossCenterX * bossCenterX + bossCenterY * bossCenterY));
if (num10 < (float)chainHeight)
{
chainWidth = (int)num10 - chainHeight + chainWidth;
draw = false;
}
num10 = (float)chainWidth / num10;
bossCenterX *= num10;
bossCenterY *= num10;
center.X += bossCenterX;
center.Y += bossCenterY;
bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X;
bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y;
Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f));
Main.spriteBatch.Draw(mod.GetTexture("NPCs/Polterghast/PolterghastChain"), new Vector2(center.X - Main.screenPosition.X, center.Y - Main.screenPosition.Y),
new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, 0, mod.GetTexture("NPCs/Polterghast/PolterghastChain").Width, chainWidth)), color2, rotation2,
new Vector2((float)mod.GetTexture("NPCs/Polterghast/PolterghastChain").Width * 0.5f, (float)mod.GetTexture("NPCs/Polterghast/PolterghastChain").Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
}
return true;
}
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)
{
if (CalamityWorld.revenge)
player.AddBuff(mod.BuffType("Horror"), 180, true);
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale);
npc.damage = (int)(npc.damage * 0.7f);
}
public override void HitEffect(int hitDirection, double damage)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default(Color), 1f);
}
if (npc.life <= 0)
{
for (int k = 0; k < 20; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default(Color), 1f);
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Projectiles;
using CalamityMod.World;
namespace CalamityMod.NPCs.Polterghast
{
public class PolterghastHook : ModNPC
{
private int despawnTimer = 300;
private bool phase2 = false;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Polterghast Hook");
Main.npcFrameCount[npc.type] = 2;
}
public override void SetDefaults()
{
npc.aiStyle = -1;
aiType = -1;
npc.damage = 120;
npc.width = 40; //324
npc.height = 40; //216
npc.defense = 50;
npc.lifeMax = CalamityWorld.revenge ? 60000 : 50000;
if (CalamityWorld.death)
{
npc.lifeMax = 100000;
}
npc.dontTakeDamage = true;
npc.noGravity = true;
npc.noTileCollide = true;
for (int k = 0; k < npc.buffImmune.Length; k++)
{
npc.buffImmune[k] = true;
}
npc.HitSound = SoundID.NPCHit34;
npc.DeathSound = SoundID.NPCDeath39;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(phase2);
writer.Write(despawnTimer);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
phase2 = reader.ReadBoolean();
despawnTimer = reader.ReadInt32();
}
public override void AI()
{
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.3f, 1f, 1f);
bool expertMode = Main.expertMode;
bool revenge = CalamityWorld.revenge;
bool speedBoost1 = false;
bool despawnBoost = false;
if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active)
{
npc.active = false;
npc.netUpdate = true;
return;
}
if (CalamityGlobalNPC.ghostBoss != -1 && !Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].ZoneDungeon &&
(double)Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].position.Y < Main.worldSurface * 16.0 && !CalamityWorld.bossRushActive)
{
despawnTimer--;
if (despawnTimer <= 0) { despawnBoost = true; }
npc.localAI[0] -= 6f;
speedBoost1 = true;
}
else { despawnTimer = 300; }
if ((double)Main.npc[CalamityGlobalNPC.ghostBoss].life <= (double)Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax * 0.75)
{
if (!phase2)
{
npc.damage = 0;
phase2 = true;
}
npc.TargetClosest(true);
if (Main.netMode == 1)
{
if (npc.ai[0] == 0f)
{
npc.ai[0] = (float)((int)(npc.Center.X / 16f));
}
if (npc.ai[1] == 0f)
{
npc.ai[1] = (float)((int)(npc.Center.X / 16f));
}
}
if (Main.netMode != 1)
{
if (npc.ai[0] == 0f || npc.ai[1] == 0f)
{
npc.localAI[0] = 0f;
}
npc.localAI[0] -= 5f;
if (speedBoost1)
{
npc.localAI[0] -= 10f;
}
if (!despawnBoost && npc.localAI[0] <= 0f && npc.ai[0] != 0f)
{
int num;
for (int num763 = 0; num763 < 200; num763 = num + 1)
{
if (num763 != npc.whoAmI && Main.npc[num763].active && Main.npc[num763].type == npc.type && (Main.npc[num763].velocity.X != 0f || Main.npc[num763].velocity.Y != 0f))
{
npc.localAI[0] = (float)Main.rand.Next(60, 300);
}
num = num763;
}
}
if (npc.localAI[0] <= 0f)
{
npc.localAI[0] = (float)Main.rand.Next(300, 600);
bool flag50 = false;
int num764 = 0;
while (!flag50 && num764 <= 1000)
{
num764++;
int num765 = (int)(Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.X / 16f);
int num766 = (int)(Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.Y / 16f);
if (npc.ai[0] == 0f)
{
num765 = (int)((Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.X + Main.npc[CalamityGlobalNPC.ghostBoss].Center.X) / 32f);
num766 = (int)((Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.Y + Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y) / 32f);
}
if (despawnBoost)
{
num765 = (int)Main.npc[CalamityGlobalNPC.ghostBoss].position.X / 16;
num766 = (int)(Main.npc[CalamityGlobalNPC.ghostBoss].position.Y + 400f) / 16;
}
int num767 = 20;
num767 += (int)(100f * ((float)num764 / 1000f));
int num768 = num765 + Main.rand.Next(-num767, num767 + 1);
int num769 = num766 + Main.rand.Next(-num767, num767 + 1);
try
{
if (WorldGen.SolidTile(num768, num769) || (Main.tile[num768, num769].wall > 0 && (num764 > 500 || Main.npc[CalamityGlobalNPC.ghostBoss].life < Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax / 2)))
{
flag50 = true;
npc.ai[0] = (float)num768;
npc.ai[1] = (float)num769;
npc.netUpdate = true;
}
}
catch
{
}
}
}
}
if (npc.ai[0] > 0f && npc.ai[1] > 0f)
{
float num772 = 8f;
if (expertMode)
{
num772 += 1f;
}
if (speedBoost1)
{
num772 *= 2f;
}
if (despawnBoost)
{
num772 *= 2f;
}
Vector2 vector95 = new Vector2(npc.Center.X, npc.Center.Y);
float num773 = npc.ai[0] * 16f - 8f - vector95.X;
float num774 = npc.ai[1] * 16f - 8f - vector95.Y;
float num775 = (float)Math.Sqrt((double)(num773 * num773 + num774 * num774));
if (num775 < 12f + num772)
{
npc.velocity.X = num773;
npc.velocity.Y = num774;
}
else
{
num775 = num772 / num775;
npc.velocity.X = num773 * num775;
npc.velocity.Y = num774 * num775;
}
}
Vector2 vector102 = new Vector2(npc.Center.X, npc.Center.Y);
float num818 = Main.player[npc.target].Center.X - vector102.X;
float num819 = Main.player[npc.target].Center.Y - vector102.Y;
float num820 = (float)Math.Sqrt((double)(num818 * num818 + num819 * num819));
float num821 = 10f;
num820 = num821 / num820;
num818 *= num820;
num819 *= num820;
npc.rotation = (float)Math.Atan2((double)num819, (double)num818) + 1.57f;
Vector2 vector17 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num147 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector17.X;
float num148 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector17.Y;
float num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148));
num149 = 4f / num149;
num147 *= num149;
num148 *= num149;
vector17 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
num147 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector17.X;
num148 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector17.Y;
num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148));
if (num149 > 1200f)
{
npc.ai[2] = 0f;
npc.ai[3] = 0f;
return;
}
npc.ai[2] += 1f;
if (npc.ai[3] == 0f)
{
if (npc.ai[2] > 120f)
{
npc.ai[2] = 0f;
npc.ai[3] = 1f;
npc.netUpdate = true;
}
}
else
{
if (npc.ai[2] > 40f)
{
npc.ai[3] = 0f;
}
if (Main.netMode != 1 && npc.ai[2] == 20f)
{
float num151 = 5f;
int num152 = 60;
int num153 = mod.ProjectileType("PhantomHookShot");
num149 = num151 / num149;
num147 *= num149;
num148 *= num149;
int num154 = Projectile.NewProjectile(vector17.X, vector17.Y, num147, num148, num153, num152, 0f, Main.myPlayer, 0f, 0f);
}
}
return;
}
if (Main.netMode == 1)
{
if (npc.ai[0] == 0f)
{
npc.ai[0] = (float)((int)(npc.Center.X / 16f));
}
if (npc.ai[1] == 0f)
{
npc.ai[1] = (float)((int)(npc.Center.X / 16f));
}
}
if (Main.netMode != 1)
{
if (npc.ai[0] == 0f || npc.ai[1] == 0f)
{
npc.localAI[0] = 0f;
}
npc.localAI[0] -= 5f;
if (speedBoost1)
{
npc.localAI[0] -= 10f;
}
if (!despawnBoost && npc.localAI[0] <= 0f && npc.ai[0] != 0f)
{
int num;
for (int num763 = 0; num763 < 200; num763 = num + 1)
{
if (num763 != npc.whoAmI && Main.npc[num763].active && Main.npc[num763].type == npc.type && (Main.npc[num763].velocity.X != 0f || Main.npc[num763].velocity.Y != 0f))
{
npc.localAI[0] = (float)Main.rand.Next(60, 300);
}
num = num763;
}
}
if (npc.localAI[0] <= 0f)
{
npc.localAI[0] = (float)Main.rand.Next(300, 600);
bool flag50 = false;
int num764 = 0;
while (!flag50 && num764 <= 1000)
{
num764++;
int num765 = (int)(Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.X / 16f);
int num766 = (int)(Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.Y / 16f);
if (npc.ai[0] == 0f)
{
num765 = (int)((Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.X + Main.npc[CalamityGlobalNPC.ghostBoss].Center.X) / 32f);
num766 = (int)((Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center.Y + Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y) / 32f);
}
if (despawnBoost)
{
num765 = (int)Main.npc[CalamityGlobalNPC.ghostBoss].position.X / 16;
num766 = (int)(Main.npc[CalamityGlobalNPC.ghostBoss].position.Y + 400f) / 16;
}
int num767 = 20;
num767 += (int)(100f * ((float)num764 / 1000f));
int num768 = num765 + Main.rand.Next(-num767, num767 + 1);
int num769 = num766 + Main.rand.Next(-num767, num767 + 1);
try
{
if (WorldGen.SolidTile(num768, num769) || (Main.tile[num768, num769].wall > 0 && (num764 > 500 || Main.npc[CalamityGlobalNPC.ghostBoss].life < Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax / 2)))
{
flag50 = true;
npc.ai[0] = (float)num768;
npc.ai[1] = (float)num769;
npc.netUpdate = true;
}
}
catch
{
}
}
}
}
if (npc.ai[0] > 0f && npc.ai[1] > 0f)
{
float num772 = 11f;
if (expertMode)
{
num772 += 1f;
}
if (speedBoost1)
{
num772 *= 2f;
}
if (despawnBoost)
{
num772 *= 2f;
}
Vector2 vector95 = new Vector2(npc.Center.X, npc.Center.Y);
float num773 = npc.ai[0] * 16f - 8f - vector95.X;
float num774 = npc.ai[1] * 16f - 8f - vector95.Y;
float num775 = (float)Math.Sqrt((double)(num773 * num773 + num774 * num774));
if (num775 < 12f + num772)
{
npc.velocity.X = num773;
npc.velocity.Y = num774;
}
else
{
num775 = num772 / num775;
npc.velocity.X = num773 * num775;
npc.velocity.Y = num774 * num775;
}
Vector2 vector96 = new Vector2(npc.Center.X, npc.Center.Y);
float num776 = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - vector96.X;
float num777 = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - vector96.Y;
npc.rotation = (float)Math.Atan2((double)num777, (double)num776) - 1.57f;
}
}
public override void FindFrame(int frameHeight)
{
if (phase2)
{
if (npc.ai[3] == 0f)
{
if (npc.frame.Y < 1)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 4.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y + frameHeight;
}
}
}
else if (npc.frame.Y > 0)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 4.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y - frameHeight;
}
}
return;
}
if (npc.velocity.X == 0f && npc.velocity.Y == 0f)
{
if (npc.frame.Y < 1)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 4.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y + frameHeight;
}
}
}
else if (npc.frame.Y > 0)
{
npc.frameCounter += 1.0;
if (npc.frameCounter > 4.0)
{
npc.frameCounter = 0.0;
npc.frame.Y = npc.frame.Y - frameHeight;
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
{
if (Main.npc[CalamityGlobalNPC.ghostBoss].active && !phase2)
{
Vector2 center = new Vector2(npc.Center.X, npc.Center.Y);
float bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X;
float bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y;
float rotation2 = (float)Math.Atan2((double)bossCenterY, (double)bossCenterX) - 1.57f;
bool draw = true;
while (draw)
{
int chainWidth = 20; //16 24
int chainHeight = 52; //32 16
float num10 = (float)Math.Sqrt((double)(bossCenterX * bossCenterX + bossCenterY * bossCenterY));
if (num10 < (float)chainHeight)
{
chainWidth = (int)num10 - chainHeight + chainWidth;
draw = false;
}
num10 = (float)chainWidth / num10;
bossCenterX *= num10;
bossCenterY *= num10;
center.X += bossCenterX;
center.Y += bossCenterY;
bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X;
bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y;
Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f));
Main.spriteBatch.Draw(mod.GetTexture("NPCs/Polterghast/PolterghastChain"), new Vector2(center.X - Main.screenPosition.X, center.Y - Main.screenPosition.Y),
new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, 0, mod.GetTexture("NPCs/Polterghast/PolterghastChain").Width, chainWidth)), color2, rotation2,
new Vector2((float)mod.GetTexture("NPCs/Polterghast/PolterghastChain").Width * 0.5f, (float)mod.GetTexture("NPCs/Polterghast/PolterghastChain").Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
}
return true;
}
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)
{
if (CalamityWorld.revenge)
player.AddBuff(mod.BuffType("Horror"), 180, true);
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale);
npc.damage = (int)(npc.damage * 0.7f);
}
public override void HitEffect(int hitDirection, double damage)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default(Color), 1f);
}
if (npc.life <= 0)
{
for (int k = 0; k < 20; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default(Color), 1f);
}
}
}
}
}