diff --git a/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs b/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs index c622bceb1a..15e199468e 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs @@ -1,7 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,7 +26,7 @@ namespace CalamityMod.NPCs.Abyss npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.alpha = 255; + npc.Opacity = 0f; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; @@ -67,39 +66,49 @@ namespace CalamityMod.NPCs.Abyss if (!NPC.AnyNPCs(ModContent.NPCType())) npc.active = false; - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + bool invisiblePhase = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 1f || Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 5f || Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 7f; + if (!invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + npc.Opacity += 0.15f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -115,17 +124,13 @@ namespace CalamityMod.NPCs.Abyss public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector = center - Main.screenPosition; - vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; + vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge").Width, ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge").Height) * 0.5f; vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); - Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); + Color color = new Color(127, 127, 127, 0).MultiplyRGBA(Color.LightYellow) * npc.Opacity; Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); } diff --git a/NPCs/Abyss/EidolonWyrmBodyHuge.cs b/NPCs/Abyss/EidolonWyrmBodyHuge.cs index d649f60464..d566a022b5 100644 --- a/NPCs/Abyss/EidolonWyrmBodyHuge.cs +++ b/NPCs/Abyss/EidolonWyrmBodyHuge.cs @@ -1,7 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,7 +26,7 @@ namespace CalamityMod.NPCs.Abyss npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.alpha = 255; + npc.Opacity = 0f; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; @@ -67,39 +66,49 @@ namespace CalamityMod.NPCs.Abyss if (!NPC.AnyNPCs(ModContent.NPCType())) npc.active = false; - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + bool invisiblePhase = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 1f || Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 5f || Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 7f; + if (!invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + npc.Opacity += 0.15f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -115,17 +124,13 @@ namespace CalamityMod.NPCs.Abyss public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector = center - Main.screenPosition; - vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; + vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge").Width, ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge").Height) * 0.5f; vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); - Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); + Color color = new Color(127, 127, 127, 0).MultiplyRGBA(Color.LightYellow) * npc.Opacity; Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); } diff --git a/NPCs/Abyss/EidolonWyrmHeadHuge.cs b/NPCs/Abyss/EidolonWyrmHeadHuge.cs index a87b6661ae..c4534b04ce 100644 --- a/NPCs/Abyss/EidolonWyrmHeadHuge.cs +++ b/NPCs/Abyss/EidolonWyrmHeadHuge.cs @@ -18,6 +18,7 @@ namespace CalamityMod.NPCs.Abyss { public class EidolonWyrmHeadHuge : ModNPC { + Vector2 chargeDestination = default; public const int minLength = 40; public const int maxLength = 41; bool TailSpawned = false; @@ -43,6 +44,7 @@ namespace CalamityMod.NPCs.Abyss npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; + npc.Opacity = 0f; npc.knockBackResist = 0f; npc.value = Item.buyPrice(10, 0, 0, 0); npc.behindTiles = true; @@ -58,6 +60,7 @@ namespace CalamityMod.NPCs.Abyss public override void SendExtraAI(BinaryWriter writer) { writer.Write(npc.dontTakeDamage); + writer.WriteVector2(chargeDestination); for (int i = 0; i < 4; i++) writer.Write(npc.Calamity().newAI[i]); } @@ -65,6 +68,7 @@ namespace CalamityMod.NPCs.Abyss public override void ReceiveExtraAI(BinaryReader reader) { npc.dontTakeDamage = reader.ReadBoolean(); + chargeDestination = reader.ReadVector2(); for (int i = 0; i < 4; i++) npc.Calamity().newAI[i] = reader.ReadSingle(); } @@ -103,8 +107,6 @@ namespace CalamityMod.NPCs.Abyss // Target variable Player player = Main.player[npc.target]; - //Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose").WithVolume(2.5f), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; @@ -171,27 +173,131 @@ namespace CalamityMod.NPCs.Abyss if (Vector2.Distance(player.Center, npc.Center) > 6400f || !NPC.AnyNPCs(ModContent.NPCType())) npc.active = false; - Vector2 destination = player.Center; - // General AI pattern - // Charge : Phase 5 - Charge becomes predictive + // Charge : Phase 5 - // Charge : Phase 2 - Spin around target and summon shadow fireballs // Charge : Phase 4 - Swim to the right and dash towards the target, summon lightning bolts from above during it // Turn invisible, swim above the target and summon predictive lightning bolts // Turn visible and charge towards the target quickly 1 time, soon after the previous attack ends // Swim a certain distance away from the target for a bit to prepare for 3 charges again - // Charge : Phase 5 - Charge becomes predictive + // Charge : Phase 5 - // Charge : Phase 3 - Turn invisible and summon ancient dooms around the target // Charge : Phase 4 - Turn visible, swim to the left and dash towards the target, summon lightning bolts from above during it // Turn invisible, swim beneath the target and summon ice mist // Turn visible and charge towards the target quickly 1 time, soon after the previous attack ends // Swim a certain distance away from the target for a bit to prepare for 3 charges again + // Vector to swim to + Vector2 destination = player.Center; + + // Locations to charge from + Vector2 chargeVector = default; + float chargeDistance = 1000f; + float turnDistance = 640f; + float chargeLocationDistance = turnDistance * 0.2f; + switch ((int)calamityGlobalNPC.newAI[1]) + { + case 0: + chargeVector.X -= chargeDistance; + break; + case 1: + chargeVector.X += chargeDistance; + break; + case 2: + chargeVector.Y -= chargeDistance; + break; + case 3: + chargeVector.Y += chargeDistance; + break; + case 4: + chargeVector.X -= chargeDistance; + chargeVector.Y -= chargeDistance; + break; + case 5: + chargeVector.X += chargeDistance; + chargeVector.Y += chargeDistance; + break; + case 6: + chargeVector.X -= chargeDistance; + chargeVector.Y += chargeDistance; + break; + case 7: + chargeVector.X += chargeDistance; + chargeVector.Y -= chargeDistance; + break; + } + Vector2 chargeLocation = destination + chargeVector; + Vector2 chargeVectorFlipped = chargeVector * -1f; + + // Velocity and turn speed values + float minVelocity = !player.wet ? 20f : 10f; + float velocity = Math.Min(minVelocity, Math.Max(minVelocity * 0.4f, player.velocity.Length())); + float turnSpeed = !player.wet ? MathHelper.ToRadians(4f) : MathHelper.ToRadians(2f); + + // Phase gate values + float chargePhaseGateValue = 180f; + float chargeGateValue = chargePhaseGateValue + 10f; + // Phase switch switch ((int)calamityGlobalNPC.newAI[0]) { - // Charge + // First charge combo case 0: + + if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) + { + turnDistance = chargeLocationDistance; + if ((chargeLocation - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[2] > chargePhaseGateValue) + { + if (calamityGlobalNPC.newAI[2] == chargePhaseGateValue) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose").WithVolume(2.5f), (int)npc.position.X, (int)npc.position.Y); + + if (calamityGlobalNPC.newAI[2] < chargeGateValue) + { + // Slow down and quickly turn for 10 frames before the charge + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] == chargeGateValue) + chargeDestination = destination + chargeVectorFlipped; + + velocity *= 0.5f; + turnSpeed *= 2f; + } + else + { + // Charge + velocity *= 2f; + turnSpeed *= 0.5f; + + destination = chargeDestination; + + if ((destination - npc.Center).Length() < chargeLocationDistance) + { + // Spin around target and summon shadow fireballs + if (phase2) + calamityGlobalNPC.newAI[0] = 6f; + + npc.ai[3] += 1f; + float maxCharges = phase4 ? 1 : phase2 ? 2 : 3; + if (npc.ai[3] >= maxCharges) + { + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 1f; + } + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] > 7f) + calamityGlobalNPC.newAI[1] = 0f; + + calamityGlobalNPC.newAI[2] = 0f; + } + } + } + else + destination += chargeLocation; + } + else + calamityGlobalNPC.newAI[2] += 1f; + break; // Turn invisible, swim above and summon predictive lightning bolts case 1: @@ -202,43 +308,105 @@ namespace CalamityMod.NPCs.Abyss // Swim away case 3: break; - // Turn invisible, swim beneath the target and summon ice mist + // Second charge combo case 4: + + if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) + { + turnDistance = chargeLocationDistance; + if ((chargeLocation - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[2] > chargePhaseGateValue) + { + if (calamityGlobalNPC.newAI[2] == chargePhaseGateValue) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose").WithVolume(2.5f), (int)npc.position.X, (int)npc.position.Y); + + if (calamityGlobalNPC.newAI[2] < chargeGateValue) + { + // Slow down and quickly turn for 10 frames before the charge + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] == chargeGateValue) + chargeDestination = destination + chargeVectorFlipped; + + velocity *= 0.5f; + turnSpeed *= 2f; + } + else + { + // Charge + velocity *= 2f; + turnSpeed *= 0.5f; + + destination = chargeDestination; + + if ((destination - npc.Center).Length() < chargeLocationDistance) + { + // Turn invisible and summon ancient dooms around the target + if (phase3) + calamityGlobalNPC.newAI[0] = 7f; + + npc.ai[3] += 1f; + float maxCharges = phase4 ? 1 : phase3 ? 2 : 3; + if (npc.ai[3] >= maxCharges) + { + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 1f; + } + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] > 7f) + calamityGlobalNPC.newAI[1] = 0f; + + calamityGlobalNPC.newAI[2] = 0f; + } + } + } + else + destination += chargeLocation; + } + else + calamityGlobalNPC.newAI[2] += 1f; + break; - // Phase 2 attack - Get in position for spin, spin around target and summon shadow fireballs + // Turn invisible, swim beneath the target and summon ice mist case 5: break; - // Phase 3 attack - Turn invisible and summon ancient dooms around the target + // Phase 2 attack - Get in position for spin, spin around target and summon shadow fireballs case 6: break; - // Phase 4 attack - Swim to the right and dash towards the target, summon lightning bolts from above during it + // Phase 3 attack - Turn invisible and summon ancient dooms around the target case 7: break; - // Phase 4 attack - Turn visible, swim to the left and dash towards the target, summon lightning bolts from above during it + // Phase 4 attack - Swim to the right and dash towards the target, summon lightning bolts from above during it case 8: break; + //Phase 4 attack - Turn visible, swim to the left and dash towards the target, summon lightning bolts from above during it + case 9: + break; } - // Adjust alpha - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - - // Movement variables - float distanceFromTarget = (destination - npc.Center).Length(); - float minVelocity = !player.wet ? 20f : 10f; - float velocity = Math.Min(minVelocity, Math.Max(minVelocity * 0.4f, player.velocity.Length())); + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC.newAI[0] == 1f || calamityGlobalNPC.newAI[0] == 5f || calamityGlobalNPC.newAI[0] == 7f; + if (!invisiblePhase) + { + npc.Opacity += 0.15f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } // Increase velocity if velocity is ever zero if (npc.velocity == Vector2.Zero) npc.velocity.X = 2f * player.direction; // Acceleration - float acceleration = !player.wet ? 0.1f : 0.05f; - if (!(distanceFromTarget < 120f)) + if (!((destination - npc.Center).Length() < turnDistance)) { float targetAngle = npc.AngleTo(destination); - float f = npc.velocity.ToRotation().AngleTowards(targetAngle, acceleration); + float f = npc.velocity.ToRotation().AngleTowards(targetAngle, turnSpeed); npc.velocity = f.ToRotationVector2() * velocity; } @@ -310,7 +478,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector = center - Main.screenPosition; vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlowHuge").Width, ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlowHuge").Height) * 0.5f; vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); - Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Color.LightYellow); + Color color = new Color(127, 127, 127, 0).MultiplyRGBA(Color.LightYellow) * npc.Opacity; Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlowHuge"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); } diff --git a/NPCs/Abyss/EidolonWyrmTailHuge.cs b/NPCs/Abyss/EidolonWyrmTailHuge.cs index 8adfa78887..8fdd938774 100644 --- a/NPCs/Abyss/EidolonWyrmTailHuge.cs +++ b/NPCs/Abyss/EidolonWyrmTailHuge.cs @@ -1,6 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.Abyss npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.alpha = 255; + npc.Opacity = 0f; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; @@ -66,39 +66,49 @@ namespace CalamityMod.NPCs.Abyss if (!NPC.AnyNPCs(ModContent.NPCType())) npc.active = false; - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + bool invisiblePhase = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 1f || Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 5f || Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 7f; + if (!invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + npc.Opacity += 0.15f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -114,17 +124,13 @@ namespace CalamityMod.NPCs.Abyss public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector = center - Main.screenPosition; - vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; + vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge").Width, ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge").Height) * 0.5f; vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); - Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); + Color color = new Color(127, 127, 127, 0).MultiplyRGBA(Color.LightYellow) * npc.Opacity; Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); }