1 - Perforators contact damage fixes.

2 - Desert Scourge velocity and acceleration changes.
3 - DoG worm wiggle fix.
4 - Removed burrow and lunge from large perf worm, because it should stay a Desert Scourge thing only (I'll give the perfs some love at some point).
5 - All perf worms have 4x HP in the zenith seed so they don't die immediately.
This commit is contained in:
mountaindrew10 committed 2024-02-29 20:14:47 -06:00
1 parent a625d7815a
commit 6606e5fac8
13 files changed
+474 -476

No files matched your search

+11 -1
View File
@@ -67,12 +67,19 @@ namespace CalamityMod.NPCs.DesertScourge
public override void AI()
{
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool masterMode = Main.masterMode || bossRush;
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
if (NPC.life > Main.npc[(int)NPC.ai[1]].life)
NPC.life = Main.npc[(int)NPC.ai[1]].life;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
@@ -147,7 +154,10 @@ namespace CalamityMod.NPCs.DesertScourge
}
// Calculate contact damage based on velocity
float maxChaseSpeed = 16f;
float maxChaseSpeed = masterMode ? DesertScourgeHead.SegmentVelocity_Master : expertMode ? DesertScourgeHead.SegmentVelocity_Expert : DesertScourgeHead.SegmentVelocity_Normal;
if (expertMode)
maxChaseSpeed += 5f * (1f - lifeRatio);
float minimalContactDamageVelocity = maxChaseSpeed * 0.25f;
float minimalDamageVelocity = maxChaseSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
+16 -8
View File
@@ -37,6 +37,10 @@ namespace CalamityMod.NPCs.DesertScourge
private bool TailSpawned = false;
public bool playRoarSound = false;
public const float SegmentVelocity_Normal = 8f;
public const float SegmentVelocity_Expert = 10f;
public const float SegmentVelocity_Master = 12f;
public static readonly SoundStyle RoarSound = new("CalamityMod/Sounds/Custom/DesertScourgeRoar");
public override void SetStaticDefaults()
@@ -134,6 +138,7 @@ namespace CalamityMod.NPCs.DesertScourge
{
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool masterMode = Main.masterMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
@@ -177,19 +182,19 @@ namespace CalamityMod.NPCs.DesertScourge
bool lungeUpward = burrow && NPC.Calamity().newAI[1] == 1f;
bool quickFall = NPC.Calamity().newAI[1] == 2f;
float speed = 0.09f;
float turnSpeed = 0.06f;
float speed = death ? 0.15f : 0.12f;
float turnSpeed = death ? 0.1f : 0.08f;
if (expertMode)
if (revenge)
{
float velocityScale = death ? 0.12f : 0.06f;
float velocityScale = death ? 0.08f : 0.06f;
speed += velocityScale * (1f - lifeRatio);
float accelerationScale = death ? 0.075f : 0.05f;
float accelerationScale = death ? 0.05f : 0.04f;
turnSpeed += accelerationScale * (1f - lifeRatio);
}
speed += 0.12f * enrageScale;
turnSpeed += 0.06f * enrageScale;
speed += 0.1f * enrageScale;
turnSpeed += 0.05f * enrageScale;
if (Main.getGoodWorld)
{
@@ -371,7 +376,10 @@ namespace CalamityMod.NPCs.DesertScourge
else
NPC.localAI[1] = 0f;
float maxChaseSpeed = 16f;
float maxChaseSpeed = masterMode ? SegmentVelocity_Master : expertMode ? SegmentVelocity_Expert : SegmentVelocity_Normal;
if (expertMode)
maxChaseSpeed += 5f * (1f - lifeRatio);
if (player.dead)
{
shouldFly = false;
+11 -1
View File
@@ -65,12 +65,19 @@ namespace CalamityMod.NPCs.DesertScourge
public override void AI()
{
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool masterMode = Main.masterMode || bossRush;
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
if (NPC.life > Main.npc[(int)NPC.ai[1]].life)
NPC.life = Main.npc[(int)NPC.ai[1]].life;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
@@ -145,7 +152,10 @@ namespace CalamityMod.NPCs.DesertScourge
}
// Calculate contact damage based on velocity
float maxChaseSpeed = 16f;
float maxChaseSpeed = masterMode ? DesertScourgeHead.SegmentVelocity_Master : expertMode ? DesertScourgeHead.SegmentVelocity_Expert : DesertScourgeHead.SegmentVelocity_Normal;
if (expertMode)
maxChaseSpeed += 5f * (1f - lifeRatio);
float minimalContactDamageVelocity = maxChaseSpeed * 0.25f;
float minimalDamageVelocity = maxChaseSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
+38 -14
View File
@@ -1372,6 +1372,8 @@ namespace CalamityMod.NPCs.DevourerofGods
if (NPC.velocity.Y > segmentVelocity)
NPC.velocity.Y = segmentVelocity;
// This bool exists to stop the strange wiggle behavior when worms are falling down
bool slowXVelocity = Math.Abs(NPC.velocity.X) > segmentVelocity;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 2.2)
{
if (NPC.velocity.X < 0f)
@@ -1381,17 +1383,27 @@ namespace CalamityMod.NPCs.DevourerofGods
}
else if (NPC.velocity.Y == segmentVelocity)
{
if (NPC.velocity.X < targetX)
NPC.velocity.X += turnSpeedCopy;
else if (NPC.velocity.X > targetX)
NPC.velocity.X -= turnSpeedCopy;
if (slowXVelocity)
{
if (NPC.velocity.X < targetX)
NPC.velocity.X += turnSpeedCopy;
else if (NPC.velocity.X > targetX)
NPC.velocity.X -= turnSpeedCopy;
}
else
NPC.velocity.X = 0f;
}
else if (NPC.velocity.Y > 4f)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X += turnSpeedCopy * 0.9f;
if (slowXVelocity)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X += turnSpeedCopy * 0.9f;
else
NPC.velocity.X -= turnSpeedCopy * 0.9f;
}
else
NPC.velocity.X -= turnSpeedCopy * 0.9f;
NPC.velocity.X = 0f;
}
}
else
@@ -2136,6 +2148,8 @@ namespace CalamityMod.NPCs.DevourerofGods
if (NPC.velocity.Y > segmentVelocity)
NPC.velocity.Y = segmentVelocity;
// This bool exists to stop the strange wiggle behavior when worms are falling down
bool slowXVelocity = Math.Abs(NPC.velocity.X) > segmentVelocity;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 2.2)
{
if (NPC.velocity.X < 0f)
@@ -2145,17 +2159,27 @@ namespace CalamityMod.NPCs.DevourerofGods
}
else if (NPC.velocity.Y == segmentVelocity)
{
if (NPC.velocity.X < targetX)
NPC.velocity.X += turnSpeedCopy;
else if (NPC.velocity.X > targetX)
NPC.velocity.X -= turnSpeedCopy;
if (slowXVelocity)
{
if (NPC.velocity.X < targetX)
NPC.velocity.X += turnSpeedCopy;
else if (NPC.velocity.X > targetX)
NPC.velocity.X -= turnSpeedCopy;
}
else
NPC.velocity.X = 0f;
}
else if (NPC.velocity.Y > 4f)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X += turnSpeedCopy * 0.9f;
if (slowXVelocity)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X += turnSpeedCopy * 0.9f;
else
NPC.velocity.X -= turnSpeedCopy * 0.9f;
}
else
NPC.velocity.X -= turnSpeedCopy * 0.9f;
NPC.velocity.X = 0f;
}
}
else
+28 -23
View File
@@ -29,7 +29,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.width = 60;
NPC.height = 60;
NPC.defense = 8;
NPC.LifeMaxNERB(2700, 3240, 80000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -70,20 +74,6 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
@@ -124,9 +114,9 @@ namespace CalamityMod.NPCs.Perforator
if (Main.player[NPC.target].dead)
NPC.TargetClosest(false);
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
Vector2 segmentPosition = NPC.Center;
float targetX = Main.player[NPC.target].Center.X;
float targetY = Main.player[NPC.target].Center.Y;
targetX = (float)((int)(targetX / 16f) * 16);
targetY = (float)((int)(targetY / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
@@ -138,28 +128,43 @@ namespace CalamityMod.NPCs.Perforator
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
targetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X;
targetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
segmentPosition = NPC.Center;
targetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentPosition.X;
targetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + 1.57f;
NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + MathHelper.PiOver2;
targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY));
int npcWidth = NPC.width;
targetDistance = (targetDistance - (float)npcWidth) / targetDistance;
targetX *= targetDistance;
targetY *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetX;
NPC.position.Y = NPC.position.Y + targetY;
NPC.position.X += targetX;
NPC.position.Y += targetY;
if (targetX < 0f)
NPC.spriteDirection = 1;
else if (targetX > 0f)
NPC.spriteDirection = -1;
}
// Calculate contact damage based on velocity
float maxChaseSpeed = 16f;
float minimalContactDamageVelocity = maxChaseSpeed * 0.25f;
float minimalDamageVelocity = maxChaseSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+27 -22
View File
@@ -32,7 +32,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.width = 40;
NPC.height = 40;
NPC.defense = 6;
NPC.LifeMaxNERB(180, 216, 7000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -70,20 +74,6 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
NPC.realLife = -1;
// Target
@@ -105,9 +95,9 @@ namespace CalamityMod.NPCs.Perforator
if (NPC.ai[0] == 0f)
{
if (NPC.ai[2] > 0f)
NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (NPC.width / 2)), (int)(NPC.position.Y + NPC.height), NPC.type, NPC.whoAmI, 0f, 0f, 0f, 0f, 255);
NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.position.Y + NPC.height), NPC.type, NPC.whoAmI);
else
NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (NPC.width / 2)), (int)(NPC.position.Y + NPC.height), ModContent.NPCType<PerforatorTailMedium>(), NPC.whoAmI, 0f, 0f, 0f, 0f, 255);
NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.position.Y + NPC.height), ModContent.NPCType<PerforatorTailMedium>(), NPC.whoAmI);
Main.npc[(int)NPC.ai[0]].ai[1] = NPC.whoAmI;
Main.npc[(int)NPC.ai[0]].ai[2] = NPC.ai[2] - 1f;
@@ -153,9 +143,9 @@ namespace CalamityMod.NPCs.Perforator
NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0);
}
Vector2 segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2);
float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2);
Vector2 segmentDirection = NPC.Center;
float targetX = Main.player[NPC.target].Center.X;
float targetY = Main.player[NPC.target].Center.Y;
targetX = (int)(targetX / 16f) * 16;
targetY = (int)(targetY / 16f) * 16;
@@ -169,9 +159,9 @@ namespace CalamityMod.NPCs.Perforator
{
try
{
segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentDirection.X;
targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentDirection.Y;
segmentDirection = NPC.Center;
targetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentDirection.X;
targetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentDirection.Y;
}
catch
{
@@ -188,6 +178,21 @@ namespace CalamityMod.NPCs.Perforator
NPC.position.X += targetX;
NPC.position.Y += targetY;
}
// Calculate contact damage based on velocity
float maxChaseSpeed = 16f;
float minimalContactDamageVelocity = maxChaseSpeed * 0.25f;
float minimalDamageVelocity = maxChaseSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+28 -23
View File
@@ -29,7 +29,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.width = 42;
NPC.height = 42;
NPC.defense = 4;
NPC.LifeMaxNERB(1200, 1440, 50000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -70,20 +74,6 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
@@ -124,9 +114,9 @@ namespace CalamityMod.NPCs.Perforator
if (Main.player[NPC.target].dead)
NPC.TargetClosest(false);
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
Vector2 segmentPosition = NPC.Center;
float targetX = Main.player[NPC.target].Center.X;
float targetY = Main.player[NPC.target].Center.Y;
targetX = (float)((int)(targetX / 16f) * 16);
targetY = (float)((int)(targetY / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
@@ -138,28 +128,43 @@ namespace CalamityMod.NPCs.Perforator
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
targetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X;
targetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
segmentPosition = NPC.Center;
targetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentPosition.X;
targetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + 1.57f;
NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + MathHelper.PiOver2;
targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY));
int npcWidth = NPC.width;
targetDistance = (targetDistance - (float)npcWidth) / targetDistance;
targetX *= targetDistance;
targetY *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetX;
NPC.position.Y = NPC.position.Y + targetY;
NPC.position.X += targetX;
NPC.position.Y += targetY;
if (targetX < 0f)
NPC.spriteDirection = 1;
else if (targetX > 0f)
NPC.spriteDirection = -1;
}
// Calculate contact damage based on velocity
float maxChaseSpeed = 16f;
float minimalContactDamageVelocity = maxChaseSpeed * 0.25f;
float minimalDamageVelocity = maxChaseSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+81 -140
View File
@@ -49,7 +49,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.width = 70;
NPC.height = 84;
NPC.defense = 4;
NPC.LifeMaxNERB(2700, 3240, 80000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -115,19 +119,6 @@ namespace CalamityMod.NPCs.Perforator
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
{
NPC.damage = (int)(NPC.defDamage * 0.5f);
}
else
{
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(NPC.defDamage * 0.5f, NPC.defDamage, velocityDamageScalar);
}
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
@@ -158,15 +149,6 @@ namespace CalamityMod.NPCs.Perforator
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
if (revenge || lifeRatio < (expertMode ? 0.75f : 0.5f))
NPC.Calamity().newAI[0] += 1f;
float burrowTimeGateValue = death ? 480f : 600f;
bool burrow = NPC.Calamity().newAI[0] >= burrowTimeGateValue;
bool resetTime = NPC.Calamity().newAI[0] >= burrowTimeGateValue + 600f;
bool lungeUpward = burrow && NPC.Calamity().newAI[1] == 1f;
bool quickFall = NPC.Calamity().newAI[1] == 2f;
float speed = 0.09f;
float turnSpeed = 0.06f;
@@ -178,15 +160,6 @@ namespace CalamityMod.NPCs.Perforator
turnSpeed += accelerationScale * (1f - lifeRatio);
}
if (lungeUpward)
{
speed *= 1.25f;
turnSpeed *= 1.5f;
if (NPC.Calamity().newAI[2] == 0f)
NPC.Calamity().newAI[2] = player.Center.Y - 600f;
}
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
@@ -204,17 +177,13 @@ namespace CalamityMod.NPCs.Perforator
{
int lol;
if (segments >= 0 && segments < maxLength - 1)
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<PerforatorBodyLarge>(), NPC.whoAmI);
}
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<PerforatorBodyLarge>(), NPC.whoAmI);
else
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<PerforatorTailLarge>(), NPC.whoAmI);
}
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<PerforatorTailLarge>(), NPC.whoAmI);
if (segments % 2 == 0)
{
Main.npc[lol].localAI[3] = 1f;
}
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].ai[2] = NPC.whoAmI;
Main.npc[lol].ai[1] = Previous;
@@ -222,6 +191,7 @@ namespace CalamityMod.NPCs.Perforator
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0);
Previous = lol;
}
TailSpawned = true;
}
}
@@ -231,22 +201,15 @@ namespace CalamityMod.NPCs.Perforator
int tilePositionY = (int)(NPC.position.Y / 16f) - 1;
int tileWidthPosY = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2;
if (tilePositionX < 0)
{
tilePositionX = 0;
}
if (tileWidthPosX > Main.maxTilesX)
{
tileWidthPosX = Main.maxTilesX;
}
if (tilePositionY < 0)
{
tilePositionY = 0;
}
if (tileWidthPosY > Main.maxTilesY)
{
tileWidthPosY = Main.maxTilesY;
}
bool shouldFly = lungeUpward;
bool shouldFly = false;
if (!shouldFly)
{
for (int k = tilePositionX; k < tileWidthPosX; k++)
@@ -267,6 +230,7 @@ namespace CalamityMod.NPCs.Perforator
}
}
}
if (!shouldFly)
{
NPC.localAI[1] = 1f;
@@ -275,7 +239,7 @@ namespace CalamityMod.NPCs.Perforator
bool outsideFlyingRadius = true;
if (NPC.position.Y > player.position.Y)
{
for (int m = 0; m < 255; m++)
for (int m = 0; m < Main.maxPlayers; m++)
{
if (Main.player[m].active)
{
@@ -287,41 +251,36 @@ namespace CalamityMod.NPCs.Perforator
}
}
}
if (outsideFlyingRadius)
{
shouldFly = true;
}
}
}
else
{
NPC.localAI[1] = 0f;
}
float fallSpeed = 16f;
float maxChargeSpeed = 16f;
if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active)
{
shouldFly = false;
NPC.velocity.Y += 1f;
if ((double)NPC.position.Y > Main.worldSurface * 16.0)
if ((double)NPC.position.Y > Main.worldSurface * 16D)
{
NPC.velocity.Y += 1f;
fallSpeed = 32f;
maxChargeSpeed *= 2f;
}
if ((double)NPC.position.Y > Main.rockLayer * 16.0)
if ((double)NPC.position.Y > Main.rockLayer * 16D)
{
for (int a = 0; a < Main.maxNPCs; a++)
{
if (Main.npc[a].type == ModContent.NPCType<PerforatorHeadLarge>() || Main.npc[a].type == ModContent.NPCType<PerforatorBodyLarge>() ||
Main.npc[a].type == ModContent.NPCType<PerforatorTailLarge>())
{
if (Main.npc[a].type == ModContent.NPCType<PerforatorHeadLarge>() || Main.npc[a].type == ModContent.NPCType<PerforatorBodyLarge>() || Main.npc[a].type == ModContent.NPCType<PerforatorTailLarge>())
Main.npc[a].active = false;
}
}
}
}
//This is possibly the best or worst idea ever conceived
// This is possibly the best or worst idea ever conceived
float laserOffset = 1500f;
float laserVelocity = 4f;
int type = ModContent.ProjectileType<DoGDeath>();
@@ -330,12 +289,12 @@ namespace CalamityMod.NPCs.Perforator
if (Main.zenithWorld)
NPC.Calamity().newAI[3]++;
if (NPC.Calamity().newAI[3] > 180f) //Effectively 10 seconds but give a little headstart in case players kill it too fast
if (NPC.Calamity().newAI[3] > 180f) // Effectively 10 seconds but give a little headstart in case players kill it too fast
{
if (NPC.Calamity().newAI[3] % 60 == 59)
{
SoundEngine.PlaySound(SoundID.Item12, player.Center);
for (int i = -7; i < 8; i++) //15 lasers
for (int i = -7; i < 8; i++) // 15 lasers
{
float laserGap = (i * 128f);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + laserOffset, player.Center.Y + laserGap, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
@@ -351,12 +310,9 @@ namespace CalamityMod.NPCs.Perforator
float speedCopy = speed;
float turnSpeedCopy = turnSpeed;
float burrowDistance = bossRush ? 500f : 800f;
float burrowTarget = player.Center.Y + burrowDistance;
float lungeTarget = NPC.Calamity().newAI[2];
Vector2 npcCenter = NPC.Center;
float playerX = player.Center.X;
float targettingPosition = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y;
float targettingPosition = player.Center.Y;
playerX = (float)((int)(playerX / 16f) * 16);
targettingPosition = (float)((int)(targettingPosition / 16f) * 16);
npcCenter.X = (float)((int)(npcCenter.X / 16f) * 16);
@@ -365,76 +321,45 @@ namespace CalamityMod.NPCs.Perforator
targettingPosition -= npcCenter.Y;
float targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition));
// Lunge up towards target
if (burrow && NPC.Center.Y >= burrowTarget - 16f)
NPC.Calamity().newAI[1] = 1f;
// Quickly fall back down once above target
if (lungeUpward && NPC.Center.Y <= NPC.Calamity().newAI[2] + 600f - 420f)
{
NPC.TargetClosest();
NPC.Calamity().newAI[1] = 2f;
}
// Quickly fall and reset variables once at target's Y position
if (quickFall)
{
NPC.velocity.Y += 0.5f;
if (NPC.Center.Y >= NPC.Calamity().newAI[2] + 600f)
{
NPC.Calamity().newAI[0] = 0f;
NPC.Calamity().newAI[1] = 0f;
NPC.Calamity().newAI[2] = 0f;
}
}
// Reset variables if the burrow and lunge attack is taking too long
if (resetTime)
{
NPC.Calamity().newAI[0] = 0f;
NPC.Calamity().newAI[1] = 0f;
}
if (!shouldFly)
{
NPC.TargetClosest(true);
NPC.velocity.Y = NPC.velocity.Y + 0.15f;
if (NPC.velocity.Y > fallSpeed)
{
NPC.velocity.Y = fallSpeed;
}
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.4)
NPC.velocity.Y += 0.15f;
if (NPC.velocity.Y > maxChargeSpeed)
NPC.velocity.Y = maxChargeSpeed;
// This bool exists to stop the strange wiggle behavior when worms are falling down
bool slowXVelocity = Math.Abs(NPC.velocity.X) > maxChargeSpeed;
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.4)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X -= speedCopy * 1.1f;
else
NPC.velocity.X += speedCopy * 1.1f;
}
else if (NPC.velocity.Y == maxChargeSpeed)
{
if (slowXVelocity)
{
NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f;
if (NPC.velocity.X < playerX)
NPC.velocity.X += speedCopy;
else if (NPC.velocity.X > playerX)
NPC.velocity.X -= speedCopy;
}
else
{
NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f;
}
}
else if (NPC.velocity.Y == fallSpeed)
{
if (NPC.velocity.X < playerX)
{
NPC.velocity.X = NPC.velocity.X + speedCopy;
}
else if (NPC.velocity.X > playerX)
{
NPC.velocity.X = NPC.velocity.X - speedCopy;
}
NPC.velocity.X = 0f;
}
else if (NPC.velocity.Y > 4f)
{
if (NPC.velocity.X < 0f)
if (slowXVelocity)
{
NPC.velocity.X = NPC.velocity.X + speedCopy * 0.9f;
if (NPC.velocity.X < 0f)
NPC.velocity.X += speedCopy * 0.9f;
else
NPC.velocity.X -= speedCopy * 0.9f;
}
else
{
NPC.velocity.X = NPC.velocity.X - speedCopy * 0.9f;
}
NPC.velocity.X = 0f;
}
}
else
@@ -443,20 +368,18 @@ namespace CalamityMod.NPCs.Perforator
{
float soundDelay = targetDistance / 40f;
if (soundDelay < 10f)
{
soundDelay = 10f;
}
if (soundDelay > 20f)
{
soundDelay = 20f;
}
NPC.soundDelay = (int)soundDelay;
SoundEngine.PlaySound(SoundID.WormDig, NPC.Center);
}
targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition));
float absoluteTargetX = Math.Abs(playerX);
float absoluteTargetPos = Math.Abs(targettingPosition);
float timeToReachTarget = fallSpeed / targetDistance;
float timeToReachTarget = maxChargeSpeed / targetDistance;
playerX *= timeToReachTarget;
targettingPosition *= timeToReachTarget;
if (((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f)) && ((NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f)))
@@ -469,6 +392,7 @@ namespace CalamityMod.NPCs.Perforator
{
NPC.velocity.X = NPC.velocity.X - turnSpeedCopy;
}
if (NPC.velocity.Y < targettingPosition)
{
NPC.velocity.Y = NPC.velocity.Y + turnSpeedCopy;
@@ -488,6 +412,7 @@ namespace CalamityMod.NPCs.Perforator
{
NPC.velocity.X = NPC.velocity.X - speedCopy;
}
if (NPC.velocity.Y < targettingPosition)
{
NPC.velocity.Y = NPC.velocity.Y + speedCopy;
@@ -496,7 +421,8 @@ namespace CalamityMod.NPCs.Perforator
{
NPC.velocity.Y = NPC.velocity.Y - speedCopy;
}
if ((double)Math.Abs(targettingPosition) < (double)fallSpeed * 0.2 && ((NPC.velocity.X > 0f && playerX < 0f) || (NPC.velocity.X < 0f && playerX > 0f)))
if ((double)Math.Abs(targettingPosition) < (double)maxChargeSpeed * 0.2 && ((NPC.velocity.X > 0f && playerX < 0f) || (NPC.velocity.X < 0f && playerX > 0f)))
{
if (NPC.velocity.Y > 0f)
{
@@ -507,7 +433,8 @@ namespace CalamityMod.NPCs.Perforator
NPC.velocity.Y = NPC.velocity.Y - speedCopy * 2f;
}
}
if ((double)Math.Abs(playerX) < (double)fallSpeed * 0.2 && ((NPC.velocity.Y > 0f && targettingPosition < 0f) || (NPC.velocity.Y < 0f && targettingPosition > 0f)))
if ((double)Math.Abs(playerX) < (double)maxChargeSpeed * 0.2 && ((NPC.velocity.Y > 0f && targettingPosition < 0f) || (NPC.velocity.Y < 0f && targettingPosition > 0f)))
{
if (NPC.velocity.X > 0f)
{
@@ -529,7 +456,8 @@ namespace CalamityMod.NPCs.Perforator
{
NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f;
}
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.5)
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.5)
{
if (NPC.velocity.Y > 0f)
{
@@ -551,7 +479,8 @@ namespace CalamityMod.NPCs.Perforator
{
NPC.velocity.Y = NPC.velocity.Y - speedCopy * 1.1f;
}
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.5)
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.5)
{
if (NPC.velocity.X > 0f)
{
@@ -564,27 +493,39 @@ namespace CalamityMod.NPCs.Perforator
}
}
}
NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f;
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = maxChargeSpeed * 0.25f;
float minimalDamageVelocity = maxChargeSpeed * 0.5f;
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
{
NPC.damage = (int)(NPC.defDamage * 0.5f);
}
else
{
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(NPC.defDamage * 0.5f, NPC.defDamage, velocityDamageScalar);
}
NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + MathHelper.PiOver2;
if (shouldFly)
{
if (NPC.localAI[0] != 1f)
{
NPC.netUpdate = true;
}
NPC.localAI[0] = 1f;
}
else
{
if (NPC.localAI[0] != 0f)
{
NPC.netUpdate = true;
}
NPC.localAI[0] = 0f;
}
if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit)
{
NPC.netUpdate = true;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+55 -39
View File
@@ -45,7 +45,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.width = 58;
NPC.height = 68;
NPC.defense = 2;
NPC.LifeMaxNERB(180, 216, 7000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -99,19 +103,6 @@ namespace CalamityMod.NPCs.Perforator
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
{
NPC.damage = (int)(NPC.defDamage * 0.5f);
}
else
{
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(NPC.defDamage * 0.5f, NPC.defDamage, velocityDamageScalar);
}
float enrageScale = bossRush ? 1f : 0f;
if ((NPC.position.Y / 16f) < Main.worldSurface || bossRush)
enrageScale += 1f;
@@ -154,7 +145,7 @@ namespace CalamityMod.NPCs.Perforator
{
int totalSegments = death ? 14 : revenge ? 13 : expertMode ? 12 : 10;
NPC.ai[2] = totalSegments;
NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (NPC.width / 2)), (int)(NPC.position.Y + NPC.height), ModContent.NPCType<PerforatorBodyMedium>(), NPC.whoAmI, 0f, 0f, 0f, 0f, 255);
NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (NPC.width / 2)), (int)(NPC.position.Y + NPC.height), ModContent.NPCType<PerforatorBodyMedium>(), NPC.whoAmI);
Main.npc[(int)NPC.ai[0]].ai[1] = NPC.whoAmI;
Main.npc[(int)NPC.ai[0]].ai[2] = NPC.ai[2] - 1f;
NPC.netUpdate = true;
@@ -213,18 +204,17 @@ namespace CalamityMod.NPCs.Perforator
{
shouldFly = true;
if (Main.rand.NextBool(100) && Main.tile[i, j].HasUnactuatedTile)
{
WorldGen.KillTile(i, j, true, true, false);
}
}
}
}
}
}
if (!shouldFly)
{
Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height);
int stopFlyingRadius = death ? 160 : revenge ? 200 : expertMode ? 240 : 300;
int stopFlyingRadius = death ? 320 : revenge ? 400 : expertMode ? 480 : 600;
bool outsideFlyRadius = true;
for (int k = 0; k < Main.maxPlayers; k++)
{
@@ -238,29 +228,29 @@ namespace CalamityMod.NPCs.Perforator
}
}
}
if (outsideFlyRadius)
shouldFly = true;
}
float fallSpeed = 16f;
float maxChargeSpeed = 16f;
if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active)
{
NPC.TargetClosest(false);
shouldFly = false;
NPC.velocity.Y += 1f;
if (NPC.position.Y > Main.worldSurface * 16.0)
if (NPC.position.Y > Main.worldSurface * 16D)
{
NPC.velocity.Y += 1f;
fallSpeed = 32f;
maxChargeSpeed *= 2f;
}
if (NPC.position.Y > Main.rockLayer * 16.0)
if (NPC.position.Y > Main.rockLayer * 16D)
{
for (int p = 0; p < Main.maxNPCs; p++)
{
if (Main.npc[p].type == NPC.type || Main.npc[p].type == ModContent.NPCType<PerforatorBodyMedium>() || Main.npc[p].type == ModContent.NPCType<PerforatorTailMedium>())
{
Main.npc[p].active = false;
}
}
}
}
@@ -293,29 +283,41 @@ namespace CalamityMod.NPCs.Perforator
if (!shouldFly)
{
NPC.velocity.Y += 0.15f;
if (NPC.velocity.Y > fallSpeed)
NPC.velocity.Y = fallSpeed;
if (NPC.velocity.Y > maxChargeSpeed)
NPC.velocity.Y = maxChargeSpeed;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * 0.4)
// This bool exists to stop the strange wiggle behavior when worms are falling down
bool slowXVelocity = Math.Abs(NPC.velocity.X) > maxChargeSpeed;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < maxChargeSpeed * 0.4)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X -= turnSpeedCopy * 1.1f;
else
NPC.velocity.X += turnSpeedCopy * 1.1f;
}
else if (NPC.velocity.Y == fallSpeed)
else if (NPC.velocity.Y == maxChargeSpeed)
{
if (NPC.velocity.X < targetX)
NPC.velocity.X += turnSpeedCopy;
else if (NPC.velocity.X > targetX)
NPC.velocity.X -= turnSpeedCopy;
if (slowXVelocity)
{
if (NPC.velocity.X < targetX)
NPC.velocity.X += turnSpeedCopy;
else if (NPC.velocity.X > targetX)
NPC.velocity.X -= turnSpeedCopy;
}
else
NPC.velocity.X = 0f;
}
else if (NPC.velocity.Y > 4f)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X += turnSpeedCopy * 0.9f;
if (slowXVelocity)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X += turnSpeedCopy * 0.9f;
else
NPC.velocity.X -= turnSpeedCopy * 0.9f;
}
else
NPC.velocity.X -= turnSpeedCopy * 0.9f;
NPC.velocity.X = 0f;
}
}
else
@@ -336,7 +338,7 @@ namespace CalamityMod.NPCs.Perforator
targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY);
float absoluteTargetX = Math.Abs(targetX);
float absoluteTargetY = Math.Abs(targetY);
float timeToReachTarget = fallSpeed / targetDistance;
float timeToReachTarget = maxChargeSpeed / targetDistance;
targetX *= timeToReachTarget;
targetY *= timeToReachTarget;
@@ -365,7 +367,7 @@ namespace CalamityMod.NPCs.Perforator
else if (NPC.velocity.Y > targetY)
NPC.velocity.Y -= speedCopy;
if (Math.Abs(targetY) < fallSpeed * 0.2 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f)))
if (Math.Abs(targetY) < maxChargeSpeed * 0.2 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f)))
{
if (NPC.velocity.Y > 0f)
NPC.velocity.Y += speedCopy * 2f;
@@ -373,7 +375,7 @@ namespace CalamityMod.NPCs.Perforator
NPC.velocity.Y -= speedCopy * 2f;
}
if (Math.Abs(targetX) < fallSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f)))
if (Math.Abs(targetX) < maxChargeSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f)))
{
if (NPC.velocity.X > 0f)
NPC.velocity.X += speedCopy * 2f;
@@ -388,7 +390,7 @@ namespace CalamityMod.NPCs.Perforator
else if (NPC.velocity.X > targetX)
NPC.velocity.X -= speedCopy * 1.1f;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * 0.5)
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < maxChargeSpeed * 0.5)
{
if (NPC.velocity.Y > 0f)
NPC.velocity.Y += speedCopy;
@@ -403,7 +405,7 @@ namespace CalamityMod.NPCs.Perforator
else if (NPC.velocity.Y > targetY)
NPC.velocity.Y -= speedCopy * 1.1f;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * 0.5)
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < maxChargeSpeed * 0.5)
{
if (NPC.velocity.X > 0f)
NPC.velocity.X += speedCopy;
@@ -413,6 +415,19 @@ namespace CalamityMod.NPCs.Perforator
}
}
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = maxChargeSpeed * 0.25f;
float minimalDamageVelocity = maxChargeSpeed * 0.5f;
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
{
NPC.damage = (int)(NPC.defDamage * 0.5f);
}
else
{
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(NPC.defDamage * 0.5f, NPC.defDamage, velocityDamageScalar);
}
NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2;
if (shouldFly)
@@ -429,6 +444,7 @@ namespace CalamityMod.NPCs.Perforator
NPC.localAI[0] = 0f;
}
if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit)
NPC.netUpdate = true;
}
+96 -139
View File
@@ -48,7 +48,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.npcSlots = 5f;
NPC.width = 42;
NPC.height = 62;
NPC.LifeMaxNERB(1200, 1440, 50000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -110,19 +114,6 @@ namespace CalamityMod.NPCs.Perforator
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
{
NPC.damage = (int)(NPC.defDamage * 0.5f);
}
else
{
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(NPC.defDamage * 0.5f, NPC.defDamage, velocityDamageScalar);
}
// Enrage
if ((!Main.player[NPC.target].ZoneCrimson || (NPC.position.Y / 16f) < Main.worldSurface) && !bossRush)
{
@@ -181,13 +172,10 @@ namespace CalamityMod.NPCs.Perforator
{
int lol;
if (segments >= 0 && segments < maxLength - 1)
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<PerforatorBodySmall>(), NPC.whoAmI);
}
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<PerforatorBodySmall>(), NPC.whoAmI);
else
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<PerforatorTailSmall>(), NPC.whoAmI);
}
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<PerforatorTailSmall>(), NPC.whoAmI);
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].ai[2] = NPC.whoAmI;
Main.npc[lol].ai[1] = Previous;
@@ -195,6 +183,7 @@ namespace CalamityMod.NPCs.Perforator
NetMessage.SendData(MsgType, -1, -1, null, lol, 0f, 0f, 0f, 0);
Previous = lol;
}
TailSpawned = true;
}
}
@@ -204,21 +193,14 @@ namespace CalamityMod.NPCs.Perforator
int tilePositionY = (int)(NPC.position.Y / 16f) - 1;
int tileWidthPosY = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2;
if (tilePositionX < 0)
{
tilePositionX = 0;
}
if (tileWidthPosX > Main.maxTilesX)
{
tileWidthPosX = Main.maxTilesX;
}
if (tilePositionY < 0)
{
tilePositionY = 0;
}
if (tileWidthPosY > Main.maxTilesY)
{
tileWidthPosY = Main.maxTilesY;
}
bool shouldFly = false;
if (!shouldFly)
{
@@ -240,15 +222,16 @@ namespace CalamityMod.NPCs.Perforator
}
}
}
if (!shouldFly)
{
NPC.localAI[1] = 1f;
Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height);
int stopFlyingRadius = death ? 160 : revenge ? 200 : expertMode ? 240 : 300;
int stopFlyingRadius = death ? 320 : revenge ? 400 : expertMode ? 480 : 600;
bool outsideFlyRadius = true;
if (NPC.position.Y > player.position.Y)
{
for (int m = 0; m < 255; m++)
for (int m = 0; m < Main.maxPlayers; m++)
{
if (Main.player[m].active)
{
@@ -260,35 +243,31 @@ namespace CalamityMod.NPCs.Perforator
}
}
}
if (outsideFlyRadius)
{
shouldFly = true;
}
}
}
else
{
NPC.localAI[1] = 0f;
}
float maxChargeSpeed = 16f;
if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active)
{
shouldFly = false;
NPC.velocity.Y += 1f;
if ((double)NPC.position.Y > Main.worldSurface * 16.0)
if ((double)NPC.position.Y > Main.worldSurface * 16D)
{
NPC.velocity.Y += 1f;
maxChargeSpeed = 32f;
maxChargeSpeed *= 2f;
}
if ((double)NPC.position.Y > Main.rockLayer * 16.0)
if ((double)NPC.position.Y > Main.rockLayer * 16D)
{
for (int a = 0; a < Main.maxNPCs; a++)
{
if (Main.npc[a].type == ModContent.NPCType<PerforatorHeadSmall>() || Main.npc[a].type == ModContent.NPCType<PerforatorBodySmall>() ||
Main.npc[a].type == ModContent.NPCType<PerforatorTailSmall>())
{
if (Main.npc[a].type == ModContent.NPCType<PerforatorHeadSmall>() || Main.npc[a].type == ModContent.NPCType<PerforatorBodySmall>() || Main.npc[a].type == ModContent.NPCType<PerforatorTailSmall>())
Main.npc[a].active = false;
}
}
}
}
@@ -296,7 +275,7 @@ namespace CalamityMod.NPCs.Perforator
if (Main.zenithWorld && CalamityGlobalNPC.perfHive >= 0)
NPC.ai[0]++;
//GFB movement
// GFB movement
if (NPC.ai[0] >= 300f && CalamityGlobalNPC.perfHive >= 0)
{
shouldFly = false;
@@ -305,14 +284,17 @@ namespace CalamityMod.NPCs.Perforator
Vector2 targetDistance = Hive.Center - NPC.Center;
float velocity = 16f;
float acceleration = 0.15f;
//Move towards the hive really quickly
// Move towards the hive really quickly
if (targetDistance.Length() > 32f)
{
CalamityUtils.SmoothMovement(NPC, 0f, targetDistance, velocity, acceleration, true);
}
else
{
//Go and succ it
// Go and succ it
NPC.Center = Hive.Center + (Vector2.UnitY * 4f).RotatedBy(NPC.rotation);
Hive.localAI[1]++;
Hive.localAI[1] += 1f;
}
if (NPC.ai[0] >= 600f)
@@ -321,14 +303,14 @@ namespace CalamityMod.NPCs.Perforator
Hive.localAI[1] = 0f;
}
}
//Normal movement
// Normal movement
else
{
float speedCopy = speed;
float turnSpeedCopy = turnSpeed;
Vector2 npcCenter = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetX = player.position.X + (float)(player.width / 2);
float targetY = player.position.Y + (float)(player.height / 2);
Vector2 npcCenter = NPC.Center;
float targetX = player.Center.X;
float targetY = player.Center.Y;
targetX = (float)((int)(targetX / 16f) * 16);
targetY = (float)((int)(targetY / 16f) * 16);
npcCenter.X = (float)((int)(npcCenter.X / 16f) * 16);
@@ -339,43 +321,42 @@ namespace CalamityMod.NPCs.Perforator
if (!shouldFly)
{
NPC.TargetClosest(true);
NPC.velocity.Y = NPC.velocity.Y + 0.15f;
NPC.velocity.Y += 0.15f;
if (NPC.velocity.Y > maxChargeSpeed)
{
NPC.velocity.Y = maxChargeSpeed;
}
// This bool exists to stop the strange wiggle behavior when worms are falling down
bool slowXVelocity = Math.Abs(NPC.velocity.X) > maxChargeSpeed;
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.4)
{
if (NPC.velocity.X < 0f)
{
NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f;
}
NPC.velocity.X -= speedCopy * 1.1f;
else
{
NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f;
}
NPC.velocity.X += speedCopy * 1.1f;
}
else if (NPC.velocity.Y == maxChargeSpeed)
{
if (NPC.velocity.X < targetX)
if (slowXVelocity)
{
NPC.velocity.X = NPC.velocity.X + speedCopy;
}
else if (NPC.velocity.X > targetX)
{
NPC.velocity.X = NPC.velocity.X - speedCopy;
if (NPC.velocity.X < targetX)
NPC.velocity.X += speedCopy;
else if (NPC.velocity.X > targetX)
NPC.velocity.X -= speedCopy;
}
else
NPC.velocity.X = 0f;
}
else if (NPC.velocity.Y > 4f)
{
if (NPC.velocity.X < 0f)
if (slowXVelocity)
{
NPC.velocity.X = NPC.velocity.X + speedCopy * 0.9f;
if (NPC.velocity.X < 0f)
NPC.velocity.X += speedCopy * 0.9f;
else
NPC.velocity.X -= speedCopy * 0.9f;
}
else
{
NPC.velocity.X = NPC.velocity.X - speedCopy * 0.9f;
}
NPC.velocity.X = 0f;
}
}
else
@@ -384,16 +365,14 @@ namespace CalamityMod.NPCs.Perforator
{
float soundDelay = targetDistance / 40f;
if (soundDelay < 10f)
{
soundDelay = 10f;
}
if (soundDelay > 20f)
{
soundDelay = 20f;
}
NPC.soundDelay = (int)soundDelay;
SoundEngine.PlaySound(SoundID.WormDig, NPC.Center);
}
targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY));
float absoluteTargetX = Math.Abs(targetX);
float absoluteTargetY = Math.Abs(targetY);
@@ -403,130 +382,108 @@ namespace CalamityMod.NPCs.Perforator
if (((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f)) && ((NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)))
{
if (NPC.velocity.X < targetX)
{
NPC.velocity.X = NPC.velocity.X + turnSpeedCopy;
}
NPC.velocity.X += turnSpeedCopy;
else if (NPC.velocity.X > targetX)
{
NPC.velocity.X = NPC.velocity.X - turnSpeedCopy;
}
NPC.velocity.X -= turnSpeedCopy;
if (NPC.velocity.Y < targetY)
{
NPC.velocity.Y = NPC.velocity.Y + turnSpeedCopy;
}
NPC.velocity.Y += turnSpeedCopy;
else if (NPC.velocity.Y > targetY)
{
NPC.velocity.Y = NPC.velocity.Y - turnSpeedCopy;
}
NPC.velocity.Y -= turnSpeedCopy;
}
if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f))
{
if (NPC.velocity.X < targetX)
{
NPC.velocity.X = NPC.velocity.X + speedCopy;
}
NPC.velocity.X += speedCopy;
else if (NPC.velocity.X > targetX)
{
NPC.velocity.X = NPC.velocity.X - speedCopy;
}
NPC.velocity.X -= speedCopy;
if (NPC.velocity.Y < targetY)
{
NPC.velocity.Y = NPC.velocity.Y + speedCopy;
}
NPC.velocity.Y += speedCopy;
else if (NPC.velocity.Y > targetY)
{
NPC.velocity.Y = NPC.velocity.Y - speedCopy;
}
NPC.velocity.Y -= speedCopy;
if ((double)Math.Abs(targetY) < (double)maxChargeSpeed * 0.2 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f)))
{
if (NPC.velocity.Y > 0f)
{
NPC.velocity.Y = NPC.velocity.Y + speedCopy * 2f;
}
NPC.velocity.Y += speedCopy * 2f;
else
{
NPC.velocity.Y = NPC.velocity.Y - speedCopy * 2f;
}
NPC.velocity.Y -= speedCopy * 2f;
}
if ((double)Math.Abs(targetX) < (double)maxChargeSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f)))
{
if (NPC.velocity.X > 0f)
{
NPC.velocity.X = NPC.velocity.X + speedCopy * 2f;
}
NPC.velocity.X += speedCopy * 2f;
else
{
NPC.velocity.X = NPC.velocity.X - speedCopy * 2f;
}
NPC.velocity.X -= speedCopy * 2f;
}
}
else if (absoluteTargetX > absoluteTargetY)
{
if (NPC.velocity.X < targetX)
{
NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f;
}
NPC.velocity.X += speedCopy * 1.1f;
else if (NPC.velocity.X > targetX)
{
NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f;
}
NPC.velocity.X -= speedCopy * 1.1f;
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.5)
{
if (NPC.velocity.Y > 0f)
{
NPC.velocity.Y = NPC.velocity.Y + speedCopy;
}
NPC.velocity.Y += speedCopy;
else
{
NPC.velocity.Y = NPC.velocity.Y - speedCopy;
}
NPC.velocity.Y -= speedCopy;
}
}
else
{
if (NPC.velocity.Y < targetY)
{
NPC.velocity.Y = NPC.velocity.Y + speedCopy * 1.1f;
}
NPC.velocity.Y += speedCopy * 1.1f;
else if (NPC.velocity.Y > targetY)
{
NPC.velocity.Y = NPC.velocity.Y - speedCopy * 1.1f;
}
NPC.velocity.Y -= speedCopy * 1.1f;
if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.5)
{
if (NPC.velocity.X > 0f)
{
NPC.velocity.X = NPC.velocity.X + speedCopy;
}
NPC.velocity.X += speedCopy;
else
{
NPC.velocity.X = NPC.velocity.X - speedCopy;
}
NPC.velocity.X -= speedCopy;
}
}
}
}
NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f;
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = maxChargeSpeed * 0.25f;
float minimalDamageVelocity = maxChargeSpeed * 0.5f;
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
{
NPC.damage = (int)(NPC.defDamage * 0.5f);
}
else
{
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(NPC.defDamage * 0.5f, NPC.defDamage, velocityDamageScalar);
}
NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + MathHelper.PiOver2;
if (shouldFly)
{
if (NPC.localAI[0] != 1f)
{
NPC.netUpdate = true;
}
NPC.localAI[0] = 1f;
}
else
{
if (NPC.localAI[0] != 0f)
{
NPC.netUpdate = true;
}
NPC.localAI[0] = 0f;
}
if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit)
{
NPC.netUpdate = true;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+29 -23
View File
@@ -29,7 +29,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.width = 60;
NPC.height = 78;
NPC.defense = 12;
NPC.LifeMaxNERB(2700, 3240, 80000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -70,20 +74,6 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
@@ -124,9 +114,9 @@ namespace CalamityMod.NPCs.Perforator
if (Main.player[NPC.target].dead)
NPC.TargetClosest(false);
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
Vector2 segmentPosition = NPC.Center;
float targetX = Main.player[NPC.target].Center.X;
float targetY = Main.player[NPC.target].Center.Y;
targetX = (float)((int)(targetX / 16f) * 16);
targetY = (float)((int)(targetY / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
@@ -138,28 +128,44 @@ namespace CalamityMod.NPCs.Perforator
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
targetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X;
targetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
segmentPosition = NPC.Center;
targetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentPosition.X;
targetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + 1.57f;
NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + MathHelper.PiOver2;
targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY));
int npcWidth = NPC.width;
targetDistance = (targetDistance - (float)npcWidth) / targetDistance;
targetX *= targetDistance;
targetY *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetX;
NPC.position.Y = NPC.position.Y + targetY;
NPC.position.X += targetX;
NPC.position.Y += targetY;
if (targetX < 0f)
NPC.spriteDirection = 1;
else if (targetX > 0f)
NPC.spriteDirection = -1;
}
// Calculate contact damage based on velocity
float maxChaseSpeed = 16f;
float minimalContactDamageVelocity = maxChaseSpeed * 0.25f;
float minimalDamageVelocity = maxChaseSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+25 -20
View File
@@ -32,7 +32,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.width = 40;
NPC.height = 50;
NPC.defense = 10;
NPC.LifeMaxNERB(180, 216, 7000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -70,20 +74,6 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
NPC.realLife = -1;
// Target
@@ -124,9 +114,9 @@ namespace CalamityMod.NPCs.Perforator
NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0);
}
Vector2 segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2);
float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2);
Vector2 segmentDirection = NPC.Center;
float targetX = Main.player[NPC.target].Center.X;
float targetY = Main.player[NPC.target].Center.Y;
targetX = (int)(targetX / 16f) * 16;
targetY = (int)(targetY / 16f) * 16;
@@ -140,9 +130,9 @@ namespace CalamityMod.NPCs.Perforator
{
try
{
segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentDirection.X;
targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentDirection.Y;
segmentDirection = NPC.Center;
targetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentDirection.X;
targetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentDirection.Y;
}
catch
{
@@ -159,6 +149,21 @@ namespace CalamityMod.NPCs.Perforator
NPC.position.X += targetX;
NPC.position.Y += targetY;
}
// Calculate contact damage based on velocity
float maxChaseSpeed = 16f;
float minimalContactDamageVelocity = maxChaseSpeed * 0.25f;
float minimalDamageVelocity = maxChaseSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+29 -23
View File
@@ -29,7 +29,11 @@ namespace CalamityMod.NPCs.Perforator
NPC.width = 40;
NPC.height = 34;
NPC.defense = 8;
NPC.LifeMaxNERB(1200, 1440, 50000);
if (Main.zenithWorld)
NPC.lifeMax *= 4;
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
NPC.aiStyle = -1;
@@ -70,20 +74,6 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = 4f;
float minimalDamageVelocity = 8f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
@@ -124,9 +114,9 @@ namespace CalamityMod.NPCs.Perforator
if (Main.player[NPC.target].dead)
NPC.TargetClosest(false);
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
Vector2 segmentPosition = NPC.Center;
float targetX = Main.player[NPC.target].Center.X;
float targetY = Main.player[NPC.target].Center.Y;
targetX = (float)((int)(targetX / 16f) * 16);
targetY = (float)((int)(targetY / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
@@ -138,28 +128,44 @@ namespace CalamityMod.NPCs.Perforator
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
targetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X;
targetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
segmentPosition = NPC.Center;
targetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentPosition.X;
targetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + 1.57f;
NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + MathHelper.PiOver2;
targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY));
int npcWidth = NPC.width;
targetDistance = (targetDistance - (float)npcWidth) / targetDistance;
targetX *= targetDistance;
targetY *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetX;
NPC.position.Y = NPC.position.Y + targetY;
NPC.position.X += targetX;
NPC.position.Y += targetY;
if (targetX < 0f)
NPC.spriteDirection = 1;
else if (targetX > 0f)
NPC.spriteDirection = -1;
}
// Calculate contact damage based on velocity
float maxChaseSpeed = 16f;
float minimalContactDamageVelocity = maxChaseSpeed * 0.25f;
float minimalDamageVelocity = maxChaseSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
NPC.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)