diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c58d00d018..ad0b6b7caa 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -9,9 +9,7 @@ using CalamityMod.Items.Armor; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.DifficultyItems; -using CalamityMod.Items.Fishing.BrimstoneCragCatches; using CalamityMod.Items.Mounts; -using CalamityMod.Items.Pets; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; @@ -54,8 +52,6 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.IO; -using Terraria.ModLoader.Config; -using System.Linq; namespace CalamityMod.CalPlayer { @@ -5753,12 +5749,35 @@ namespace CalamityMod.CalPlayer if (damage < bossRushDamage) damage = bossRushDamage; } + + if (areThereAnyDamnBosses && CalamityMod.bossVelocityDamageScaleValues.ContainsKey(npc.type)) + { + CalamityMod.bossVelocityDamageScaleValues.TryGetValue(npc.type, out float velocityScalar); + + if (((npc.type == NPCID.EyeofCthulhu || npc.type == NPCID.Spazmatism) && npc.ai[0] >= 2f) || (npc.type == NPCID.Plantera && npc.life / (float)npc.lifeMax <= 0.5f)) + velocityScalar = CalamityMod.bitingEnemeyVelocityScale; + + if (npc.velocity == Vector2.Zero) + { + damage = (int)(damage * velocityScalar); + } + else + { + float amount = npc.velocity.Length() / npc.Calamity().maxVelocity; + if (amount > 1f) + amount = 1f; + + damage = (int)(damage * MathHelper.Lerp(velocityScalar, 1.1f, amount)); + } + } + if (triumph) { - double HPMultiplier = 0.15 * (1.0 - ((double)npc.life / (double)npc.lifeMax)); + double HPMultiplier = 0.15 * (1.0 - (npc.life / (double)npc.lifeMax)); int damageReduction = (int)(damage * HPMultiplier); damage -= damageReduction; } + if (aSparkRare) { if (npc.type == NPCID.BlueJellyfish || npc.type == NPCID.PinkJellyfish || npc.type == NPCID.GreenJellyfish || @@ -5766,6 +5785,7 @@ namespace CalamityMod.CalPlayer npc.type == NPCID.MartianTurret || npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) damage /= 2; } + if (fleshTotem && !fleshTotemCooldown) { player.AddBuff(ModContent.BuffType(), 1200, false); //20 seconds diff --git a/CalamityMod.cs b/CalamityMod.cs index c1f1ddf3fd..a45ea7e09b 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -124,8 +124,15 @@ namespace CalamityMod // DR data structure public static SortedDictionary DRValues; + + // Boss Kill Time data structure public static SortedDictionary bossKillTimes; + // Boss velocity scaling data structure + public static SortedDictionary bossVelocityDamageScaleValues; + public const float velocityScaleMin = 0.5f; + public const float bitingEnemeyVelocityScale = 0.8f; + // Lists public static IList donatorList; public static List rangedProjectileExceptionList; @@ -240,6 +247,7 @@ namespace CalamityMod SetupLists(); SetupVanillaDR(); SetupBossKillTimes(); + SetupBossVelocityScalingValues(); SetupThoriumBossDR(thorium); CalamityLocalization.AddLocalizations(); @@ -345,6 +353,8 @@ namespace CalamityMod DRValues = null; bossKillTimes?.Clear(); bossKillTimes = null; + bossVelocityDamageScaleValues?.Clear(); + bossVelocityDamageScaleValues = null; donatorList = null; rangedProjectileExceptionList = null; @@ -2695,6 +2705,8 @@ namespace CalamityMod #region Boss Kill Times private void SetupBossKillTimes() { + // 3600 = 1 minute + bossKillTimes = new SortedDictionary { { NPCID.KingSlime, 3600 }, { NPCID.EyeofCthulhu, 5400 }, @@ -2702,6 +2714,7 @@ namespace CalamityMod { NPCID.EaterofWorldsBody, 7200 }, { NPCID.EaterofWorldsTail, 7200 }, { NPCID.BrainofCthulhu, 5400 }, + { NPCID.Creeper, 1800 }, { NPCID.QueenBee, 7200 }, { NPCID.SkeletronHead, 9000 }, { NPCID.WallofFlesh, 10800 }, @@ -2713,7 +2726,7 @@ namespace CalamityMod { NPCID.TheDestroyerTail, 10800 }, { NPCID.SkeletronPrime, 10800 }, { NPCID.Plantera, 10800 }, - { NPCID.Golem, 10800 }, + { NPCID.Golem, 9000 }, { NPCID.GolemHead, 3600 }, { NPCID.DukeFishron, 9000 }, { NPCID.CultistBoss, 9000 }, @@ -2740,8 +2753,8 @@ namespace CalamityMod { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 1200 }, { ModContent.NPCType(), 11400 }, - { ModContent.NPCType(), 9000 }, - { ModContent.NPCType(), 9000 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, @@ -2770,7 +2783,138 @@ namespace CalamityMod { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, - { ModContent.NPCType(), 14400 } + { ModContent.NPCType(), 18000 } + }; + } + #endregion + + #region Boss Velocity Contact Damage Scale Values + private void SetupBossVelocityScalingValues() + { + bossVelocityDamageScaleValues = new SortedDictionary { + { NPCID.KingSlime, velocityScaleMin }, + { NPCID.EyeofCthulhu, velocityScaleMin }, // Increases in phase 2 + { NPCID.EaterofWorldsHead, bitingEnemeyVelocityScale }, + { NPCID.EaterofWorldsBody, velocityScaleMin }, + { NPCID.EaterofWorldsTail, velocityScaleMin }, + { NPCID.Creeper, velocityScaleMin }, + { NPCID.BrainofCthulhu, velocityScaleMin }, + { NPCID.QueenBee, velocityScaleMin }, + { NPCID.SkeletronHead, velocityScaleMin }, + { NPCID.SkeletronHand, velocityScaleMin }, + { NPCID.TheHungry, bitingEnemeyVelocityScale }, + { NPCID.TheHungryII, bitingEnemeyVelocityScale }, + { NPCID.LeechHead, bitingEnemeyVelocityScale }, + { NPCID.LeechBody, velocityScaleMin }, + { NPCID.LeechTail, velocityScaleMin }, + { NPCID.Spazmatism, velocityScaleMin }, // Increases in phase 2 + { NPCID.Retinazer, velocityScaleMin }, + { NPCID.TheDestroyer, bitingEnemeyVelocityScale }, + { NPCID.TheDestroyerBody, velocityScaleMin }, + { NPCID.TheDestroyerTail, velocityScaleMin }, + { NPCID.Probe, velocityScaleMin }, + { NPCID.SkeletronPrime, velocityScaleMin }, + { NPCID.PrimeCannon, velocityScaleMin }, + { NPCID.PrimeLaser, velocityScaleMin }, + { NPCID.PrimeSaw, velocityScaleMin }, + { NPCID.PrimeVice, velocityScaleMin }, + { NPCID.Plantera, velocityScaleMin }, // Increases in phase 2 + { NPCID.PlanterasTentacle, bitingEnemeyVelocityScale }, + { NPCID.Golem, velocityScaleMin }, + { NPCID.GolemFistLeft, velocityScaleMin }, + { NPCID.GolemFistRight, velocityScaleMin }, + { NPCID.GolemHead, velocityScaleMin }, + { NPCID.DukeFishron, velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin } }; } #endregion diff --git a/Dusts/CalamityDusts.cs b/Dusts/CalamityDusts.cs index ae879445dd..f2fcd21237 100644 --- a/Dusts/CalamityDusts.cs +++ b/Dusts/CalamityDusts.cs @@ -12,6 +12,7 @@ Phantoplasm = 60, Plague = 46, ProfanedFire = 244, + Nightwither = 185, PurpleCosmolite = 173 } } \ No newline at end of file diff --git a/ExtraTextures/Lasers/ProvidenceHolyRayEndNight.png b/ExtraTextures/Lasers/ProvidenceHolyRayEndNight.png new file mode 100644 index 0000000000..8b3548582f Binary files /dev/null and b/ExtraTextures/Lasers/ProvidenceHolyRayEndNight.png differ diff --git a/ExtraTextures/Lasers/ProvidenceHolyRayMidNight.png b/ExtraTextures/Lasers/ProvidenceHolyRayMidNight.png new file mode 100644 index 0000000000..1640082930 Binary files /dev/null and b/ExtraTextures/Lasers/ProvidenceHolyRayMidNight.png differ diff --git a/Items/SummonItems/DecapoditaSprout.cs b/Items/SummonItems/DecapoditaSprout.cs index 47d775cfba..ff4f73d0ed 100644 --- a/Items/SummonItems/DecapoditaSprout.cs +++ b/Items/SummonItems/DecapoditaSprout.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.SummonItems { if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.NewNPC((int)(player.position.X + (float)Main.rand.Next(-50, 51)), (int)(player.position.Y - 50f), ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + NPC.NewNPC((int)(player.position.X + Main.rand.Next(-50, 51)), (int)(player.position.Y - 50f), ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); Main.PlaySound(SoundID.Roar, player.position, 0); } return true; diff --git a/Items/SummonItems/ProfanedCore.cs b/Items/SummonItems/ProfanedCore.cs index a5c7eff7ba..bc31dd4d4a 100644 --- a/Items/SummonItems/ProfanedCore.cs +++ b/Items/SummonItems/ProfanedCore.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.SummonItems DisplayName.SetDefault("Profaned Core"); Tooltip.SetDefault("The core of the unholy flame\n" + "Summons Providence\n" + - "Can only be used during daytime"); + "Should be used during daytime"); } public override void SetDefaults() @@ -30,13 +30,16 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { - return !NPC.AnyNPCs(ModContent.NPCType()) && Main.dayTime && (player.ZoneHoly || player.ZoneUnderworldHeight) && CalamityWorld.downedBossAny; + return !NPC.AnyNPCs(ModContent.NPCType()) && (player.ZoneHoly || player.ZoneUnderworldHeight) && CalamityWorld.downedBossAny; } public override bool UseItem(Player player) { - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceSpawn"), (int)player.position.X, (int)player.position.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC((int)(player.position.X + Main.rand.Next(-500, 501)), (int)(player.position.Y - 250f), ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceSpawn"), (int)player.position.X, (int)player.position.Y); + } return true; } } diff --git a/Items/SummonItems/ProfanedCoreUnlimited.cs b/Items/SummonItems/ProfanedCoreUnlimited.cs index e9651a26bc..9e0593ff33 100644 --- a/Items/SummonItems/ProfanedCoreUnlimited.cs +++ b/Items/SummonItems/ProfanedCoreUnlimited.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems DisplayName.SetDefault("Profaned Core"); Tooltip.SetDefault("The core of the unholy flame\n" + "Summons Providence\n" + - "Can only be used during daytime\n" + + "Should be used during daytime\n" + "Not consumable"); } @@ -32,13 +32,16 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { - return !NPC.AnyNPCs(ModContent.NPCType()) && Main.dayTime && (player.ZoneHoly || player.ZoneUnderworldHeight) && CalamityWorld.downedBossAny; + return !NPC.AnyNPCs(ModContent.NPCType()) && (player.ZoneHoly || player.ZoneUnderworldHeight) && CalamityWorld.downedBossAny; } public override bool UseItem(Player player) { - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceSpawn"), (int)player.position.X, (int)player.position.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC((int)(player.position.X + Main.rand.Next(-500, 501)), (int)(player.position.Y - 250f), ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceSpawn"), (int)player.position.X, (int)player.position.Y); + } return true; } diff --git a/NPCs/Abyss/BobbitWormHead.cs b/NPCs/Abyss/BobbitWormHead.cs index c2fc5f21c7..737f521aac 100644 --- a/NPCs/Abyss/BobbitWormHead.cs +++ b/NPCs/Abyss/BobbitWormHead.cs @@ -95,7 +95,7 @@ namespace CalamityMod.NPCs.Abyss npc.noTileCollide = true; npc.collideX = false; npc.collideY = false; - float num663 = 11f; + float num663 = 16f; Vector2 vector80 = new Vector2(npc.Center.X, npc.Center.Y); float num664 = Main.player[npc.target].Center.X - vector80.X; float num665 = Main.player[npc.target].Center.Y - vector80.Y; @@ -144,7 +144,7 @@ namespace CalamityMod.NPCs.Abyss else if (npc.ai[0] == 3f) { npc.noTileCollide = true; - float num671 = 11f; + float num671 = 16f; float num672 = 0.25f; Vector2 vector82 = new Vector2(npc.Center.X, npc.Center.Y); float num673 = Main.player[npc.target].Center.X - vector82.X; diff --git a/NPCs/Abyss/BoxJellyfish.cs b/NPCs/Abyss/BoxJellyfish.cs index f35a30cd7a..c1ef114b12 100644 --- a/NPCs/Abyss/BoxJellyfish.cs +++ b/NPCs/Abyss/BoxJellyfish.cs @@ -21,11 +21,11 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { npc.noGravity = true; - npc.damage = 22; + npc.damage = 44; npc.width = 30; npc.height = 33; npc.defense = 5; - npc.lifeMax = 45; + npc.lifeMax = 90; npc.alpha = 20; npc.aiStyle = -1; aiType = -1; @@ -49,7 +49,7 @@ namespace CalamityMod.NPCs.Abyss if (npc.velocity.Y == 0f) { npc.velocity.X = npc.velocity.X * 0.98f; - if ((double)npc.velocity.X > -0.01 && (double)npc.velocity.X < 0.01) + if (npc.velocity.X > -0.01 && npc.velocity.X < 0.01) { npc.velocity.X = 0f; } @@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.Abyss } bool flag16 = false; npc.TargetClosest(false); - if (Main.player[npc.target].wet && !Main.player[npc.target].dead) + if (Main.player[npc.target].wet && !Main.player[npc.target].dead && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { flag16 = true; } diff --git a/NPCs/Abyss/Cuttlefish.cs b/NPCs/Abyss/Cuttlefish.cs index f713b850d0..db90af3107 100644 --- a/NPCs/Abyss/Cuttlefish.cs +++ b/NPCs/Abyss/Cuttlefish.cs @@ -26,11 +26,11 @@ namespace CalamityMod.NPCs.Abyss { npc.noGravity = true; npc.chaseable = false; - npc.damage = 17; + npc.damage = 34; npc.width = 50; npc.height = 28; npc.defense = 12; - npc.lifeMax = 55; + npc.lifeMax = 110; npc.aiStyle = -1; aiType = -1; npc.buffImmune[ModContent.BuffType()] = true; @@ -56,7 +56,7 @@ namespace CalamityMod.NPCs.Abyss { npc.ai[2] = -16f; } - if (npc.velocity.X != 0f || npc.velocity.Y < 0f || npc.velocity.Y > 2f || npc.justHit || npc.localAI[0] >= 420f) + if (npc.justHit) { npc.ai[2] = -16f; } diff --git a/NPCs/Abyss/DevilFish.cs b/NPCs/Abyss/DevilFish.cs index 47f86a1bd4..55e9ce3829 100644 --- a/NPCs/Abyss/DevilFish.cs +++ b/NPCs/Abyss/DevilFish.cs @@ -29,11 +29,11 @@ namespace CalamityMod.NPCs.Abyss { npc.noGravity = true; npc.lavaImmune = true; - npc.damage = 60; + npc.damage = 90; npc.width = 126; npc.height = 66; npc.defense = 999999; - npc.lifeMax = 200; + npc.lifeMax = 400; npc.aiStyle = -1; aiType = -1; npc.buffImmune[ModContent.BuffType()] = true; @@ -91,7 +91,7 @@ namespace CalamityMod.NPCs.Abyss { flag14 = true; } - if ((!player.wet || player.dead) && flag14) + if ((!player.wet || player.dead || !Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) && flag14) { flag14 = false; } diff --git a/NPCs/Abyss/DevilFishAlt.cs b/NPCs/Abyss/DevilFishAlt.cs index 1acd7e7e22..34804ca5a3 100644 --- a/NPCs/Abyss/DevilFishAlt.cs +++ b/NPCs/Abyss/DevilFishAlt.cs @@ -29,11 +29,11 @@ namespace CalamityMod.NPCs.Abyss { npc.noGravity = true; npc.lavaImmune = true; - npc.damage = 60; + npc.damage = 90; npc.width = 126; npc.height = 66; npc.defense = 999999; - npc.lifeMax = 200; + npc.lifeMax = 400; npc.aiStyle = -1; aiType = -1; npc.buffImmune[ModContent.BuffType()] = true; @@ -91,7 +91,7 @@ namespace CalamityMod.NPCs.Abyss { flag14 = true; } - if ((!player.wet || player.dead) && flag14) + if ((!player.wet || player.dead || !Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) && flag14) { flag14 = false; } diff --git a/NPCs/Abyss/EidolonWyrmBody.cs b/NPCs/Abyss/EidolonWyrmBody.cs index a59ed55160..b452a26832 100644 --- a/NPCs/Abyss/EidolonWyrmBody.cs +++ b/NPCs/Abyss/EidolonWyrmBody.cs @@ -53,19 +53,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -93,10 +80,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/EidolonWyrmBodyAlt.cs b/NPCs/Abyss/EidolonWyrmBodyAlt.cs index 0e608c3275..80445f1a6f 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAlt.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAlt.cs @@ -53,19 +53,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -93,10 +80,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs b/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs index c189c0833d..ed2a89ea59 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs @@ -53,19 +53,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -93,10 +80,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/EidolonWyrmBodyHuge.cs b/NPCs/Abyss/EidolonWyrmBodyHuge.cs index 7bb9441d8f..65b6664261 100644 --- a/NPCs/Abyss/EidolonWyrmBodyHuge.cs +++ b/NPCs/Abyss/EidolonWyrmBodyHuge.cs @@ -53,19 +53,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -93,10 +80,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index fa38820a2e..914f799fe8 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -73,7 +73,7 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { - if (npc.justHit || (double)npc.life <= (double)npc.lifeMax * 0.98 || Main.player[npc.target].chaosState) + if (npc.justHit || npc.life <= npc.lifeMax * 0.98 || Main.player[npc.target].chaosState) { detectsPlayer = true; npc.damage = Main.expertMode ? 340 : 170; @@ -106,7 +106,6 @@ namespace CalamityMod.NPCs.Abyss { npc.TargetClosest(true); } - npc.velocity.Length(); if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && npc.ai[0] == 0f) @@ -237,44 +236,21 @@ namespace CalamityMod.NPCs.Abyss 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); - int num42 = -1; - int num43 = (int)(Main.player[npc.target].Center.X / 16f); - int num44 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - { - break; - } - } - if (num42 > 0) - { - num42 *= 16; - float num47 = (float)(num42 - 600); //800 - if (!detectsPlayer) - { - num192 = num47; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 400f) //500 - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 500f; //600 - } - else - { - num191 = Main.player[npc.target].Center.X - 500f; //600 - } - } - } - } + if (!detectsPlayer) + { + num192 += 800; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 400f) //500 + { + if (npc.velocity.X > 0f) + { + num191 = Main.player[npc.target].Center.X + 500f; //600 + } + else + { + num191 = Main.player[npc.target].Center.X - 500f; //600 + } + } + } if (detectsPlayer) { num188 = 7.5f; @@ -301,40 +277,6 @@ namespace CalamityMod.NPCs.Abyss npc.velocity *= num49; } } - if (!detectsPlayer) - { - for (int num51 = 0; num51 < 200; num51++) - { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) - { - Vector2 vector3 = Main.npc[num51].Center - npc.Center; - if (vector3.Length() < 400f) - { - vector3.Normalize(); - vector3 *= 1000f; - num191 -= vector3.X; - num192 -= vector3.Y; - } - } - } - } - else - { - for (int num52 = 0; num52 < 200; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - } num191 = (float)((int)(num191 / 16f) * 16); num192 = (float)((int)(num192 / 16f) * 16); vector18.X = (float)((int)(vector18.X / 16f) * 16); diff --git a/NPCs/Abyss/EidolonWyrmHeadHuge.cs b/NPCs/Abyss/EidolonWyrmHeadHuge.cs index 4a027e7e3f..f731084835 100644 --- a/NPCs/Abyss/EidolonWyrmHeadHuge.cs +++ b/NPCs/Abyss/EidolonWyrmHeadHuge.cs @@ -75,7 +75,7 @@ namespace CalamityMod.NPCs.Abyss { npc.TargetClosest(true); } - if (npc.justHit || (double)npc.life <= (double)npc.lifeMax * 0.98 || Main.player[npc.target].chaosState) + if (npc.justHit || npc.life <= npc.lifeMax * 0.98 || Main.player[npc.target].chaosState) { if (!detectsPlayer) { @@ -111,7 +111,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - npc.velocity.Length(); if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && npc.ai[0] == 0f) @@ -240,44 +239,21 @@ namespace CalamityMod.NPCs.Abyss 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); - int num42 = -1; - int num43 = (int)(Main.player[npc.target].Center.X / 16f); - int num44 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - { - break; - } - } - if (num42 > 0) - { - num42 *= 16; - float num47 = (float)(num42 - 600); //800 - if (!detectsPlayer) - { - num192 = num47; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 400f) //500 - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 500f; //600 - } - else - { - num191 = Main.player[npc.target].Center.X - 500f; //600 - } - } - } - } + if (!detectsPlayer) + { + num192 += 800; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 400f) //500 + { + if (npc.velocity.X > 0f) + { + num191 = Main.player[npc.target].Center.X + 500f; //600 + } + else + { + num191 = Main.player[npc.target].Center.X - 500f; //600 + } + } + } if (detectsPlayer) { num188 = 10f; @@ -304,40 +280,6 @@ namespace CalamityMod.NPCs.Abyss npc.velocity *= num49; } } - if (!detectsPlayer) - { - for (int num51 = 0; num51 < 200; num51++) - { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) - { - Vector2 vector3 = Main.npc[num51].Center - npc.Center; - if (vector3.Length() < 400f) - { - vector3.Normalize(); - vector3 *= 1000f; - num191 -= vector3.X; - num192 -= vector3.Y; - } - } - } - } - else - { - for (int num52 = 0; num52 < 200; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - } num191 = (float)((int)(num191 / 16f) * 16); num192 = (float)((int)(num192 / 16f) * 16); vector18.X = (float)((int)(vector18.X / 16f) * 16); diff --git a/NPCs/Abyss/EidolonWyrmTail.cs b/NPCs/Abyss/EidolonWyrmTail.cs index adb543c760..596881f6d5 100644 --- a/NPCs/Abyss/EidolonWyrmTail.cs +++ b/NPCs/Abyss/EidolonWyrmTail.cs @@ -52,19 +52,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -92,10 +79,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/EidolonWyrmTailHuge.cs b/NPCs/Abyss/EidolonWyrmTailHuge.cs index 900f9d5747..e09cc8cb5e 100644 --- a/NPCs/Abyss/EidolonWyrmTailHuge.cs +++ b/NPCs/Abyss/EidolonWyrmTailHuge.cs @@ -52,19 +52,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -92,10 +79,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/GiantSquid.cs b/NPCs/Abyss/GiantSquid.cs index 430a054eca..ad5f35f5dd 100644 --- a/NPCs/Abyss/GiantSquid.cs +++ b/NPCs/Abyss/GiantSquid.cs @@ -27,11 +27,11 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { npc.noGravity = true; - npc.damage = 80; + npc.damage = 100; npc.width = 50; npc.height = 220; npc.defense = 25; - npc.lifeMax = 400; + npc.lifeMax = 800; npc.aiStyle = -1; aiType = -1; npc.buffImmune[ModContent.BuffType()] = true; @@ -65,7 +65,7 @@ namespace CalamityMod.NPCs.Abyss if (npc.velocity.Y == 0f) { npc.velocity.X = npc.velocity.X * 0.98f; - if ((double)npc.velocity.X > -0.01 && (double)npc.velocity.X < 0.01) + if (npc.velocity.X > -0.01 && npc.velocity.X < 0.01) { npc.velocity.X = 0f; } diff --git a/NPCs/Abyss/GulperEelBody.cs b/NPCs/Abyss/GulperEelBody.cs index ce9d81c95d..88d4dad3c8 100644 --- a/NPCs/Abyss/GulperEelBody.cs +++ b/NPCs/Abyss/GulperEelBody.cs @@ -53,19 +53,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -93,10 +80,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/GulperEelBodyAlt.cs b/NPCs/Abyss/GulperEelBodyAlt.cs index b80ec4dfc2..dea59b558a 100644 --- a/NPCs/Abyss/GulperEelBodyAlt.cs +++ b/NPCs/Abyss/GulperEelBodyAlt.cs @@ -53,19 +53,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -93,10 +80,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index cdc7c2acaf..c055df6dbd 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -84,7 +84,6 @@ namespace CalamityMod.NPCs.Abyss { npc.TargetClosest(true); } - npc.velocity.Length(); if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && npc.ai[0] == 0f) @@ -144,44 +143,26 @@ namespace CalamityMod.NPCs.Abyss 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); - int num42 = -1; - int num43 = (int)(Main.player[npc.target].Center.X / 16f); - int num44 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - { - break; - } - } - if (num42 > 0) - { - num42 *= 16; - float num47 = (float)(num42 - 400); //800 - if (!detectsPlayer) - { - num192 = num47; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 300f) - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 400f; - } - else - { - num191 = Main.player[npc.target].Center.X - 400f; - } - } - } - } + if (!detectsPlayer) + { + num192 += 500; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 300f) + { + if (npc.velocity.X > 0f) + { + num191 = Main.player[npc.target].Center.X + 400f; + } + else + { + num191 = Main.player[npc.target].Center.X - 400f; + } + } + } + else + { + num188 *= 1.5f; + num189 *= 1.5f; + } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); @@ -198,40 +179,6 @@ namespace CalamityMod.NPCs.Abyss npc.velocity *= num49; } } - if (!detectsPlayer) - { - for (int num51 = 0; num51 < 200; num51++) - { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) - { - Vector2 vector3 = Main.npc[num51].Center - npc.Center; - if (vector3.Length() < 400f) - { - vector3.Normalize(); - vector3 *= 1000f; - num191 -= vector3.X; - num192 -= vector3.Y; - } - } - } - } - else - { - for (int num52 = 0; num52 < 200; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - } num191 = (float)((int)(num191 / 16f) * 16); num192 = (float)((int)(num192 / 16f) * 16); vector18.X = (float)((int)(vector18.X / 16f) * 16); diff --git a/NPCs/Abyss/GulperEelTail.cs b/NPCs/Abyss/GulperEelTail.cs index eea75a9444..053e70442a 100644 --- a/NPCs/Abyss/GulperEelTail.cs +++ b/NPCs/Abyss/GulperEelTail.cs @@ -53,19 +53,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -93,10 +80,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Abyss/Laserfish.cs b/NPCs/Abyss/Laserfish.cs index 372125df97..d73890241b 100644 --- a/NPCs/Abyss/Laserfish.cs +++ b/NPCs/Abyss/Laserfish.cs @@ -24,11 +24,11 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { npc.noGravity = true; - npc.damage = 20; + npc.damage = 40; npc.width = 60; npc.height = 26; npc.defense = 25; - npc.lifeMax = 240; + npc.lifeMax = 480; npc.aiStyle = -1; aiType = -1; npc.buffImmune[ModContent.BuffType()] = true; diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index 4703c5b19f..bfb7bc187b 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Abyss { npc.noGravity = true; npc.noTileCollide = true; - npc.damage = 80; + npc.damage = 100; npc.width = 70; npc.height = 162; npc.defense = 10; @@ -100,15 +100,18 @@ namespace CalamityMod.NPCs.Abyss num1250 = (int)player.Center.X / 16; num1251 = (int)player.Center.Y / 16; - int min = 9; - int max = 16; + int min = 6; + int max = 9; if (Main.rand.NextBool(2)) num1250 += Main.rand.Next(min, max); else num1250 -= Main.rand.Next(min, max); - num1251 += Main.rand.Next(min, max); + min = 11; + max = 26; + + num1251 += Main.rand.Next(min, max); if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, player.position, player.width, player.height) && Main.tile[num1250, num1251].liquid > 204) @@ -149,7 +152,7 @@ namespace CalamityMod.NPCs.Abyss npc.alpha -= 5; if (npc.alpha <= 0) { - npc.damage = Main.expertMode ? 160 : 80; + npc.damage = Main.expertMode ? 200 : 100; npc.chaseable = true; npc.dontTakeDamage = false; npc.alpha = 0; diff --git a/NPCs/Abyss/MorayEel.cs b/NPCs/Abyss/MorayEel.cs index e28028007d..f4ff9cf5d4 100644 --- a/NPCs/Abyss/MorayEel.cs +++ b/NPCs/Abyss/MorayEel.cs @@ -23,11 +23,11 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { npc.noGravity = true; - npc.damage = 45; + npc.damage = 55; npc.width = 136; npc.height = 40; npc.defense = 8; - npc.lifeMax = 180; + npc.lifeMax = 360; npc.aiStyle = -1; aiType = -1; npc.buffImmune[ModContent.BuffType()] = true; diff --git a/NPCs/Abyss/OarfishBody.cs b/NPCs/Abyss/OarfishBody.cs index 83a6ed58c4..056607a01a 100644 --- a/NPCs/Abyss/OarfishBody.cs +++ b/NPCs/Abyss/OarfishBody.cs @@ -15,11 +15,11 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - npc.damage = 20; //70 + npc.damage = 30; //70 npc.width = 16; //28 npc.height = 16; //28 npc.defense = 20; - npc.lifeMax = 2000; + npc.lifeMax = 4000; npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; @@ -51,19 +51,6 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - /*if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - }*/ bool flag = false; if (npc.ai[1] <= 0f) { @@ -91,10 +78,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); @@ -124,14 +107,14 @@ namespace CalamityMod.NPCs.Abyss npc.velocity = Vector2.Zero; npc.position.X = npc.position.X + num191; npc.position.Y = npc.position.Y + num192; - /*if (num191 < 0f) + if (num191 < 0f) { npc.spriteDirection = -1; } else if (num191 > 0f) { npc.spriteDirection = 1; - }*/ + } } } diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index 892b749993..bfaa2f8da0 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.World; using Microsoft.Xna.Framework; using System; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,7 +14,8 @@ namespace CalamityMod.NPCs.Abyss { public class OarfishHead : ModNPC { - public const int minLength = 40; + public bool detectsPlayer = false; + public const int minLength = 40; public const int maxLength = 41; public float speed = 3f; //10 public float turnSpeed = 0.05f; //0.15 @@ -26,11 +28,11 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - npc.damage = 30; - npc.width = 59; //36 - npc.height = 38; //20 + npc.damage = 60; + npc.width = 59; + npc.height = 38; npc.defense = 10; - npc.lifeMax = 2000; + npc.lifeMax = 4000; npc.aiStyle = -1; aiType = -1; for (int k = 0; k < npc.buffImmune.Length; k++) @@ -49,9 +51,27 @@ namespace CalamityMod.NPCs.Abyss bannerItem = ModContent.ItemType(); } - public override void AI() + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(detectsPlayer); + writer.Write(npc.chaseable); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + detectsPlayer = reader.ReadBoolean(); + npc.chaseable = reader.ReadBoolean(); + } + + public override void AI() { - if (npc.ai[3] > 0f) + if ((Main.player[npc.target].Center - npc.Center).Length() < Main.player[npc.target].Calamity().GetAbyssAggro(250f, 150f) || + npc.justHit) + { + detectsPlayer = true; + } + npc.chaseable = detectsPlayer; + if (npc.ai[3] > 0f) { npc.realLife = (int)npc.ai[3]; } @@ -86,14 +106,14 @@ namespace CalamityMod.NPCs.Abyss TailSpawned = true; } } - /*if (npc.velocity.X < 0f) + if (npc.velocity.X < 0f) { npc.spriteDirection = -1; } else if (npc.velocity.X > 0f) { npc.spriteDirection = 1; - }*/ + } if (Main.player[npc.target].dead) { npc.TargetClosest(false); @@ -112,47 +132,26 @@ namespace CalamityMod.NPCs.Abyss 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); - int num42 = -1; - int num43 = (int)(Main.player[npc.target].Center.X / 16f); - int num44 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) + if (!detectsPlayer) { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - { - break; - } - } - if (num42 > 0) - { - num42 *= 16; - float num47 = (float)(num42 - 200); //800 - //if ((Main.player[npc.target].Center - npc.Center).Length() > ((Main.player[npc.target].GetCalamityPlayer().anechoicPlating || - // Main.player[npc.target].GetCalamityPlayer().anechoicCoating) ? 150f : 250f) * - // (Main.player[npc.target].GetCalamityPlayer().fishAlert ? 3f : 1f)) - if ((Main.player[npc.target].Center - npc.Center).Length() < Main.player[npc.target].Calamity().GetAbyssAggro(250f, 150f)) - { - num192 = num47; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 300f; - } - else - { - num191 = Main.player[npc.target].Center.X - 300f; - } - } - } + num192 += 300; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) + { + if (npc.velocity.X > 0f) + { + num191 = Main.player[npc.target].Center.X + 300f; + } + else + { + num191 = Main.player[npc.target].Center.X - 300f; + } + } } + else + { + num188 *= 1.5f; + num189 *= 1.5f; + } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); @@ -169,43 +168,6 @@ namespace CalamityMod.NPCs.Abyss npc.velocity *= num49; } } - //if ((Main.player[npc.target].Center - npc.Center).Length() > ((Main.player[npc.target].GetCalamityPlayer().anechoicPlating || - // Main.player[npc.target].GetCalamityPlayer().anechoicCoating) ? 150f : 250f) * - // (Main.player[npc.target].GetCalamityPlayer().fishAlert ? 3f : 1f)) - if ((Main.player[npc.target].Center - npc.Center).Length() < Main.player[npc.target].Calamity().GetAbyssAggro(250f, 150f)) - { - for (int num51 = 0; num51 < 200; num51++) - { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) - { - Vector2 vector3 = Main.npc[num51].Center - npc.Center; - if (vector3.Length() < 400f) - { - vector3.Normalize(); - vector3 *= 1000f; - num191 -= vector3.X; - num192 -= vector3.Y; - } - } - } - } - else - { - for (int num52 = 0; num52 < 200; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - } num191 = (float)((int)(num191 / 16f) * 16); num192 = (float)((int)(num192 / 16f) * 16); vector18.X = (float)((int)(vector18.X / 16f) * 16); @@ -315,7 +277,16 @@ namespace CalamityMod.NPCs.Abyss npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override bool? CanBeHitByProjectile(Projectile projectile) + { + if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) + { + return detectsPlayer; + } + return null; + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.player.Calamity().ZoneAbyssLayer2 && spawnInfo.water && !NPC.AnyNPCs(ModContent.NPCType())) { diff --git a/NPCs/Abyss/OarfishTail.cs b/NPCs/Abyss/OarfishTail.cs index fb1b1fe882..694fc9dc94 100644 --- a/NPCs/Abyss/OarfishTail.cs +++ b/NPCs/Abyss/OarfishTail.cs @@ -15,11 +15,11 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - npc.damage = 10; //70 + npc.damage = 15; //70 npc.width = 14; //28 npc.height = 16; //28 npc.defense = 30; - npc.lifeMax = 2000; + npc.lifeMax = 4000; npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; @@ -51,19 +51,7 @@ namespace CalamityMod.NPCs.Abyss { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } npc.velocity.Length(); - /*if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - }*/ bool flag = false; if (npc.ai[1] <= 0f) { @@ -91,10 +79,6 @@ namespace CalamityMod.NPCs.Abyss npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); @@ -124,14 +108,14 @@ namespace CalamityMod.NPCs.Abyss npc.velocity = Vector2.Zero; npc.position.X = npc.position.X + num191; npc.position.Y = npc.position.Y + num192; - /*if (num191 < 0f) + if (num191 < 0f) { npc.spriteDirection = -1; } else if (num191 > 0f) { npc.spriteDirection = 1; - }*/ + } } } diff --git a/NPCs/Abyss/Viperfish.cs b/NPCs/Abyss/Viperfish.cs index 7b62d4d7b0..89cd2d67a7 100644 --- a/NPCs/Abyss/Viperfish.cs +++ b/NPCs/Abyss/Viperfish.cs @@ -25,11 +25,11 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { npc.noGravity = true; - npc.damage = 60; + npc.damage = 75; npc.width = 72; npc.height = 30; npc.defense = 15; - npc.lifeMax = 160; + npc.lifeMax = 320; npc.aiStyle = -1; aiType = -1; npc.buffImmune[ModContent.BuffType()] = true; diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index a4c37a4cd2..a5952ea92a 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -81,7 +81,7 @@ namespace CalamityMod.NPCs.AquaticScourge public override void AI() { - if (npc.justHit || (double)npc.life <= (double)npc.lifeMax * 0.99 || CalamityWorld.bossRushActive) + if (npc.justHit || npc.life <= npc.lifeMax * 0.99 || CalamityWorld.bossRushActive) { Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); if (calamityModMusic != null) diff --git a/NPCs/AquaticScourge/AquaticSeekerHead.cs b/NPCs/AquaticScourge/AquaticSeekerHead.cs index 847aa16995..c2350963c2 100644 --- a/NPCs/AquaticScourge/AquaticSeekerHead.cs +++ b/NPCs/AquaticScourge/AquaticSeekerHead.cs @@ -114,44 +114,21 @@ namespace CalamityMod.NPCs.AquaticScourge 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); - int num42 = -1; - int num43 = (int)(Main.player[npc.target].Center.X / 16f); - int num44 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - { - break; - } - } - if (num42 > 0) - { - num42 *= 16; - float num47 = (float)(num42 - 200); //800 - if ((Main.player[npc.target].Center - npc.Center).Length() > 200f) - { - num192 = num47; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 300f; - } - else - { - num191 = Main.player[npc.target].Center.X - 300f; - } - } - } - } + if ((Main.player[npc.target].Center - npc.Center).Length() > 200f) + { + num192 -= 160; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) + { + if (npc.velocity.X > 0f) + { + num191 = Main.player[npc.target].Center.X + 300f; + } + else + { + num191 = Main.player[npc.target].Center.X - 300f; + } + } + } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); @@ -168,40 +145,6 @@ namespace CalamityMod.NPCs.AquaticScourge npc.velocity *= num49; } } - if ((Main.player[npc.target].Center - npc.Center).Length() > 200f) - { - for (int num51 = 0; num51 < 200; num51++) - { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) - { - Vector2 vector3 = Main.npc[num51].Center - npc.Center; - if (vector3.Length() < 400f) - { - vector3.Normalize(); - vector3 *= 1000f; - num191 -= vector3.X; - num192 -= vector3.Y; - } - } - } - } - else - { - for (int num52 = 0; num52 < 200; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - } num191 = (float)((int)(num191 / 16f) * 16); num192 = (float)((int)(num192 / 16f) * 16); vector18.X = (float)((int)(vector18.X / 16f) * 16); diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 316a528d53..672df00fdf 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -359,40 +359,18 @@ namespace CalamityMod.NPCs Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num191 = player.position.X + (player.width / 2); float num192 = player.position.Y + (player.height / 2); - int num42 = -1; - int num43 = (int)(player.Center.X / 16f); - int num44 = (int)(player.Center.Y / 16f); if (head && !doSpiral) { - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) + if (calamityGlobalNPC.newAI[0] != 1f) { - for (int num46 = num44; num46 <= num44 + 15; num46++) + num192 += 400; + if (Math.Abs(npc.Center.X - player.Center.X) < 500f) { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - break; - } - - if (num42 > 0) - { - num42 *= 16; - float num47 = num42 + (notOcean ? 800 : 400); //800 - if (calamityGlobalNPC.newAI[0] != 1f) - { - num192 = num47; - if (Math.Abs(npc.Center.X - player.Center.X) < (notOcean ? 500f : 400f)) //500 - { - if (npc.velocity.X > 0f) - num191 = player.Center.X + (notOcean ? 600f : 480f); //600 - else - num191 = player.Center.X - (notOcean ? 600f : 480f); //600 - } + if (npc.velocity.X > 0f) + num191 = player.Center.X + 600f; + else + num191 = player.Center.X - 600f; } } @@ -5173,7 +5151,7 @@ namespace CalamityMod.NPCs Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(vortexSpawn.X, vortexSpawn.Y, 0f, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); + Projectile.NewProjectile(vortexSpawn, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); } } @@ -5580,7 +5558,7 @@ namespace CalamityMod.NPCs Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(vortexSpawn.X, vortexSpawn.Y, 0f, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); + Projectile.NewProjectile(vortexSpawn, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); } } @@ -6714,7 +6692,7 @@ namespace CalamityMod.NPCs } } } - if (Main.player[npc.target].dead && flag14) + if ((Main.player[npc.target].dead || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) && flag14) { flag14 = false; } @@ -6778,10 +6756,10 @@ namespace CalamityMod.NPCs num8 = speed / num8; num6 *= num8; num7 *= num8; - int damage = 40; + int damage = 50; if (Main.expertMode) { - damage = 30; + damage = 40; } int beam = Projectile.NewProjectile(npc.Center.X + (npc.spriteDirection == 1 ? 25f : -25f), npc.Center.Y + (Main.player[npc.target].position.Y > npc.Center.Y ? 5f : -5f), num6, num7, ProjectileID.EyeBeam, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[beam].tileCollide = true; @@ -6806,10 +6784,10 @@ namespace CalamityMod.NPCs num8 = speed / num8; num6 *= num8; num7 *= num8; - int damage = 25; + int damage = 35; if (Main.expertMode) { - damage = 19; + damage = 25; } int beam = Projectile.NewProjectile(npc.Center.X + (npc.spriteDirection == 1 ? 10f : -10f), npc.Center.Y, num6, num7, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index c1798531bb..d1a11035ac 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -8135,7 +8135,7 @@ namespace CalamityMod.NPCs { velocity = 10f; acceleration = 0.1f; - if (tentaclesDead) + if (tentaclesDead || spawnMoreTentacles) { velocity = 12f; acceleration = 0.12f; @@ -8425,7 +8425,7 @@ namespace CalamityMod.NPCs // If tentacles are alive, gain high defense if (!tentaclesDead) - npc.defense = 9999; + npc.defense = spawnMoreTentacles ? 99 : 9999; npc.chaseable = tentaclesDead; // Spawn gore @@ -8516,7 +8516,7 @@ namespace CalamityMod.NPCs } // Fire spread of spore clouds - if (tentaclesDead) + if (tentaclesDead || spawnMoreTentacles) { float shootBoost = death ? 1f : 2f * (0.5f - lifeRatio); calamityGlobalNPC.newAI[0] += 1f + shootBoost; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 3f5e146fa3..6f6a616e52 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1,10 +1,7 @@ -using CalamityMod; using CalamityMod.Buffs; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.Placeables; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Buffs.Potions; using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Events; @@ -39,7 +36,6 @@ using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.HiveMind; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Perforator; using CalamityMod.NPCs.PlaguebringerGoliath; using CalamityMod.NPCs.Polterghast; @@ -65,13 +61,11 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; -using System.IO; using System.Linq; using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using Terraria.ModLoader.Config; using static Terraria.ModLoader.ModContent; namespace CalamityMod.NPCs @@ -99,6 +93,9 @@ namespace CalamityMod.NPCs // Iron Heart (currently unimplemented) // private int ironHeartDamage = 0; + // Max velocity used in contact damage scaling + public float maxVelocity = 0f; + // Town NPC shop alert animation variables private int shopAlertAnimTimer = 0; private int shopAlertAnimFrame = 0; @@ -1041,19 +1038,6 @@ namespace CalamityMod.NPCs npc.width = npc.height = 36; } - //Reduce damage in Death Mode by the Beach - if (CalamityWorld.death && !CalamityPlayer.areThereAnyDamnBosses) - { - if (npc.type == NPCID.Sharkron) - { - npc.damage = 25; - } - if (npc.type == NPCID.Sharkron2) - { - npc.damage = 50; - } - } - if (npc.type == NPCID.CultistBoss) { npc.lifeMax = (int)(npc.lifeMax * (CalamityWorld.revenge ? 2 : 1.2)); @@ -1532,8 +1516,14 @@ namespace CalamityMod.NPCs // Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac if (KillTime > 0 && AITimer < KillTime && !CalamityWorld.bossRushActive) { + float DRScalar = !GetDownedBossVariable(npc.type) || CalamityMod.CalamityConfig.ExtraBossDR ? 1.5f : 1f; + + // Boost Providence timed DR during the night + if (npc.type == NPCType() && !Main.dayTime) + DRScalar = 10f; + // The limit for how much extra DR the boss can have - float extraDRLimit = (1f - DR) * (!GetDownedBossVariable(npc.type) || CalamityMod.CalamityConfig.ExtraBossDR ? 1.5f : 1f); + float extraDRLimit = (1f - DR) * DRScalar; // Ranges from 1 to 0 float currentHPRatio = npc.life / (float)npc.lifeMax; @@ -1662,6 +1652,12 @@ namespace CalamityMod.NPCs { SetPatreonTownNPCName(npc); + if (CalamityPlayer.areThereAnyDamnBosses) + { + if (npc.velocity.Length() > maxVelocity) + maxVelocity = npc.velocity.Length(); + } + if (KillTime > 0 && AITimer < KillTime) AITimer++; @@ -3592,7 +3588,7 @@ namespace CalamityMod.NPCs } else if (DestroyerIDs.Contains(npc.type)) { - if (((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion)) + if ((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) { damage = (int)(damage * 0.5); } diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs index c19edecb2a..0a8fcc8143 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs @@ -24,8 +24,6 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using Terraria.ModLoader.Config; -using CalamityMod; namespace CalamityMod.NPCs.DevourerofGods { diff --git a/NPCs/DevourerofGods/DoGSky.cs b/NPCs/DevourerofGods/DoGSky.cs index c6d9b27812..c4938af624 100644 --- a/NPCs/DevourerofGods/DoGSky.cs +++ b/NPCs/DevourerofGods/DoGSky.cs @@ -27,12 +27,12 @@ namespace CalamityMod.NPCs.DevourerofGods private float GetIntensity() { - if (this.UpdateDoGIndex()) + if (UpdateDoGIndex()) { float x = 0f; - if (this.DoGIndex != -1) + if (DoGIndex != -1) { - x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this.DoGIndex].Center); + x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[DoGIndex].Center); } return (1f - Utils.SmoothStep(3000f, 6000f, x)) * 0.5f; } @@ -41,7 +41,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override Color OnTileColor(Color inColor) { - float intensity = this.GetIntensity(); + float intensity = GetIntensity(); return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); } @@ -70,8 +70,8 @@ namespace CalamityMod.NPCs.DevourerofGods { if (Main.npc[CalamityGlobalNPC.DoGHead].active) { - float intensity = this.GetIntensity(); - if ((double)Main.npc[CalamityGlobalNPC.DoGHead].life < (double)Main.npc[CalamityGlobalNPC.DoGHead].lifeMax * 0.15 || CalamityWorld.death) + float intensity = GetIntensity(); + if (Main.npc[CalamityGlobalNPC.DoGHead].life < Main.npc[CalamityGlobalNPC.DoGHead].lifeMax * 0.15 || CalamityWorld.death) { spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * (intensity + 0.5f)); diff --git a/NPCs/Polterghast/PhantomFuckYou.cs b/NPCs/Polterghast/PhantomFuckYou.cs index 4746ec170d..c5293bcfa1 100644 --- a/NPCs/Polterghast/PhantomFuckYou.cs +++ b/NPCs/Polterghast/PhantomFuckYou.cs @@ -74,7 +74,7 @@ namespace CalamityMod.NPCs.Polterghast } // Percent life remaining, Polter - float lifeRatio = (float)Main.npc[CalamityGlobalNPC.ghostBoss].life / (float)Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax; + float lifeRatio = Main.npc[CalamityGlobalNPC.ghostBoss].life / Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax; npc.TargetClosest(true); @@ -96,7 +96,7 @@ namespace CalamityMod.NPCs.Polterghast } Player player = Main.player[npc.target]; - double deg = (double)npc.ai[1]; + double deg = npc.ai[1]; double rad = deg * (Math.PI / 180); double dist = 500; npc.position.X = player.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; @@ -125,7 +125,7 @@ namespace CalamityMod.NPCs.Polterghast spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Color color36 = Color.White; float amount9 = 0.5f; int num153 = 5; @@ -137,16 +137,16 @@ namespace CalamityMod.NPCs.Polterghast Color color38 = lightColor; color38 = Color.Lerp(color38, color36, amount9); color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); diff --git a/NPCs/Providence/ProvidenceAltGlow.png b/NPCs/Providence/Glowmasks/ProvidenceAltGlow.png similarity index 100% rename from NPCs/Providence/ProvidenceAltGlow.png rename to NPCs/Providence/Glowmasks/ProvidenceAltGlow.png diff --git a/NPCs/Providence/ProvidenceAltGlow2.png b/NPCs/Providence/Glowmasks/ProvidenceAltGlow2.png similarity index 100% rename from NPCs/Providence/ProvidenceAltGlow2.png rename to NPCs/Providence/Glowmasks/ProvidenceAltGlow2.png diff --git a/NPCs/Providence/Glowmasks/ProvidenceAltGlow2Night.png b/NPCs/Providence/Glowmasks/ProvidenceAltGlow2Night.png new file mode 100644 index 0000000000..04cb6c8f39 Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceAltGlow2Night.png differ diff --git a/NPCs/Providence/Glowmasks/ProvidenceAltGlowNight.png b/NPCs/Providence/Glowmasks/ProvidenceAltGlowNight.png new file mode 100644 index 0000000000..bbcffd77bf Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceAltGlowNight.png differ diff --git a/NPCs/Providence/ProvidenceAttackAltGlow.png b/NPCs/Providence/Glowmasks/ProvidenceAttackAltGlow.png similarity index 100% rename from NPCs/Providence/ProvidenceAttackAltGlow.png rename to NPCs/Providence/Glowmasks/ProvidenceAttackAltGlow.png diff --git a/NPCs/Providence/ProvidenceAttackAltGlow2.png b/NPCs/Providence/Glowmasks/ProvidenceAttackAltGlow2.png similarity index 100% rename from NPCs/Providence/ProvidenceAttackAltGlow2.png rename to NPCs/Providence/Glowmasks/ProvidenceAttackAltGlow2.png diff --git a/NPCs/Providence/Glowmasks/ProvidenceAttackAltGlow2Night.png b/NPCs/Providence/Glowmasks/ProvidenceAttackAltGlow2Night.png new file mode 100644 index 0000000000..b019542ded Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceAttackAltGlow2Night.png differ diff --git a/NPCs/Providence/Glowmasks/ProvidenceAttackAltGlowNight.png b/NPCs/Providence/Glowmasks/ProvidenceAttackAltGlowNight.png new file mode 100644 index 0000000000..df0186d580 Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceAttackAltGlowNight.png differ diff --git a/NPCs/Providence/ProvidenceAttackGlow.png b/NPCs/Providence/Glowmasks/ProvidenceAttackGlow.png similarity index 100% rename from NPCs/Providence/ProvidenceAttackGlow.png rename to NPCs/Providence/Glowmasks/ProvidenceAttackGlow.png diff --git a/NPCs/Providence/ProvidenceAttackGlow2.png b/NPCs/Providence/Glowmasks/ProvidenceAttackGlow2.png similarity index 100% rename from NPCs/Providence/ProvidenceAttackGlow2.png rename to NPCs/Providence/Glowmasks/ProvidenceAttackGlow2.png diff --git a/NPCs/Providence/Glowmasks/ProvidenceAttackGlow2Night.png b/NPCs/Providence/Glowmasks/ProvidenceAttackGlow2Night.png new file mode 100644 index 0000000000..0ce832dc3f Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceAttackGlow2Night.png differ diff --git a/NPCs/Providence/Glowmasks/ProvidenceAttackGlowNight.png b/NPCs/Providence/Glowmasks/ProvidenceAttackGlowNight.png new file mode 100644 index 0000000000..8a8fab82c6 Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceAttackGlowNight.png differ diff --git a/NPCs/Providence/ProvidenceDefenseAltGlow.png b/NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlow.png similarity index 100% rename from NPCs/Providence/ProvidenceDefenseAltGlow.png rename to NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlow.png diff --git a/NPCs/Providence/ProvidenceDefenseAltGlow2.png b/NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlow2.png similarity index 100% rename from NPCs/Providence/ProvidenceDefenseAltGlow2.png rename to NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlow2.png diff --git a/NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlow2Night.png b/NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlow2Night.png new file mode 100644 index 0000000000..687d9e3336 Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlow2Night.png differ diff --git a/NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlowNight.png b/NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlowNight.png new file mode 100644 index 0000000000..3b9c2e7427 Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceDefenseAltGlowNight.png differ diff --git a/NPCs/Providence/ProvidenceDefenseGlow.png b/NPCs/Providence/Glowmasks/ProvidenceDefenseGlow.png similarity index 100% rename from NPCs/Providence/ProvidenceDefenseGlow.png rename to NPCs/Providence/Glowmasks/ProvidenceDefenseGlow.png diff --git a/NPCs/Providence/ProvidenceDefenseGlow2.png b/NPCs/Providence/Glowmasks/ProvidenceDefenseGlow2.png similarity index 100% rename from NPCs/Providence/ProvidenceDefenseGlow2.png rename to NPCs/Providence/Glowmasks/ProvidenceDefenseGlow2.png diff --git a/NPCs/Providence/Glowmasks/ProvidenceDefenseGlow2Night.png b/NPCs/Providence/Glowmasks/ProvidenceDefenseGlow2Night.png new file mode 100644 index 0000000000..78d8a5d5df Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceDefenseGlow2Night.png differ diff --git a/NPCs/Providence/Glowmasks/ProvidenceDefenseGlowNight.png b/NPCs/Providence/Glowmasks/ProvidenceDefenseGlowNight.png new file mode 100644 index 0000000000..bd27430046 Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceDefenseGlowNight.png differ diff --git a/NPCs/Providence/ProvidenceGlow.png b/NPCs/Providence/Glowmasks/ProvidenceGlow.png similarity index 100% rename from NPCs/Providence/ProvidenceGlow.png rename to NPCs/Providence/Glowmasks/ProvidenceGlow.png diff --git a/NPCs/Providence/ProvidenceGlow2.png b/NPCs/Providence/Glowmasks/ProvidenceGlow2.png similarity index 100% rename from NPCs/Providence/ProvidenceGlow2.png rename to NPCs/Providence/Glowmasks/ProvidenceGlow2.png diff --git a/NPCs/Providence/Glowmasks/ProvidenceGlow2Night.png b/NPCs/Providence/Glowmasks/ProvidenceGlow2Night.png new file mode 100644 index 0000000000..d9e79a8288 Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceGlow2Night.png differ diff --git a/NPCs/Providence/Glowmasks/ProvidenceGlowNight.png b/NPCs/Providence/Glowmasks/ProvidenceGlowNight.png new file mode 100644 index 0000000000..3d1a8a1623 Binary files /dev/null and b/NPCs/Providence/Glowmasks/ProvidenceGlowNight.png differ diff --git a/NPCs/Providence/ProvSky.cs b/NPCs/Providence/ProvSky.cs index 23a36ae34e..1ee38e5c67 100644 --- a/NPCs/Providence/ProvSky.cs +++ b/NPCs/Providence/ProvSky.cs @@ -26,21 +26,27 @@ namespace CalamityMod.NPCs.Providence private float GetIntensity() { - if (this.UpdatePIndex()) + if (UpdatePIndex()) { float x = 0f; - if (this.ProvIndex != -1) + if (ProvIndex != -1) { - x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this.ProvIndex].Center); + x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[ProvIndex].Center); } - return (1f - Utils.SmoothStep(3000f, 6000f, x)) * 0.25f; + + float spawnAnimationTimer = 180f; + float intensityScalar = Main.dayTime ? 0.25f : 0.2f; + if (Main.npc[CalamityGlobalNPC.holyBoss].Calamity().newAI[3] < spawnAnimationTimer) + intensityScalar = MathHelper.Lerp(0f, intensityScalar, Main.npc[CalamityGlobalNPC.holyBoss].Calamity().newAI[3] / spawnAnimationTimer); + + return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar; } return 0f; //0.5 } public override Color OnTileColor(Color inColor) { - float intensity = this.GetIntensity(); + float intensity = GetIntensity(); return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); } @@ -67,8 +73,9 @@ namespace CalamityMod.NPCs.Providence { if (maxDepth >= 0 && minDepth < 0) { - float intensity = this.GetIntensity(); - spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), new Color(255, 200, 100) * intensity); + float intensity = GetIntensity(); + Color color = Main.dayTime ? new Color(255, 200, 100) : new Color(100, 150, 255); + spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color * intensity); } } diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 99de93d7cc..4981529049 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -35,6 +35,7 @@ namespace CalamityMod.NPCs.Providence [AutoloadBossHead] public class Providence : ModNPC { + private bool hasTakenDaytimeDamage = false; private bool text = false; private bool useDefenseFrames = false; private float bossLife; @@ -76,6 +77,7 @@ namespace CalamityMod.NPCs.Providence aiType = -1; npc.value = Item.buyPrice(0, 50, 0, 0); npc.boss = true; + npc.Opacity = 0f; for (int k = 0; k < npc.buffImmune.Length; k++) { npc.buffImmune[k] = true; @@ -155,11 +157,6 @@ namespace CalamityMod.NPCs.Providence Player player = Main.player[npc.target]; Vector2 vector = npc.Center; - // Difficulty bools - bool death = CalamityWorld.death || CalamityWorld.bossRushActive; - bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; - bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; - // Target's current biome bool isHoly = player.ZoneHoly; bool isHell = player.ZoneUnderworldHeight; @@ -167,12 +164,60 @@ namespace CalamityMod.NPCs.Providence // Fire projectiles at normal rate or not bool normalAttackRate = true; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Is in spawning animation + float spawnAnimationTime = 180f; + bool spawnAnimation = calamityGlobalNPC.newAI[3] < spawnAnimationTime; - // Phases - bool ignoreGuardianAmt = lifeRatio < (death ? 0.2f : 0.15f); - bool phase2 = lifeRatio < 0.75f || death; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Night bool + bool nightTime = !Main.dayTime; + + // Play enrage animation if night starts + if (nightTime && calamityGlobalNPC.newAI[3] == spawnAnimationTime) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + } + + // Difficulty bools + bool death = CalamityWorld.death || CalamityWorld.bossRushActive || nightTime; + bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive || nightTime; + bool expertMode = Main.expertMode || CalamityWorld.bossRushActive || nightTime; + + // Projectile damage values + bool scaleExpertProjectileDamage = Main.expertMode && !nightTime; + int holyLaserDamage = 100; + int crystalDamage = scaleExpertProjectileDamage ? 57 : 70; + int holySpearDamage = scaleExpertProjectileDamage ? 52 : 65; + int holyBombDamage = scaleExpertProjectileDamage ? 48 : 60; + int moltenBlastDamage = scaleExpertProjectileDamage ? 42 : 55; + int holyFireDamage = scaleExpertProjectileDamage ? 48 : 60; + int holyBlastDamage = scaleExpertProjectileDamage ? 52 : 65; + + // Increase all projectile damage at night + int projectileDamageNight = 100; + if (nightTime) + { + holyLaserDamage = crystalDamage = holySpearDamage = holyBombDamage = moltenBlastDamage = holyFireDamage = holyBlastDamage = projectileDamageNight; + } + + // Change dust type at night + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + + // Phase times + float phaseTime = nightTime ? 240f : 300f; + float crystalPhaseTime = nightTime ? 60f : 120f; + + // Phases + bool ignoreGuardianAmt = lifeRatio < (death ? 0.2f : 0.15f); + bool phase2 = (lifeRatio < 0.75f || death) && !nightTime; // Projectile fire rate multiplier double attackRateMult = 1D; @@ -300,14 +345,14 @@ namespace CalamityMod.NPCs.Providence // Despawn bool targetDead = false; - if ((!Main.dayTime && npc.ai[0] != 2f && npc.ai[0] != 5f && npc.ai[0] != 7f) || !player.active || player.dead) + if (!player.active || player.dead) { if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; } - if ((!Main.dayTime && npc.ai[0] != 2f && npc.ai[0] != 5f && npc.ai[0] != 7f) || !player.active || player.dead) + if (!player.active || player.dead) { targetDead = true; @@ -325,28 +370,31 @@ namespace CalamityMod.NPCs.Providence else if (npc.timeLeft < 1800) npc.timeLeft = 1800; - // Guardian spawn - if (bossLife == 0f && npc.life > 0) - bossLife = npc.lifeMax; - if (npc.life > 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num660 = (int)(npc.lifeMax * 0.66); - if ((npc.life + num660) < bossLife) - { - bossLife = npc.life; - int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); - int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); - NPC.NewNPC(x - 100, y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - NPC.NewNPC(x + 100, y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - NPC.NewNPC(x, y + 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - } - } - } + // Guardian spawn + if (!nightTime) + { + if (bossLife == 0f && npc.life > 0) + bossLife = npc.lifeMax; + if (npc.life > 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int num660 = (int)(npc.lifeMax * 0.66); + if ((npc.life + num660) < bossLife) + { + bossLife = npc.life; + int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); + int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); + NPC.NewNPC(x - 100, y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + NPC.NewNPC(x + 100, y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + NPC.NewNPC(x, y + 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + } + } + } + } // Set DR based on current attack phase - npc.Calamity().DR = (npc.ai[0] == 2f || npc.ai[0] == 5f || npc.ai[0] == 7f) ? cocoonDR : normalDR; + npc.Calamity().DR = (npc.ai[0] == 2f || npc.ai[0] == 5f || npc.ai[0] == 7f || spawnAnimation) ? cocoonDR : normalDR; // Movement if (npc.ai[0] != 2f && npc.ai[0] != 5f) @@ -398,7 +446,7 @@ namespace CalamityMod.NPCs.Providence float velocityBoost = death ? 4f : 4f * (1f - lifeRatio); float acceleration = (expertMode ? 1.1f : 1.05f) + accelerationBoost; float velocity = (expertMode ? 16f : 15f) + velocityBoost; - if (CalamityWorld.bossRushActive) + if (CalamityWorld.bossRushActive || nightTime) { acceleration = 1.3f; velocity = 20f; @@ -435,7 +483,16 @@ namespace CalamityMod.NPCs.Providence if (npc.velocity.Y < (firingLaser ? -speedVariance : -6f)) npc.velocity.Y = firingLaser ? -speedVariance : -6f; } - } + + // Slowly drift down when spawning + if (spawnAnimation) + { + float minSpawnVelocity = 0.4f; + float maxSpawnVelocity = 4f; + float velocityY = maxSpawnVelocity - MathHelper.Lerp(minSpawnVelocity, maxSpawnVelocity, calamityGlobalNPC.newAI[3] / spawnAnimationTime); + npc.velocity = new Vector2(0f, velocityY); + } + } // Phase switch if (npc.ai[0] == -1f) @@ -476,7 +533,7 @@ namespace CalamityMod.NPCs.Providence phase = 0; break; // 2175 or 2100 case 3: - phase = useCrystal ? 6 : 3; + phase = (useCrystal || nightTime) ? 6 : 3; break; case 4: phase = useCrystal ? 3 : 2; @@ -485,8 +542,8 @@ namespace CalamityMod.NPCs.Providence phase = useCrystal ? 2 : 1; break; // 900 case 6: - phase = useLaser ? 7 : 4; // 1875 or 1800 - if (useLaser) + phase = (useLaser || nightTime) ? 7 : 4; // 1875 or 1800 + if (useLaser || nightTime) { npc.TargetClosest(false); Vector2 v3 = player.Center - vector - new Vector2(0f, -22f); @@ -503,23 +560,23 @@ namespace CalamityMod.NPCs.Providence } break; // 1200 case 7: - phase = useLaser ? 4 : 3; + phase = (useLaser || nightTime) ? 4 : 3; break; // 1500 case 8: - phase = useLaser ? 3 : 5; + phase = (useLaser || nightTime) ? 3 : 5; break; case 9: phase = 0; break; // 2175 or 2100 case 10: - phase = useCrystal ? 6 : 2; + phase = (useCrystal || nightTime) ? 6 : 2; break; case 11: - phase = 3; + phase = nightTime ? 2 : 3; break; // 300 case 12: - phase = useLaser ? 7 : 4; // 675 or 600 - if (useLaser) + phase = (useLaser || nightTime) ? 7 : 4; // 675 or 600 + if (useLaser || nightTime) { npc.TargetClosest(false); Vector2 v3 = player.Center - vector - new Vector2(0f, -22f); @@ -539,7 +596,7 @@ namespace CalamityMod.NPCs.Providence phase = 5; break; // 975 or 900 case 14: - phase = useLaser ? 4 : 0; + phase = (useLaser || nightTime) ? 4 : 0; break; // 1275 or 1200 default: break; @@ -642,6 +699,7 @@ namespace CalamityMod.NPCs.Providence npc.ai[2] = 0f; npc.ai[3] = 0f; calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; } // Holy blasts @@ -650,6 +708,65 @@ namespace CalamityMod.NPCs.Providence npc.noGravity = true; npc.noTileCollide = true; + if (spawnAnimation) + { + if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[3] == 0f) + Projectile.NewProjectile(vector + new Vector2(0f, -80f), Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, biomeType, 0f); + + if (calamityGlobalNPC.newAI[3] == 10f && nightTime) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyRay"), (int)npc.position.X, (int)npc.position.Y); + + if (calamityGlobalNPC.newAI[3] > 10f && calamityGlobalNPC.newAI[3] < 150f) + { + int dustAmt = (int)MathHelper.Lerp(4f, 8f, calamityGlobalNPC.newAI[3] / spawnAnimationTime); + for (int m = 0; m < dustAmt; m++) + { + float fade = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity) * CalamityUtils.GetLerpValue(0f, 120f, calamityGlobalNPC.newAI[3], clamped: true); + Color newColor = Main.hslToRgb(calamityGlobalNPC.newAI[3] / 180f, 1f, 0.5f); + + if (!nightTime) + { + newColor.R = 255; + if (biomeType == 2) + newColor.B = 0; + } + else + { + newColor.B = 255; + if (biomeType == 2) + newColor.G = 0; + else + newColor.R = 0; + } + + int dust = Dust.NewDust(npc.position, npc.width, npc.height, 267, 0f, 0f, 0, newColor); + Main.dust[dust].position = npc.Center + Main.rand.NextVector2Circular(npc.width * 2f, npc.height * 2f) + new Vector2(0f, -150f); + Main.dust[dust].velocity *= Main.rand.NextFloat() * 0.8f; + Main.dust[dust].noGravity = true; + Main.dust[dust].fadeIn = 0.6f + Main.rand.NextFloat() * 0.7f * fade; + Main.dust[dust].velocity += Vector2.UnitY * 3f; + Main.dust[dust].scale = 1.2f; + + if (dust != 6000) + { + Dust dust2 = Dust.CloneDust(dust); + dust2.scale /= 2f; + dust2.fadeIn *= 0.85f; + dust2.color = new Color(255, 255, 0, 255); + } + } + } + + npc.Opacity = MathHelper.Clamp(calamityGlobalNPC.newAI[3] / spawnAnimationTime, 0f, 1f); + + calamityGlobalNPC.newAI[3] += 1f; + + if (nightTime && calamityGlobalNPC.newAI[3] >= spawnAnimationTime) + calamityGlobalNPC.newAI[3] += 1f; + + return; + } + float num852 = Math.Abs(vector.X - player.Center.X); if (num852 > distanceNeededToShoot && npc.position.Y < player.position.Y) { @@ -684,15 +801,14 @@ namespace CalamityMod.NPCs.Providence num857 *= num859; num858 *= num859; - int holyDamage = expertMode ? 52 : 65; - Projectile.NewProjectile(vector.X, vector.Y, num857, num858, ModContent.ProjectileType(), holyDamage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(vector.X, vector.Y, num857, num858, ModContent.ProjectileType(), holyBlastDamage, 0f, Main.myPlayer, 0f, 0f); } } else if (npc.ai[3] < 0f) npc.ai[3] += 1f; npc.ai[1] += 1f; - if (npc.ai[1] >= 300f) + if (npc.ai[1] >= phaseTime) npc.ai[0] = -1f; } @@ -725,13 +841,12 @@ namespace CalamityMod.NPCs.Providence num865 += expertMode ? 4f : 3f; - int fireDamage = expertMode ? 48 : 60; - Projectile.NewProjectile(vector113.X, vector113.Y, npc.velocity.X * 0.25f, num865, ModContent.ProjectileType(), fireDamage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(vector113.X, vector113.Y, npc.velocity.X * 0.25f, num865, ModContent.ProjectileType(), holyFireDamage, 0f, Main.myPlayer, 0f, 0f); } } npc.ai[1] += 1f; - if (npc.ai[1] >= 300f) + if (npc.ai[1] >= phaseTime) npc.ai[0] = -1f; } @@ -809,23 +924,11 @@ namespace CalamityMod.NPCs.Providence } if (npc.ai[3] == 0f) - { - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - projectile.Kill(); - } - } - } - } + DespawnSpecificProjectiles(); // Air is burning text npc.ai[3] += 1f; - if (npc.ai[3] >= 450f && !text) + if (npc.ai[3] >= (phaseTime * 1.5f) && !text) { text = true; string key = "Mods.CalamityMod.ProfanedBossText"; @@ -838,7 +941,7 @@ namespace CalamityMod.NPCs.Providence } // Inflict Icarus Folly - if (npc.ai[3] >= 600f) + if (npc.ai[3] >= (phaseTime * 2f)) { if (Main.netMode != NetmodeID.Server) { @@ -853,7 +956,7 @@ namespace CalamityMod.NPCs.Providence for (int num621 = 0; num621 < 40; num621++) { int num622 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), - player2.width, player2.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + player2.width, player2.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -865,11 +968,11 @@ namespace CalamityMod.NPCs.Providence for (int num623 = 0; num623 < 60; num623++) { int num624 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), - player2.width, player2.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 3f); + player2.width, player2.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; num624 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), - player2.width, player2.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + player2.width, player2.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } @@ -920,15 +1023,14 @@ namespace CalamityMod.NPCs.Providence num857 *= num859; num858 *= num859; - int holyDamage = expertMode ? 42 : 55; - Projectile.NewProjectile(vector.X, vector.Y, num857 * 0.1f, num858, ModContent.ProjectileType(), holyDamage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(vector.X, vector.Y, num857 * 0.1f, num858, ModContent.ProjectileType(), moltenBlastDamage, 0f, Main.myPlayer, 0f, 0f); } } else if (npc.ai[3] < 0f) npc.ai[3] += 1f; npc.ai[1] += 1f; - if (npc.ai[1] >= 300f) + if (npc.ai[1] >= phaseTime) npc.ai[0] = -1f; } @@ -961,13 +1063,12 @@ namespace CalamityMod.NPCs.Providence num865 += expertMode ? 4f : 3f; - int fireDamage = expertMode ? 48 : 60; - Projectile.NewProjectile(vector113.X, vector113.Y, npc.velocity.X * 0.25f, num865, ModContent.ProjectileType(), fireDamage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(vector113.X, vector113.Y, npc.velocity.X * 0.25f, num865, ModContent.ProjectileType(), holyBombDamage, 0f, Main.myPlayer, 0f, 0f); } } npc.ai[1] += 1f; - if (npc.ai[1] >= 300f) + if (npc.ai[1] >= phaseTime) npc.ai[0] = -1f; } @@ -991,19 +1092,7 @@ namespace CalamityMod.NPCs.Providence } if (npc.ai[1] == 0f) - { - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - projectile.Kill(); - } - } - } - } + DespawnSpecificProjectiles(); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -1019,7 +1108,6 @@ namespace CalamityMod.NPCs.Providence npc.ai[2] = 0f; float velocity = 3f; - int damage = expertMode ? 52 : 65; int projectileType = ModContent.ProjectileType(); if (calamityGlobalNPC.newAI[2] % 2f == 0f) @@ -1031,7 +1119,7 @@ namespace CalamityMod.NPCs.Providence for (int i = 0; i < totalProjectiles; i++) { Vector2 vector2 = spinningPoint.RotatedBy(radians * i); - Projectile.NewProjectile(vector, vector2, projectileType, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(vector, vector2, projectileType, holySpearDamage, 0f, Main.myPlayer, 0f, 0f); } calamityGlobalNPC.newAI[1] += 0.2f; @@ -1041,12 +1129,12 @@ namespace CalamityMod.NPCs.Providence velocity = expertMode ? 12f : 10f; Vector2 velocity2 = Vector2.Normalize(player.Center - vector) * velocity; - Projectile.NewProjectile(vector, velocity2, projectileType, damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(vector, velocity2, projectileType, holySpearDamage, 0f, Main.myPlayer, 1f, 0f); } } npc.ai[1] += 1f; - if (npc.ai[1] >= 300f) + if (npc.ai[1] >= phaseTime) npc.ai[0] = -1f; } @@ -1064,11 +1152,13 @@ namespace CalamityMod.NPCs.Providence if (Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[1] += 1f; - if (npc.ai[1] >= 120f) + if (npc.ai[1] >= crystalPhaseTime) { - int damage = expertMode ? 57 : 70; - Projectile.NewProjectile(player.Center.X, player.Center.Y - 360f, 0f, 0f, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); - npc.ai[0] = -1f; + if (npc.ai[1] == crystalPhaseTime) + Projectile.NewProjectile(player.Center.X, player.Center.Y - 360f, 0f, 0f, ModContent.ProjectileType(), crystalDamage, 0f, player.whoAmI, 0f, 0f); + + if (npc.ai[1] >= crystalPhaseTime + 210f || !nightTime) + npc.ai[0] = -1f; } } } @@ -1098,13 +1188,12 @@ namespace CalamityMod.NPCs.Providence for (int num1221 = 0; num1221 < 1 + num1220; num1221++) { - int num1222 = (int)CalamityDusts.ProfanedFire; float num1223 = 1.2f; if (num1221 % 2 == 1) num1223 = 2.8f; - Vector2 vector199 = vector + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value19 / 2f; - int num1224 = Dust.NewDust(vector199 - Vector2.One * 8f, 16, 16, num1222, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); + Vector2 vector199 = new Vector2(vector.X, vector.Y + 32f) + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value19 / 2f; + int num1224 = Dust.NewDust(vector199 - Vector2.One * 8f, 16, 16, dustType, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); Main.dust[num1224].velocity = Vector2.Normalize(vector - vector199) * 3.5f * (10f - num1220 * 2f) / 10f; Main.dust[num1224].noGravity = true; Main.dust[num1224].scale = num1223; @@ -1133,10 +1222,10 @@ namespace CalamityMod.NPCs.Providence num1225 = 1f; vector200 = vector200.RotatedBy(-(double)num1225 * MathHelper.TwoPi / 6f, default); - Projectile.NewProjectile(vector.X, vector.Y - 32f, vector200.X, vector200.Y, ModContent.ProjectileType(), 100, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); + Projectile.NewProjectile(vector.X, vector.Y + 32f, vector200.X, vector200.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); if (revenge) - Projectile.NewProjectile(vector.X, vector.Y - 32f, -vector200.X, -vector200.Y, ModContent.ProjectileType(), 100, 0f, Main.myPlayer, -num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); + Projectile.NewProjectile(vector.X, vector.Y + 32f, -vector200.X, -vector200.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, -num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); npc.ai[3] = (vector200.ToRotation() + MathHelper.TwoPi + MathHelper.Pi) * num1225; npc.netUpdate = true; @@ -1169,6 +1258,23 @@ namespace CalamityMod.NPCs.Providence } } + private void DespawnSpecificProjectiles() + { + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + { + projectile.Kill(); + } + else if (projectile.type == ModContent.ProjectileType()) + projectile.active = false; + } + } + } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { return false; @@ -1185,12 +1291,17 @@ namespace CalamityMod.NPCs.Providence npc.Calamity().SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedProvidence); - //Accessories clientside only in Expert + // Accessories clientside only in Expert DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, biomeType != 2 && Main.expertMode); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, biomeType == 2 && Main.expertMode); - //drops pre-scal, cannot be sold, does nothing aka purely vanity. Requires at least expert for consistency with other post scal dev items. + + // Drops pre-scal, cannot be sold, does nothing aka purely vanity. Requires at least expert for consistency with other post scal dev items. bool shouldDrop = challenge || (Main.expertMode && Main.rand.NextBool(CalamityWorld.downedSCal ? 10 : 200)); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, shouldDrop); + + // Special drop for defeating her at night + //DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !hasTakenDaytimeDamage); + // All other drops are contained in the bag, so they only drop directly on Normal if (!Main.expertMode) { @@ -1258,8 +1369,8 @@ namespace CalamityMod.NPCs.Providence private void SpawnLootBox() { - int tileCenterX = (int)(npc.position.X + (float)(npc.width / 2)) / 16; - int tileCenterY = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; + int tileCenterX = (int)(npc.position.X + (npc.width / 2)) / 16; + int tileCenterY = (int)(npc.position.Y + (npc.height / 2)) / 16; int halfBox = npc.width / 2 / 16 + 1; for (int x = tileCenterX - halfBox; x <= tileCenterX + halfBox; x++) { @@ -1289,58 +1400,73 @@ namespace CalamityMod.NPCs.Providence public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture = Main.npcTexture[npc.type]; - Texture2D textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceGlow"); - Texture2D textureGlow2 = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceGlow2"); + bool nightTime = !Main.dayTime; + + string baseTextureString = "CalamityMod/NPCs/Providence/"; + string baseGlowTextureString = baseTextureString + "Glowmasks/"; + + string getTextureString = baseTextureString + "Providence"; + string getTextureGlowString = baseGlowTextureString + "ProvidenceGlow"; + string getTextureGlow2String = baseGlowTextureString + "ProvidenceGlow2"; if (npc.ai[0] == 2f || npc.ai[0] == 5f) { if (!useDefenseFrames) { - texture = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceDefense"); - textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceDefenseGlow"); - textureGlow2 = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceDefenseGlow2"); + getTextureString = baseTextureString + "ProvidenceDefense"; + getTextureGlowString = baseGlowTextureString + "ProvidenceDefenseGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceDefenseGlow2"; } else { - texture = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceDefenseAlt"); - textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceDefenseAltGlow"); - textureGlow2 = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceDefenseAltGlow2"); + getTextureString = baseTextureString + "ProvidenceDefenseAlt"; + getTextureGlowString = baseGlowTextureString + "ProvidenceDefenseAltGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceDefenseAltGlow2"; } } else { if (frameUsed == 0) { - texture = Main.npcTexture[npc.type]; - textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceGlow"); - textureGlow2 = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceGlow2"); + getTextureGlowString = baseGlowTextureString + "ProvidenceGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceGlow2"; } else if (frameUsed == 1) { - texture = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAlt"); - textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAltGlow"); - textureGlow2 = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAltGlow2"); + getTextureString = baseTextureString + "ProvidenceAlt"; + getTextureGlowString = baseGlowTextureString + "ProvidenceAltGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceAltGlow2"; } else if (frameUsed == 2) { - texture = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAttack"); - textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAttackGlow"); - textureGlow2 = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAttackGlow2"); + getTextureString = baseTextureString + "ProvidenceAttack"; + getTextureGlowString = baseGlowTextureString + "ProvidenceAttackGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceAttackGlow2"; } else { - texture = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAttackAlt"); - textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAttackAltGlow"); - textureGlow2 = ModContent.GetTexture("CalamityMod/NPCs/Providence/ProvidenceAttackAltGlow2"); + getTextureString = baseTextureString + "ProvidenceAttackAlt"; + getTextureGlowString = baseGlowTextureString + "ProvidenceAttackAltGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceAttackAltGlow2"; } } + if (nightTime) + { + getTextureString += "Night"; + getTextureGlowString += "Night"; + getTextureGlow2String += "Night"; + } + + Texture2D texture = ModContent.GetTexture(getTextureString); + Texture2D textureGlow = ModContent.GetTexture(getTextureGlowString); + Texture2D textureGlow2 = ModContent.GetTexture(getTextureGlow2String); + SpriteEffects spriteEffects = SpriteEffects.None; if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - 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 / Main.npcFrameCount[npc.type] / 2); Color color36 = Color.White; float amount9 = 0.5f; int num153 = 5; @@ -1352,21 +1478,21 @@ namespace CalamityMod.NPCs.Providence Color color38 = lightColor; color38 = Color.Lerp(color38, color36, amount9); color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); spriteBatch.Draw(texture, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); spriteBatch.Draw(texture, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); + Color color37 = Color.Lerp(Color.White, Main.dayTime ? Color.Yellow : Color.Cyan, 0.5f) * npc.Opacity; + Color color42 = Color.Lerp(Color.White, Main.dayTime ? Color.Violet : Color.BlueViolet, 0.5f) * npc.Opacity; if (CalamityMod.CalamityConfig.Afterimages) { @@ -1375,16 +1501,16 @@ namespace CalamityMod.NPCs.Providence Color color41 = color37; color41 = Color.Lerp(color41, color36, amount9); color41 = npc.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)textureGlow.Width, (float)(textureGlow.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(textureGlow.Width, textureGlow.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; vector44 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); spriteBatch.Draw(textureGlow, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); Color color43 = color42; color43 = Color.Lerp(color43, color36, amount9); color43 = npc.GetAlpha(color43); - color43 *= (float)(num153 - num163) / 15f; + color43 *= (num153 - num163) / 15f; spriteBatch.Draw(textureGlow2, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -1403,7 +1529,7 @@ namespace CalamityMod.NPCs.Providence if (!useDefenseFrames) { npc.frameCounter += 1.0; - if (npc.frameCounter > 5.0) + if (npc.frameCounter > 8.0) { npc.frame.Y = npc.frame.Y + frameHeight; npc.frameCounter = 0.0; @@ -1417,7 +1543,7 @@ namespace CalamityMod.NPCs.Providence else { npc.frameCounter += 1.0; - if (npc.frameCounter > 5.0) + if (npc.frameCounter > 8.0) { npc.frame.Y = npc.frame.Y + frameHeight; npc.frameCounter = 0.0; @@ -1432,7 +1558,7 @@ namespace CalamityMod.NPCs.Providence useDefenseFrames = false; npc.frameCounter += 1.0; - if (npc.frameCounter > 5.0) + if (npc.frameCounter > (npc.Calamity().newAI[3] < 180f ? 8.0 : 5.0)) { npc.frameCounter = 0.0; npc.frame.Y = npc.frame.Y + frameHeight; @@ -1461,6 +1587,8 @@ namespace CalamityMod.NPCs.Providence public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) { + hasTakenDaytimeDamage = Main.dayTime; + if (challenge) { bool goldenGun = projectile.type == ModContent.ProjectileType(); @@ -1476,6 +1604,8 @@ namespace CalamityMod.NPCs.Providence public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit) { + hasTakenDaytimeDamage = Main.dayTime; + if (challenge) challenge = false; } @@ -1487,38 +1617,40 @@ namespace CalamityMod.NPCs.Providence npc.soundDelay = 8; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/ProvidenceHurt"), npc.Center); } - for (int k = 0; k < 15; k++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, hitDirection, -1f, 0, default, 1f); + + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int k = 0; k < 15; k++) + Dust.NewDust(npc.position, npc.width, npc.height, dustType, hitDirection, -1f, 0, default, 1f); if (npc.life <= 0) { - float randomSpread = (float)(Main.rand.Next(-50, 50) / 100); + float randomSpread = Main.rand.Next(-50, 50) / 100; Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/Providence"), 1f); Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/Providence2"), 1f); Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/Providence3"), 1f); Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/Providence4"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 400; npc.height = 350; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); for (int num621 = 0; num621 < 60; num621++) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 90; num623++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 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, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } diff --git a/NPCs/Providence/ProvidenceAltNight.png b/NPCs/Providence/ProvidenceAltNight.png new file mode 100644 index 0000000000..4fe2e26f7b Binary files /dev/null and b/NPCs/Providence/ProvidenceAltNight.png differ diff --git a/NPCs/Providence/ProvidenceAttackAltNight.png b/NPCs/Providence/ProvidenceAttackAltNight.png new file mode 100644 index 0000000000..abeb35d1e3 Binary files /dev/null and b/NPCs/Providence/ProvidenceAttackAltNight.png differ diff --git a/NPCs/Providence/ProvidenceAttackNight.png b/NPCs/Providence/ProvidenceAttackNight.png new file mode 100644 index 0000000000..d49baf5c6f Binary files /dev/null and b/NPCs/Providence/ProvidenceAttackNight.png differ diff --git a/NPCs/Providence/ProvidenceDefenseAltNight.png b/NPCs/Providence/ProvidenceDefenseAltNight.png new file mode 100644 index 0000000000..ecbd22e542 Binary files /dev/null and b/NPCs/Providence/ProvidenceDefenseAltNight.png differ diff --git a/NPCs/Providence/ProvidenceDefenseNight.png b/NPCs/Providence/ProvidenceDefenseNight.png new file mode 100644 index 0000000000..df1ff403ac Binary files /dev/null and b/NPCs/Providence/ProvidenceDefenseNight.png differ diff --git a/NPCs/Providence/ProvidenceNight.png b/NPCs/Providence/ProvidenceNight.png new file mode 100644 index 0000000000..be68806d96 Binary files /dev/null and b/NPCs/Providence/ProvidenceNight.png differ diff --git a/NPCs/SunkenSea/SeaSerpent1.cs b/NPCs/SunkenSea/SeaSerpent1.cs index fa3b2f7a3c..ad4a79c985 100644 --- a/NPCs/SunkenSea/SeaSerpent1.cs +++ b/NPCs/SunkenSea/SeaSerpent1.cs @@ -55,7 +55,6 @@ namespace CalamityMod.NPCs.SunkenSea { npc.TargetClosest(true); } - npc.velocity.Length(); if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && npc.ai[0] == 0f) @@ -116,44 +115,26 @@ namespace CalamityMod.NPCs.SunkenSea 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); - int num42 = -1; - int num43 = (int)(Main.player[npc.target].Center.X / 16f); - int num44 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - { - break; - } - } - if (num42 > 0) - { - num42 *= 16; - float num47 = (float)(num42 - 200); //800 - if ((Main.player[npc.target].Center - npc.Center).Length() > 250f) - { - num192 = num47; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 300f; - } - else - { - num191 = Main.player[npc.target].Center.X - 300f; - } - } - } - } + if (npc.life > npc.lifeMax * 0.99) + { + num192 += 300; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) + { + if (npc.velocity.X > 0f) + { + num191 = Main.player[npc.target].Center.X + 300f; + } + else + { + num191 = Main.player[npc.target].Center.X - 300f; + } + } + } + else + { + num188 *= 1.5f; + num189 *= 1.5f; + } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); @@ -170,40 +151,6 @@ namespace CalamityMod.NPCs.SunkenSea npc.velocity *= num49; } } - if ((Main.player[npc.target].Center - npc.Center).Length() > 250f) - { - for (int num51 = 0; num51 < 200; num51++) - { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) - { - Vector2 vector3 = Main.npc[num51].Center - npc.Center; - if (vector3.Length() < 400f) - { - vector3.Normalize(); - vector3 *= 1000f; - num191 -= vector3.X; - num192 -= vector3.Y; - } - } - } - } - else - { - for (int num52 = 0; num52 < 200; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - } num191 = (float)((int)(num191 / 16f) * 16); num192 = (float)((int)(num192 / 16f) * 16); vector18.X = (float)((int)(vector18.X / 16f) * 16); diff --git a/NPCs/SunkenSea/SeaSerpent2.cs b/NPCs/SunkenSea/SeaSerpent2.cs index 6bb4875a14..afb0259d2e 100644 --- a/NPCs/SunkenSea/SeaSerpent2.cs +++ b/NPCs/SunkenSea/SeaSerpent2.cs @@ -54,19 +54,6 @@ namespace CalamityMod.NPCs.SunkenSea { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -94,10 +81,6 @@ namespace CalamityMod.NPCs.SunkenSea npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/SunkenSea/SeaSerpent3.cs b/NPCs/SunkenSea/SeaSerpent3.cs index c56fce5006..ed96037da1 100644 --- a/NPCs/SunkenSea/SeaSerpent3.cs +++ b/NPCs/SunkenSea/SeaSerpent3.cs @@ -51,19 +51,6 @@ namespace CalamityMod.NPCs.SunkenSea { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -91,10 +78,6 @@ namespace CalamityMod.NPCs.SunkenSea npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/SunkenSea/SeaSerpent4.cs b/NPCs/SunkenSea/SeaSerpent4.cs index fd1e86d84d..4a1047a659 100644 --- a/NPCs/SunkenSea/SeaSerpent4.cs +++ b/NPCs/SunkenSea/SeaSerpent4.cs @@ -51,19 +51,6 @@ namespace CalamityMod.NPCs.SunkenSea { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -91,10 +78,6 @@ namespace CalamityMod.NPCs.SunkenSea npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/SunkenSea/SeaSerpent5.cs b/NPCs/SunkenSea/SeaSerpent5.cs index ab8b4fff4b..e6361fef6c 100644 --- a/NPCs/SunkenSea/SeaSerpent5.cs +++ b/NPCs/SunkenSea/SeaSerpent5.cs @@ -51,19 +51,6 @@ namespace CalamityMod.NPCs.SunkenSea { npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } bool flag = false; if (npc.ai[1] <= 0f) { @@ -91,10 +78,6 @@ namespace CalamityMod.NPCs.SunkenSea npc.alpha = 0; } } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } 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); diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 3d405f54ae..9d92548304 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -126,7 +126,10 @@ namespace CalamityMod.NPCs.Yharon writer.Write(safeBox.Y); writer.Write(safeBox.Width); writer.Write(safeBox.Height); - } + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + } public override void ReceiveExtraAI(BinaryReader reader) { @@ -147,7 +150,10 @@ namespace CalamityMod.NPCs.Yharon safeBox.Y = reader.ReadInt32(); safeBox.Width = reader.ReadInt32(); safeBox.Height = reader.ReadInt32(); - } + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + } public override void AI() { @@ -224,6 +230,7 @@ namespace CalamityMod.NPCs.Yharon return; } + // Timed DR adjustment if (CalamityWorld.buffedEclipse) { if (npc.Calamity().AITimer < 3600) @@ -233,103 +240,97 @@ namespace CalamityMod.NPCs.Yharon // Phase bools bool phase2Check = npc.life <= npc.lifeMax * (revenge ? 0.8 : 0.7); bool phase3Check = npc.life <= npc.lifeMax * (revenge ? 0.5 : 0.4); - bool phase4Check = npc.life <= npc.lifeMax * (revenge ? 0.25 : 0.2); - bool phase5Check = npc.life <= npc.lifeMax * 0.1; + bool phase4Check = npc.life <= npc.lifeMax * 0.1; bool phase2Change = npc.ai[0] > 5f; bool phase3Change = npc.ai[0] > 12f; - bool phase4Change = npc.ai[0] > 20f; bool isCharging = npc.ai[3] < 20f; // Flare limit int flareCount = 3; - // Velocity and acceleration - int aiChangeRate = expertMode ? 36 : 38; - float npcVelocity = expertMode ? 0.7f : 0.69f; - float scaleFactor = expertMode ? 11f : 10.8f; + // Timer, velocity and acceleration for idle phase before phase switch + int phaseSwitchTimer = expertMode ? 36 : 38; + float acceleration = expertMode ? 0.7f : 0.69f; + float velocity = expertMode ? 11f : 10.8f; - if (phase4Change || npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) + if (npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { - npcVelocity = 0.95f; - scaleFactor = 14f; - aiChangeRate = 25; + acceleration = 0.95f; + velocity = 14f; + phaseSwitchTimer = 25; } else if (phase3Change) { - npcVelocity = 0.9f; - scaleFactor = 13f; - aiChangeRate = 25; + acceleration = 0.85f; + velocity = 13f; + phaseSwitchTimer = 25; } else if (phase2Change && isCharging) { - npcVelocity = expertMode ? 0.8f : 0.78f; - scaleFactor = expertMode ? 12.2f : 12f; - aiChangeRate = expertMode ? 36 : 38; + acceleration = expertMode ? 0.8f : 0.78f; + velocity = expertMode ? 12.2f : 12f; + phaseSwitchTimer = expertMode ? 36 : 38; } - else if (isCharging && !phase2Change && !phase3Change && !phase4Change) + else if (isCharging && !phase2Change && !phase3Change) { - aiChangeRate = 25; + phaseSwitchTimer = 25; } - int chargeTime = expertMode ? 38 : 40; - int chargeTime2 = expertMode ? 34 : 36; - float chargeSpeed = expertMode ? 22f : 20.5f; - float chargeSpeed2 = expertMode ? 37f : 34f; - if (phase4Change || npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) + // Timers and velocity for charging + int chargeTime = expertMode ? 60 : 70; + float chargeSpeed = expertMode ? 26f : 24f; + float fastChargeVelocityMultiplier = 1.5f; + int fastChargeTelegraphTimer = 120; + + if (npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { - chargeTime = 28; - chargeSpeed = 31f; + chargeTime = 40; + chargeSpeed = 35f; } else if (phase3Change) { - chargeTime = 32; - chargeTime2 = 27; - chargeSpeed = 25f; - chargeSpeed2 = 41f; + chargeTime = 50; + chargeSpeed = 28f; } else if (isCharging && phase2Change) { - chargeTime = expertMode ? 35 : 37; - chargeTime2 = expertMode ? 31 : 33; + chargeTime = expertMode ? 55 : 65; + if (expertMode) - { - chargeSpeed = 24f; - chargeSpeed2 = 39f; - } + chargeSpeed = 27f; } if (revenge) { int chargeTimeDecrease = death ? 4 : 2; float velocityMult = death ? 1.1f : 1.05f; - aiChangeRate -= chargeTimeDecrease; - npcVelocity *= velocityMult; - scaleFactor *= velocityMult; + phaseSwitchTimer -= chargeTimeDecrease; + acceleration *= velocityMult; + velocity *= velocityMult; chargeTime -= chargeTimeDecrease; - chargeTime2 -= chargeTimeDecrease; chargeSpeed *= velocityMult; - chargeSpeed2 *= velocityMult; } - // Variables for charging and etc. - int xPos = 60 * npc.direction; - int num1454 = 80; - int num1455 = 4; - float num1456 = 0.3f; - float scaleFactor11 = 5f; - int num1457 = 90; - int num1458 = 180; - int num1459 = 180; - int num1460 = 30; - int num1461 = 120; - int num1462 = 4; - float scaleFactor13 = 20f; - float num1463 = MathHelper.TwoPi / (num1461 / 2); - int num1464 = 75; + // Phase timers and velocities + int flareBombPhaseTimer = 60; + int flareBombSpawnDivisor = 3; + float flareBombPhaseAcceleration = 0.5f; + float flareBombPhaseVelocity = 10f; + int fireTornadoPhaseTimer = 90; + int newPhaseTimer = 180; + int flareDustPhaseTimer = 300; + int flareDustPhaseTimer2 = 150; + float spinTime = flareDustPhaseTimer / 2; + int flareDustSpawnDivisor = 30; + int flareDustSpawnDivisor2 = 5; + float spinPhaseVelocity = 25f; + float spinPhaseRotation = MathHelper.TwoPi * 3 / spinTime; + Vector2 vectorCenter = npc.Center; + int spawnPhaseTimer = 75; + int projectileDamage = expertMode ? 75 : 90; - // Center and target - Vector2 vectorCenter = npc.Center; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + // Target + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(true); npc.netUpdate = true; @@ -362,11 +363,15 @@ namespace CalamityMod.NPCs.Yharon else if (npc.timeLeft < 1800) npc.timeLeft = 1800; - // Create the arena, but not as a multiplayer client. - // In single player, the arena gets created and never gets synced because it's single player. - // In multiplayer, only the server/host creates the arena, and everyone else receives it on the next frame via SendExtraAI. - // Everyone however sets spawnArena to true to confirm that the fight has started. - if (!spawnArena) + int xPos = 60 * npc.direction; + Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (npc.width + 20) / 2f + vectorCenter; + Vector2 fromMouth = new Vector2((int)vector.X + xPos, (int)vector.Y - 15); + + // Create the arena, but not as a multiplayer client. + // In single player, the arena gets created and never gets synced because it's single player. + // In multiplayer, only the server/host creates the arena, and everyone else receives it on the next frame via SendExtraAI. + // Everyone however sets spawnArena to true to confirm that the fight has started. + if (!spawnArena) { spawnArena = true; enraged = false; @@ -389,7 +394,7 @@ namespace CalamityMod.NPCs.Yharon enraged = !player.Hitbox.Intersects(safeBox); if (enraged) { - aiChangeRate = 15; + phaseSwitchTimer = 15; protectionBoost = true; npc.damage = npc.defDamage * 5; chargeSpeed += 25f; @@ -425,34 +430,17 @@ namespace CalamityMod.NPCs.Yharon npcRotation += MathHelper.TwoPi; if (npcRotation > MathHelper.TwoPi) npcRotation -= MathHelper.TwoPi; - if (npc.ai[0] == -1f) - npcRotation = 0f; - if (npc.ai[0] == 3f) - npcRotation = 0f; - if (npc.ai[0] == 4f) - npcRotation = 0f; - if (npc.ai[0] == 9f) - npcRotation = 0f; - if (npc.ai[0] == 10f) - npcRotation = 0f; - if (npc.ai[0] == 16f) - npcRotation = 0f; - if (npc.ai[0] == 20f) + if (npc.ai[0] == -1f || npc.ai[0] == 3f || npc.ai[0] == 4f || npc.ai[0] == 9f || npc.ai[0] == 10f || npc.ai[0] == 16f) npcRotation = 0f; float npcRotationSpeed = 0.04f; - if (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f) + if (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 8f || npc.ai[0] == 11f || npc.ai[0] == 12f || + npc.ai[0] == 14f || npc.ai[0] == 15f || npc.ai[0] == 18f || npc.ai[0] == 19f) npcRotationSpeed = 0f; - if (npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f) - npcRotationSpeed = 0f; - if (npc.ai[0] == 3f) - npcRotationSpeed = 0.01f; - if (npc.ai[0] == 4f) - npcRotationSpeed = 0.01f; - if (npc.ai[0] == 9f || npc.ai[0] == 16f || npc.ai[0] == 20f) + if (npc.ai[0] == 3f || npc.ai[0] == 4f || npc.ai[0] == 9f || npc.ai[0] == 16f) npcRotationSpeed = 0.01f; - if (npc.rotation < npcRotation) + /*if (npc.rotation < npcRotation) { if (npcRotation - npc.rotation > pie) npc.rotation -= npcRotationSpeed; @@ -474,10 +462,13 @@ namespace CalamityMod.NPCs.Yharon if (npc.rotation > MathHelper.TwoPi) npc.rotation -= MathHelper.TwoPi; if (npc.rotation > npcRotation - npcRotationSpeed && npc.rotation < npcRotation + npcRotationSpeed) - npc.rotation = npcRotation; + npc.rotation = npcRotation;*/ - // Alpha - if (npc.ai[0] != -1f && npc.ai[0] < 9f) + if (npcRotationSpeed != 0f) + npc.rotation = npc.rotation.AngleTowards(npcRotation, npcRotationSpeed); + + // Alpha effects + if (npc.ai[0] != -1f && npc.ai[0] < 9f) { bool colliding = Collision.SolidCollision(npc.position, npc.width, npc.height); @@ -500,7 +491,6 @@ namespace CalamityMod.NPCs.Yharon npc.velocity *= 0.98f; - // Direction int num1467 = Math.Sign(player.Center.X - vectorCenter.X); if (num1467 != 0) { @@ -508,7 +498,6 @@ namespace CalamityMod.NPCs.Yharon npc.spriteDirection = -npc.direction; } - // Alpha if (npc.ai[2] > 20f) { npc.velocity.Y = -2f; @@ -526,8 +515,7 @@ namespace CalamityMod.NPCs.Yharon npc.alpha = 150; } - // Dust - if (npc.ai[2] == num1457 - 30) + if (npc.ai[2] == fireTornadoPhaseTimer - 30) { int num1468 = 72; for (int num1469 = 0; num1469 < num1468; num1469++) @@ -545,7 +533,7 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= num1464) + if (npc.ai[2] >= spawnPhaseTimer) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -555,39 +543,17 @@ namespace CalamityMod.NPCs.Yharon } #region Phase1 + // Phase switch else if (npc.ai[0] == 0f && !player.dead) { npc.dontTakeDamage = false; if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((vectorCenter - player.Center).X); + npc.ai[1] = 500 * Math.Sign((vectorCenter - player.Center).X); Vector2 value17 = player.Center + new Vector2(npc.ai[1], -200f) - vectorCenter; - Vector2 vector170 = Vector2.Normalize(value17 - npc.velocity) * scaleFactor; - if (npc.velocity.X < vector170.X) - { - npc.velocity.X += npcVelocity; - if (npc.velocity.X < 0f && vector170.X > 0f) - npc.velocity.X += npcVelocity; - } - else if (npc.velocity.X > vector170.X) - { - npc.velocity.X -= npcVelocity; - if (npc.velocity.X > 0f && vector170.X < 0f) - npc.velocity.X -= npcVelocity; - } - if (npc.velocity.Y < vector170.Y) - { - npc.velocity.Y += npcVelocity; - if (npc.velocity.Y < 0f && vector170.Y > 0f) - npc.velocity.Y += npcVelocity; - } - else if (npc.velocity.Y > vector170.Y) - { - npc.velocity.Y -= npcVelocity; - if (npc.velocity.Y > 0f && vector170.Y < 0f) - npc.velocity.Y -= npcVelocity; - } + Vector2 vector170 = Vector2.Normalize(value17 - npc.velocity) * velocity; + npc.SimpleFlyMovement(vector170, acceleration); int num1471 = Math.Sign(player.Center.X - vectorCenter.X); if (num1471 != 0) @@ -604,28 +570,26 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= aiChangeRate) + if (npc.ai[2] >= phaseSwitchTimer) { int aiState = 0; - switch ((int)npc.ai[3]) //0 2 4 6 1 3 5 7 repeat + switch ((int)npc.ai[3]) { case 0: case 1: case 2: + aiState = 1; + break; case 3: + aiState = 5; + break; case 4: - aiState = 1; //normal charges + npc.ai[3] = 1f; + aiState = 2; break; case 5: - aiState = 5; //fast charge - break; - case 6: - npc.ai[3] = 1f; - aiState = 2; //fireball attack - break; - case 7: npc.ai[3] = 0f; - aiState = 3; //tornadoes + aiState = 3; break; } @@ -671,41 +635,40 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + npc.localAI[1] += 1f; + if (npc.localAI[1] == fastChargeTelegraphTimer - 60) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed2; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + if (npc.localAI[1] > fastChargeTelegraphTimer) + { + npc.ai[0] = 5f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[1] = 0f; - if (num1471 != 0) - { - npc.direction = num1471; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (npc.spriteDirection == 1) - npc.rotation += pie; + if (num1471 != 0) + { + npc.direction = num1471; - npc.spriteDirection = -npc.direction; - } + if (npc.spriteDirection == 1) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + } } npc.netUpdate = true; } } - else if (npc.ai[0] == 1f) //charge attack + + // Charge + else if (npc.ai[0] == 1f) { - int num1473 = 7; - for (int num1474 = 0; num1474 < num1473; num1474++) - { - Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (num1473 / 2 - 1)) * (double)pie / (float)num1473) + vectorCenter; - Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= npc.velocity; - } + ChargeDust(7, pie); npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) @@ -717,54 +680,35 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } - else if (npc.ai[0] == 2f) //fireball attack + + // Fireball breath + else if (npc.ai[0] == 2f) { if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((vectorCenter - player.Center).X); + npc.ai[1] = 500 * Math.Sign((vectorCenter - player.Center).X); - Vector2 value19 = player.Center + new Vector2(npc.ai[1], -200f) - vectorCenter; - Vector2 vector172 = Vector2.Normalize(value19 - npc.velocity) * scaleFactor11; - if (npc.velocity.X < vector172.X) - { - npc.velocity.X += num1456; - if (npc.velocity.X < 0f && vector172.X > 0f) - npc.velocity.X += num1456; - } - else if (npc.velocity.X > vector172.X) - { - npc.velocity.X -= num1456; - if (npc.velocity.X > 0f && vector172.X < 0f) - npc.velocity.X -= num1456; - } - if (npc.velocity.Y < vector172.Y) - { - npc.velocity.Y += num1456; - if (npc.velocity.Y < 0f && vector172.Y > 0f) - npc.velocity.Y += num1456; - } - else if (npc.velocity.Y > vector172.Y) - { - npc.velocity.Y -= num1456; - if (npc.velocity.Y > 0f && vector172.Y < 0f) - npc.velocity.Y -= num1456; - } + Vector2 value19 = player.Center + new Vector2(npc.ai[1], -400f) - vectorCenter; + Vector2 vector172 = Vector2.Normalize(value19 - npc.velocity) * flareBombPhaseVelocity; + npc.SimpleFlyMovement(vector172, flareBombPhaseAcceleration); if (npc.ai[2] == 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] % num1455 == 0f) //fire flare bombs from mouth + if (npc.ai[2] % flareBombSpawnDivisor == 0f) { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (npc.width + 20) / 2f + vectorCenter; + if (NPC.CountNPCS(ModContent.NPCType()) < flareCount) + { + int num1062 = NPC.NewNPC((int)fromMouth.X, (int)fromMouth.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - if (NPC.CountNPCS(ModContent.NPCType()) < flareCount) - NPC.NewNPC((int)vector.X + xPos, (int)vector.Y - 15, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + Main.npc[num1062].velocity = player.Center - fromMouth; + Main.npc[num1062].velocity.Normalize(); + Main.npc[num1062].velocity *= CalamityWorld.bossRushActive ? 15f : 10f; + Main.npc[num1062].netUpdate = true; + } - int damage = expertMode ? 75 : 90; - Projectile.NewProjectile((int)vector.X + xPos, (int)vector.Y - 15, 0f, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(fromMouth, Vector2.Zero, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 0f, 0f); } } @@ -780,7 +724,7 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= num1454) + if (npc.ai[2] >= flareBombPhaseTimer) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -788,22 +732,24 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } - else if (npc.ai[0] == 3f) //Fire small flares + + // Fire tornadoes + else if (npc.ai[0] == 3f) { npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == num1457 - 30) + if (npc.ai[2] == fireTornadoPhaseTimer - 30) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num1457 - 30) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == fireTornadoPhaseTimer - 30) { - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, npc.direction * 2, 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); //changed - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, -(float)npc.direction * 2, 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); //changed + Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, npc.direction * 4, 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, -(float)npc.direction * 4, 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); } npc.ai[2] += 1f; - if (npc.ai[2] >= num1457) + if (npc.ai[2] >= fireTornadoPhaseTimer) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -811,18 +757,20 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } - else if (npc.ai[0] == 4f) //enter phase 2 + + // Enter new phase + else if (npc.ai[0] == 4f) { npc.dontTakeDamage = true; npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == num1458 - 60) + if (npc.ai[2] == newPhaseTimer - 60) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); npc.ai[2] += 1f; - if (npc.ai[2] >= num1458) + if (npc.ai[2] >= newPhaseTimer) { npc.ai[0] = 6f; npc.ai[1] = 0f; @@ -831,23 +779,14 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } + + // Fast charge else if (npc.ai[0] == 5f) { - int num1473 = 14; - for (int num1474 = 0; num1474 < num1473; num1474++) - { - Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (num1473 / 2 - 1)) * pie / (double)num1473) + vectorCenter; - Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); //changed - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= npc.velocity; - } + ChargeDust(14, pie); npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime2) + if (npc.ai[2] >= chargeTime) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -859,39 +798,17 @@ namespace CalamityMod.NPCs.Yharon #endregion #region Phase2 - else if (npc.ai[0] == 6f && !player.dead) //phase 2 + // Phase switch + else if (npc.ai[0] == 6f && !player.dead) { npc.dontTakeDamage = false; if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((vectorCenter - player.Center).X); + npc.ai[1] = 500 * Math.Sign((vectorCenter - player.Center).X); Vector2 value20 = player.Center + new Vector2(npc.ai[1], -200f) - vectorCenter; - Vector2 vector175 = Vector2.Normalize(value20 - npc.velocity) * scaleFactor; - if (npc.velocity.X < vector175.X) - { - npc.velocity.X += npcVelocity; - if (npc.velocity.X < 0f && vector175.X > 0f) - npc.velocity.X += npcVelocity; - } - else if (npc.velocity.X > vector175.X) - { - npc.velocity.X -= npcVelocity; - if (npc.velocity.X > 0f && vector175.X < 0f) - npc.velocity.X -= npcVelocity; - } - if (npc.velocity.Y < vector175.Y) - { - npc.velocity.Y += npcVelocity; - if (npc.velocity.Y < 0f && vector175.Y > 0f) - npc.velocity.Y += npcVelocity; - } - else if (npc.velocity.Y > vector175.Y) - { - npc.velocity.Y -= npcVelocity; - if (npc.velocity.Y > 0f && vector175.Y < 0f) - npc.velocity.Y -= npcVelocity; - } + Vector2 vector175 = Vector2.Normalize(value20 - npc.velocity) * velocity; + npc.SimpleFlyMovement(vector175, acceleration); int num1477 = Math.Sign(player.Center.X - vectorCenter.X); if (num1477 != 0) @@ -908,30 +825,28 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= aiChangeRate) + if (npc.ai[2] >= phaseSwitchTimer) { int aiState = 0; - switch ((int)npc.ai[3]) //0 2 4 6 8 1 3 5 7 9 repeat + switch ((int)npc.ai[3]) { case 0: case 1: case 2: case 3: - case 4: - case 5: aiState = 1; break; - case 6: + case 4: aiState = 5; break; - case 7: + case 5: aiState = 6; break; - case 8: + case 6: npc.ai[3] = 1f; aiState = 2; break; - case 9: + case 7: npc.ai[3] = 0f; aiState = 3; break; @@ -961,7 +876,7 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 2) { - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * scaleFactor13; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); if (num1477 != 0) @@ -992,26 +907,34 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - npc.ai[0] = 11f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + npc.localAI[1] += 1f; + if (npc.localAI[1] == fastChargeTelegraphTimer - 60) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed2; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + if (npc.localAI[1] > fastChargeTelegraphTimer) + { + npc.ai[0] = 11f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[1] = 0f; - if (num1477 != 0) - { - npc.direction = num1477; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (npc.spriteDirection == 1) - npc.rotation += pie; + if (num1477 != 0) + { + npc.direction = num1477; - npc.spriteDirection = -npc.direction; - } + if (npc.spriteDirection == 1) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + } } else if (aiState == 6) { - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * scaleFactor13; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); if (num1477 != 0) @@ -1032,20 +955,11 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } - else if (npc.ai[0] == 7f) //charge + + // Charge + else if (npc.ai[0] == 7f) { - int num1479 = 7; - for (int num1480 = 0; num1480 < num1479; num1480++) - { - Vector2 vector176 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector176 = vector176.RotatedBy((num1480 - (num1479 / 2 - 1)) * pie / (double)num1479) + vectorCenter; - Vector2 value21 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1481 = Dust.NewDust(vector176 + value21, 0, 0, 244, value21.X * 2f, value21.Y * 2f, 100, default, 1.4f); //changed - Main.dust[num1481].noGravity = true; - Main.dust[num1481].noLight = true; - Main.dust[num1481].velocity /= 4f; - Main.dust[num1481].velocity -= npc.velocity; - } + ChargeDust(7, pie); npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) @@ -1057,51 +971,77 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } + + // Flare Dust bullet hell else if (npc.ai[0] == 8f) { if (npc.ai[2] == 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] % num1462 == 0f) + npc.ai[2] += 1f; + + if (npc.ai[2] % flareDustSpawnDivisor == 0f) { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[2] >= 120f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient) + Vector2 flareDustBulletHellSpawn = vectorCenter + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (npc.width + 20) / 2f + vectorCenter; + if (NPC.CountNPCS(ModContent.NPCType()) < flareCount) + { + int num1062 = NPC.NewNPC((int)flareDustBulletHellSpawn.X, (int)flareDustBulletHellSpawn.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - if (NPC.CountNPCS(ModContent.NPCType()) < flareCount) - NPC.NewNPC((int)vector.X + xPos, (int)vector.Y - 15, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + Main.npc[num1062].velocity = player.Center - flareDustBulletHellSpawn; + Main.npc[num1062].velocity.Normalize(); + Main.npc[num1062].velocity *= CalamityWorld.bossRushActive ? 15f : 10f; + Main.npc[num1062].netUpdate = true; + } - Projectile.NewProjectile((int)vector.X + xPos, (int)vector.Y - 15, Main.rand.Next(-400, 401) * 0.13f, Main.rand.Next(-30, 31) * 0.13f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); - } + int totalProjectiles = 45; + float offsetAngle = 360 / totalProjectiles; + int totalSpaces = 9; + int spaceStart = Main.rand.Next(totalProjectiles - totalSpaces); + float ai0 = npc.ai[2] % (flareDustSpawnDivisor * 2) == 0f ? 1f : 0f; + + int spacesMade = 0; + for (int i = 0; i < totalProjectiles; i++) + { + if (i >= spaceStart && spacesMade < totalSpaces) + spacesMade++; + else + Projectile.NewProjectile(flareDustBulletHellSpawn, Vector2.Zero, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, ai0, i * offsetAngle); + } + } } - npc.velocity = npc.velocity.RotatedBy(-(double)num1463 * (float)npc.direction); - npc.rotation -= num1463 * npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); + npc.rotation -= spinPhaseRotation * npc.direction; - npc.ai[2] += 1f; - if (npc.ai[2] >= num1461) + if (npc.ai[2] >= flareDustPhaseTimer) { - npc.ai[0] = 6f; + npc.ai[0] = 6f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.netUpdate = true; } } + + // Infernado else if (npc.ai[0] == 9f) { npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == num1457 - 30) + if (npc.ai[2] == fireTornadoPhaseTimer - 30) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num1457 - 30) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == fireTornadoPhaseTimer - 30) Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); npc.ai[2] += 1f; - if (npc.ai[2] >= num1457) + if (npc.ai[2] >= fireTornadoPhaseTimer) { npc.ai[0] = 6f; npc.ai[1] = 0f; @@ -1109,18 +1049,20 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } - else if (npc.ai[0] == 10f) //start phase 3 + + // Enter new phase + else if (npc.ai[0] == 10f) { npc.dontTakeDamage = true; npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == num1459 - 60) + if (npc.ai[2] == newPhaseTimer - 60) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); npc.ai[2] += 1f; - if (npc.ai[2] >= num1459) + if (npc.ai[2] >= newPhaseTimer) { npc.ai[0] = 13f; npc.ai[1] = 0f; @@ -1129,23 +1071,14 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } + + // Fast charge else if (npc.ai[0] == 11f) { - int num1479 = 14; - for (int num1480 = 0; num1480 < num1479; num1480++) - { - Vector2 vector176 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * pie / (float)num1479) + vectorCenter; - Vector2 value21 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1481 = Dust.NewDust(vector176 + value21, 0, 0, 244, value21.X * 2f, value21.Y * 2f, 100, default, 1.4f); //changed - Main.dust[num1481].noGravity = true; - Main.dust[num1481].noLight = true; - Main.dust[num1481].velocity /= 4f; - Main.dust[num1481].velocity -= npc.velocity; - } + ChargeDust(14, pie); - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime2) + npc.ai[2] += 1f; + if (npc.ai[2] >= chargeTime) { npc.ai[0] = 6f; npc.ai[1] = 0f; @@ -1154,36 +1087,30 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } + + // Flare Dust that speeds up and whips around in a wave else if (npc.ai[0] == 12f) { if (npc.ai[2] == 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] % num1462 == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + npc.ai[2] += 1f; + if (npc.ai[2] % flareDustSpawnDivisor2 == 0f) + { if (Main.netMode != NetmodeID.MultiplayerClient) { - int damage = expertMode ? 75 : 90; - Vector2 vector173 = Vector2.Normalize(player.Center - vectorCenter) * (npc.width + 20) / 2f + vectorCenter; - float speed = 0.01f; - Vector2 vectorShoot = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f + 30f); - float playerX = player.position.X + player.width * 0.5f - vectorShoot.X; - float playerY = player.position.Y - vectorShoot.Y; - float playerXY = (float)Math.Sqrt(playerX * playerX + playerY * playerY); - playerXY = speed / playerXY; - playerX *= playerXY; - playerY *= playerXY; - Projectile.NewProjectile((int)vector173.X + xPos, (int)vector173.Y - 15, playerX, playerY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); + Vector2 projectileVelocity = player.Center - fromMouth; + projectileVelocity.Normalize(); + projectileVelocity *= 0.1f; + Projectile.NewProjectile(fromMouth, projectileVelocity, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 0f, 0f); } } - npc.velocity = npc.velocity.RotatedBy(-(double)num1463 * (float)npc.direction); - npc.rotation -= num1463 * npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); + npc.rotation -= spinPhaseRotation * npc.direction; - npc.ai[2] += 1f; - if (npc.ai[2] >= num1461) + if (npc.ai[2] >= flareDustPhaseTimer2) { npc.ai[0] = 6f; npc.ai[1] = 0f; @@ -1195,39 +1122,17 @@ namespace CalamityMod.NPCs.Yharon #endregion #region Phase3 + // Phase switch else if (npc.ai[0] == 13f && !player.dead) { - npc.dontTakeDamage = phase5Check; + npc.dontTakeDamage = phase4Check; if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((vectorCenter - player.Center).X); + npc.ai[1] = 500 * Math.Sign((vectorCenter - player.Center).X); Vector2 value20 = player.Center + new Vector2(npc.ai[1], -200f) - vectorCenter; - Vector2 vector175 = Vector2.Normalize(value20 - npc.velocity) * scaleFactor; - if (npc.velocity.X < vector175.X) - { - npc.velocity.X += npcVelocity; - if (npc.velocity.X < 0f && vector175.X > 0f) - npc.velocity.X += npcVelocity; - } - else if (npc.velocity.X > vector175.X) - { - npc.velocity.X -= npcVelocity; - if (npc.velocity.X > 0f && vector175.X < 0f) - npc.velocity.X -= npcVelocity; - } - if (npc.velocity.Y < vector175.Y) - { - npc.velocity.Y += npcVelocity; - if (npc.velocity.Y < 0f && vector175.Y > 0f) - npc.velocity.Y += npcVelocity; - } - else if (npc.velocity.Y > vector175.Y) - { - npc.velocity.Y -= npcVelocity; - if (npc.velocity.Y > 0f && vector175.Y < 0f) - npc.velocity.Y -= npcVelocity; - } + Vector2 vector175 = Vector2.Normalize(value20 - npc.velocity) * velocity; + npc.SimpleFlyMovement(vector175, acceleration); int num1477 = Math.Sign(player.Center.X - vectorCenter.X); if (num1477 != 0) @@ -1244,36 +1149,34 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= aiChangeRate) + if (npc.ai[2] >= phaseSwitchTimer) { int aiState = 0; - switch ((int)npc.ai[3]) //0 2 4 6 8 9 1 3 5 7 10 repeat + switch ((int)npc.ai[3]) { case 0: case 1: + aiState = 1; + break; case 2: case 3: - aiState = death ? 5 : 1; //normal charges - break; case 4: + aiState = 5; + break; case 5: + aiState = 3; + break; case 6: - aiState = 5; //fast charges + aiState = 6; break; case 7: - aiState = 3; //big tornado - break; - case 8: - aiState = 6; //slow flare bombs - break; - case 9: npc.ai[3] = 1f; - aiState = 7; //small tornado - break; - case 10: - npc.ai[3] = 0f; - aiState = 2; //flare circle + aiState = 7; break; + case 8: + npc.ai[3] = 0f; + aiState = 2; + break; } if (phase4Check) @@ -1300,7 +1203,7 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 2) { - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * scaleFactor13; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); if (num1477 != 0) @@ -1331,26 +1234,34 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - npc.ai[0] = 18f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + npc.localAI[1] += 1f; + if (npc.localAI[1] == fastChargeTelegraphTimer - 60) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed2; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + if (npc.localAI[1] > fastChargeTelegraphTimer) + { + npc.ai[0] = 18f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[1] = 0f; - if (num1477 != 0) - { - npc.direction = num1477; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (npc.spriteDirection == 1) - npc.rotation += pie; + if (num1477 != 0) + { + npc.direction = num1477; - npc.spriteDirection = -npc.direction; - } + if (npc.spriteDirection == 1) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + } } else if (aiState == 6) { - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * scaleFactor13; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); if (num1477 != 0) @@ -1367,34 +1278,25 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; } - else if (aiState == 7) - { - npc.ai[0] = 20f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } + else if (aiState == 7) + { + npc.ai[0] = 20f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } - npc.netUpdate = true; + npc.netUpdate = true; } } - else if (npc.ai[0] == 14f) //charge + + // Charge + else if (npc.ai[0] == 14f) { - npc.dontTakeDamage = phase5Check; + npc.dontTakeDamage = phase4Check; - int num1479 = 7; - for (int num1480 = 0; num1480 < num1479; num1480++) - { - Vector2 vector176 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * pie / (float)num1479) + vectorCenter; - Vector2 value21 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1481 = Dust.NewDust(vector176 + value21, 0, 0, 244, value21.X * 2f, value21.Y * 2f, 100, default, 1.4f); - Main.dust[num1481].noGravity = true; - Main.dust[num1481].noLight = true; - Main.dust[num1481].velocity /= 4f; - Main.dust[num1481].velocity -= npc.velocity; - } + ChargeDust(7, pie); - npc.ai[2] += 1f; + npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) { npc.ai[0] = 13f; @@ -1404,56 +1306,88 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } - else if (npc.ai[0] == 15f) + + // Flare Dust bullet hell + else if (npc.ai[0] == 15f) { - npc.dontTakeDamage = phase5Check; + npc.dontTakeDamage = phase4Check; - if (npc.ai[2] == 0f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + Vector2 flareDustBulletHellSpawn = vectorCenter + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; - if (npc.ai[2] % num1462 == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[2] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (npc.width + 20) / 2f + vectorCenter; + npc.ai[2] += 1f; - if (NPC.CountNPCS(ModContent.NPCType()) < flareCount && NPC.CountNPCS(ModContent.NPCType()) < flareCount) - NPC.NewNPC((int)vector.X + xPos, (int)vector.Y - 15, Main.rand.NextBool(2) ? ModContent.NPCType() : ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + if (npc.ai[2] % flareDustSpawnDivisor == 0f) + { + if (npc.ai[2] >= 120f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - Projectile.NewProjectile((int)vector.X + xPos, (int)vector.Y - 15, Main.rand.Next(-401, 401) * 0.13f, Main.rand.Next(-31, 31) * 0.13f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); //changed - Projectile.NewProjectile((int)vector.X + xPos, (int)vector.Y - 15, Main.rand.Next(-31, 31) * 0.13f, Main.rand.Next(-151, 151) * 0.13f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); //changed - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.CountNPCS(ModContent.NPCType()) < flareCount && NPC.CountNPCS(ModContent.NPCType()) < flareCount) + { + int NPCType = Main.rand.NextBool(2) ? ModContent.NPCType() : ModContent.NPCType(); + int num1062 = NPC.NewNPC((int)flareDustBulletHellSpawn.X, (int)flareDustBulletHellSpawn.Y, NPCType, 0, 0f, 0f, 0f, 0f, 255); - npc.velocity = npc.velocity.RotatedBy(-(double)num1463 * (float)npc.direction); - npc.rotation -= num1463 * npc.direction; + Main.npc[num1062].velocity = player.Center - flareDustBulletHellSpawn; + Main.npc[num1062].velocity.Normalize(); + Main.npc[num1062].velocity *= CalamityWorld.bossRushActive ? 15f : 10f; + Main.npc[num1062].netUpdate = true; + } + } + } - npc.ai[2] += 1f; - if (npc.ai[2] >= num1461) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } + if (npc.ai[2] % flareDustSpawnDivisor2 == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float projectileVelocity = 4f; + int totalProjectiles = 4; + double radians = MathHelper.TwoPi / totalProjectiles; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-npc.localAI[2], -projectileVelocity)) * projectileVelocity; + + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector2 = spinningPoint.RotatedBy(radians * i); + Projectile.NewProjectile(flareDustBulletHellSpawn, vector2, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 2f, 0f); + } + + float radialOffset = 1.2f; + npc.localAI[2] += npc.ai[2] < (flareDustPhaseTimer / 2) ? radialOffset : -radialOffset; + } + } + + npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); + npc.rotation -= spinPhaseRotation * npc.direction; + + if (npc.ai[2] >= flareDustPhaseTimer) + { + npc.ai[0] = 13f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[2] = 0f; + npc.netUpdate = true; + } } + + // Infernado else if (npc.ai[0] == 16f) { - npc.dontTakeDamage = phase5Check; + npc.dontTakeDamage = phase4Check; npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == num1457 - 30) + if (npc.ai[2] == fireTornadoPhaseTimer - 30) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num1457 - 30) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == fireTornadoPhaseTimer - 30) Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); npc.ai[2] += 1f; - if (npc.ai[2] >= num1457) + if (npc.ai[2] >= fireTornadoPhaseTimer) { npc.ai[0] = 13f; npc.ai[1] = 0f; @@ -1462,67 +1396,39 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } + + // Enter new phase else if (npc.ai[0] == 17f) { - npc.dontTakeDamage = true; + npc.dontTakeDamage = true; - if (npc.ai[2] < num1459 - 90) - { - bool colliding = Collision.SolidCollision(npc.position, npc.width, npc.height); + npc.velocity *= 0.98f; + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (colliding) - npc.alpha += 15; - else - npc.alpha -= 15; + if (npc.ai[2] == newPhaseTimer - 60) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.alpha < 0) - npc.alpha = 0; - - if (npc.alpha > 150) - npc.alpha = 150; - } - else if (npc.alpha < 255) - { - npc.alpha += 4; - if (npc.alpha > 255) - npc.alpha = 255; - } - - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - if (npc.ai[2] == num1459 - 60) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - - npc.ai[2] += 1f; - if (npc.ai[2] >= num1459) - { - npc.ai[0] = 21f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } + npc.ai[2] += 1f; + if (npc.ai[2] >= newPhaseTimer) + { + startSecondAI = true; + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } } + + // Fast charge else if (npc.ai[0] == 18f) { - npc.dontTakeDamage = phase5Check; + npc.dontTakeDamage = phase4Check; - int num1479 = 14; - for (int num1480 = 0; num1480 < num1479; num1480++) - { - Vector2 vector176 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector176 = vector176.RotatedBy((num1480 - (num1479 / 2 - 1)) * (double)pie / (float)num1479) + vectorCenter; - Vector2 value21 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1481 = Dust.NewDust(vector176 + value21, 0, 0, 244, value21.X * 2f, value21.Y * 2f, 100, default, 1.4f); - Main.dust[num1481].noGravity = true; - Main.dust[num1481].noLight = true; - Main.dust[num1481].velocity /= 4f; - Main.dust[num1481].velocity -= npc.velocity; - } + ChargeDust(14, pie); - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime2) + npc.ai[2] += 1f; + if (npc.ai[2] >= chargeTime) { npc.ai[0] = 13f; npc.ai[1] = 0f; @@ -1531,311 +1437,104 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } + + // Fireball ring else if (npc.ai[0] == 19f) { - npc.dontTakeDamage = phase5Check; + npc.dontTakeDamage = phase4Check; - if (npc.ai[2] == 0f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[2] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] % num1462 == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + npc.ai[2] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int damage = expertMode ? 75 : 90; - Vector2 vector173 = Vector2.Normalize(player.Center - vectorCenter) * (npc.width + 20) / 2f + vectorCenter; - float speed = 0.01f; - Vector2 vectorShoot = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f + 30f); - float playerX = player.position.X + player.width * 0.5f - vectorShoot.X; - float playerY = player.position.Y - vectorShoot.Y; - float playerXY = (float)Math.Sqrt(playerX * playerX + playerY * playerY); - playerXY = speed / playerXY; - playerX *= playerXY; - playerY *= playerXY; - Projectile.NewProjectile((int)vector173.X + xPos, (int)vector173.Y - 15, playerX, playerY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); - } - } - - npc.velocity = npc.velocity.RotatedBy(-(double)num1463 * (float)npc.direction); - npc.rotation -= num1463 * npc.direction; - - npc.ai[2] += 1f; - if (npc.ai[2] >= num1461) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 1f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 20f) - { - npc.dontTakeDamage = phase5Check; - - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - if (npc.ai[2] == num1457 - 30) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - - if (death) - { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num1457 - 30) - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); - } - else - { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num1457 - 30) - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= num1457) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - #endregion - - #region Phase4 - else if (npc.ai[0] == 21f && !player.dead) - { - npc.dontTakeDamage = phase5Check; - - if (npc.alpha < 225) - { - npc.alpha += 25; - if (npc.alpha > 225) - npc.alpha = 225; - } - - if (npc.ai[1] == 0f) - { - teleportLocation = Main.rand.NextBool(2) ? (revenge ? 500 : 600) : (revenge ? -500 : -600); - npc.ai[1] = 360 * Math.Sign((vectorCenter - player.Center).X); - } - - Vector2 value7 = player.Center + new Vector2(npc.ai[1], teleportLocation) - vectorCenter; //teleport distance - Vector2 desiredVelocity = Vector2.Normalize(value7 - npc.velocity) * scaleFactor; - npc.SimpleFlyMovement(desiredVelocity, npcVelocity); - - int num32 = Math.Sign(player.Center.X - vectorCenter.X); - if (num32 != 0) - { - if (npc.ai[2] == 0f && num32 != npc.direction) + if (npc.ai[2] % flareDustSpawnDivisor2 == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.rotation += pie; - for (int l = 0; l < npc.oldPos.Length; l++) - npc.oldPos[l] = Vector2.Zero; + Vector2 projectileVelocity = player.Center - fromMouth; + projectileVelocity.Normalize(); + projectileVelocity *= 0.1f; + Projectile.NewProjectile(fromMouth, projectileVelocity, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 0f, 0f); } + } - npc.direction = num32; + npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); + npc.rotation -= spinPhaseRotation * npc.direction; - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= aiChangeRate) - { - int aiState = 0; - switch ((int)npc.ai[3]) - { - case 0: //skip 1 - case 2: - case 3: //skip 4 - case 5: - case 6: - case 7: //skip 8 - case 9: - case 10: - case 11: - case 12: //skip 13 - case 14: - case 15: - case 16: - case 17: - case 18: //skip 19 - aiState = 1; - break; - case 1: //+3 - case 4: //+4 - case 8: //+5 - case 13: //+6 - case 19: - aiState = 2; - break; - } - - if (phase5Check) - aiState = 3; - - if (aiState == 1) - { - npc.ai[0] = 22f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - if (num32 != 0) - { - npc.direction = num32; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - else if (aiState == 2) - { - npc.ai[0] = 23f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - else if (aiState == 3) - { - npc.ai[0] = 24f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - npc.netUpdate = true; - } + if (npc.ai[2] >= flareDustPhaseTimer2 - 50) + { + npc.ai[0] = 13f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] += 1f; + npc.netUpdate = true; + } } - else if (npc.ai[0] == 22f) - { - npc.dontTakeDamage = phase5Check; - npc.alpha -= 25; - if (npc.alpha < 0) - npc.alpha = 0; + // Fireball breath + else if (npc.ai[0] == 20f) + { + npc.dontTakeDamage = phase4Check; - int num34 = 7; - for (int m = 0; m < num34; m++) - { - Vector2 vector11 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector11 = vector11.RotatedBy((m - (num34 / 2 - 1)) * pie / num34) + vectorCenter; - Vector2 value8 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num35 = Dust.NewDust(vector11 + value8, 0, 0, 244, value8.X * 2f, value8.Y * 2f, 100, default, 1.4f); - Main.dust[num35].noGravity = true; - Main.dust[num35].noLight = true; - Main.dust[num35].velocity /= 4f; - Main.dust[num35].velocity -= npc.velocity; - } + if (npc.ai[1] == 0f) + npc.ai[1] = 400 * Math.Sign((vectorCenter - player.Center).X); - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) - { - npc.ai[0] = 21f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 1f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 23f) - { - npc.dontTakeDamage = true; + Vector2 value19 = player.Center + new Vector2(npc.ai[1], -400f) - vectorCenter; + Vector2 vector172 = Vector2.Normalize(value19 - npc.velocity) * flareBombPhaseVelocity; + npc.SimpleFlyMovement(vector172, flareBombPhaseAcceleration); - if (npc.alpha < 225) - { - npc.alpha += 17; - if (npc.alpha > 225) - npc.alpha = 225; - } + if (npc.ai[2] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] % flareBombSpawnDivisor == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.CountNPCS(ModContent.NPCType()) < flareCount && NPC.CountNPCS(ModContent.NPCType()) < flareCount) + { + int NPCType = Main.rand.NextBool(2) ? ModContent.NPCType() : ModContent.NPCType(); + int num1062 = NPC.NewNPC((int)fromMouth.X, (int)fromMouth.Y, NPCType, 0, 0f, 0f, 0f, 0f, 255); - if (npc.ai[2] == num1460 / 2) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num1460 / 2) - { - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((vectorCenter - player.Center).X); - - Vector2 center = player.Center + new Vector2(-npc.ai[1], teleportLocation); //teleport distance - vectorCenter = npc.Center = center; - - int num36 = Math.Sign(player.Center.X - vectorCenter.X); - if (num36 != 0) - { - if (npc.ai[2] == 0f && num36 != npc.direction) - { - npc.rotation += pie; - for (int n = 0; n < npc.oldPos.Length; n++) - npc.oldPos[n] = Vector2.Zero; + Main.npc[num1062].velocity = player.Center - fromMouth; + Main.npc[num1062].velocity.Normalize(); + Main.npc[num1062].velocity *= CalamityWorld.bossRushActive ? 15f : 10f; + Main.npc[num1062].netUpdate = true; } - npc.direction = num36; + Projectile.NewProjectile(fromMouth, Vector2.Zero, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 0f, 0f); + } + } - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; + int num1476 = Math.Sign(player.Center.X - vectorCenter.X); + if (num1476 != 0) + { + npc.direction = num1476; - npc.spriteDirection = -npc.direction; - } - } + if (npc.spriteDirection != -npc.direction) + npc.rotation += pie; - npc.ai[2] += 1f; - if (npc.ai[2] >= num1460) - { - npc.ai[0] = 21f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 1f; + npc.spriteDirection = -npc.direction; + } - if (npc.ai[3] == 5f && Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); - - if (npc.ai[3] >= 20f) //14 - npc.ai[3] = 0f; - - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 24f) //start phase 5 - { - npc.alpha = 0; - npc.dontTakeDamage = true; - - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - if (npc.ai[2] == num1459 - 60) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - - npc.ai[2] += 1f; - if (npc.ai[2] >= num1459) - { - startSecondAI = true; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - #endregion - } + npc.ai[2] += 1f; + if (npc.ai[2] >= flareBombPhaseTimer - 15) + { + npc.ai[0] = 13f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + } + } + #endregion + } #region AI2 public void Yharon_AI2(bool expertMode, bool revenge, bool death, float pie) { - bool phase2 = npc.life <= npc.lifeMax * (revenge ? 0.85 : 0.75); - bool phase3 = npc.life <= npc.lifeMax * (revenge ? 0.6 : 0.5); - bool phase4 = npc.life <= npc.lifeMax * (revenge ? 0.2 : 0.1); + bool phase2 = npc.life <= npc.lifeMax * (revenge ? 0.8 : 0.7); + bool phase3 = npc.life <= npc.lifeMax * (revenge ? 0.5 : 0.4); + bool phase4 = npc.life <= npc.lifeMax * 0.15 && revenge; if (npc.ai[0] != 8f) { @@ -1941,57 +1640,59 @@ namespace CalamityMod.NPCs.Yharon // Set DR based on protection boost (aka enrage) npc.Calamity().DR = protectionBoost ? EnragedDR : Phase2_DR; - int num = -1; - float num2 = 1f; - int num4 = expertMode ? 110 : 125; + int projectileDamage = expertMode ? 110 : 125; if (phase4) - num4 = (int)(num4 * 1.1); + projectileDamage = (int)(projectileDamage * 1.1); - float num6 = 0.575f; - float scaleFactor = 10f; - float chargeTime = 34f; - float chargeTime2 = 30f; - float chargeSpeed = 25.75f; - float chargeSpeed2 = 39f; - float num11 = 40f; - float num13 = num11 + 80f; - float num15 = 60f; - float scaleFactor3 = 14f; - float scaleFactor4 = 15.75f; - int num16 = 10; - int num17 = 6 * num16; - float num18 = 60f; - float num19 = num15 + num17 + num18; - float num20 = 60f; - float num22 = MathHelper.TwoPi * (1f / num20); - float scaleFactor5 = 37.25f; + float phaseSwitchTimer = expertMode ? 30f : 32f; + float acceleration = expertMode ? 0.92f : 0.9f; + float velocity = expertMode ? 13.5f : 13f; + float chargeTime = expertMode ? 47f : 50f; + float chargeSpeed = expertMode ? 28f : 27f; + float fastChargeVelocityMultiplier = 1.5f; + int fastChargeTelegraphTimer = 120; + + float fireballBreathTimer = 60f; + float fireballBreathPhaseTimer = fireballBreathTimer + 120f; + float fireballBreathPhaseVelocity = 22f; + + float splittingFireballBreathTimer = 40f; + float splittingFireballBreathPhaseVelocity = 22f; + int splittingFireballBreathDivisor = 10; + int splittingFireballs = 10; + int splittingFireballBreathTimer2 = splittingFireballs * splittingFireballBreathDivisor; + float splittingFireballBreathYVelocityTimer = 40f; + float splittingFireballBreathPhaseTimer = splittingFireballBreathTimer + splittingFireballBreathTimer2 + splittingFireballBreathYVelocityTimer; + + float spinPhaseTimer = 240f; + float spinTime = spinPhaseTimer / 2; + float spinRotation = MathHelper.TwoPi * 3 / spinTime; + float spinPhaseVelocity = 25f; + int flareDustSpawnDivisor = 24; + int flareDustSpawnDivisor2 = 4 + (phase4 ? 4 : 0); + + float flareSpawnDecelerationTimer = 90f; + float flareSpawnPhaseTimer = 180f; + + float teleportPhaseTimer = 45f; if (npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { - num6 = 0.7f; - scaleFactor = 12f; - chargeTime = 28f; - chargeTime2 = 24f; - chargeSpeed = 32f; - chargeSpeed2 = 45f; - scaleFactor4 = 20f; - scaleFactor5 = 43f; + acceleration = 1.2f; + velocity = 18f; + chargeTime = 35f; + chargeSpeed = 34f; } else if (revenge) { float chargeTimeDecrease = death ? 4f : 2f; float velocityMult = death ? 1.1f : 1.05f; - num6 *= velocityMult; - scaleFactor *= velocityMult; + acceleration *= velocityMult; + velocity *= velocityMult; chargeTime -= chargeTimeDecrease; - chargeTime2 -= chargeTimeDecrease; chargeSpeed *= velocityMult; - chargeSpeed2 *= velocityMult; - scaleFactor4 *= velocityMult; - scaleFactor5 *= velocityMult; } - float num25 = 20f; if (npc.ai[0] == 0f) { npc.ai[1] += 1f; @@ -2008,17 +1709,17 @@ namespace CalamityMod.NPCs.Yharon if (npc.ai[2] == 0f) npc.ai[2] = (npc.Center.X < targetData.Center.X) ? 1 : -1; - Vector2 destination = targetData.Center + new Vector2(-npc.ai[2] * 300f, -200f); - Vector2 desiredVelocity = npc.DirectionTo(destination) * scaleFactor; + Vector2 destination = targetData.Center + new Vector2(-npc.ai[2] * 450f, -200f); + Vector2 desiredVelocity = npc.DirectionTo(destination) * velocity; if (!targetDead) - npc.SimpleFlyMovement(desiredVelocity, num6); + npc.SimpleFlyMovement(desiredVelocity, acceleration); int num27 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.direction = npc.spriteDirection = num27; npc.ai[1] += 1f; - if (npc.ai[1] >= 30f) + if (npc.ai[1] >= phaseSwitchTimer) { int num28 = 1; if (phase4) @@ -2146,7 +1847,7 @@ namespace CalamityMod.NPCs.Yharon break; case 4: case 5: - num28 = 2; //charge + num28 = 7; //fast charge break; case 6: num28 = 4; //fireballs @@ -2161,12 +1862,22 @@ namespace CalamityMod.NPCs.Yharon } } + if (num28 == 7 && npc.localAI[1] <= fastChargeTelegraphTimer) + { + npc.localAI[1] += 1f; + if (npc.localAI[1] == fastChargeTelegraphTimer - 60) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + + return; + } + npc.ai[0] = num28; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 1f; + npc.localAI[1] = 0f; - switch (secondPhasePhase) + switch (secondPhasePhase) { case 1: if (phase2) @@ -2245,7 +1956,7 @@ namespace CalamityMod.NPCs.Yharon if (npc.spriteDirection == -1) npc.rotation += pie; - npc.velocity = vector3 * scaleFactor5; + npc.velocity = vector3 * spinPhaseVelocity; break; } @@ -2258,30 +1969,21 @@ namespace CalamityMod.NPCs.Yharon if (npc.spriteDirection == -1) npc.rotation += pie; - npc.velocity = vector * chargeSpeed2; + npc.velocity = vector * chargeSpeed * fastChargeVelocityMultiplier; break; } } } } + + // Charge else if (npc.ai[0] == 2f) { if (npc.ai[1] == 1f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - int num1473 = 7; - for (int num1474 = 0; num1474 < num1473; num1474++) - { - Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * pie / (float)num1473) + npc.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= npc.velocity; - } + ChargeDust(7, pie); npc.ai[1] += 1f; if (npc.ai[1] >= chargeTime) @@ -2291,89 +1993,82 @@ namespace CalamityMod.NPCs.Yharon npc.ai[2] = 0f; } } - else if (npc.ai[0] == 3f) //fireball spit + + // Fireball spit + else if (npc.ai[0] == 3f) { int num29 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.ai[2] = num29; npc.ai[1] += 1f; - if (npc.ai[1] < num11) + if (npc.ai[1] < fireballBreathTimer) { - Vector2 vector4 = targetData.Center + new Vector2(num29 * -600f, -250f); - Vector2 value = npc.DirectionTo(vector4) * 12f; + Vector2 vector4 = targetData.Center + new Vector2(num29 * -750f, -300f); + Vector2 value = npc.DirectionTo(vector4) * 16f; - if (npc.Distance(vector4) < 12f) + if (npc.Distance(vector4) < 16f) npc.Center = vector4; else npc.position += value; - if (Vector2.Distance(vector4, npc.Center) < 16f) - npc.ai[1] = num11 - 1f; - - num2 = 1.5f; + if (Vector2.Distance(vector4, npc.Center) < 32f) + npc.ai[1] = fireballBreathTimer - 1f; } - if (npc.ai[1] == num11) + if (npc.ai[1] == fireballBreathTimer) { - int num30 = (targetData.Center.X > npc.Center.X) ? 1 : -1; - npc.velocity = new Vector2(num30, 0f) * 22f; //10f - npc.direction = npc.spriteDirection = num30; + int direction = (targetData.Center.X > npc.Center.X) ? 1 : -1; + npc.velocity = new Vector2(direction, 0f) * fireballBreathPhaseVelocity; + npc.direction = npc.spriteDirection = direction; } - if (npc.ai[1] >= num11) + if (npc.ai[1] >= fireballBreathTimer) { - if (npc.ai[1] % 8 == 0 && Main.netMode != NetmodeID.MultiplayerClient) + if (npc.ai[1] % 10 == 0 && Main.netMode != NetmodeID.MultiplayerClient) { - float num33 = 30f; - Vector2 position = npc.Center + new Vector2((110f + num33) * npc.direction, -20f).RotatedBy(npc.rotation); - float speed = 0.01f; - Vector2 vectorShoot = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f + 30f); - float playerX = targetData.Center.X - vectorShoot.X; - float playerY = targetData.Center.Y - vectorShoot.Y; - float playerXY = (float)Math.Sqrt(playerX * playerX + playerY * playerY); - playerXY = speed / playerXY; - playerX *= playerXY; - playerY *= playerXY; - Projectile.NewProjectile(position.X, position.Y, playerX, playerY, ModContent.ProjectileType(), num4, 0f, Main.myPlayer, 1f, 0f); + float xOffset = 30f; + Vector2 position = npc.Center + new Vector2((110f + xOffset) * npc.direction, -20f).RotatedBy(npc.rotation); + Vector2 projectileVelocity = targetData.Center - position; + projectileVelocity.Normalize(); + projectileVelocity *= 0.1f; + Projectile.NewProjectile(position, projectileVelocity, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 1f, 0f); } - num2 = 1.5f; - - if (Math.Abs(targetData.Center.X - npc.Center.X) > 550f && Math.Abs(npc.velocity.X) < 20f) + if (Math.Abs(targetData.Center.X - npc.Center.X) > 700f && Math.Abs(npc.velocity.X) < chargeSpeed) npc.velocity.X += Math.Sign(npc.velocity.X) * 0.5f; } - if (npc.ai[1] >= num13) + if (npc.ai[1] >= fireballBreathPhaseTimer) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; } } - else if (npc.ai[0] == 4f) //fireball spit + + // Splitting fireball breath + else if (npc.ai[0] == 4f) { int num31 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.ai[2] = num31; - if (npc.ai[1] < num15) + if (npc.ai[1] < splittingFireballBreathTimer) { - Vector2 vector5 = targetData.Center + new Vector2(num31 * -1500f, -350f); - Vector2 value2 = npc.DirectionTo(vector5) * scaleFactor3; + Vector2 vector5 = targetData.Center + new Vector2(num31 * -750f, -300f); + Vector2 value2 = npc.DirectionTo(vector5) * splittingFireballBreathPhaseVelocity; npc.velocity = Vector2.Lerp(npc.velocity, value2, 0.0333333351f); - int num32 = (npc.Center.X < targetData.Center.X) ? 1 : -1; - npc.direction = npc.spriteDirection = num32; + int direction = (npc.Center.X < targetData.Center.X) ? 1 : -1; + npc.direction = npc.spriteDirection = direction; - if (Vector2.Distance(vector5, npc.Center) < 16f) - npc.ai[1] = num15 - 1f; - - num2 = 1.5f; + if (Vector2.Distance(vector5, npc.Center) < 32f) + npc.ai[1] = splittingFireballBreathTimer - 1f; } - else if (npc.ai[1] == num15) + else if (npc.ai[1] == splittingFireballBreathTimer) { Vector2 vector6 = npc.DirectionTo(targetData.Center); - vector6.Y *= 0.25f; + vector6.Y *= 0.15f; vector6 = vector6.SafeNormalize(Vector2.UnitX * npc.direction); npc.spriteDirection = (vector6.X > 0f) ? 1 : -1; @@ -2382,100 +2077,143 @@ namespace CalamityMod.NPCs.Yharon if (npc.spriteDirection == -1) npc.rotation += pie; - npc.velocity = vector6 * scaleFactor4; + npc.velocity = vector6 * splittingFireballBreathPhaseVelocity; } else { - npc.position.X = npc.position.X + npc.DirectionTo(targetData.Center).X * 7f; - npc.position.Y = npc.position.Y + npc.DirectionTo(targetData.Center + new Vector2(0f, -400f)).Y * 6f; + npc.position.X += npc.DirectionTo(targetData.Center).X * 7f; + npc.position.Y += npc.DirectionTo(targetData.Center + new Vector2(0f, -400f)).Y * 6f; - if (npc.ai[1] <= num19 - num18) - num2 = 1.5f; + float xOffset = 30f; + Vector2 position = npc.Center + new Vector2((110f + xOffset) * npc.direction, -20f).RotatedBy(npc.rotation); + int num34 = (int)(npc.ai[1] - splittingFireballBreathTimer + 1f); - float num33 = 30f; - Vector2 position = npc.Center + new Vector2((110f + num33) * npc.direction, -20f).RotatedBy(npc.rotation); - int num34 = (int)(npc.ai[1] - num15 + 1f); - - if (num34 <= num17 && num34 % num16 == 0 && Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(position, npc.velocity, ModContent.ProjectileType(), num4, 0f, Main.myPlayer, 0f, 0f); + if (num34 <= splittingFireballBreathTimer2 && num34 % splittingFireballBreathDivisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(position, npc.velocity, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 0f, 0f); } - if (npc.ai[1] > num19 - num18) + if (npc.ai[1] > splittingFireballBreathPhaseTimer - splittingFireballBreathYVelocityTimer) npc.velocity.Y -= 0.1f; npc.ai[1] += 1f; - if (npc.ai[1] >= num19) + if (npc.ai[1] >= splittingFireballBreathPhaseTimer) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; } } - else if (npc.ai[0] == 5f) //spin 2 win + + // Fireball spin + else if (npc.ai[0] == 5f) { - npc.velocity = npc.velocity.RotatedBy(-(double)num22 * (float)npc.direction); + npc.velocity = npc.velocity.RotatedBy(-(double)spinRotation * (float)npc.direction); npc.position.Y = npc.position.Y - 0.1f; npc.position += npc.DirectionTo(targetData.Center) * 10f; - npc.rotation -= num22 * npc.direction; + npc.rotation -= spinRotation * npc.direction; - num2 *= 0.7f; - - if (npc.ai[1] == 1f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[1] == 1f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); npc.ai[1] += 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { - if (npc.ai[1] % 12 == 0) - { - float num33 = 30f; - Vector2 position = npc.Center + new Vector2((110f + num33) * npc.direction, -20f).RotatedBy(npc.rotation); - Projectile.NewProjectile(position, npc.velocity, ModContent.ProjectileType(), num4, 0f, Main.myPlayer, 0f, 0f); + Vector2 flareDustBulletHellSpawn = npc.Center + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; - if (phase4) - { - float speed = 0.01f; - Vector2 vectorShoot = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f + 30f); - float playerX = targetData.Center.X - vectorShoot.X; - float playerY = targetData.Center.Y - vectorShoot.Y; - float playerXY = (float)Math.Sqrt(playerX * playerX + playerY * playerY); - playerXY = speed / playerXY; - playerX *= playerXY; - playerY *= playerXY; - Projectile.NewProjectile(position.X, position.Y, playerX, playerY, ModContent.ProjectileType(), num4, 0f, Main.myPlayer, 0f, 0f); - } - } + if (npc.ai[1] % flareDustSpawnDivisor == 0f) + { + if (npc.ai[1] >= 120f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + } - if (npc.ai[1] == 45f && phase4 && useTornado) + if (phase3) + { + if (npc.ai[1] % flareDustSpawnDivisor2 == 0f) + { + float projectileVelocity = 4f; + int totalProjectiles = 5; + double radians = MathHelper.TwoPi / totalProjectiles; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-npc.localAI[2], -projectileVelocity)) * projectileVelocity; + + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector2 = spinningPoint.RotatedBy(radians * i); + Projectile.NewProjectile(flareDustBulletHellSpawn, vector2, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 2f, 0f); + } + + float radialOffset = phase4 ? 3f : 1.5f; + npc.localAI[2] += npc.ai[1] < (spinPhaseTimer / 2) ? radialOffset : -radialOffset; + } + } + else if (phase2) + { + if (npc.ai[1] % flareDustSpawnDivisor == 0f) + { + int totalProjectiles = 30; + float offsetAngle = 360 / totalProjectiles; + int totalSpaces = 5; + int spaceStart = Main.rand.Next(totalProjectiles - totalSpaces); + float ai0 = npc.ai[1] % (flareDustSpawnDivisor * 2) == 0f ? 1f : 0f; + + int spacesMade = 0; + for (int i = 0; i < totalProjectiles; i++) + { + if (i >= spaceStart && spacesMade < totalSpaces) + spacesMade++; + else + Projectile.NewProjectile(flareDustBulletHellSpawn, Vector2.Zero, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, ai0, i * offsetAngle); + } + } + } + else + { + if (npc.ai[1] % flareDustSpawnDivisor2 == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float xOffset = 30f; + Vector2 position = npc.Center + new Vector2((110f + xOffset) * npc.direction, -20f).RotatedBy(npc.rotation); + Vector2 projectileVelocity = targetData.Center - position; + projectileVelocity.Normalize(); + projectileVelocity *= 0.1f; + Projectile.NewProjectile(position, projectileVelocity, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + + if (npc.ai[1] == 210f && phase4 && useTornado) { useTornado = false; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); } } - if (npc.ai[1] >= num20) + if (npc.ai[1] >= spinPhaseTimer) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.velocity /= 2f; + npc.localAI[2] = 0f; + npc.velocity /= 2f; } } - else if (npc.ai[0] == 6f) //flare spawn + + // Flare spawn and fire ring + else if (npc.ai[0] == 6f) { if (npc.ai[1] == 0f) { Vector2 destination2 = targetData.Center + new Vector2(0f, -200f); - Vector2 desiredVelocity2 = npc.DirectionTo(destination2) * scaleFactor * 2f; - npc.SimpleFlyMovement(desiredVelocity2, num6 * 2f); + Vector2 desiredVelocity2 = npc.DirectionTo(destination2) * velocity * 1.5f; + npc.SimpleFlyMovement(desiredVelocity2, acceleration * 1.5f); int num35 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.direction = npc.spriteDirection = num35; npc.ai[2] += 1f; - if (npc.Distance(targetData.Center) < 1000f || npc.ai[2] >= 180f) //450f + if (npc.Distance(targetData.Center) < 600f || npc.ai[2] >= 180f) { npc.ai[1] = 1f; npc.netUpdate = true; @@ -2483,15 +2221,12 @@ namespace CalamityMod.NPCs.Yharon } else { - if (npc.ai[1] == 1f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - - if (npc.ai[1] < num25) + if (npc.ai[1] < flareSpawnDecelerationTimer) npc.velocity *= 0.95f; else npc.velocity *= 0.98f; - if (npc.ai[1] == num25) + if (npc.ai[1] == flareSpawnDecelerationTimer) { if (npc.velocity.Y > 0f) npc.velocity.Y /= 3f; @@ -2499,72 +2234,78 @@ namespace CalamityMod.NPCs.Yharon npc.velocity.Y -= 3f; } - num2 *= 0.85f; - - bool flag3 = npc.ai[1] == 20f || npc.ai[1] == 45f || npc.ai[1] == 70f; + bool spawnNPC = npc.ai[1] == 20f || npc.ai[1] == 80f || npc.ai[1] == 140f; int flareCount = NPC.CountNPCS(ModContent.NPCType()) + NPC.CountNPCS(ModContent.NPCType()); - if (flareCount > 5) - flag3 = false; + if (flareCount > 6) + spawnNPC = false; - if (flag3 && Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector7 = npc.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 100f * (0.6f + Main.rand.NextFloat() * 0.4f); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Vector2.Distance(vector7, targetData.Center) > 100f) - { - Point point2 = vector7.ToPoint(); - NPC.NewNPC(point2.X, point2.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); - NPC.NewNPC(point2.X, point2.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); - } + Boom(600, projectileDamage); - NPC.NewNPC((int)npc.Center.X + (Main.rand.NextBool(2) ? 100 : -100), (int)npc.Center.Y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - NPC.NewNPC((int)npc.Center.X + (Main.rand.NextBool(2) ? 100 : -100), (int)npc.Center.Y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); + if (spawnNPC) + { + Vector2 vector7 = npc.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 100f * (0.6f + Main.rand.NextFloat() * 0.4f); + + if (Vector2.Distance(vector7, targetData.Center) > 150f) + { + Point point2 = vector7.ToPoint(); + + int npc2 = NPC.NewNPC(point2.X, point2.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); + + Main.npc[npc2].velocity = targetData.Center - vector7; + Main.npc[npc2].velocity.Normalize(); + Main.npc[npc2].velocity *= CalamityWorld.bossRushActive ? 15f : 10f; + Main.npc[npc2].netUpdate = true; + + int npc3 = NPC.NewNPC(point2.X, point2.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); + + Main.npc[npc3].velocity = targetData.Center - vector7; + Main.npc[npc3].velocity.Normalize(); + Main.npc[npc3].velocity *= CalamityWorld.bossRushActive ? 15f : 10f; + Main.npc[npc3].netUpdate = true; + } + } } npc.ai[1] += 1f; } - if (npc.ai[1] >= 90f) + if (npc.ai[1] >= flareSpawnPhaseTimer) { - if (Main.netMode != NetmodeID.MultiplayerClient) - { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + + if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); - Boom(600, num4); - } npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; } } - else if (npc.ai[0] == 7f) //speedee chargee + + // Fast charge + else if (npc.ai[0] == 7f) { if (npc.ai[1] == 1f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - int num1473 = 7; - for (int num1474 = 0; num1474 < num1473; num1474++) - { - Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * pie / (float)num1473) + npc.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= npc.velocity; - } + ChargeDust(14, pie); npc.ai[1] += 1f; - if (npc.ai[1] >= chargeTime2) + if (npc.ai[1] >= chargeTime) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; } } - else if (npc.ai[0] == 8f) //teleport + + // Teleport + else if (npc.ai[0] == 8f) { Vector2 npcCenter = npc.Center; @@ -2587,20 +2328,23 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 450 * Math.Sign((npcCenter - targetData.Center).X); teleportLocation = Main.rand.NextBool(2) ? (revenge ? 500 : 600) : (revenge ? -500 : -600); - Vector2 center = targetData.Center + new Vector2(-npc.ai[1], teleportLocation); //teleport distance + Vector2 center = targetData.Center + new Vector2(-npc.ai[1], teleportLocation); npcCenter = npc.Center = center; } npc.ai[2] += 1f; - if (npc.ai[2] >= 30f) + if (npc.ai[2] >= teleportPhaseTimer) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.netUpdate = true; + npc.localAI[1] = fastChargeTelegraphTimer + 1f; + npc.netUpdate = true; } } - else if (npc.ai[0] == 9f) //enter next phase + + // Enter new phase + else if (npc.ai[0] == 9f) { npc.velocity *= 0.95f; @@ -2615,8 +2359,7 @@ namespace CalamityMod.NPCs.Yharon { if (phase4) { - int proj; - for (int x = 0; x < 1000; x = proj + 1) + for (int x = 0; x < 1000; x++) { Projectile projectile = Main.projectile[x]; if (projectile.active) @@ -2631,7 +2374,6 @@ namespace CalamityMod.NPCs.Yharon else if (projectile.type == ModContent.ProjectileType()) projectile.active = false; } - proj = x; } } @@ -2649,17 +2391,6 @@ namespace CalamityMod.NPCs.Yharon } } - npc.localAI[0] += num2; - if (npc.localAI[0] >= 36f) - npc.localAI[0] = 0f; - - if (num != -1) - npc.localAI[0] = num * 4; - - npc.localAI[1] += 1f; - if (npc.localAI[1] >= 60f) - npc.localAI[1] = 0f; - float num42 = npc.DirectionTo(targetData.Center).ToRotation(); float num43 = 0.04f; @@ -2679,7 +2410,7 @@ namespace CalamityMod.NPCs.Yharon if (npc.spriteDirection == -1) num42 -= pie; - if (npc.ai[1] >= num11) + if (npc.ai[1] >= fireballBreathTimer) { num42 += npc.spriteDirection * pie / 12f; num43 = 0.05f; @@ -2710,19 +2441,44 @@ namespace CalamityMod.NPCs.Yharon if (num43 != 0f) npc.rotation = npc.rotation.AngleTowards(num42, num43); } - #endregion + #endregion - #region Drawing - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + #region Charge Dust + private void ChargeDust(int dustAmt, float pie) + { + for (int num1474 = 0; num1474 < dustAmt; num1474++) + { + Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; + vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + npc.Center; + Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); + Main.dust[num1475].noGravity = true; + Main.dust[num1475].noLight = true; + Main.dust[num1475].velocity /= 4f; + Main.dust[num1475].velocity -= npc.velocity; + } + } + #endregion + + #region Drawing + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f || npc.ai[0] == 21f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); - bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f || npc.ai[0] == 22f)) || + bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); + + bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f)) || (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f)); - bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f)) || + + bool fastChargePhase = (!startSecondAI && (npc.ai[0] == 5f || npc.ai[0] == 11f || npc.ai[0] == 18f)) || (startSecondAI && npc.ai[0] == 7f); + + bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 20f)) || (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f)); - bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f || npc.ai[0] == 20f); - bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f || npc.ai[0] == 24f)) || (startSecondAI && npc.ai[0] == 9f); - bool pauseAfterTeleportPhase = (!startSecondAI && npc.ai[0] == 23f) || (startSecondAI && npc.ai[0] == 8f); + + bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f); + + bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f)) || (startSecondAI && npc.ai[0] == 9f); + + bool pauseAfterTeleportPhase = startSecondAI && npc.ai[0] == 8f; + bool ai2 = startSecondAI && !phaseOneLoot; SpriteEffects spriteEffects = ai2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; @@ -2739,7 +2495,7 @@ namespace CalamityMod.NPCs.Yharon bool invincible = ai2 && invincibilityCounter < 900; bool flag8 = npc.ai[0] > 5f; bool flag9 = npc.ai[0] > 12f; - bool flag10 = npc.ai[0] > 20f || startSecondAI; + bool flag10 = startSecondAI; int num150 = 120; int num151 = 60; @@ -2762,6 +2518,8 @@ namespace CalamityMod.NPCs.Yharon num153 = 0; if (idlePhases) num153 = 7; + if (fastChargePhase) + num153 = 30; if (invincible) color36 = invincibleColor; @@ -3037,7 +2795,7 @@ namespace CalamityMod.NPCs.Yharon DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); // Other - DropHelper.DropItem(npc, ModContent.ItemType()); + //DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedYharon); DropHelper.DropResidentEvilAmmo(npc, CalamityWorld.downedYharon, 6, 3, 2); @@ -3066,7 +2824,7 @@ namespace CalamityMod.NPCs.Yharon } #endregion - #region StrikeNPC + #region Strike NPC public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { if (CalamityUtils.AntiButcher(npc, ref damage, 0.5f)) @@ -3082,7 +2840,7 @@ namespace CalamityMod.NPCs.Yharon } #endregion - #region HPBarCooldownSlotandStats + #region HP Bar Cooldown Slot and Stats public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { scale = 2f; @@ -3102,21 +2860,55 @@ namespace CalamityMod.NPCs.Yharon } #endregion - #region FindFrame + #region Find Frame public override void FindFrame(int frameHeight) { - bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f || npc.ai[0] == 21f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); - bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f || npc.ai[0] == 22f)) || + bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); + + bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f)) || (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f)); - bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 23f)) || + + bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 20f)) || (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f || npc.ai[0] == 8f)); - bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f || npc.ai[0] == 20f); - bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f || npc.ai[0] == 24f)) || (startSecondAI && npc.ai[0] == 9f); + + bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f); + + bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f)) || (startSecondAI && npc.ai[0] == 9f); + + bool chargeTelegraph = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f) && npc.localAI[1] > 0f) || + (startSecondAI && npc.ai[0] < 2f && npc.localAI[1] > 0f); + + if (chargeTelegraph) + { + int num86 = 120; + if (npc.localAI[1] < num86 - 60 || npc.localAI[1] > num86 - 20) + { + npc.frameCounter += 1D; + if (npc.frameCounter > 5D) + { + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; + } + if (npc.frame.Y >= frameHeight * 5) + { + npc.frame.Y = 0; + } + } + else + { + npc.frame.Y = frameHeight * 5; + if (npc.localAI[1] > num86 - 50 && npc.localAI[1] < num86 - 25) + { + npc.frame.Y = frameHeight * 6; + } + } + return; + } if (idlePhases) { int num84 = 5; - if (!startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 13f || npc.ai[0] == 21f)) + if (!startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 13f)) { num84 = 4; } @@ -3131,14 +2923,13 @@ namespace CalamityMod.NPCs.Yharon npc.frame.Y = 0; } } + if (chargingOrSpawnPhases) - { npc.frame.Y = frameHeight * 5; - } + if (projectileOrCirclePhases) - { npc.frame.Y = frameHeight * 5; - } + if (tornadoPhase) { int num85 = 90; @@ -3164,6 +2955,7 @@ namespace CalamityMod.NPCs.Yharon } } } + if (newPhasePhase) { int num86 = 180; @@ -3210,7 +3002,7 @@ namespace CalamityMod.NPCs.Yharon } #endregion - #region HitEffect + #region Hit Effect public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) diff --git a/Projectiles/Boss/BrimstoneMonster.cs b/Projectiles/Boss/BrimstoneMonster.cs index 690c378bff..6b0ddf35cb 100644 --- a/Projectiles/Boss/BrimstoneMonster.cs +++ b/Projectiles/Boss/BrimstoneMonster.cs @@ -134,7 +134,7 @@ namespace CalamityMod.Projectiles.Boss } // Fly away from other brimstone monsters - float velocity = 0.1f; + float velocity = 0.05f; for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active) diff --git a/Projectiles/Boss/Flare.cs b/Projectiles/Boss/Flare.cs index db2d60410e..6d58ddbdb0 100644 --- a/Projectiles/Boss/Flare.cs +++ b/Projectiles/Boss/Flare.cs @@ -27,6 +27,7 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 600; + projectile.extraUpdates = 1; } public override void SendExtraAI(BinaryWriter writer) @@ -59,6 +60,7 @@ namespace CalamityMod.Projectiles.Boss projectile.ai[0] += 1f; num632 = (float)(Math.Cos((double)(num630 * projectile.ai[0])) - 0.5) * num631; projectile.velocity.Y = projectile.velocity.Y + num632; + projectile.localAI[0] += 1f; if (projectile.localAI[0] > 10f) { diff --git a/Projectiles/Boss/FlareBomb.cs b/Projectiles/Boss/FlareBomb.cs index ba6d98b64e..ea566b0ab9 100644 --- a/Projectiles/Boss/FlareBomb.cs +++ b/Projectiles/Boss/FlareBomb.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Boss } Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); float num953 = revenge ? 110f : 100f; //100 - float scaleFactor12 = revenge ? 27f : 25f; //5 + float scaleFactor12 = revenge ? 35f : 30f; //5 float num954 = 40f; if (projectile.timeLeft > 30 && projectile.alpha > 0) { diff --git a/Projectiles/Boss/FlareDust.cs b/Projectiles/Boss/FlareDust.cs index 981e2a4bf9..3560d62f37 100644 --- a/Projectiles/Boss/FlareDust.cs +++ b/Projectiles/Boss/FlareDust.cs @@ -1,12 +1,19 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { public class FlareDust : ModProjectile { - public override void SetStaticDefaults() + private bool start = true; + private Vector2 center = Vector2.Zero; + private Vector2 velocity = Vector2.Zero; + private double distance = 0D; + + public override void SetStaticDefaults() { DisplayName.SetDefault("Flare Dust"); Main.projFrames[projectile.type] = 4; @@ -21,11 +28,29 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; - projectile.timeLeft = 120; + projectile.timeLeft = 840; cooldownSlot = 1; } - public override void AI() + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(start); + writer.WriteVector2(center); + writer.Write(distance); + writer.WriteVector2(velocity); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + start = reader.ReadBoolean(); + center = reader.ReadVector2(); + distance = reader.ReadDouble(); + velocity = reader.ReadVector2(); + } + + public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 4) @@ -37,9 +62,49 @@ namespace CalamityMod.Projectiles.Boss { projectile.frame = 0; } - projectile.velocity *= 0.975f; + Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); - } + + if (projectile.ai[0] == 2f) + { + projectile.ai[1] += 0.05f; + + projectile.velocity *= MathHelper.Lerp(0.95f, 1.05f, (float)Math.Abs(Math.Sin(projectile.ai[1]))); + + return; + } + + if (start) + { + center = projectile.Center; + velocity = Vector2.Normalize(Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center) * 2f; + start = false; + } + + center += velocity; + + double rad = MathHelper.ToRadians(projectile.ai[1]); + + float amount = 1f - projectile.localAI[0] / 180f; + if (amount < 0f) + amount = 0f; + + distance += MathHelper.Lerp(1f, 3f, amount); + + if (projectile.ai[0] == 0f) + { + projectile.position.X = center.X - (int)(Math.Sin(rad) * distance) - projectile.width / 2; + projectile.position.Y = center.Y - (int)(Math.Cos(rad) * distance) - projectile.height / 2; + } + else + { + projectile.position.X = center.X - (int)(Math.Cos(rad) * distance) - projectile.width / 2; + projectile.position.Y = center.Y - (int)(Math.Sin(rad) * distance) - projectile.height / 2; + } + + projectile.ai[1] += (0.25f + amount) * 0.5f; + projectile.localAI[0] += 1f; + } public override Color? GetAlpha(Color lightColor) { @@ -59,10 +124,10 @@ namespace CalamityMod.Projectiles.Boss { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); projectile.position = projectile.Center; - projectile.width = projectile.height = 80; + projectile.width = projectile.height = 48; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int num621 = 0; num621 < 2; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[num622].velocity *= 3f; @@ -72,7 +137,7 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 8; num623++) + for (int num623 = 0; num623 < 4; num623++) { int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].noGravity = true; diff --git a/Projectiles/Boss/FlareDust2.cs b/Projectiles/Boss/FlareDust2.cs index 1ca8c24acd..16839a0373 100644 --- a/Projectiles/Boss/FlareDust2.cs +++ b/Projectiles/Boss/FlareDust2.cs @@ -1,13 +1,17 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.IO; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { public class FlareDust2 : ModProjectile { - public override void SetStaticDefaults() + private bool start = true; + private Vector2 velocity = Vector2.Zero; + + public override void SetStaticDefaults() { DisplayName.SetDefault("Flare Bomb"); Main.projFrames[projectile.type] = 4; @@ -26,7 +30,19 @@ namespace CalamityMod.Projectiles.Boss cooldownSlot = 1; } - public override void AI() + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(start); + writer.WriteVector2(velocity); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + start = reader.ReadBoolean(); + velocity = reader.ReadVector2(); + } + + public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 4) @@ -38,20 +54,60 @@ namespace CalamityMod.Projectiles.Boss { projectile.frame = 0; } + if (projectile.ai[0] == 1f) { - if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < 8f && projectile.timeLeft < 630) - { - projectile.velocity *= 1.025f; - } + if (projectile.timeLeft < 630) + { + if (projectile.velocity.Length() < 6f) + { + projectile.velocity *= 1.025f; + } + else + { + if (start) + { + velocity = projectile.velocity; + start = false; + } + + projectile.ai[1] += 0.1f; + + float amplitude = velocity.Length(); + + float wavyVelocity = (float)Math.Cos(projectile.ai[1]); + + projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * amplitude; + } + } } else { - if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < 16f && projectile.timeLeft < 420) - { - projectile.velocity *= 1.05f; - } + if (projectile.timeLeft < 420) + { + if (projectile.velocity.Length() < 12f) + { + projectile.velocity *= 1.05f; + } + else + { + if (start) + { + velocity = projectile.velocity; + start = false; + } + + projectile.ai[1] += 0.1f; + + float amplitude = velocity.Length(); + + float wavyVelocity = (float)Math.Sin(projectile.ai[1]); + + projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * amplitude; + } + } } + Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); } @@ -74,20 +130,20 @@ namespace CalamityMod.Projectiles.Boss Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); projectile.position = projectile.Center; projectile.width = projectile.height = 48; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); projectile.Damage(); - for (int num621 = 0; num621 < 5; num621++) + for (int num621 = 0; num621 < 2; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 8; num623++) + for (int num623 = 0; num623 < 4; num623++) { int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].noGravity = true; diff --git a/Projectiles/Boss/HolyAura.cs b/Projectiles/Boss/HolyAura.cs new file mode 100644 index 0000000000..6b0ab9cac2 --- /dev/null +++ b/Projectiles/Boss/HolyAura.cs @@ -0,0 +1,110 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class HolyAura : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Holy Aura"); + } + + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.hostile = true; + projectile.aiStyle = -1; + aiType = -1; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 210; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D value = Main.projectileTexture[projectile.type]; + Vector2 origin = value.Size() / 2f; + float num = Main.GlobalTime % 10f / 10f; + Vector2 value2 = projectile.Center - Main.screenPosition; + float[] array = new float[15]; + float[] array2 = new float[15]; + float[] array3 = new float[15]; + float[] array4 = new float[15]; + float num2 = 0.5f; + int num3 = 210; + num2 = CalamityUtils.GetLerpValue(0f, 60f, projectile.timeLeft, clamped: true) * CalamityUtils.GetLerpValue(num3, num3 - 60, projectile.timeLeft, clamped: true); + float amount = CalamityUtils.GetLerpValue(0f, 60f, projectile.timeLeft, clamped: true) * CalamityUtils.GetLerpValue(num3, 90f, projectile.timeLeft, clamped: true); + amount = CalamityUtils.GetLerpValue(0.2f, 0.5f, amount, clamped: true); + float num4 = 800f / value.Width; + float num5 = num4 * 0.8f; + float num6 = (num4 - num5) / 15f; + float num7 = 30f; + float num8 = 300f; + Vector2 value3 = new Vector2(6f, 6f); + + for (int i = 0; i < 15; i++) + { + float num9 = (float)Math.Sin(num * ((float)Math.PI * 2f) + (float)Math.PI / 2f + i / 2f); + + array[i] = num9 * (num8 - i * 3f); + + array2[i] = (float)Math.Sin(num * ((float)Math.PI * 2f) * 2f + (float)Math.PI / 3f + i) * num7; + array2[i] -= i * 3f; + + array3[i] = i / 15f * 2f + num; + array3[i] = (num9 * 0.5f + 0.5f) * 0.6f + num; + + array4[i] = num5 + (i + 1) * num6; + array4[i] *= 0.3f; + + Color color = Main.hslToRgb(array3[i] % 1f, 1f, 0.5f) * num2 * amount; + + bool underworld = projectile.ai[0] == 2f; + if (Main.dayTime) + { + color.R = 255; + if (underworld) + color.B = 0; + } + else + { + color.B = 255; + if (underworld) + color.G = 0; + else + color.R = 0; + } + + color.A /= 4; + + int fadeTime = 30; + if (projectile.timeLeft < fadeTime) + { + float amount2 = projectile.timeLeft / (float)fadeTime; + + if (color.R > 0) + color.R = (byte)MathHelper.Lerp(0, color.R, amount2); + if (color.G > 0) + color.G = (byte)MathHelper.Lerp(0, color.G, amount2); + if (color.B > 0) + color.B = (byte)MathHelper.Lerp(0, color.B, amount2); + + color.A = (byte)MathHelper.Lerp(0, color.A, amount2); + } + + float rotation = (float)Math.PI / 2f + num9 * ((float)Math.PI / 4f) * -0.3f + (float)Math.PI * i; + + spriteBatch.Draw(value, value2 + new Vector2(array[i], array2[i]), null, color, rotation, origin, new Vector2(array4[i], array4[i]) * value3, SpriteEffects.None, 0); + } + + return false; + } + } +} diff --git a/Projectiles/Boss/HolyAura.png b/Projectiles/Boss/HolyAura.png new file mode 100644 index 0000000000..4254c6a1d5 Binary files /dev/null and b/Projectiles/Boss/HolyAura.png differ diff --git a/Projectiles/Boss/HolyBlast.cs b/Projectiles/Boss/HolyBlast.cs index ed3b4d113f..6fb98462e3 100644 --- a/Projectiles/Boss/HolyBlast.cs +++ b/Projectiles/Boss/HolyBlast.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -42,44 +43,45 @@ namespace CalamityMod.Projectiles.Boss } if (projectile.ai[1] == 0f) { - for (int num621 = 0; num621 < 10; num621++) + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 10; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } projectile.ai[1] = 1f; Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); } - if ((double)Math.Abs(projectile.velocity.X) > 0.2) + if (Math.Abs(projectile.velocity.X) > 0.2) { projectile.spriteDirection = -projectile.direction; } if (projectile.velocity.X < 0f) { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X); } else { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X); } } public override Color? GetAlpha(Color lightColor) { - return new Color(250, 150, 0, projectile.alpha); + return Main.dayTime ? new Color(250, 150, 0, projectile.alpha) : new Color(0, 150, 250, projectile.alpha); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; + Texture2D texture2D13 = Main.dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyBlastNight"); int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; } @@ -101,16 +103,17 @@ namespace CalamityMod.Projectiles.Boss } } Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); - for (int num193 = 0; num193 < 6; num193++) + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num193 = 0; num193 < 6; num193++) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 50, default, 1.5f); + Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); } for (int num194 = 0; num194 < 60; num194++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 0, default, 2.5f); + int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 2.5f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 50, default, 1.5f); + num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); Main.dust[num195].velocity *= 2f; Main.dust[num195].noGravity = true; } @@ -118,8 +121,9 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 240); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 240); + } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { diff --git a/Projectiles/Boss/HolyBlastNight.png b/Projectiles/Boss/HolyBlastNight.png new file mode 100644 index 0000000000..cd5a260342 Binary files /dev/null and b/Projectiles/Boss/HolyBlastNight.png differ diff --git a/Projectiles/Boss/HolyBomb.cs b/Projectiles/Boss/HolyBomb.cs index 68fb95bf5b..b521ae0237 100644 --- a/Projectiles/Boss/HolyBomb.cs +++ b/Projectiles/Boss/HolyBomb.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.IO; @@ -44,12 +45,12 @@ namespace CalamityMod.Projectiles.Boss if (flareShootTimer <= 0) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); + projectile.position.X = projectile.position.X + (projectile.width / 2); + projectile.position.Y = projectile.position.Y + (projectile.height / 2); projectile.width = 50; projectile.height = 50; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); if (projectile.owner == Main.myPlayer) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -2f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); @@ -74,39 +75,40 @@ namespace CalamityMod.Projectiles.Boss } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 150, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(250, 150, 0, projectile.alpha) : new Color(0, 150, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + Texture2D texture2D13 = Main.dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyBombNight"); + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; } public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); + projectile.position.X = projectile.position.X + (projectile.width / 2); + projectile.position.Y = projectile.position.Y + (projectile.height / 2); projectile.width = 150; projectile.height = 150; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num193 = 0; num193 < 3; num193++) + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num193 = 0; num193 < 3; num193++) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 50, default, 1.5f); + Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); } for (int num194 = 0; num194 < 30; num194++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 0, default, 2.5f); + int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 2.5f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 50, default, 1.5f); + num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); Main.dust[num195].velocity *= 2f; Main.dust[num195].noGravity = true; } @@ -114,8 +116,9 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 180); + } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { diff --git a/Projectiles/Boss/HolyBombNight.png b/Projectiles/Boss/HolyBombNight.png new file mode 100644 index 0000000000..90ce1f0516 Binary files /dev/null and b/Projectiles/Boss/HolyBombNight.png differ diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index 2cea35d476..39e45b9d5a 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -1,6 +1,8 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.DataStructures; @@ -12,48 +14,46 @@ namespace CalamityMod.Projectiles.Boss public override void SetStaticDefaults() { DisplayName.SetDefault("Holy Orb"); - Main.projFrames[projectile.type] = 4; } public override void SetDefaults() { - projectile.width = 20; - projectile.height = 20; - projectile.scale = 1.5f; + projectile.width = 30; + projectile.height = 30; projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; + projectile.alpha = 255; projectile.penetrate = 1; - projectile.timeLeft = 240; + projectile.timeLeft = 200; } public override void AI() { - bool expertMode = Main.expertMode; - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - projectile.velocity.X *= 1.01f; - projectile.velocity.Y *= 1.01f; - int num487 = (int)Player.FindClosest(projectile.position, projectile.width, projectile.height); - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + if (projectile.ai[0] < 80f) + { + projectile.ai[0] += 1f; + + if (projectile.timeLeft < 160) + projectile.timeLeft = 160; + } + + bool expertMode = Main.expertMode; + projectile.velocity *= 1.01f; + int num487 = Player.FindClosest(projectile.position, projectile.width, projectile.height); + Vector2 vector36 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); float num489 = Main.player[num487].Center.X - vector36.X; float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) + float num491 = (float)Math.Sqrt(num489 * num489 + num490 * num490); + + if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + Main.player[num487].width && projectile.position.X + projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + Main.player[num487].height && projectile.position.Y + projectile.height > Main.player[num487].position.Y) { int num492 = expertMode ? -150 : -100; if (CalamityWorld.death || CalamityWorld.bossRushActive) - { num492 = -200; - } + if (!Main.dayTime) + num492 = -300; + Main.player[num487].HealEffect(num492, false); Main.player[num487].statLife += num492; if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) @@ -64,48 +64,81 @@ namespace CalamityMod.Projectiles.Boss { Main.player[num487].KillMe(PlayerDeathReason.ByCustomReason(Main.player[Main.myPlayer].name + " burst into sinless ash."), 1000.0, 0, false); } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); + NetMessage.SendData(66, -1, -1, null, num487, num492, 0f, 0f, 0, 0, 0); projectile.Kill(); } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 150, 0, projectile.alpha); - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D value = Main.projectileTexture[projectile.type]; + Color baseColor = Main.dayTime ? new Color(255, 150, 0, 255) : new Color(0, 150, 255, 255); + Color color33 = baseColor * 0.5f; + color33.A = 0; + Vector2 vector28 = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color color34 = color33; + Vector2 origin5 = value.Size() / 2f; + Color color35 = color33 * 0.5f; + float num162 = CalamityUtils.GetLerpValue(15f, 30f, projectile.timeLeft, clamped: true) * CalamityUtils.GetLerpValue(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + Vector2 vector29 = new Vector2(0.5f, 1.5f) * num162; + Vector2 vector30 = new Vector2(0.5f, 1.5f) * num162; + color34 *= num162; + color35 *= num162; - public override void Kill(int timeLeft) + int num163 = 0; + Vector2 position3 = vector28 + projectile.velocity.SafeNormalize(Vector2.Zero) * CalamityUtils.GetLerpValue(0.5f, 1f, projectile.localAI[0] / 60f, clamped: true) * num163; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver2, origin5, vector29, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color34, 0f, origin5, vector30, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver2, origin5, vector29 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, 0f, origin5, vector30 * 0.6f, spriteEffects, 0); + + spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver4, origin5, vector29 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver4, origin5, vector29 * 0.36f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.36f, spriteEffects, 0); + + return false; + } + + public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); + projectile.position.X = projectile.position.X + (projectile.width / 2); + projectile.position.Y = projectile.position.Y + (projectile.height / 2); projectile.width = 50; projectile.height = 50; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 10; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 15; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 247, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 60); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 60); + } } } diff --git a/Projectiles/Boss/HolyBurnOrb.png b/Projectiles/Boss/HolyBurnOrb.png index 385e7d67b1..0968156e79 100644 Binary files a/Projectiles/Boss/HolyBurnOrb.png and b/Projectiles/Boss/HolyBurnOrb.png differ diff --git a/Projectiles/Boss/HolyFire.cs b/Projectiles/Boss/HolyFire.cs index 72d254ee98..ccca0e7846 100644 --- a/Projectiles/Boss/HolyFire.cs +++ b/Projectiles/Boss/HolyFire.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -50,17 +51,17 @@ namespace CalamityMod.Projectiles.Boss } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 150, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(250, 150, 0, projectile.alpha) : new Color(0, 150, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + Texture2D texture2D13 = Main.dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyFireNight"); + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; } @@ -84,33 +85,35 @@ namespace CalamityMod.Projectiles.Boss } } Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); + projectile.position.X = projectile.position.X + (projectile.width / 2); + projectile.position.Y = projectile.position.Y + (projectile.height / 2); projectile.width = 150; projectile.height = 150; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 5; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 10; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); } } public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 120); + } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { diff --git a/Projectiles/Boss/HolyFire2.cs b/Projectiles/Boss/HolyFire2.cs index ccb584388f..cb6fc777f7 100644 --- a/Projectiles/Boss/HolyFire2.cs +++ b/Projectiles/Boss/HolyFire2.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -42,7 +43,7 @@ namespace CalamityMod.Projectiles.Boss { projectile.velocity.X *= 1.05f; } - int num103 = (int)Player.FindClosest(projectile.Center, 1, 1); + int num103 = Player.FindClosest(projectile.Center, 1, 1); projectile.ai[1] += 1f; if (projectile.ai[1] < 180f && projectile.ai[1] > 60f) { @@ -56,50 +57,52 @@ namespace CalamityMod.Projectiles.Boss } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 150, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(250, 150, 0, projectile.alpha) : new Color(0, 150, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + Texture2D texture2D13 = Main.dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyFire2"); + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; } public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); + projectile.position.X = projectile.position.X + (projectile.width / 2); + projectile.position.Y = projectile.position.Y + (projectile.height / 2); projectile.width = 150; projectile.height = 150; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 5; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 10; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); } } public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 120); + } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { diff --git a/Projectiles/Boss/HolyFire2Night.png b/Projectiles/Boss/HolyFire2Night.png new file mode 100644 index 0000000000..605203c3bb Binary files /dev/null and b/Projectiles/Boss/HolyFire2Night.png differ diff --git a/Projectiles/Boss/HolyFireNight.png b/Projectiles/Boss/HolyFireNight.png new file mode 100644 index 0000000000..6a2c0038d6 Binary files /dev/null and b/Projectiles/Boss/HolyFireNight.png differ diff --git a/Projectiles/Boss/HolyFlare.cs b/Projectiles/Boss/HolyFlare.cs index 30459eb9fe..b4bd36ae31 100644 --- a/Projectiles/Boss/HolyFlare.cs +++ b/Projectiles/Boss/HolyFlare.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -39,19 +40,19 @@ namespace CalamityMod.Projectiles.Boss if (projectile.frame > 3) projectile.frame = 0; - float velocityY = projectile.position.Y + (float)projectile.height < player.position.Y ? 1f : 0.25f; + float velocityY = projectile.position.Y + projectile.height < player.position.Y ? 1f : 0.25f; projectile.velocity.Y += 0.01f; if (projectile.velocity.Y > velocityY) projectile.velocity.Y = velocityY; - if (projectile.position.X + (float)projectile.width < player.position.X) + if (projectile.position.X + projectile.width < player.position.X) { if (projectile.velocity.X < 0f) projectile.velocity.X *= 0.99f; projectile.velocity.X += 0.02f; } - else if (projectile.position.X > player.position.X + (float)player.width) + else if (projectile.position.X > player.position.X + player.width) { if (projectile.velocity.X > 0f) projectile.velocity.X *= 0.99f; @@ -64,50 +65,52 @@ namespace CalamityMod.Projectiles.Boss projectile.rotation = projectile.velocity.X * 0.025f; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 150, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(250, 150, 0, projectile.alpha) : new Color(0, 150, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + Texture2D texture2D13 = Main.dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyFlareNight"); + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; } public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); + projectile.position.X = projectile.position.X + (projectile.width / 2); + projectile.position.Y = projectile.position.Y + (projectile.height / 2); projectile.width = 50; projectile.height = 50; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 5; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 10; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); } } public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 120); + } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { diff --git a/Projectiles/Boss/HolyFlareNight.png b/Projectiles/Boss/HolyFlareNight.png new file mode 100644 index 0000000000..950f6775e8 Binary files /dev/null and b/Projectiles/Boss/HolyFlareNight.png differ diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 41fbdcc170..6bd41b956d 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ModLoader; @@ -9,7 +10,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetStaticDefaults() { DisplayName.SetDefault("Holy Light"); - Main.projFrames[projectile.type] = 4; } public override void SetDefaults() @@ -19,31 +19,29 @@ namespace CalamityMod.Projectiles.Boss projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; + projectile.alpha = 255; projectile.penetrate = 1; - projectile.timeLeft = 240; + projectile.timeLeft = 200; } public override void AI() { - bool expertMode = Main.expertMode; - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - projectile.velocity.X *= 1.01f; - projectile.velocity.Y *= 1.01f; - int num487 = (int)Player.FindClosest(projectile.position, projectile.width, projectile.height); - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + if (projectile.ai[0] < 80f) + { + projectile.ai[0] += 1f; + + if (projectile.timeLeft < 160) + projectile.timeLeft = 160; + } + + bool expertMode = Main.expertMode; + projectile.velocity *= 1.01f; + int num487 = Player.FindClosest(projectile.position, projectile.width, projectile.height); + Vector2 vector36 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); float num489 = Main.player[num487].Center.X - vector36.X; float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) + float num491 = (float)Math.Sqrt(num489 * num489 + num490 * num490); + if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + Main.player[num487].width && projectile.position.X + projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + Main.player[num487].height && projectile.position.Y + projectile.height > Main.player[num487].position.Y) { int num492 = expertMode ? 50 : 35; Main.player[num487].HealEffect(num492, false); @@ -52,25 +50,56 @@ namespace CalamityMod.Projectiles.Boss { Main.player[num487].statLife = Main.player[num487].statLifeMax2; } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); + NetMessage.SendData(66, -1, -1, null, num487, num492, 0f, 0f, 0, 0, 0); projectile.Kill(); } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(150, 255, 0, projectile.alpha); - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D value = Main.projectileTexture[projectile.type]; + Color baseColor = new Color(100, 255, 0, 255); + Color color33 = baseColor * 0.5f; + color33.A = 0; + Vector2 vector28 = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color color34 = color33; + Vector2 origin5 = value.Size() / 2f; + Color color35 = color33 * 0.5f; + float num162 = CalamityUtils.GetLerpValue(15f, 30f, projectile.timeLeft, clamped: true) * CalamityUtils.GetLerpValue(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + Vector2 vector29 = new Vector2(0.5f, 1f) * num162; + Vector2 vector30 = new Vector2(0.5f, 1f) * num162; + color34 *= num162; + color35 *= num162; - public override void Kill(int timeLeft) + int num163 = 0; + Vector2 position3 = vector28 + projectile.velocity.SafeNormalize(Vector2.Zero) * CalamityUtils.GetLerpValue(0.5f, 1f, projectile.localAI[0] / 60f, clamped: true) * num163; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(value, position3, null, color34, (float)Math.PI / 2f, origin5, vector29, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color34, 0f, origin5, vector30, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, (float)Math.PI / 2f, origin5, vector29 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, 0f, origin5, vector30 * 0.6f, spriteEffects, 0); + + spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver4, origin5, vector29 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver4, origin5, vector29 * 0.36f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.36f, spriteEffects, 0); + + return false; + } + + public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); + projectile.position.X = projectile.position.X + (projectile.width / 2); + projectile.position.Y = projectile.position.Y + (projectile.height / 2); projectile.width = 50; projectile.height = 50; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); for (int num621 = 0; num621 < 10; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 2f); @@ -78,7 +107,7 @@ namespace CalamityMod.Projectiles.Boss if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 15; num623++) diff --git a/Projectiles/Boss/HolyLight.png b/Projectiles/Boss/HolyLight.png index 5df586c460..0968156e79 100644 Binary files a/Projectiles/Boss/HolyLight.png and b/Projectiles/Boss/HolyLight.png differ diff --git a/Projectiles/Boss/HolySpear.cs b/Projectiles/Boss/HolySpear.cs index 6fbae0083b..27bd3afa89 100644 --- a/Projectiles/Boss/HolySpear.cs +++ b/Projectiles/Boss/HolySpear.cs @@ -27,8 +27,7 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; - projectile.alpha = 100; - projectile.timeLeft = 900; + projectile.timeLeft = 200; cooldownSlot = 1; } @@ -65,21 +64,30 @@ namespace CalamityMod.Projectiles.Boss float fastGateValue = 30f; float minVelocity = 3f; float maxVelocity = 12f; + float extremeVelocity = 16f; float deceleration = 0.95f; float acceleration = 1.2f; - if (projectile.ai[1] <= slowGateValue) + if (projectile.localAI[1] > 480f) { - if (projectile.velocity.Length() > minVelocity) - projectile.velocity *= deceleration; - } - else if (projectile.ai[1] < slowGateValue + fastGateValue) - { - if (projectile.velocity.Length() < maxVelocity) + if (projectile.velocity.Length() < extremeVelocity) projectile.velocity *= acceleration; } else - projectile.ai[1] = 0f; + { + if (projectile.ai[1] <= slowGateValue) + { + if (projectile.velocity.Length() > minVelocity) + projectile.velocity *= deceleration; + } + else if (projectile.ai[1] < slowGateValue + fastGateValue) + { + if (projectile.velocity.Length() < maxVelocity) + projectile.velocity *= acceleration; + } + else + projectile.ai[1] = 0f; + } } else { @@ -93,37 +101,77 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity).RotatedBy(MathHelper.ToRadians(velocity.ToRotation())) * amplitude; } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - } + if (projectile.localAI[1] < 540f) + { + projectile.localAI[1] += 1f; - public override Color? GetAlpha(Color lightColor) - { - if (projectile.timeLeft > 883) - { - projectile.localAI[1] += 5f; - byte b2 = (byte)(((int)projectile.localAI[1]) * 3); - byte a2 = (byte)(projectile.alpha * (b2 / 255f)); - return new Color(b2, b2, b2, a2); - } - if (projectile.timeLeft < 85) - { - byte b2 = (byte)(projectile.timeLeft * 3); - byte a2 = (byte)(projectile.alpha * (b2 / 255f)); - return new Color(b2, b2, b2, a2); - } - return new Color(255, 255, 255, projectile.alpha); + if (projectile.timeLeft < 160) + projectile.timeLeft = 160; + } + + projectile.Opacity = MathHelper.Lerp(240f, 220f, projectile.timeLeft); + + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); - return false; + Texture2D value = Main.projectileTexture[projectile.type]; + int green = projectile.ai[0] != 0f ? 255 : 100; + int blue = projectile.ai[0] != 0f ? 0 : 100; + Color baseColor = new Color(255, green, blue, 255); + + if (!Main.dayTime) + { + int red = projectile.ai[0] != 0f ? 0 : 100; + green = projectile.ai[0] != 0f ? 255 : 100; + baseColor = new Color(red, green, 255, 255); + } + + Color color33 = baseColor * 0.5f; + color33.A = 0; + Vector2 vector28 = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color color34 = color33; + Vector2 origin5 = value.Size() / 2f; + Color color35 = color33 * 0.5f; + float num162 = CalamityUtils.GetLerpValue(15f, 30f, projectile.timeLeft, clamped: true) * CalamityUtils.GetLerpValue(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + Vector2 vector29 = new Vector2(1f, 1.5f) * num162; + Vector2 vector30 = new Vector2(0.5f, 1f) * num162; + color34 *= num162; + color35 *= num162; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + if (CalamityMod.CalamityConfig.Afterimages) + { + for (int i = 0; i < projectile.oldPos.Length; i++) + { + Vector2 drawPos = projectile.oldPos[i] + vector28; + Color color = projectile.GetAlpha(color34) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length); + Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector29, spriteEffects, 0f); + Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector30, spriteEffects, 0f); + + color = projectile.GetAlpha(color35) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length); + Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector29 * 0.6f, spriteEffects, 0f); + Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector30 * 0.6f, spriteEffects, 0f); + } + } + + spriteBatch.Draw(value, vector28, null, color34, projectile.rotation, origin5, vector29, spriteEffects, 0); + spriteBatch.Draw(value, vector28, null, color34, projectile.rotation, origin5, vector30, spriteEffects, 0); + spriteBatch.Draw(value, vector28, null, color35, projectile.rotation, origin5, vector29 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, vector28, null, color35, projectile.rotation, origin5, vector30 * 0.6f, spriteEffects, 0); + + return false; } public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 120); + } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { diff --git a/Projectiles/Boss/HolySpear.png b/Projectiles/Boss/HolySpear.png index e64b5053e6..c1e6c2161d 100644 Binary files a/Projectiles/Boss/HolySpear.png and b/Projectiles/Boss/HolySpear.png differ diff --git a/Projectiles/Boss/MoltenBlast.cs b/Projectiles/Boss/MoltenBlast.cs index 8224f79da3..a00aef3307 100644 --- a/Projectiles/Boss/MoltenBlast.cs +++ b/Projectiles/Boss/MoltenBlast.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -51,16 +52,18 @@ namespace CalamityMod.Projectiles.Boss { projectile.Kill(); } - if (projectile.ai[1] == 0f) + + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + if (projectile.ai[1] == 0f) { for (int num621 = 0; num621 < 10; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } projectile.ai[1] = 1f; @@ -72,10 +75,10 @@ namespace CalamityMod.Projectiles.Boss projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(projectile.Center, 0, 0, 244, 0f, 0f, 160, default, 1f); + Vector2 vector3 = Vector2.UnitX * -projectile.width / 2f; + vector3 += -Vector2.UnitY.RotatedBy(l * 3.14159274f / 6f, default) * new Vector2(8f, 16f); + vector3 = vector3.RotatedBy(projectile.rotation - 1.57079637f, default); + int num9 = Dust.NewDust(projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); Main.dust[num9].scale = 1.1f; Main.dust[num9].noGravity = true; Main.dust[num9].position = projectile.Center + vector3; @@ -83,20 +86,20 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num9].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; } } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 150, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(250, 150, 0, projectile.alpha) : new Color(0, 150, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + Texture2D texture2D13 = Main.dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/MoltenBlastNight"); + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; } @@ -107,27 +110,29 @@ namespace CalamityMod.Projectiles.Boss { for (int num252 = 0; num252 < num251; num252++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); while (value15.X == 0f && value15.Y == 0f) { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); } value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 121) * 0.1f; //70 101 + value15 *= Main.rand.Next(70, 121) * 0.1f; //70 101 Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 0f); } } Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); - for (int num193 = 0; num193 < 3; num193++) + + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num193 = 0; num193 < 3; num193++) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 50, default, 1.5f); + Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); } for (int num194 = 0; num194 < 30; num194++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 0, default, 2.5f); + int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 2.5f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 50, default, 1.5f); + num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); Main.dust[num195].velocity *= 2f; Main.dust[num195].noGravity = true; } @@ -135,8 +140,9 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 180); + } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { diff --git a/Projectiles/Boss/MoltenBlastNight.png b/Projectiles/Boss/MoltenBlastNight.png new file mode 100644 index 0000000000..9d9f45141c Binary files /dev/null and b/Projectiles/Boss/MoltenBlastNight.png differ diff --git a/Projectiles/Boss/MoltenBlob.cs b/Projectiles/Boss/MoltenBlob.cs index bb33c42184..78c1d38c0d 100644 --- a/Projectiles/Boss/MoltenBlob.cs +++ b/Projectiles/Boss/MoltenBlob.cs @@ -1,5 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss @@ -65,41 +67,52 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 150, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(250, 150, 0, projectile.alpha) : new Color(0, 150, 250, projectile.alpha); + } - public override void Kill(int timeLeft) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture2D13 = Main.dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/MoltenBlobNight"); + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); + projectile.position.X = projectile.position.X + (projectile.width / 2); + projectile.position.Y = projectile.position.Y + (projectile.height / 2); projectile.width = 10; projectile.height = 10; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 3; num621++) + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 3; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 5; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); } } public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 90); + } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { diff --git a/Projectiles/Boss/MoltenBlobNight.png b/Projectiles/Boss/MoltenBlobNight.png new file mode 100644 index 0000000000..fa915552df Binary files /dev/null and b/Projectiles/Boss/MoltenBlobNight.png differ diff --git a/Projectiles/Boss/ProvidenceCrystal.cs b/Projectiles/Boss/ProvidenceCrystal.cs index 31238630d7..7efad65207 100644 --- a/Projectiles/Boss/ProvidenceCrystal.cs +++ b/Projectiles/Boss/ProvidenceCrystal.cs @@ -10,9 +10,6 @@ namespace CalamityMod.Projectiles.Boss { public class ProvidenceCrystal : ModProjectile { - private float speedX = -21f; - private float speedY = -3f; - public override void SetStaticDefaults() { DisplayName.SetDefault("Holy Crystal"); @@ -32,15 +29,11 @@ namespace CalamityMod.Projectiles.Boss public override void SendExtraAI(BinaryWriter writer) { - writer.Write(speedX); - writer.Write(speedY); writer.Write(projectile.localAI[0]); } public override void ReceiveExtraAI(BinaryReader reader) { - speedX = reader.ReadSingle(); - speedY = reader.ReadSingle(); projectile.localAI[0] = reader.ReadSingle(); } @@ -53,8 +46,12 @@ namespace CalamityMod.Projectiles.Boss projectile.netUpdate = true; return; } - projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); - projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2) + Main.player[projectile.owner].gfxOffY - 360f; + + if (!Main.dayTime) + projectile.timeLeft -= CalamityWorld.death ? 9 : 16; + + projectile.position.X = Main.player[projectile.owner].Center.X - (projectile.width / 2); + projectile.position.Y = Main.player[projectile.owner].Center.Y - (projectile.height / 2) + Main.player[projectile.owner].gfxOffY - 360f; if (Main.player[projectile.owner].gravDir == -1f) { projectile.position.Y = projectile.position.Y + 400f; @@ -64,8 +61,8 @@ namespace CalamityMod.Projectiles.Boss { projectile.rotation = 0f; } - projectile.position.X = (float)(int)projectile.position.X; - projectile.position.Y = (float)(int)projectile.position.Y; + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; projectile.velocity = Vector2.Zero; projectile.alpha -= 5; if (projectile.alpha < 0) @@ -78,29 +75,32 @@ namespace CalamityMod.Projectiles.Boss } if (projectile.alpha == 0 && Main.rand.NextBool(15)) { - Dust dust34 = Main.dust[Dust.NewDust(projectile.Top, 0, 0, 267, 0f, 0f, 100, new Color(255, 200, Main.DiscoB), 1f)]; + Dust dust34 = Main.dust[Dust.NewDust(projectile.Top, 0, 0, 267, 0f, 0f, 100, Main.dayTime ? new Color(255, 200, Main.DiscoB) : new Color(Main.DiscoR, 200, 255), 1f)]; dust34.velocity.X = 0f; dust34.noGravity = true; dust34.fadeIn = 1f; dust34.position = projectile.Center + Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (4f * Main.rand.NextFloat() + 26f); dust34.scale = 0.5f; } + projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 300f) + if (projectile.localAI[0] >= (Main.dayTime ? 300f : 30f)) { projectile.localAI[0] = 0f; Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 109); projectile.netUpdate = true; if (projectile.owner == Main.myPlayer) { - for (int num1083 = 0; num1083 < 14; num1083++) + int totalProjectiles = Main.dayTime ? 15 : (projectile.localAI[0] % 60f == 0f ? 15 : 10); + float speedX = Main.dayTime ? -21f : -15f; + float speedAdjustment = Math.Abs(speedX * 2f / (totalProjectiles - 1)); + float speedY = -3f; + for (int i = 0; i < totalProjectiles; i++) { - float x4 = Main.rgbToHsl(new Color(255, 200, Main.DiscoB)).X; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speedX, speedY, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, x4, (float)projectile.whoAmI); - speedX += 3f; // -21, -18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18, 21 + float x4 = Main.dayTime ? Main.rgbToHsl(new Color(255, 200, Main.DiscoB)).X : Main.rgbToHsl(new Color(Main.DiscoR, 200, 255)).X; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speedX + speedAdjustment * i, speedY, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, x4, projectile.whoAmI); } } - speedX = -21f; } } @@ -111,16 +111,16 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - Vector2 vector59 = projectile.position + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Color color25 = Lighting.GetColor((int)(projectile.position.X + projectile.width * 0.5) / 16, (int)((projectile.position.Y + projectile.height * 0.5) / 16.0)); + Vector2 vector59 = projectile.position + new Vector2(projectile.width, projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; Texture2D texture2D34 = Main.projectileTexture[projectile.type]; Rectangle rectangle17 = texture2D34.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); Color alpha5 = projectile.GetAlpha(color25); Vector2 origin11 = rectangle17.Size() / 2f; - float scaleFactor5 = (float)Math.Cos((double)(6.28318548f * (projectile.localAI[0] / 60f))) + 3f + 3f; + float scaleFactor5 = (float)Math.Cos(6.28318548f * (projectile.localAI[0] / 60f)) + 3f + 3f; for (float num286 = 0f; num286 < 4f; num286 += 1f) { - double angle = (double)(num286 * 1.57079637f); + double angle = num286 * 1.57079637f; Vector2 center = default; Main.spriteBatch.Draw(texture2D34, vector59 + Vector2.UnitY.RotatedBy(angle, center) * scaleFactor5, new Microsoft.Xna.Framework.Rectangle?(rectangle17), alpha5 * 0.2f, projectile.rotation, origin11, projectile.scale, SpriteEffects.None, 0f); } diff --git a/Projectiles/Boss/ProvidenceCrystalShard.cs b/Projectiles/Boss/ProvidenceCrystalShard.cs index 390d56b5f2..b5014f3d86 100644 --- a/Projectiles/Boss/ProvidenceCrystalShard.cs +++ b/Projectiles/Boss/ProvidenceCrystalShard.cs @@ -39,7 +39,10 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - if (projectile.timeLeft < 300) + if (!Main.dayTime) + projectile.extraUpdates = 1; + + if (projectile.timeLeft < 300) { projectile.tileCollide = true; } @@ -64,7 +67,7 @@ namespace CalamityMod.Projectiles.Boss else { projectile.velocity.Y *= 1.06f; - float fallSpeed = (CalamityWorld.revenge || CalamityWorld.bossRushActive) ? 3.5f : 3f; + float fallSpeed = (CalamityWorld.revenge || CalamityWorld.bossRushActive || !Main.dayTime) ? 3.5f : 3f; if (projectile.velocity.Y > fallSpeed) { projectile.velocity.Y = fallSpeed; @@ -75,13 +78,13 @@ namespace CalamityMod.Projectiles.Boss projectile.localAI[1] = 1f; projectile.velocity.Y = 0.5f; } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) - 1.57f; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - 1.57f; int num3; for (int num979 = 0; num979 < 2; num979 = num3 + 1) { if (Main.rand.NextBool(10)) { - Vector2 value55 = Vector2.UnitY.RotatedBy((double)((float)num979 * 3.14159274f), default).RotatedBy((double)projectile.rotation, default); + Vector2 value55 = Vector2.UnitY.RotatedBy(num979 * 3.14159274f).RotatedBy(projectile.rotation); Dust dust24 = Main.dust[Dust.NewDust(projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; dust24.noGravity = true; dust24.noLight = true; @@ -95,7 +98,7 @@ namespace CalamityMod.Projectiles.Boss { if (Main.rand.NextBool(10)) { - Vector2 value56 = Vector2.UnitY.RotatedBy((double)((float)num980 * 3.14159274f), default); + Vector2 value56 = Vector2.UnitY.RotatedBy(num980 * 3.14159274f); Dust dust25 = Main.dust[Dust.NewDust(projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; dust25.noGravity = true; dust25.noLight = true; @@ -150,7 +153,7 @@ namespace CalamityMod.Projectiles.Boss { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 27); Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(3.1415927410125732); - float num69 = (float)Main.rand.Next(7, 13); + float num69 = Main.rand.Next(7, 13); Vector2 value5 = new Vector2(2.1f, 2f); Color newColor = Main.hslToRgb(projectile.ai[0], 1f, 0.5f); newColor.A = 255; @@ -159,7 +162,7 @@ namespace CalamityMod.Projectiles.Boss { int num71 = Dust.NewDust(projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); Main.dust[num71].position = projectile.Center; - Main.dust[num71].velocity = spinningpoint.RotatedBy((double)(6.28318548f * num70 / num69), default) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); + Main.dust[num71].velocity = spinningpoint.RotatedBy(6.28318548f * num70 / num69) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); Main.dust[num71].noGravity = true; Main.dust[num71].scale = 2f; Main.dust[num71].fadeIn = Main.rand.NextFloat() * 2f; @@ -175,7 +178,7 @@ namespace CalamityMod.Projectiles.Boss { int num74 = Dust.NewDust(projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); Main.dust[num74].position = projectile.Center; - Main.dust[num74].velocity = spinningpoint.RotatedBy((double)(6.28318548f * num73 / num69), default) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); + Main.dust[num74].velocity = spinningpoint.RotatedBy(6.28318548f * num73 / num69) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); Dust dust = Main.dust[num74]; dust.velocity *= Main.rand.NextFloat() * 0.8f; dust.noGravity = true; diff --git a/Projectiles/Boss/ProvidenceHolyRay.cs b/Projectiles/Boss/ProvidenceHolyRay.cs index 45ffa4f0a1..8a33dff998 100644 --- a/Projectiles/Boss/ProvidenceHolyRay.cs +++ b/Projectiles/Boss/ProvidenceHolyRay.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using CalamityMod.NPCs.Providence; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -53,9 +54,9 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[(int)projectile.ai[1]].active && Main.npc[(int)projectile.ai[1]].type == ModContent.NPCType()) { Vector2 value21 = new Vector2(27f, 59f); - Vector2 fireFrom = new Vector2(Main.npc[(int)projectile.ai[1]].Center.X, Main.npc[(int)projectile.ai[1]].Center.Y - 32f); + Vector2 fireFrom = new Vector2(Main.npc[(int)projectile.ai[1]].Center.X, Main.npc[(int)projectile.ai[1]].Center.Y + 32f); Vector2 value22 = Utils.Vector2FromElipse(Main.npc[(int)projectile.ai[1]].localAI[0].ToRotationVector2(), value21 * Main.npc[(int)projectile.ai[1]].localAI[1]); - projectile.position = fireFrom + value22 - new Vector2((float)projectile.width, (float)projectile.height) / 2f; + projectile.position = fireFrom + value22 - new Vector2(projectile.width, projectile.height) / 2f; } if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) @@ -71,7 +72,7 @@ namespace CalamityMod.Projectiles.Boss return; } - projectile.scale = (float)Math.Sin((double)(projectile.localAI[0] * 3.14159274f / ((CalamityWorld.revenge || CalamityWorld.bossRushActive) ? 100f : 180f))) * 10f * num801; + projectile.scale = (float)Math.Sin(projectile.localAI[0] * 3.14159274f / ((CalamityWorld.revenge || CalamityWorld.bossRushActive) ? 100f : 180f)) * 10f * num801; if (projectile.scale > num801) { projectile.scale = num801; @@ -83,7 +84,7 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity = num804.ToRotationVector2(); float num805 = 3f; //3f - float num806 = (float)projectile.width; + float num806 = projectile.width; Vector2 samplingPoint = projectile.Center; if (vector78.HasValue) @@ -94,11 +95,9 @@ namespace CalamityMod.Projectiles.Boss float[] array3 = new float[(int)num805]; Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); float num807 = 0f; - int num3; - for (int num808 = 0; num808 < array3.Length; num808 = num3 + 1) + for (int num808 = 0; num808 < array3.Length; num808++) { num807 += array3[num808]; - num3 = num808; } num807 /= num805; @@ -108,31 +107,31 @@ namespace CalamityMod.Projectiles.Boss num807 = 2400f; } - float amount = 0.5f; //0.5f + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + float amount = 0.5f; //0.5f projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); //length of laser, linear interpolation Vector2 vector79 = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f); - for (int num809 = 0; num809 < 2; num809 = num3 + 1) + for (int num809 = 0; num809 < 2; num809++) { float num810 = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f; float num811 = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 vector80 = new Vector2((float)Math.Cos((double)num810) * num811, (float)Math.Sin((double)num810) * num811); - int num812 = Dust.NewDust(vector79, 0, 0, 244, vector80.X, vector80.Y, 0, default, 1f); + Vector2 vector80 = new Vector2((float)Math.Cos(num810) * num811, (float)Math.Sin(num810) * num811); + int num812 = Dust.NewDust(vector79, 0, 0, dustType, vector80.X, vector80.Y, 0, default, 1f); Main.dust[num812].noGravity = true; Main.dust[num812].scale = 1.7f; - num3 = num809; } if (Main.rand.NextBool(5)) { - Vector2 value29 = projectile.velocity.RotatedBy(1.5707963705062866, default) * ((float)Main.rand.NextDouble() - 0.5f) * (float)projectile.width; - int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 244, 0f, 0f, 100, default, 1.5f); + Vector2 value29 = projectile.velocity.RotatedBy(1.5707963705062866, default) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; + int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f); Dust dust = Main.dust[num813]; dust.velocity *= 0.5f; Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); } DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f); - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -141,30 +140,30 @@ namespace CalamityMod.Projectiles.Boss { return false; } - Texture2D texture2D19 = Main.projectileTexture[projectile.type]; - Texture2D texture2D20 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayMid"); - Texture2D texture2D21 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEnd"); + Texture2D texture2D19 = Main.dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/ProvidenceHolyRayNight"); + Texture2D texture2D20 = Main.dayTime ? ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayMid") : ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayMidNight"); + Texture2D texture2D21 = Main.dayTime ? ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEnd") : ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEndNight"); float num223 = projectile.localAI[1]; //length of laser - Color color44 = new Color(255, 255, 255, 0) * 0.9f; + Color color44 = Main.dayTime ? new Color(250, 250, 250, 0) : new Color(150, 150, 250, 0) * 0.9f; Vector2 vector = projectile.Center - Main.screenPosition; Rectangle? sourceRectangle2 = null; Main.spriteBatch.Draw(texture2D19, vector, sourceRectangle2, color44, projectile.rotation, texture2D19.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - num223 -= (float)(texture2D19.Height / 2 + texture2D21.Height) * projectile.scale; + num223 -= (texture2D19.Height / 2 + texture2D21.Height) * projectile.scale; Vector2 value20 = projectile.Center; - value20 += projectile.velocity * projectile.scale * (float)texture2D19.Height / 2f; + value20 += projectile.velocity * projectile.scale * texture2D19.Height / 2f; if (num223 > 0f) { float num224 = 0f; Rectangle rectangle7 = new Rectangle(0, 16 * (projectile.timeLeft / 3 % 5), texture2D20.Width, 16); while (num224 + 1f < num223) { - if (num223 - num224 < (float)rectangle7.Height) + if (num223 - num224 < rectangle7.Height) { rectangle7.Height = (int)(num223 - num224); } - Main.spriteBatch.Draw(texture2D20, value20 - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(rectangle7), color44, projectile.rotation, new Vector2((float)(rectangle7.Width / 2), 0f), projectile.scale, SpriteEffects.None, 0f); - num224 += (float)rectangle7.Height * projectile.scale; - value20 += projectile.velocity * (float)rectangle7.Height * projectile.scale; + Main.spriteBatch.Draw(texture2D20, value20 - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(rectangle7), color44, projectile.rotation, new Vector2(rectangle7.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f); + num224 += rectangle7.Height * projectile.scale; + value20 += projectile.velocity * rectangle7.Height * projectile.scale; rectangle7.Y += 16; if (rectangle7.Y + rectangle7.Height > texture2D20.Height) { @@ -182,7 +181,7 @@ namespace CalamityMod.Projectiles.Boss { DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; Vector2 unit = projectile.velocity; - Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -201,7 +200,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 300); + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 300); } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) diff --git a/Projectiles/Boss/ProvidenceHolyRayNight.png b/Projectiles/Boss/ProvidenceHolyRayNight.png new file mode 100644 index 0000000000..a374d54f3f Binary files /dev/null and b/Projectiles/Boss/ProvidenceHolyRayNight.png differ diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 7f077815ca..d43bc0bb0b 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Hybrid; using CalamityMod.Projectiles.Magic; @@ -465,7 +466,108 @@ namespace CalamityMod.Projectiles } } } - return true; + + if (CalamityWorld.death && !CalamityPlayer.areThereAnyDamnBosses) + { + if (projectile.type == ProjectileID.Sharknado || projectile.type == ProjectileID.Cthulunado) + { + int num520 = 10; + int num521 = 15; + float num522 = 1f; + int num523 = 150; + int num524 = 42; + if (projectile.type == ProjectileID.Cthulunado) + { + num520 = 16; + num521 = 16; + num522 = 1.5f; + } + if (projectile.velocity.X != 0f) + { + projectile.direction = (projectile.spriteDirection = -Math.Sign(projectile.velocity.X)); + } + projectile.frameCounter++; + if (projectile.frameCounter > 2) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 6) + { + projectile.frame = 0; + } + if (projectile.localAI[0] == 0f && Main.myPlayer == projectile.owner) + { + projectile.localAI[0] = 1f; + projectile.position.X += projectile.width / 2; + projectile.position.Y += projectile.height / 2; + projectile.scale = ((float)(num520 + num521) - projectile.ai[1]) * num522 / (float)(num521 + num520); + projectile.width = (int)((float)num523 * projectile.scale); + projectile.height = (int)((float)num524 * projectile.scale); + projectile.position.X -= projectile.width / 2; + projectile.position.Y -= projectile.height / 2; + projectile.netUpdate = true; + } + if (projectile.ai[1] != -1f) + { + projectile.scale = ((float)(num520 + num521) - projectile.ai[1]) * num522 / (float)(num521 + num520); + projectile.width = (int)((float)num523 * projectile.scale); + projectile.height = (int)((float)num524 * projectile.scale); + } + if (!Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.alpha -= 30; + if (projectile.alpha < 60) + { + projectile.alpha = 60; + } + if (projectile.type == ProjectileID.Cthulunado && projectile.alpha < 100) + { + projectile.alpha = 100; + } + } + else + { + projectile.alpha += 30; + if (projectile.alpha > 150) + { + projectile.alpha = 150; + } + } + if (projectile.ai[0] > 0f) + { + projectile.ai[0] -= 1f; + } + if (projectile.ai[0] == 1f && projectile.ai[1] > 0f && projectile.owner == Main.myPlayer) + { + projectile.netUpdate = true; + Vector2 center2 = projectile.Center; + center2.Y -= (float)num524 * projectile.scale / 2f; + float num525 = ((float)(num520 + num521) - projectile.ai[1] + 1f) * num522 / (float)(num521 + num520); + center2.Y -= (float)num524 * num525 / 2f; + center2.Y += 2f; + Projectile.NewProjectile(center2, projectile.velocity, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 10f, projectile.ai[1] - 1f); + } + if (projectile.ai[0] <= 0f) + { + float num529 = (float)Math.PI / 30f; + float num530 = (float)projectile.width / 5f; + if (projectile.type == ProjectileID.Cthulunado) + { + num530 *= 2f; + } + float num531 = (float)(Math.Cos(num529 * (-projectile.ai[0])) - 0.5) * num530; + projectile.position.X -= num531 * (float)(-projectile.direction); + projectile.ai[0] -= 1f; + num531 = (float)(Math.Cos(num529 * (-projectile.ai[0])) - 0.5) * num530; + projectile.position.X += num531 * (float)(-projectile.direction); + } + + return false; + } + } + + return true; } #endregion @@ -1681,10 +1783,13 @@ namespace CalamityMod.Projectiles int frameHeight = texture.Height / Main.projFrames[projectile.type]; int frameY = frameHeight * projectile.frame; + float scale = projectile.scale; + float rotation = projectile.rotation; - Rectangle rectangle = new Rectangle(0, frameY, texture.Width, frameHeight); + Rectangle rectangle = new Rectangle(0, frameY, texture.Width, frameHeight); + Vector2 origin = rectangle.Size() / 2f; - SpriteEffects spriteEffects = SpriteEffects.None; + SpriteEffects spriteEffects = SpriteEffects.None; if (projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; @@ -1698,7 +1803,7 @@ namespace CalamityMod.Projectiles { Vector2 drawPos = projectile.oldPos[i] + centerOffset - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); Color color = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length); - Main.spriteBatch.Draw(texture, drawPos, rectangle, color, projectile.rotation, rectangle.Size() / 2f, projectile.scale, spriteEffects, 0f); + Main.spriteBatch.Draw(texture, drawPos, rectangle, color, rotation, origin, scale, spriteEffects, 0f); } break; @@ -1712,7 +1817,7 @@ namespace CalamityMod.Projectiles color26 = projectile.GetAlpha(color26); float num164 = whyIsThisAlwaysEight - k; color26 *= num164 / (ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f); - Main.spriteBatch.Draw(texture, projectile.oldPos[k] + centerOffset - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), rectangle, color26, projectile.rotation, rectangle.Size() / 2f, projectile.scale, spriteEffects, 0f); + Main.spriteBatch.Draw(texture, projectile.oldPos[k] + centerOffset - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), rectangle, color26, rotation, origin, scale, spriteEffects, 0f); k += afterimageCounter; } break; @@ -1724,7 +1829,7 @@ namespace CalamityMod.Projectiles // Draw the projectile itself Vector2 startPos = drawCentered ? projectile.Center : projectile.position; - Main.spriteBatch.Draw(texture, startPos - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), rectangle, projectile.GetAlpha(lightColor), projectile.rotation, rectangle.Size() / 2f, projectile.scale, spriteEffects, 0f); + Main.spriteBatch.Draw(texture, startPos - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), rectangle, projectile.GetAlpha(lightColor), rotation, origin, scale, spriteEffects, 0f); } #endregion diff --git a/Tiles/Abyss/Tenebris.cs b/Tiles/Abyss/Tenebris.cs index 40fa30d268..dc25dad660 100644 --- a/Tiles/Abyss/Tenebris.cs +++ b/Tiles/Abyss/Tenebris.cs @@ -1,8 +1,6 @@ - using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss @@ -50,48 +48,6 @@ namespace CalamityMod.Tiles.Abyss } } - public override void RandomUpdate(int i, int j) - { - if (Main.rand.NextBool(5)) - { - if (CalamityWorld.downedCalamitas) - { - int random = WorldGen.genRand.Next(4); - if (random == 0) - { - i++; - } - if (random == 1) - { - i--; - } - if (random == 2) - { - j++; - } - if (random == 3) - { - j--; - } - if (Main.tile[i, j] != null) - { - if (Main.tile[i, j].active()) - { - if (Main.tile[i, j].type == ModContent.TileType() && !Main.tile[i, j].lava()) - { - Main.tile[i, j].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(i, j, true); - if (Main.netMode == 2) - { - NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None); - } - } - } - } - } - } - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { TileFraming.CustomMergeFrame(i, j, Type, ModContent.TileType(), false, false, false, false, resetFrame); diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 507235a53a..fc3e2d46f7 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Tiles public class CalamityGlobalTile : GlobalTile { public static IList WaterStyles => (IList)typeof(WaterStyleLoader).GetField("waterStyles", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); - public static ushort[] PlantTypes = new ushort[] + + public static ushort[] PlantTypes = new ushort[] { TileID.Plants, TileID.CorruptPlants, @@ -33,9 +34,16 @@ namespace CalamityMod.Tiles TileID.HallowedPlants2, TileID.FleshWeeds, (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), + (ushort)ModContent.TileType() }; + public static List GrowthTiles = new List + { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType() + }; + public override bool PreHitWire(int i, int j, int type) { return !CalamityWorld.bossRushActive; @@ -492,7 +500,7 @@ namespace CalamityMod.Tiles if (type == ModContent.TileType() || type == ModContent.TileType()) ai0 = 1f; int projectileType = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile((float)(i * 16), (float)(j * 16), 0f, 0f, projectileType, 0, 0f, Main.myPlayer, ai0, 0f); + int proj = Projectile.NewProjectile(i * 16, j * 16, 0f, 0f, projectileType, 0, 0f, Main.myPlayer, ai0, 0f); Main.projectile[proj].netUpdate = true; } } diff --git a/Tiles/SunkenSea/Navystone.cs b/Tiles/SunkenSea/Navystone.cs index 70fc9a618f..58b3e28939 100644 --- a/Tiles/SunkenSea/Navystone.cs +++ b/Tiles/SunkenSea/Navystone.cs @@ -43,63 +43,6 @@ namespace CalamityMod.Tiles.SunkenSea num = fail ? 1 : 3; } - public override void RandomUpdate(int i, int j) - { - if (Main.rand.NextBool(100)) - { - int random = WorldGen.genRand.Next(4); - if (random == 0) - { - i++; - } - if (random == 1) - { - i--; - } - if (random == 2) - { - j++; - } - if (random == 3) - { - j--; - } - if (Main.tile[i, j] != null) - { - if (!Main.tile[i, j].active()) - { - if (!Main.tile[i, j].lava() && Main.tile[i, j].slope() == 0 && !Main.tile[i, j].halfBrick()) - { - Main.tile[i, j].type = (ushort)ModContent.TileType(); - Main.tile[i, j].active(true); - if (Main.tile[i, j + 1].active() && Main.tileSolid[Main.tile[i, j + 1].type] && Main.tile[i, j + 1].slope() == 0 && !Main.tile[i, j + 1].halfBrick()) - { - Main.tile[i, j].frameY = (short)(0 * 18); - } - else if (Main.tile[i, j - 1].active() && Main.tileSolid[Main.tile[i, j - 1].type] && Main.tile[i, j - 1].slope() == 0 && !Main.tile[i, j - 1].halfBrick()) - { - Main.tile[i, j].frameY = (short)(1 * 18); - } - else if (Main.tile[i + 1, j].active() && Main.tileSolid[Main.tile[i + 1, j].type] && Main.tile[i + 1, j].slope() == 0 && !Main.tile[i + 1, j].halfBrick()) - { - Main.tile[i, j].frameY = (short)(2 * 18); - } - else if (Main.tile[i - 1, j].active() && Main.tileSolid[Main.tile[i - 1, j].type] && Main.tile[i - 1, j].slope() == 0 && !Main.tile[i - 1, j].halfBrick()) - { - Main.tile[i, j].frameY = (short)(3 * 18); - } - Main.tile[i, j].frameX = (short)(WorldGen.genRand.Next(18) * 18); - WorldGen.SquareTileFrame(i, j, true); - if (Main.netMode == 2) - { - NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None); - } - } - } - } - } - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { TileFraming.CustomMergeFrame(i, j, Type, ModContent.TileType()); diff --git a/Tiles/SunkenSea/SeaPrism.cs b/Tiles/SunkenSea/SeaPrism.cs index 3b0eb761fb..f820476eaa 100644 --- a/Tiles/SunkenSea/SeaPrism.cs +++ b/Tiles/SunkenSea/SeaPrism.cs @@ -44,63 +44,6 @@ namespace CalamityMod.Tiles.SunkenSea num = fail ? 1 : 3; } - public override void RandomUpdate(int i, int j) - { - if (Main.rand.NextBool(25)) - { - int random = WorldGen.genRand.Next(4); - if (random == 0) - { - i++; - } - if (random == 1) - { - i--; - } - if (random == 2) - { - j++; - } - if (random == 3) - { - j--; - } - if (Main.tile[i, j] != null) - { - if (!Main.tile[i, j].active()) - { - if (!Main.tile[i, j].lava() && Main.tile[i, j].slope() == 0 && !Main.tile[i, j].halfBrick()) - { - Main.tile[i, j].type = (ushort)ModContent.TileType(); - Main.tile[i, j].active(true); - if (Main.tile[i, j + 1].active() && Main.tileSolid[Main.tile[i, j + 1].type] && Main.tile[i, j + 1].slope() == 0 && !Main.tile[i, j + 1].halfBrick()) - { - Main.tile[i, j].frameY = (short)(0 * 18); - } - else if (Main.tile[i, j - 1].active() && Main.tileSolid[Main.tile[i, j - 1].type] && Main.tile[i, j - 1].slope() == 0 && !Main.tile[i, j - 1].halfBrick()) - { - Main.tile[i, j].frameY = (short)(1 * 18); - } - else if (Main.tile[i + 1, j].active() && Main.tileSolid[Main.tile[i + 1, j].type] && Main.tile[i + 1, j].slope() == 0 && !Main.tile[i + 1, j].halfBrick()) - { - Main.tile[i, j].frameY = (short)(2 * 18); - } - else if (Main.tile[i - 1, j].active() && Main.tileSolid[Main.tile[i - 1, j].type] && Main.tile[i - 1, j].slope() == 0 && !Main.tile[i - 1, j].halfBrick()) - { - Main.tile[i, j].frameY = (short)(3 * 18); - } - Main.tile[i, j].frameX = (short)(WorldGen.genRand.Next(18) * 18); - WorldGen.SquareTileFrame(i, j, true); - if (Main.netMode == 2) - { - NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None); - } - } - } - } - } - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { TileFraming.CustomMergeFrame(i, j, Type, ModContent.TileType(), false, false, false, false, resetFrame); diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index 3b0ddfbb48..0dc77fd126 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -4,88 +4,92 @@ using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; +using System; namespace CalamityMod.UI { - public class StealthUI - { - public static Vector2 DrawPosition = new Vector2(CalamityMod.CalamityConfig.StealthMeterPosX, CalamityMod.CalamityConfig.StealthMeterPosY); - public static Vector2 Offset = DrawPosition; - public static void Draw(SpriteBatch spriteBatch, Player player) - { - if (DrawPosition.X <= 60f && DrawPosition.Y <= 20f) - { - DrawPosition.X = Main.screenWidth / 2f; - DrawPosition.Y = Main.screenHeight / 2 + Main.LocalPlayer.height / 2f + 24f; - } - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.stealthUIAlpha <= 0f || !CalamityMod.CalamityConfig.StealthBar || modPlayer.rogueStealthMax <= 0) - { - if (CalamityMod.CalamityConfig.StealthMeterPosX != DrawPosition.X) - { - CalamityMod.CalamityConfig.StealthMeterPosX = DrawPosition.X; - CalamityMod.SaveConfig(CalamityMod.CalamityConfig); - } - if (CalamityMod.CalamityConfig.StealthMeterPosY != DrawPosition.Y) - { - CalamityMod.CalamityConfig.StealthMeterPosY = DrawPosition.Y; - CalamityMod.SaveConfig(CalamityMod.CalamityConfig); - } - return; - } - Texture2D edgeTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeter"); - Texture2D indicatorTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterStrikeIndicator"); - Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBar"); - Texture2D fullBarTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBarFull"); - spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, edgeTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); - if (modPlayer.rogueStealth >= modPlayer.rogueStealthMax * (modPlayer.stealthStrikeHalfCost ? 0.5f : 1f)) - { - spriteBatch.Draw(indicatorTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); - } + public class StealthUI + { + public static Vector2 DrawPosition = new Vector2(CalamityMod.CalamityConfig.StealthMeterPosX, CalamityMod.CalamityConfig.StealthMeterPosY); + public static Vector2 Offset = DrawPosition; + public static void Draw(SpriteBatch spriteBatch, Player player) + { + if (DrawPosition.X <= 60f && DrawPosition.Y <= 20f) + { + DrawPosition.X = Main.screenWidth / 2f; + DrawPosition.Y = Main.screenHeight / 2 + Main.LocalPlayer.height / 2f + 24f; + } + CalamityPlayer modPlayer = player.Calamity(); + if (modPlayer.stealthUIAlpha <= 0f || !CalamityMod.CalamityConfig.StealthBar || modPlayer.rogueStealthMax <= 0) + { + if (CalamityMod.CalamityConfig.StealthMeterPosX != DrawPosition.X) + { + CalamityMod.CalamityConfig.StealthMeterPosX = DrawPosition.X; + CalamityMod.SaveConfig(CalamityMod.CalamityConfig); + } + if (CalamityMod.CalamityConfig.StealthMeterPosY != DrawPosition.Y) + { + CalamityMod.CalamityConfig.StealthMeterPosY = DrawPosition.Y; + CalamityMod.SaveConfig(CalamityMod.CalamityConfig); + } + return; + } + Texture2D edgeTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeter"); + Texture2D indicatorTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterStrikeIndicator"); + Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBar"); + Texture2D fullBarTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBarFull"); + spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, edgeTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + if (modPlayer.rogueStealth >= modPlayer.rogueStealthMax * (modPlayer.stealthStrikeHalfCost ? 0.5f : 1f)) + { + spriteBatch.Draw(indicatorTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + } - float completionRatio = modPlayer.rogueStealth / modPlayer.rogueStealthMax; - Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); - bool full = modPlayer.rogueStealth >= modPlayer.rogueStealthMax; - spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition, barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); - if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - player.width / 2), (int)(DrawPosition.Y + Main.screenPosition.Y), barTexture.Width, barTexture.Height).Intersects( - new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) - { - if (modPlayer.rogueStealthMax > 0f && modPlayer.stealthUIAlpha >= 0.5f) - { - Main.LocalPlayer.mouseInterface = true; - Main.instance.MouseText("Stealth: " + (int)(modPlayer.rogueStealth * 100) + "/" + (int)(modPlayer.rogueStealthMax * 100) + "", 0, 0, -1, -1, -1, -1); //only way I got this to show up consistently, otherwise it fucked up and showed up anywhere onscreen lol. - modPlayer.stealthUIAlpha = MathHelper.Lerp(modPlayer.stealthUIAlpha, 0.25f, 0.035f); - } - } - if (!CalamityMod.CalamityConfig.MeterPosLock) - { - if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - 26), (int)(DrawPosition.Y + Main.screenPosition.Y - 9), 52, 18).Intersects( - new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) - { - if (Mouse.GetState().LeftButton == ButtonState.Pressed) - { - Offset = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); - DrawPosition.X = Offset.X; - DrawPosition.Y = Offset.Y; - } - if (Mouse.GetState().LeftButton == ButtonState.Released) - { - DrawPosition.X = Offset.X; - DrawPosition.Y = Offset.Y; - } - } + float completionRatio = modPlayer.rogueStealth / modPlayer.rogueStealthMax; + Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); + bool full = modPlayer.rogueStealth >= modPlayer.rogueStealthMax; + spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition, barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - player.width / 2), (int)(DrawPosition.Y + Main.screenPosition.Y), barTexture.Width, barTexture.Height).Intersects( + new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) + { + if (modPlayer.rogueStealthMax > 0f && modPlayer.stealthUIAlpha >= 0.5f) + { + Main.LocalPlayer.mouseInterface = true; + int stealthInt = (int)Math.Round(modPlayer.rogueStealth * 100f); + int maxStealthInt = (int)Math.Round(modPlayer.rogueStealthMax * 100f); + //only way I got this to show up consistently, otherwise it fucked up and showed up anywhere onscreen lol. + Main.instance.MouseText("Stealth: " + stealthInt + "/" + maxStealthInt + "", 0, 0, -1, -1, -1, -1); + modPlayer.stealthUIAlpha = MathHelper.Lerp(modPlayer.stealthUIAlpha, 0.25f, 0.035f); + } + } + if (!CalamityMod.CalamityConfig.MeterPosLock) + { + if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - 26), (int)(DrawPosition.Y + Main.screenPosition.Y - 9), 52, 18).Intersects( + new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) + { + if (Mouse.GetState().LeftButton == ButtonState.Pressed) + { + Offset = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); + DrawPosition.X = Offset.X; + DrawPosition.Y = Offset.Y; + } + if (Mouse.GetState().LeftButton == ButtonState.Released) + { + DrawPosition.X = Offset.X; + DrawPosition.Y = Offset.Y; + } + } - if (CalamityMod.CalamityConfig.StealthMeterPosX != DrawPosition.X) - { - CalamityMod.CalamityConfig.StealthMeterPosX = DrawPosition.X; - CalamityMod.SaveConfig(CalamityMod.CalamityConfig); - } - if (CalamityMod.CalamityConfig.StealthMeterPosY != DrawPosition.Y) - { - CalamityMod.CalamityConfig.StealthMeterPosY = DrawPosition.Y; - CalamityMod.SaveConfig(CalamityMod.CalamityConfig); - } - } - } - } + if (CalamityMod.CalamityConfig.StealthMeterPosX != DrawPosition.X) + { + CalamityMod.CalamityConfig.StealthMeterPosX = DrawPosition.X; + CalamityMod.SaveConfig(CalamityMod.CalamityConfig); + } + if (CalamityMod.CalamityConfig.StealthMeterPosY != DrawPosition.Y) + { + CalamityMod.CalamityConfig.StealthMeterPosY = DrawPosition.Y; + CalamityMod.SaveConfig(CalamityMod.CalamityConfig); + } + } + } + } } diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 745f611edf..2d9d3c5dc9 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -2611,6 +2611,37 @@ namespace CalamityMod } public static int SecondsToFrames(float seconds) => (int)(seconds * 60); - #endregion - } + + // REMOVE THIS IN CALAMITY 1.4, it's a 1.4 Main.cs function + public static float GetLerpValue(float from, float to, float t, bool clamped = false) + { + if (clamped) + { + if (from < to) + { + if (t < from) + { + return 0f; + } + if (t > to) + { + return 1f; + } + } + else + { + if (t < to) + { + return 1f; + } + if (t > from) + { + return 0f; + } + } + } + return (t - from) / (to - from); + } + #endregion + } } diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index b2adc93dff..5b7748ec10 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -1,4 +1,3 @@ -using CalamityMod; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Events; @@ -31,6 +30,7 @@ using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; using CalamityMod.Projectiles.Boss; +using CalamityMod.Tiles; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.AstralDesert; @@ -49,7 +49,6 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.IO; -using Terraria.ModLoader.Config; using Terraria.World.Generation; namespace CalamityMod.World @@ -924,7 +923,7 @@ namespace CalamityMod.World WorldGen.UndergroundDesertLocation.Width, WorldGen.UndergroundDesertLocation.Height / 2); // Player variable, always finds the closest player relative to the center of the map - int closestPlayer = (int)Player.FindClosest(new Vector2((float)(Main.maxTilesX / 2), (float)Main.worldSurface / 2f) * 16f, 0, 0); + int closestPlayer = Player.FindClosest(new Vector2(Main.maxTilesX / 2, (float)Main.worldSurface / 2f) * 16f, 0, 0); Player player = Main.player[closestPlayer]; CalamityPlayer modPlayer = player.Calamity(); @@ -1037,8 +1036,101 @@ namespace CalamityMod.World startAcidicDownpour = false; } - // Boss Rush shit - if (bossRushActive) + // Lumenyl crystal, tenebris spread and sea prism crystal spawn rates + int l = 0; + float mult2 = 1.5E-05f * Main.worldRate; + while (l < Main.maxTilesX * Main.maxTilesY * mult2) + { + int x = WorldGen.genRand.Next(10, Main.maxTilesX - 10); + int y = WorldGen.genRand.Next((int)Main.worldSurface - 1, Main.maxTilesY - 20); + + if (Main.tile[x, y] != null) + { + if (Main.tile[x, y].nactive()) + { + int tileType = Main.tile[x, y].type; + bool tenebris = tileType == ModContent.TileType() && downedCalamitas; + + if (CalamityGlobalTile.GrowthTiles.Contains(tileType) || tenebris) + { + int growthChance = tenebris ? 4 : 2; + if (tileType == ModContent.TileType()) + growthChance *= 5; + + if (Main.rand.NextBool(growthChance)) + { + switch (WorldGen.genRand.Next(4)) + { + case 0: + x++; + break; + case 1: + x--; + break; + case 2: + y++; + break; + case 3: + y--; + break; + default: + break; + } + + if (Main.tile[x, y] != null) + { + Tile tile = Main.tile[x, y]; + bool growTile = tenebris ? (tile.active() && tile.type == ModContent.TileType()) : (!tile.active() && tile.liquid >= 128); + bool meetsAdditionalGrowConditions = tile.slope() == 0 && !tile.halfBrick() && !tile.lava(); + if (growTile && meetsAdditionalGrowConditions) + { + int tileType2 = ModContent.TileType(); + + if (tileType == ModContent.TileType()) + tileType2 = ModContent.TileType(); + + if (CanPlaceBasedOnProximity(x, y, tileType2) || tenebris) + { + tile.type = tenebris ? (ushort)tileType : (ushort)tileType2; + + if (!tenebris) + { + tile.active(true); + if (Main.tile[x, y + 1].active() && Main.tileSolid[Main.tile[x, y + 1].type] && Main.tile[x, y + 1].slope() == 0 && !Main.tile[x, y + 1].halfBrick()) + { + tile.frameY = 0; + } + else if (Main.tile[x, y - 1].active() && Main.tileSolid[Main.tile[x, y - 1].type] && Main.tile[x, y - 1].slope() == 0 && !Main.tile[x, y - 1].halfBrick()) + { + tile.frameY = 18; + } + else if (Main.tile[x + 1, y].active() && Main.tileSolid[Main.tile[x + 1, y].type] && Main.tile[x + 1, y].slope() == 0 && !Main.tile[x + 1, y].halfBrick()) + { + tile.frameY = 36; + } + else if (Main.tile[x - 1, y].active() && Main.tileSolid[Main.tile[x - 1, y].type] && Main.tile[x - 1, y].slope() == 0 && !Main.tile[x - 1, y].halfBrick()) + { + tile.frameY = 54; + } + tile.frameX = (short)(WorldGen.genRand.Next(18) * 18); + } + + WorldGen.SquareTileFrame(x, y, true); + + if (Main.netMode == 2) + NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); + } + } + } + } + } + } + } + l++; + } + + // Boss Rush shit + if (bossRushActive) { // Prevent Moon Lord from spawning naturally if (NPC.MoonLordCountdown > 0) @@ -1844,10 +1936,35 @@ namespace CalamityMod.World } } } - #endregion + #endregion - #region ChangeTime - public static void ChangeTime(bool day) + #region Check Placement Proximity + private bool CanPlaceBasedOnProximity(int x, int y, int tileType) + { + if (tileType == ModContent.TileType() && !downedCalamitas) + return false; + + int minDistanceFromOtherTiles = 6; + int sameTilesNearby = 0; + for (int i = x - minDistanceFromOtherTiles; i < x + minDistanceFromOtherTiles; i++) + { + for (int j = y - minDistanceFromOtherTiles; j < y + minDistanceFromOtherTiles; j++) + { + if (Main.tile[i, j].active() && Main.tile[i, j].type == tileType) + { + sameTilesNearby++; + if (sameTilesNearby > 1) + return false; + } + } + } + + return true; + } + #endregion + + #region ChangeTime + public static void ChangeTime(bool day) { Main.time = 0.0; Main.dayTime = day; diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index bf28a2fea5..7c58b60de3 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -17,12 +17,12 @@ namespace CalamityMod.World public Hub(Vector2 position) { - this.Position = position; + Position = position; } public Hub(float x, float y) { - this.Position = new Vector2(x, y); + Position = new Vector2(x, y); } } @@ -47,19 +47,19 @@ namespace CalamityMod.World } if (x > 0 && hubMap[x - 1, y]) { - this.SearchForCluster(hubMap, pointCluster, x - 1, y, level); + SearchForCluster(hubMap, pointCluster, x - 1, y, level); } if (x < hubMap.GetLength(0) - 1 && hubMap[x + 1, y]) { - this.SearchForCluster(hubMap, pointCluster, x + 1, y, level); + SearchForCluster(hubMap, pointCluster, x + 1, y, level); } if (y > 0 && hubMap[x, y - 1]) { - this.SearchForCluster(hubMap, pointCluster, x, y - 1, level); + SearchForCluster(hubMap, pointCluster, x, y - 1, level); } if (y < hubMap.GetLength(1) - 1 && hubMap[x, y + 1]) { - this.SearchForCluster(hubMap, pointCluster, x, y + 1, level); + SearchForCluster(hubMap, pointCluster, x, y + 1, level); } } @@ -78,9 +78,9 @@ namespace CalamityMod.World public void Generate(int width, int height) //Creates clusters for cluster group { - this.Width = width; - this.Height = height; - base.Clear(); + Width = width; + Height = height; + Clear(); bool[,] array = new bool[width, height]; int num = (width >> 1) - 1; int num2 = (height >> 1) - 1; @@ -88,8 +88,8 @@ namespace CalamityMod.World Point point = new Point(num, num2); for (int i = point.Y - num2; i <= point.Y + num2; i++) { - float num4 = (float)num / (float)num2 * (float)(i - point.Y); - int num5 = Math.Min(num, (int)Math.Sqrt((double)((float)num3 - num4 * num4))); + float num4 = num / num2 * (i - point.Y); + int num5 = Math.Min(num, (int)Math.Sqrt(num3 - num4 * num4)); for (int j = point.X - num5; j <= point.X + num5; j++) { array[j, i] = WorldGen.genRand.Next(2) == 0; @@ -103,7 +103,7 @@ namespace CalamityMod.World if (array[k, l] && WorldGen.genRand.Next(2) == 0) { List list2 = new List(); - this.SearchForCluster(array, list2, k, l, 2); + SearchForCluster(array, list2, k, l, 2); if (list2.Count > 2) { list.Add(list2); @@ -139,19 +139,19 @@ namespace CalamityMod.World int index = array2[x, y]; if (x > 0) { - this.AttemptClaim(x - 1, y, array2, list, index); + AttemptClaim(x - 1, y, array2, list, index); } if (x < array2.GetLength(0) - 1) { - this.AttemptClaim(x + 1, y, array2, list, index); + AttemptClaim(x + 1, y, array2, list, index); } if (y > 0) { - this.AttemptClaim(x, y - 1, array2, list, index); + AttemptClaim(x, y - 1, array2, list, index); } if (y < array2.GetLength(1) - 1) { - this.AttemptClaim(x, y + 1, array2, list, index); + AttemptClaim(x, y + 1, array2, list, index); } } } @@ -186,9 +186,9 @@ namespace CalamityMod.World { foreach (Point current4 in current3) { - cluster.Add(new Hub((float)current4.X + (WorldGen.genRand.NextFloat() - 0.5f) * 0.5f, (float)current4.Y + (WorldGen.genRand.NextFloat() - 0.5f) * 0.5f)); + cluster.Add(new Hub(current4.X + (WorldGen.genRand.NextFloat() - 0.5f) * 0.5f, current4.Y + (WorldGen.genRand.NextFloat() - 0.5f) * 0.5f)); } - base.Add(cluster); + Add(cluster); } } } @@ -196,10 +196,10 @@ namespace CalamityMod.World private static void PlaceClusters(ClusterGroup clusters, Point start, Vector2 scale) //Places tile/wall clusters in Sunken Sea area { - int num = (int)(scale.X * (float)clusters.Width); - int num2 = (int)(scale.Y * (float)clusters.Height); - Vector2 value = new Vector2((float)num, (float)num2); - Vector2 value2 = new Vector2((float)clusters.Width, (float)clusters.Height); + int num = (int)(scale.X * clusters.Width); + int num2 = (int)(scale.Y * clusters.Height); + Vector2 value = new Vector2(num, num2); + Vector2 value2 = new Vector2(clusters.Width, clusters.Height); for (int i = -20; i < num + 20; i++) { for (int j = -20; j < num2 + 20; j++) @@ -209,8 +209,8 @@ namespace CalamityMod.World float num5 = 0f; int num6 = i + start.X; int num7 = j + start.Y; - Vector2 vector = new Vector2((float)i, (float)j) / value * value2; - float num8 = (new Vector2((float)i, (float)j) / value * 2f - Vector2.One).Length(); + Vector2 vector = new Vector2(i, j) / value * value2; + float num8 = (new Vector2(i, j) / value * 2f - Vector2.One).Length(); for (int k = 0; k < clusters.Count; k++) { Cluster cluster = clusters[k]; @@ -303,17 +303,17 @@ namespace CalamityMod.World private static void AddTileVariance(ClusterGroup clusters, Point start, Vector2 scale, float size) /*Adds tile variation to the generated tile clusters and generates open areas with sea prism ore; Generates sea prism crystals on prism ore and occasionally on navystone*/ { - int num = (int)(scale.X * (float)clusters.Width); - int num2 = (int)(scale.Y * (float)clusters.Height); + int num = (int)(scale.X * clusters.Width); + int num2 = (int)(scale.Y * clusters.Height); bool genCentalHole = true; Rectangle rectangle = default; - int radius = (int)(((float)WorldGen.genRand.Next(24, 28)) * size); //Radius of the generated hole + int radius = (int)(WorldGen.genRand.Next(24, 28) * size); //Radius of the generated hole int diameter = radius * 2; Point point = new Point(WorldGen.UndergroundDesertLocation.Left + (WorldGen.UndergroundDesertLocation.Width / 2), WorldGen.UndergroundDesertLocation.Bottom + (WorldGen.UndergroundDesertLocation.Height / 3)); //Around the center of the Sunken Sea area ShapeData holeShape = new ShapeData(); - float outerRadiusPercentage = (float)((double)WorldGen.genRand.Next(40, 56) * 0.01); //Small radius for ore patch to fit inside holes - int sunkenSeaBottom = WorldGen.UndergroundDesertLocation.Bottom + (int)((double)WorldGen.UndergroundDesertLocation.Height * 0.7); + float outerRadiusPercentage = (float)(WorldGen.genRand.Next(40, 56) * 0.01); //Small radius for ore patch to fit inside holes + int sunkenSeaBottom = WorldGen.UndergroundDesertLocation.Bottom + (int)(WorldGen.UndergroundDesertLocation.Height * 0.7); int smallHoles = 0; int amt = (int)(4f * size); //Scale amount of holes with world size for (int i = -20; i < num + 20; i++) @@ -341,7 +341,7 @@ namespace CalamityMod.World new Actions.SetFrames(true) })); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radius * outerRadiusPercentage)), Actions.Chain(new GenAction[] //Smallest is 6 + WorldUtils.Gen(point, new Shapes.Circle((int)(radius * outerRadiusPercentage)), Actions.Chain(new GenAction[] //Smallest is 6 { new Modifiers.Blotches(2, 0.3).Output(holeShape), new Actions.SetTile((ushort)ModContent.TileType(), true) //Place outer shell @@ -355,13 +355,13 @@ namespace CalamityMod.World new Actions.SetFrames(true) })); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radius * (outerRadiusPercentage * 0.6f))), Actions.Chain(new GenAction[] //Smallest is 4 + WorldUtils.Gen(point, new Shapes.Circle((int)(radius * (outerRadiusPercentage * 0.6f))), Actions.Chain(new GenAction[] //Smallest is 4 { new Modifiers.Blotches(2, 0.3), new Actions.SetTile((ushort)ModContent.TileType(), true) //Place prism })); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radius * (outerRadiusPercentage * 0.3f))), Actions.Chain(new GenAction[] //Smallest is 2 + WorldUtils.Gen(point, new Shapes.Circle((int)(radius * (outerRadiusPercentage * 0.3f))), Actions.Chain(new GenAction[] //Smallest is 2 { new Modifiers.Blotches(2, 0.3).Output(holeShape), new Actions.ClearTile(true), //Clear all tiles @@ -381,7 +381,7 @@ namespace CalamityMod.World if (smallHoles < amt && WorldGen.genRand.Next(3) == 0 && !rectangle.Contains(point)) { smallHoles++; - int radiusSmall = (int)(((float)WorldGen.genRand.Next(8, 11)) * size); + int radiusSmall = (int)(WorldGen.genRand.Next(8, 11) * size); WorldUtils.Gen(point, new Shapes.Circle(radiusSmall), Actions.Chain(new GenAction[] { new Modifiers.Blotches(2, 0.45).Output(holeShape), @@ -397,8 +397,8 @@ namespace CalamityMod.World new Actions.SetFrames(true) })); - outerRadiusPercentage = (float)((double)WorldGen.genRand.Next(65, 81) * 0.01); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radiusSmall * outerRadiusPercentage)), Actions.Chain(new GenAction[] //Smallest is 4 + outerRadiusPercentage = (float)(WorldGen.genRand.Next(65, 81) * 0.01); + WorldUtils.Gen(point, new Shapes.Circle((int)(radiusSmall * outerRadiusPercentage)), Actions.Chain(new GenAction[] //Smallest is 4 { new Modifiers.Blotches(2, 0.3).Output(holeShape), new Actions.SetTile((ushort)ModContent.TileType(), true) //Place outer shell @@ -412,13 +412,13 @@ namespace CalamityMod.World new Actions.SetFrames(true) })); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radiusSmall * (outerRadiusPercentage * 0.6f))), Actions.Chain(new GenAction[] //Smallest is 2 + WorldUtils.Gen(point, new Shapes.Circle((int)(radiusSmall * (outerRadiusPercentage * 0.6f))), Actions.Chain(new GenAction[] //Smallest is 2 { new Modifiers.Blotches(2, 0.3), new Actions.SetTile((ushort)ModContent.TileType(), true) //Place prism })); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radiusSmall * (outerRadiusPercentage * 0.3f))), Actions.Chain(new GenAction[] //Smallest is 1 + WorldUtils.Gen(point, new Shapes.Circle((int)(radiusSmall * (outerRadiusPercentage * 0.3f))), Actions.Chain(new GenAction[] //Smallest is 1 { new Modifiers.Blotches(2, 0.3).Output(holeShape), new Actions.ClearTile(true), //Clear center @@ -501,11 +501,11 @@ namespace CalamityMod.World tile3.type = (ushort)ModContent.TileType(); if (Main.tile[num5 - 1, num6].type == ModContent.TileType()) { - Main.tile[num5 - 1, num6].frameY = (short)(2 * 18); + Main.tile[num5 - 1, num6].frameY = 2 * 18; } else if (Main.tile[num5 + 1, num6].type == ModContent.TileType()) { - Main.tile[num5 + 1, num6].frameY = (short)(3 * 18); + Main.tile[num5 + 1, num6].frameY = 3 * 18; } tile3.frameX = (short)(WorldGen.genRand.Next(18) * 18); tile3.active(true); @@ -519,11 +519,11 @@ namespace CalamityMod.World tile3.type = (ushort)ModContent.TileType(); if (Main.tile[num5, num6 - 1].type == ModContent.TileType()) { - Main.tile[num5, num6 - 1].frameY = (short)(0 * 18); + Main.tile[num5, num6 - 1].frameY = 0 * 18; } else if (Main.tile[num5, num6 + 1].type == ModContent.TileType()) { - Main.tile[num5, num6 + 1].frameY = (short)(1 * 18); + Main.tile[num5, num6 + 1].frameY = 1 * 18; } tile3.frameX = (short)(WorldGen.genRand.Next(18) * 18); tile3.active(true); @@ -576,19 +576,19 @@ namespace CalamityMod.World public static bool Place(Point origin) { // 1 on Small, 1.52 on Medium, 2 on Large - float scale = (float)Main.maxTilesX / 4200f; + float scale = Main.maxTilesX / 4200f; // Clamp scale to prevent problems on extra large worlds scale = MathHelper.Clamp(scale, 1f, 2f); int sunkenSeaAreaX = (int)(80f * scale); //80f int sunkenSeaAreaY = (int)((WorldGen.genRand.NextFloat() + 1f) * 60f * scale); //80f - float radius = (float)WorldGen.genRand.Next(6, 10); + float radius = WorldGen.genRand.Next(6, 10); Vector2 vector = new Vector2(4f, 2f); //4, 2 ClusterGroup clusterGroup = new ClusterGroup(); clusterGroup.Generate(sunkenSeaAreaX, sunkenSeaAreaY); - SunkenSea.PlaceClusters(clusterGroup, origin, vector); - SunkenSea.AddTileVariance(clusterGroup, origin, vector, scale); - int num4 = (int)(vector.X * (float)clusterGroup.Width); - int num5 = (int)(vector.Y * (float)clusterGroup.Height); + PlaceClusters(clusterGroup, origin, vector); + AddTileVariance(clusterGroup, origin, vector, scale); + int num4 = (int)(vector.X * clusterGroup.Width); + int num5 = (int)(vector.Y * clusterGroup.Height); for (int i = -40; i < num4 + 40; i++) //40 { for (int j = -40; j < num5 + 40; j++) //40