diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index 2a9e74d96e..14a6ba60c0 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -11,7 +11,11 @@ namespace CalamityMod.Buffs { public override void Update(int type, Player player, ref int buffIndex) { - if (type == BuffID.Panic) + if (type == BuffID.MagicPower) + { + player.magicDamage -= 0.1f; + } + else if (type == BuffID.Panic) { player.moveSpeed -= 0.5f; } @@ -85,9 +89,13 @@ namespace CalamityMod.Buffs { Player player = Main.player[Main.myPlayer]; - //Vanilla buffs + // Vanilla buffs switch (type) { + case BuffID.MagicPower: + tip = "10% increased magic damage"; + break; + case BuffID.Archery: tip = "20% increased arrow speed and 1.05x arrow damage"; break; diff --git a/Buffs/StatBuffs/ProfanedCrystalBuff.cs b/Buffs/StatBuffs/ProfanedCrystalBuff.cs index 72bfce7a05..9a3cf2b919 100644 --- a/Buffs/StatBuffs/ProfanedCrystalBuff.cs +++ b/Buffs/StatBuffs/ProfanedCrystalBuff.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Buffs.StatBuffs public override void SetDefaults() { DisplayName.SetDefault("Devotion"); - Description.SetDefault("The profaned soul within has been defiled by the powerful magic of a supreme witch"); + Description.SetDefault(""); Main.debuff[Type] = true; Main.buffNoSave[Type] = true; Main.buffNoTimeDisplay[Type] = true; @@ -18,7 +18,7 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { - if (CalamityWorld.downedSCal && (player.Calamity().minionSlotStat - player.slotsMinions) >= 10 && !player.Calamity().profanedCrystalForce) + if (CalamityWorld.downedSCal && CalamityWorld.downedExoMechs && (player.Calamity().minionSlotStat - player.slotsMinions) >= 10 && !player.Calamity().profanedCrystalForce) { player.Calamity().profanedCrystalBuffs = true; } @@ -47,10 +47,14 @@ namespace CalamityMod.Buffs.StatBuffs (enrage ? "\nYour weakened life force fuels your desperate attacks" : ""); } } - else if (CalamityWorld.downedSCal) + else if (CalamityWorld.downedSCal && CalamityWorld.downedExoMechs) { tip = "Your profaned soul is constrained by your insufficient summoning powers"; } + else + { + tip = !CalamityWorld.downedExoMechs ? "The soul within this crystal has been defiled by overwhelming energy waves from dangerous mechanations" : "The profaned soul within has been defiled by the powerful magic of a supreme witch"; + } } } } diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 39ff92eb89..13a09385d9 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -140,11 +140,16 @@ namespace CalamityMod.CalPlayer public bool GivenBrimstoneLocus = false; public DoGCartSegment[] DoGCartSegments = new DoGCartSegment[DoGCartMount.SegmentCount]; public float SmoothenedMinecartRotation; - public float MusicMuffleFactor; - #endregion + #endregion - #region Tile Entity Trackers - public int CurrentlyViewedFactoryID = -1; + #region Speedrun Timer + public int speedrunTimer = 0; + public int bossTypeJustDowned = -1; + public int bossTypeJustDownedTime = 0; + #endregion + + #region Tile Entity Trackers + public int CurrentlyViewedFactoryID = -1; public int CurrentlyViewedChargerID = -1; public int CurrentlyViewedHologramID = -1; public string CurrentlyViewedHologramText; @@ -1098,7 +1103,7 @@ namespace CalamityMod.CalPlayer #endregion - #region SavingAndLoading + #region Saving And Loading public override void Initialize() { extraAccessoryML = false; @@ -1220,8 +1225,11 @@ namespace CalamityMod.CalPlayer { "itemTypeLastReforged", itemTypeLastReforged }, { "reforgeTierSafety", reforgeTierSafety }, { "moveSpeedStat", moveSpeedStat }, - { "defenseDamage", defenseDamage } - }; + { "defenseDamage", defenseDamage }, + { "speedrunTimer", speedrunTimer }, + { "bossTypeJustDowned", bossTypeJustDowned }, + { "bossTypeJustDownedTime", bossTypeJustDownedTime } + }; } public override void Load(TagCompound tag) @@ -1312,7 +1320,11 @@ namespace CalamityMod.CalPlayer moveSpeedStat = tag.GetInt("moveSpeedStat"); defenseDamage = tag.GetInt("defenseDamage"); - } + + speedrunTimer = tag.GetInt("speedrunTimer"); + bossTypeJustDowned = tag.GetInt("bossTypeJustDowned"); + bossTypeJustDownedTime = tag.GetInt("bossTypeJustDownedTime"); + } public override void LoadLegacy(BinaryReader reader) { @@ -1351,7 +1363,11 @@ namespace CalamityMod.CalPlayer defenseDamage = reader.ReadInt32(); - if (loadVersion == 0) + speedrunTimer = reader.ReadInt32(); + bossTypeJustDowned = reader.ReadInt32(); + bossTypeJustDownedTime = reader.ReadInt32(); + + if (loadVersion == 0) { BitsByte flags = reader.ReadByte(); extraAccessoryML = flags[0]; @@ -1481,8 +1497,6 @@ namespace CalamityMod.CalPlayer ResetRogueStealth(); - MusicMuffleFactor = 0f; - contactDamageReduction = 0D; projectileDamageReduction = 0D; @@ -2573,10 +2587,7 @@ namespace CalamityMod.CalPlayer bool useNebula = NPC.AnyNPCs(ModContent.NPCType()); player.ManageSpecialBiomeVisuals("CalamityMod:DevourerofGodsHead", useNebula); - bool useNebulaS = NPC.AnyNPCs(ModContent.NPCType()); - player.ManageSpecialBiomeVisuals("CalamityMod:DevourerofGodsHeadS", useNebulaS); - - bool useFlash = NPC.AnyNPCs(ModContent.NPCType()); + bool useFlash = NPC.AnyNPCs(ModContent.NPCType()); if (SkyManager.Instance["CalamityMod:StormWeaverFlash"] != null && useFlash != SkyManager.Instance["CalamityMod:StormWeaverFlash"].IsActive()) { if (useFlash) @@ -3888,10 +3899,17 @@ namespace CalamityMod.CalPlayer player.AddBuff(ModContent.BuffType(), 60, true); } } - #endregion + #endregion - #region PreUpdate - public override void PreUpdate() + #region Update Autopause + public override void UpdateAutopause() + { + speedrunTimer++; + } + #endregion + + #region PreUpdate + public override void PreUpdate() { tailFrameUp++; if (tailFrameUp == 8) @@ -3927,7 +3945,9 @@ namespace CalamityMod.CalPlayer GameShaders.Armor.GetSecondaryShader(player.dye[i].dye, player)?.UseColor(CalamityPlayerDrawEffects.GetCurrentMoonlightDyeColor()); } } - } + + speedrunTimer++; + } #endregion #region PreUpdateBuffs @@ -5079,10 +5099,12 @@ namespace CalamityMod.CalPlayer case ProjectileID.TheRottedFork: case ProjectileID.TheMeatball: + case ProjectileID.CrimsonYoyo: target.AddBuff(ModContent.BuffType(), 60); break; case ProjectileID.BallOHurt: + case ProjectileID.CorruptYoyo: target.AddBuff(BuffID.ShadowFlame, 60); break; @@ -5559,10 +5581,6 @@ namespace CalamityMod.CalPlayer int defenseAdd = (int)(target.defense * 0.05 * (proj.damage / 50D) * acidRoundMultiplier); //100 defense * 0.05 = 5 damage += defenseAdd; } - if (uberBees && CalamityLists.friendlyBeeList.Contains(proj.type)) - { - damage += Main.rand.Next(20, 31); - } if (plaguebringerPatronSummon) { if (isSummon && proj.active && proj.friendly && !proj.npcProj && !proj.trap && proj.damage > 0) @@ -5782,11 +5800,19 @@ namespace CalamityMod.CalPlayer } if (!isImmune && !invincible && !lol) { - double defenseStatDamageMult = (CalamityWorld.death || CalamityWorld.malice) ? 0.15 : CalamityWorld.revenge ? 0.125 : Main.expertMode ? 0.1 : 0.05; + double defenseStatDamageMult = CalamityWorld.malice ? 0.2 : CalamityWorld.death ? 0.15 : CalamityWorld.revenge ? 0.125 : Main.expertMode ? 0.1 : 0.075; if (draedonsHeart) defenseStatDamageMult *= 0.5; int damageToDefense = (int)(damage * defenseStatDamageMult); + + if (areThereAnyDamnBosses) + { + int defenseDamageFloor = (CalamityWorld.malice ? 5 : CalamityWorld.death ? 4 : CalamityWorld.revenge ? 3 : Main.expertMode ? 2 : 1) * (NPC.downedMoonlord ? 3 : Main.hardMode ? 2 : 1); + if (damageToDefense < defenseDamageFloor) + damageToDefense = defenseDamageFloor; + } + defenseDamage += damageToDefense; if (timeBeforeDefenseDamageRecovery < defaultTimeBeforeDefenseDamageRecovery) @@ -6229,12 +6255,20 @@ namespace CalamityMod.CalPlayer } if (!isImmune && !invincible && !lol) { - double defenseStatDamageMult = (CalamityWorld.death || CalamityWorld.malice) ? 0.15 : CalamityWorld.revenge ? 0.125 : Main.expertMode ? 0.1 : 0.05; - if (draedonsHeart) + double defenseStatDamageMult = CalamityWorld.malice ? 0.2 : CalamityWorld.death ? 0.15 : CalamityWorld.revenge ? 0.125 : Main.expertMode ? 0.1 : 0.075; + if (draedonsHeart) defenseStatDamageMult *= 0.5; int damageToDefense = (int)(damage * defenseStatDamageMult); - defenseDamage += damageToDefense; + + if (areThereAnyDamnBosses) + { + int defenseDamageFloor = (CalamityWorld.malice ? 5 : CalamityWorld.death ? 4 : CalamityWorld.revenge ? 3 : Main.expertMode ? 2 : 1) * (NPC.downedMoonlord ? 3 : Main.hardMode ? 2 : 1); + if (damageToDefense < defenseDamageFloor) + damageToDefense = defenseDamageFloor; + } + + defenseDamage += damageToDefense; if (timeBeforeDefenseDamageRecovery < defaultTimeBeforeDefenseDamageRecovery) timeBeforeDefenseDamageRecovery = defaultTimeBeforeDefenseDamageRecovery; @@ -6548,7 +6582,7 @@ namespace CalamityMod.CalPlayer else if (proj.type == ProjectileID.CultistBossIceMist || proj.type == ProjectileID.CultistBossLightningOrbArc) { if (bannerNPCType == ModContent.NPCType() || bannerNPCType == ModContent.NPCType()) - reduceDamage = !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(NPCID.CultistBoss) && proj.Calamity().lineColor != 1; + reduceDamage = !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(NPCID.CultistBoss) && proj.Calamity().lineColor != 1; } else if (proj.type == ProjectileID.SaucerScrap) { @@ -7470,23 +7504,6 @@ namespace CalamityMod.CalPlayer // Rage capping is handled in MiscEffects } - if (CalamityWorld.revenge) - { - // Apply custom damage in Revengeance Mode. All this actually does is provide a minimum damage - customDamage = true; - - // Revengeance uses the same defense effectiveness as Expert, 75%. - double defenseMultiplier = /*Main.masterMode ? 1D :*/ 0.75; - double newDamage = damage - (player.statDefense * defenseMultiplier); - - double newDamageLimit = NPC.downedMoonlord ? 20D : (NPC.downedPlantBoss || CalamityWorld.downedCalamitas) ? 15D : Main.hardMode ? 10D : 5D; - - if (newDamage < newDamageLimit) - newDamage = newDamageLimit; - - damage = (int)newDamage; - } - // Resilient Candle makes defense 5% more effective, aka 5% of defense is subtracted from all incoming damage. if (purpleCandle) damage = (int)(damage - (player.statDefense * 0.05)); diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 21e8f60e60..d749de7c23 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -1,10 +1,38 @@ using CalamityMod.Dusts; +using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Dyes; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs; +using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.AquaticScourge; +using CalamityMod.NPCs.AstrumAureus; +using CalamityMod.NPCs.AstrumDeus; +using CalamityMod.NPCs.BrimstoneElemental; +using CalamityMod.NPCs.Bumblebirb; +using CalamityMod.NPCs.Calamitas; +using CalamityMod.NPCs.CeaselessVoid; +using CalamityMod.NPCs.Crabulon; +using CalamityMod.NPCs.Cryogen; +using CalamityMod.NPCs.DesertScourge; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.HiveMind; +using CalamityMod.NPCs.Leviathan; +using CalamityMod.NPCs.OldDuke; +using CalamityMod.NPCs.Perforator; +using CalamityMod.NPCs.PlaguebringerGoliath; +using CalamityMod.NPCs.Polterghast; +using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.Providence; +using CalamityMod.NPCs.Ravager; +using CalamityMod.NPCs.Signus; +using CalamityMod.NPCs.SlimeGod; +using CalamityMod.NPCs.StormWeaver; +using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.NPCs.Yharon; +using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Summon; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -17,8 +45,6 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence; - namespace CalamityMod.CalPlayer { public class CalamityPlayerDrawEffects : ModPlayer @@ -349,7 +375,62 @@ namespace CalamityMod.CalPlayer } }); - public static readonly PlayerLayer ForbiddenCircletSign = new PlayerLayer("CalamityMod", "ForbiddenSigil", PlayerLayer.BackAcc, drawInfo => + public static readonly PlayerLayer DrawRancorBookManually = new PlayerLayer("CalamityMod", "RancorBook", PlayerLayer.Arms, drawInfo => + { + Player drawPlayer = drawInfo.drawPlayer; + CalamityPlayer modPlayer = drawPlayer.Calamity(); + if (drawInfo.shadow != 0f || drawPlayer.dead) + return; + + int bookType = ModContent.ProjectileType(); + Texture2D bookTexture = Main.projectileTexture[bookType]; + Projectile book = Main.projectile[drawPlayer.heldProj]; + Rectangle frame = bookTexture.Frame(1, Main.projFrames[bookType], 0, book.frame); + Vector2 origin = frame.Size() * 0.5f; + Vector2 drawPosition = drawPlayer.Center + Vector2.UnitX * drawPlayer.direction * 8f - Main.screenPosition; + Color drawColor = book.GetAlpha(Color.White); + SpriteEffects direction = book.spriteDirection == 1f ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + DrawData bookDrawData = new DrawData(bookTexture, drawPosition, frame, drawColor, book.rotation, origin, book.scale, direction, 0); + Main.playerDrawData.Add(bookDrawData); + }); + + public static readonly PlayerLayer ArtemisAndApolloMaskPieces = new PlayerLayer("CalamityMod", "ArtemisApolloMaskPieces", PlayerLayer.Head, drawInfo => + { + Player drawPlayer = drawInfo.drawPlayer; + CalamityPlayer modPlayer = drawPlayer.Calamity(); + if (drawInfo.shadow != 0f || drawPlayer.dead) + return; + + int dyeShader = drawPlayer.dye?[0].dye ?? 0; + int headItemType = drawPlayer.armor[0].type; + if (drawPlayer.armor[10].type > ItemID.None) + headItemType = drawPlayer.armor[10].type; + + Vector2 origin = drawInfo.headOrigin; + Vector2 headDrawPosition = drawInfo.position + origin - Main.screenPosition; + headDrawPosition.Y += drawPlayer.mount.PlayerOffset; + if (headItemType == ModContent.ItemType()) + { + headDrawPosition.X -= drawPlayer.direction == 1f ? 16f : 12f; + headDrawPosition.Y -= 10f; + + Texture2D extraPieceTexture = ModContent.GetTexture("CalamityMod/Items/Armor/Vanity/ArtemisMask_Extra"); + Rectangle frame = extraPieceTexture.Frame(1, 20, 0, drawPlayer.bodyFrame.Y / drawPlayer.bodyFrame.Height); + DrawData pieceDrawData = new DrawData(extraPieceTexture, headDrawPosition, frame, drawInfo.eyeColor, drawPlayer.fullRotation, origin, 1f, drawInfo.spriteEffects, 0); + Main.playerDrawData.Add(pieceDrawData); + } + if (headItemType == ModContent.ItemType()) + { + headDrawPosition.X -= drawPlayer.direction == 1f ? 16f : 4.5f; + headDrawPosition.Y -= 10f; + + Texture2D extraPieceTexture = ModContent.GetTexture("CalamityMod/Items/Armor/Vanity/ApolloMask_Extra"); + DrawData pieceDrawData = new DrawData(extraPieceTexture, headDrawPosition, drawPlayer.bodyFrame, drawInfo.eyeColor, 0f, origin, 1f, drawInfo.spriteEffects, 0); + Main.playerDrawData.Add(pieceDrawData); + } + }); + + public static readonly PlayerLayer ForbiddenCircletSign = new PlayerLayer("CalamityMod", "ForbiddenSigil", PlayerLayer.BackAcc, drawInfo => { DrawData drawData = new DrawData(); Player drawPlayer = drawInfo.drawPlayer; @@ -656,20 +737,24 @@ namespace CalamityMod.CalPlayer list[list.IndexOf(PlayerLayer.ShoeAcc)].visible = false; if (player.Calamity().fab || player.Calamity().crysthamyr || player.Calamity().onyxExcavator) - { AddPlayerLayer(list, clAfterAll, list[list.Count - 1], false); - } + + if (player.heldProj != -1 && Main.projectile[player.heldProj].active && Main.projectile[player.heldProj].type == ModContent.ProjectileType()) + list.Insert(list.IndexOf(PlayerLayer.Arms), DrawRancorBookManually); if (player.Calamity().fathomSwarmerTail) { int skinIndex = list.IndexOf(PlayerLayer.Skin); list.Insert(skinIndex - 1, Tail); } + if (player.Calamity().forbiddenCirclet) { int drawTheStupidSign = list.IndexOf(PlayerLayer.Skin); list.Insert(drawTheStupidSign, ForbiddenCircletSign); } + + list.Add(ArtemisAndApolloMaskPieces); list.Add(ColdDivinityOverlay); list.Add(ConcentratedVoidAura); list.Add(RoverDriveShield); @@ -685,8 +770,269 @@ namespace CalamityMod.CalPlayer { CalamityPlayer calamityPlayer = player.Calamity(); - // Dust modifications while high. - if (calamityPlayer.trippy) + if (Main.myPlayer == player.whoAmI && !Main.gameMenu) + { + if (CalamityConfig.Instance.SpeedrunTimer) + { + double fractionsOfSeconds = calamityPlayer.speedrunTimer / 60D; + fractionsOfSeconds -= Math.Truncate(fractionsOfSeconds); + fractionsOfSeconds *= 1000D; + int milliseconds = (int)Math.Truncate(fractionsOfSeconds); + int seconds = calamityPlayer.speedrunTimer / 60; + int minutes = calamityPlayer.speedrunTimer / 3600; + int hours = calamityPlayer.speedrunTimer / 216000; + + seconds -= minutes * 60; + minutes -= hours * 60; + + if (hours > 99) + { + seconds = minutes = 59; + hours = 99; + } + + string fractionsOfSecondsText = milliseconds > 99 ? milliseconds.ToString() : "0" + milliseconds.ToString(); + string secondsText = seconds > 9 ? seconds.ToString() : "0" + seconds.ToString(); + string minutesText = minutes > 9 ? minutes.ToString() : "0" + minutes.ToString(); + string hoursText = hours > 9 ? hours.ToString() : "0" + hours.ToString(); + + string text = hoursText + ":" + minutesText + ":" + secondsText + "." + fractionsOfSecondsText; + float scale = 2f; + float xOffset = CalamityConfig.Instance.SpeedrunTimerPosX; + float yOffset = CalamityConfig.Instance.SpeedrunTimerPosY; + + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale); + + if (calamityPlayer.bossTypeJustDowned > -1) + { + fractionsOfSeconds = calamityPlayer.bossTypeJustDownedTime / 60D; + fractionsOfSeconds -= Math.Truncate(fractionsOfSeconds); + fractionsOfSeconds *= 1000D; + milliseconds = (int)Math.Truncate(fractionsOfSeconds); + seconds = calamityPlayer.bossTypeJustDownedTime / 60; + minutes = calamityPlayer.bossTypeJustDownedTime / 3600; + hours = calamityPlayer.bossTypeJustDownedTime / 216000; + + seconds -= minutes * 60; + minutes -= hours * 60; + + if (hours > 99) + { + seconds = minutes = 59; + hours = 99; + } + + fractionsOfSecondsText = milliseconds > 99 ? milliseconds.ToString() : "0" + milliseconds.ToString(); + secondsText = seconds > 9 ? seconds.ToString() : "0" + seconds.ToString(); + minutesText = minutes > 9 ? minutes.ToString() : "0" + minutes.ToString(); + hoursText = hours > 9 ? hours.ToString() : "0" + hours.ToString(); + + text = hoursText + ":" + minutesText + ":" + secondsText + "." + fractionsOfSecondsText; + scale = 1f; + yOffset += 44f; + + Texture2D texture = null; + switch (calamityPlayer.bossTypeJustDowned) + { + // King Slime + case 1: + texture = Main.npcHeadBossTexture[7]; + break; + + case 2: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Eye of Cthulhu + case 3: + texture = Main.npcHeadBossTexture[1]; + break; + + case 4: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Eater of Worlds + case 5: + texture = Main.npcHeadBossTexture[2]; + break; + + // Brain of Cthulhu + case 6: + texture = Main.npcHeadBossTexture[23]; + break; + + case 7: + texture = ModContent.GetTexture("CalamityMod/NPCs/HiveMind/HiveMindP2_Head_Boss"); + break; + + case 8: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Queen Bee + case 9: + texture = Main.npcHeadBossTexture[14]; + break; + + // Skeletron + case 10: + texture = Main.npcHeadBossTexture[19]; + break; + + case 11: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Wall of Flesh + case 12: + texture = Main.npcHeadBossTexture[22]; + break; + + case 13: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // The Twins + case 14: + texture = Main.npcHeadBossTexture[21]; + break; + + case 15: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // The Destroyer + case 16: + texture = Main.npcHeadBossTexture[25]; + break; + + case 17: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Skeletron Prime + case 18: + texture = Main.npcHeadBossTexture[18]; + break; + + case 19: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Plantera + case 20: + texture = Main.npcHeadBossTexture[12]; + break; + + case 21: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 22: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Golem + case 23: + texture = Main.npcHeadBossTexture[5]; + break; + + case 24: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Duke Fishron + case 25: + texture = Main.npcHeadBossTexture[4]; + break; + + case 26: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Lunatic Cultist + case 27: + texture = Main.npcHeadBossTexture[31]; + break; + + case 28: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + // Moon Lord + case 29: + texture = Main.npcHeadBossTexture[8]; + break; + + case 30: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 31: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 32: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 33: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 34: + texture = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked_Head_Boss"); + break; + + case 35: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 36: + texture = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/Necroplasm_Head_Boss"); + break; + + case 37: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 38: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 39: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 40: + texture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/HoodlessHeadIcon"); + break; + + case 41: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + case 42: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; + + default: + break; + } + + xOffset -= 58f; + + if (texture != null) + Main.spriteBatch.Draw(texture, new Vector2(Main.screenWidth / 2f - xOffset - texture.Width - 4f, yOffset), null, Color.White, 0f, default, 1f, SpriteEffects.None, 0f); + + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale); + } + } + } + + // Dust modifications while high. + if (calamityPlayer.trippy) { if (Main.myPlayer == player.whoAmI) { diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index d06f0c6a7e..442081cf6f 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -482,7 +482,7 @@ namespace CalamityMod.CalPlayer } } - Vector2 startingStickPosition = player.Center + stickOffset + Vector2.UnitY * 12f; + Vector2 startingStickPosition = player.Center + stickOffset + new Vector2(direction * (float)Math.Cos(modPlayer.SmoothenedMinecartRotation * 2f) * -34f, 12f); modPlayer.DoGCartSegments[0].Update(player, startingStickPosition, idealRotation); modPlayer.DoGCartSegments[0].Center = startingStickPosition; @@ -1079,7 +1079,7 @@ namespace CalamityMod.CalPlayer modPlayer.AllCritBoost(critUp); } - bool canProvideBuffs = modPlayer.profanedCrystalBuffs || (!modPlayer.profanedCrystal && modPlayer.pArtifact) || (modPlayer.profanedCrystal && CalamityWorld.downedSCal); + bool canProvideBuffs = modPlayer.profanedCrystalBuffs || (!modPlayer.profanedCrystal && modPlayer.pArtifact) || (modPlayer.profanedCrystal && CalamityWorld.downedSCal && CalamityWorld.downedExoMechs); bool attack = player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; // Guardian bonuses if not burnt out if (!modPlayer.bOut && canProvideBuffs) @@ -3004,7 +3004,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.pFlames) { - player.blind = !modPlayer.alchFlask; + player.blind = !modPlayer.reducedPlagueDmg; player.statDefense -= Plague.DefenseReduction; player.moveSpeed -= 0.15f; } @@ -3482,7 +3482,6 @@ namespace CalamityMod.CalPlayer player.lifeRegen += 5; } bool enrage = player.statLife <= (int)(player.statLifeMax2 * 0.5); - bool notRetro = Lighting.NotRetro; if (!modPlayer.ZoneAbyss) //No abyss memes. Lighting.AddLight(player.Center, enrage ? 1.2f : offenseBuffs ? 1f : 0.2f, enrage ? 0.21f : offenseBuffs ? 0.2f : 0.01f, 0); if (enrage) diff --git a/CalamityConfig.cs b/CalamityConfig.cs index 51c27677d8..4a38eca484 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -118,6 +118,28 @@ namespace CalamityMod [Tooltip("The Y position of the Charge Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] public float ChargeMeterPosY { get; set; } + [Label("Speedrun Timer")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Enables a Speedrun Timer.")] + public bool SpeedrunTimer { get; set; } + + [Label("Speedrun Timer X Position")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(-800f, 800f)] + [DefaultValue(68f)] + [Tooltip("The X position of the Speedrun Timer.")] + public float SpeedrunTimerPosX { get; set; } + + [Label("Speedrun Timer Y Position")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(16f, 1000f)] + [DefaultValue(16f)] + [Tooltip("The Y position of the Speedrun Timer.")] + public float SpeedrunTimerPosY { get; set; } + [Header("General Gameplay Changes")] [Label("Early Hardmode Progression Rework")] @@ -142,12 +164,6 @@ namespace CalamityMod [Tooltip("Enables the Proficiency system which allows the player to gain slight stat bonuses by persistently using one damage class.\nDisabling the system does not remove levels players already have, but disables their stat bonuses and prevents experience gain.")] public bool Proficiency { get; set; } - [Label("Sell Vanilla Boss Summons")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Adds vanilla boss summons to NPC shops after the corresponding boss is defeated.\nThis does not affect Calamity's boss summons, which are always sold.\nTo apply changes, close and reopen the shop.")] - public bool SellVanillaSummons { get; set; } - [Label("Boss Zen")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] diff --git a/CalamityLists.cs b/CalamityLists.cs index cb33cda65c..2b1f69ad4e 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -37,7 +37,9 @@ using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Apollo; using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Artemis; using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.GreatSandShark; using CalamityMod.NPCs.HiveMind; @@ -47,6 +49,8 @@ using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Perforator; using CalamityMod.NPCs.PlaguebringerGoliath; using CalamityMod.NPCs.PlagueEnemies; +using CalamityMod.NPCs.Polterghast; +using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.Ravager; using CalamityMod.NPCs.Signus; @@ -62,7 +66,6 @@ using CalamityMod.Projectiles.Enemy; using CalamityMod.Projectiles.Hybrid; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Melee.Spears; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; @@ -155,6 +158,8 @@ namespace CalamityMod public static List pierceResistList; public static List pierceResistExceptionList; + public static SortedDictionary bossTypes; + public static List legOverrideList; public static List kamiDebuffColorImmuneList; @@ -225,7 +230,7 @@ namespace CalamityMod "Sandblast", "ThomasThePencil", "Aero (Aero#4599)", - "GlitchOut", + "Shirosity", // used to be GlitchOut "Daawnz", "CrabBar", "Yatagarasu", @@ -291,7 +296,7 @@ namespace CalamityMod "Mendzey", "GameRDheAsianSandwich", "Tobias", - "Streakist .", + "Streakist", "Eisaya", "Xenocrona", "RKMoon", @@ -308,7 +313,7 @@ namespace CalamityMod "dawn thunder", "asdf935", "GentSkeleton", - "Fizzlpoprock .", + "Fizzlpoprock", "Pigeon", "Aleksh", "Just a random guy", @@ -359,7 +364,7 @@ namespace CalamityMod "Timon", "F00d Demon", "Olkothan", - "Vmar98 .", + "Vmar98", "Dasdruid", "Cinder", "Brutzli", @@ -414,7 +419,7 @@ namespace CalamityMod "Arcadia", "JensB__", "Nuclei", - "Picasso’s Bean", + "Picasso's Bean", "Corn M. Cobb", "kgh8090", "Luke", @@ -509,7 +514,7 @@ namespace CalamityMod "WillyDilly", "xAqult", "Himakaze", - "Face.", + "Face", "Carboniferous", "James" }; @@ -579,6 +584,8 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), @@ -1354,6 +1361,7 @@ namespace CalamityMod fiftySizeBuffList = new List() { + ItemID.EnchantedSword, ItemID.BreakerBlade, ItemID.StylistKilLaKillScissorsIWish, ItemID.NightsEdge, @@ -1938,12 +1946,8 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), NPCType(), NPCType(), NPCType(), @@ -2701,18 +2705,15 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), - NPCType(), + NPCType(), + NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), - NPCType(), NPCType(), NPCType(), NPCType(), @@ -2769,6 +2770,61 @@ namespace CalamityMod ProjectileType() }; + bossTypes = new SortedDictionary() + { + { NPCID.KingSlime, 1 }, + { NPCType(), 2 }, + { NPCID.EyeofCthulhu, 3 }, + { NPCType(), 4 }, + { NPCID.EaterofWorldsHead, 5 }, + { NPCID.EaterofWorldsBody, 5 }, + { NPCID.EaterofWorldsTail, 5 }, + { NPCID.BrainofCthulhu, 6 }, + { NPCType(), 7 }, + { NPCType(), 8 }, + { NPCID.QueenBee, 9 }, + { NPCID.SkeletronHead, 10 }, + { NPCType(), 11 }, + { NPCType(), 11 }, + { NPCType(), 11 }, + { NPCID.WallofFlesh, 12 }, + { NPCType(), 13 }, + { NPCID.Retinazer, 14 }, + { NPCID.Spazmatism, 14 }, + { NPCType(), 15 }, + { NPCID.TheDestroyer, 16 }, + { NPCType(), 17 }, + { NPCID.SkeletronPrime, 18 }, + { NPCType(), 19 }, + { NPCID.Plantera, 20 }, + { NPCType(), 21 }, + { NPCType(), 21 }, + { NPCType(), 22 }, + { NPCID.Golem, 23 }, + { NPCType(), 24 }, + { NPCID.DukeFishron, 25 }, + { NPCType(), 26 }, + { NPCID.CultistBoss, 27 }, + { NPCType(), 28 }, + { NPCID.MoonLordCore, 29 }, + { NPCType(), 30 }, + { NPCType(), 31 }, + { NPCType(), 32 }, + { NPCType(), 33 }, + { NPCType(), 34 }, + { NPCType(), 35 }, + { NPCType(), 36 }, + { NPCType(), 37 }, + { NPCType(), 38 }, + { NPCType(), 39 }, + { NPCType(), 40 }, + { NPCType(), 41 }, + { NPCType(), 41 }, + { NPCType(), 41 }, + { NPCType(), 41 }, + { NPCType(), 42 } + }; + bossMinionList = new List() { NPCType(), @@ -2894,7 +2950,10 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType() + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType() }; ZeroMinionSlotExceptionList = new List() @@ -2999,6 +3058,9 @@ namespace CalamityMod pierceResistList = null; pierceResistExceptionList = null; + bossTypes?.Clear(); + bossTypes = null; + legOverrideList = null; kamiDebuffColorImmuneList = null; diff --git a/CalamityMod.cs b/CalamityMod.cs index b7bff76bd1..657b1a3131 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -62,6 +62,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Config; using Terraria.UI; +using CalamityMod.Particles; namespace CalamityMod { @@ -241,9 +242,6 @@ namespace CalamityMod Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.1f, 1.0f).UseOpacity(0.5f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:DevourerofGodsHead"] = new DoGSky(); - Filters.Scene["CalamityMod:DevourerofGodsHeadS"] = new Filter(new DoGScreenShaderDataS("FilterMiniTower").UseColor(0.4f, 0.1f, 1.0f).UseOpacity(0.5f), EffectPriority.VeryHigh); - SkyManager.Instance["CalamityMod:DevourerofGodsHeadS"] = new DoGSkyS(); - Filters.Scene["CalamityMod:CalamitasRun3"] = new Filter(new CalScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.6f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:CalamitasRun3"] = new CalSky(); @@ -279,14 +277,21 @@ namespace CalamityMod SkyManager.Instance["CalamityMod:StormWeaverFlash"] = new StormWeaverFlashSky(); CalamityShaders.LoadShaders(); + FusableParticleManager.LoadParticleRenderSets(); + Main.OnPreDraw += _ => FusableParticleManager.PrepareFusableParticleTargets(); RipperUI.Load(); AstralArcanumUI.Load(this); Apollo.LoadHeadIcons(); Artemis.LoadHeadIcons(); + DevourerofGodsHead.LoadHeadIcons(); + DevourerofGodsBody.LoadHeadIcons(); + DevourerofGodsTail.LoadHeadIcons(); + HiveMind.LoadHeadIcons(); Polterghast.LoadHeadIcons(); - SupremeCalamitas.LoadHeadIcons(); + StormWeaverHead.LoadHeadIcons(); + SupremeCalamitas.LoadHeadIcons(); ThanatosHead.LoadHeadIcons(); ThanatosBody1.LoadHeadIcons(); ThanatosBody2.LoadHeadIcons(); @@ -355,6 +360,9 @@ namespace CalamityMod TileFraming.Unload(); + FusableParticleManager.UnloadParticleRenderSets(); + Main.OnPreDraw -= _ => FusableParticleManager.PrepareFusableParticleTargets(); + RipperUI.Unload(); AstralArcanumUI.Unload(); @@ -404,6 +412,19 @@ namespace CalamityMod } #endregion + #region Fusable Particle Updating + public override void MidUpdateProjectileItem() + { + // Update all fusable particles. + // These are really only visual and as such don't really need any complex netcode. + foreach (BaseFusableParticleSet.FusableParticleRenderCollection particleSet in FusableParticleManager.ParticleSets) + { + foreach (BaseFusableParticleSet.FusableParticle particle in particleSet.ParticleSet.Particles) + particleSet.ParticleSet.UpdateBehavior(particle); + } + } + #endregion + #region Vanilla Enemy DR private void SetupVanillaDR() { @@ -555,8 +576,7 @@ namespace CalamityMod { ModContent.NPCType(), 3600 }, { ModContent.NPCType(), 3600 }, { ModContent.NPCType(), 5400 }, - { ModContent.NPCType(), 1800 }, - { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 7200 }, { ModContent.NPCType(), 7200 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 5400 }, @@ -583,18 +603,15 @@ namespace CalamityMod { ModContent.NPCType(), 14400 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 1200 }, - { ModContent.NPCType(), 7200 }, - { ModContent.NPCType(), 7200 }, - { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 8100 }, + { ModContent.NPCType(), 8100 }, + { ModContent.NPCType(), 8100 }, { ModContent.NPCType(), 7200 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, - { ModContent.NPCType(), 5400 }, - { ModContent.NPCType(), 5400 }, - { ModContent.NPCType(), 5400 }, - { ModContent.NPCType(), 9000 }, - { ModContent.NPCType(), 9000 }, - { ModContent.NPCType(), 9000 }, + { ModContent.NPCType(), 14400 }, + { ModContent.NPCType(), 14400 }, + { ModContent.NPCType(), 14400 }, { ModContent.NPCType(), 15300 }, { ModContent.NPCType(), 18000 }, { ModContent.NPCType(), 21600 }, @@ -657,7 +674,7 @@ namespace CalamityMod { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), bitingEnemeyVelocityScale }, - { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), bitingEnemeyVelocityScale }, { ModContent.NPCType(), velocityScaleMin }, @@ -710,9 +727,6 @@ namespace CalamityMod { 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(), bitingEnemeyVelocityScale }, @@ -724,9 +738,6 @@ namespace CalamityMod { 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 }, @@ -828,14 +839,6 @@ namespace CalamityMod music = GetMusicFromMusicMod("Sulphur") ?? MusicID.Desert; } } - if (CalamityWorld.DoGSecondStageCountdown <= 530 && CalamityWorld.DoGSecondStageCountdown > 50) // 8 seconds before DoG spawns - { - if (!CalamityPlayer.areThereAnyDamnBosses) - { - music = GetMusicFromMusicMod("UniversalCollapse") ?? MusicID.LunarBoss; - priority = MusicPriority.BossMedium; - } - } // This section handles boss rush music. However, at the time of PR-ing the boss rush visuals branch not all // of the boss rush themes have been completed. As such, the custom music is intentionally omitted for the time being. diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index 0dcb703949..64f1b013b6 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -280,11 +280,11 @@ namespace CalamityMod Main.player[reader.ReadInt32()].Calamity().HandleReforgeTierSafety(reader); break; - // - // Default case: with no idea how long the packet is, we can't safely read data. - // Throw an exception now instead of allowing the network stream to corrupt. - // - default: + // + // Default case: with no idea how long the packet is, we can't safely read data. + // Throw an exception now instead of allowing the network stream to corrupt. + // + default: CalamityMod.Instance.Logger.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {msgType}."); throw new Exception("Failed to parse Calamity packet: Invalid Calamity packet ID."); } @@ -399,6 +399,6 @@ namespace CalamityMod // Reforge syncs ItemTypeLastReforgedSync, // TODO -- there has to be a better way to do this, but I don't know what it is - ReforgeTierSafetySync, - } + ReforgeTierSafetySync + } } diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 57c7475a92..c50ec787a4 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -23,6 +23,10 @@ namespace CalamityMod.Effects public static Effect PrismCrystalShader; public static Effect ImpFlameTrailShader; public static Effect SCalShieldShader; + public static Effect RancorMagicCircleShader; + + public static Effect BaseFusableParticleEdgeShader; + public static Effect AdditiveFusableParticleEdgeShader; public static void LoadShaders() { @@ -44,6 +48,10 @@ namespace CalamityMod.Effects FadingSolidTrailShader = CalamityMod.Instance.GetEffect("Effects/FadingSolidTrail"); ImpFlameTrailShader = CalamityMod.Instance.GetEffect("Effects/ImpFlameTrail"); SCalShieldShader = CalamityMod.Instance.GetEffect("Effects/SupremeShieldShader"); + RancorMagicCircleShader = CalamityMod.Instance.GetEffect("Effects/RancorMagicCircle"); + + BaseFusableParticleEdgeShader = CalamityMod.Instance.GetEffect("Effects/ParticleFusion/BaseFusableParticleEdgeShader"); + AdditiveFusableParticleEdgeShader = CalamityMod.Instance.GetEffect("Effects/ParticleFusion/AdditiveFusableParticleEdgeShader"); Filters.Scene["CalamityMod:Astral"] = new Filter(new AstralScreenShaderData(new Ref(AstralFogShader), "AstralPass").UseColor(0.18f, 0.08f, 0.24f), EffectPriority.VeryHigh); @@ -63,6 +71,10 @@ namespace CalamityMod.Effects GameShaders.Misc["CalamityMod:PrismaticStreak"] = new MiscShaderData(new Ref(PrismCrystalShader), "TrailPass"); GameShaders.Misc["CalamityMod:ImpFlameTrail"] = new MiscShaderData(new Ref(ImpFlameTrailShader), "TrailPass"); GameShaders.Misc["CalamityMod:SupremeShield"] = new MiscShaderData(new Ref(SCalShieldShader), "ShieldPass"); + GameShaders.Misc["CalamityMod:RancorMagicCircle"] = new MiscShaderData(new Ref(RancorMagicCircleShader), "ShieldPass"); + + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"] = new MiscShaderData(new Ref(BaseFusableParticleEdgeShader), "ParticlePass"); + GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"] = new MiscShaderData(new Ref(AdditiveFusableParticleEdgeShader), "ParticlePass"); } } } diff --git a/Effects/ImpFlameTrail.fx b/Effects/ImpFlameTrail.fx new file mode 100644 index 0000000000..b2e2d4b511 --- /dev/null +++ b/Effects/ImpFlameTrail.fx @@ -0,0 +1,64 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +// Inputted images go into uImage1 sampler, in case you have a noise map or something similar. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + // Fade out at the edges of the trail to give a blur effect. + // This is very important. + float flameStreakBrightness = tex2D(uImage1, float2(frac(coords.x - uTime * 2.9), coords.y)).r; + float bloomOpacity = lerp(pow(sin(coords.y * 3.141), lerp(3, 10, coords.x)), 0.7, coords.x); + return color * pow(bloomOpacity, 6.0) * lerp(2.0, 7, flameStreakBrightness); +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx b/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx new file mode 100644 index 0000000000..0181c7fec2 --- /dev/null +++ b/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx @@ -0,0 +1,50 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float edgeBorderSize; +bool borderShouldBeSolid; +float3 edgeBorderColor; +float2 screenArea; +float2 renderTargetArea; +float2 screenMoveOffset; +float2 generalBackgroundOffset; +bool invertedScreen; +float2 upscaleFactor; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float2 originalCoords = coords; + if (invertedScreen) + coords.y = 1 - coords.y; + + // Account for screen movements. Not doing this causes the scene to move based on that. + coords += screenMoveOffset / renderTargetArea; + + float2 offset = 3 / screenArea; + float4 color = tex2D(uImage0, coords); + float4 leftColor = tex2D(uImage0, coords + float2(-offset.x, 0)); + float4 rightColor = tex2D(uImage0, coords + float2(-offset.x, 0)); + float4 topColor = tex2D(uImage0, coords + float2(0, -offset.y)); + float4 bottomColor = tex2D(uImage0, coords + float2(0, offset.y)); + float4 avergeColor = (color + leftColor + rightColor + topColor + bottomColor) / 4.7; + avergeColor = lerp(avergeColor, float4(1, 1, 1, 1), pow(avergeColor.b, 0.5)) * avergeColor.a; + return avergeColor; +} +technique Technique1 +{ + pass ParticlePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb b/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb new file mode 100644 index 0000000000..c25b1c138e Binary files /dev/null and b/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb differ diff --git a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx new file mode 100644 index 0000000000..77470954e8 --- /dev/null +++ b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx @@ -0,0 +1,77 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float edgeBorderSize; +bool borderShouldBeSolid; +float3 edgeBorderColor; +float2 screenArea; +float2 renderTargetArea; +float2 screenMoveOffset; +float2 generalBackgroundOffset; +bool invertedScreen; +float2 upscaleFactor; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float2 originalCoords = coords; + if (invertedScreen) + coords.y = 1 - coords.y; + + // Account for screen movements. Not doing this causes the scene to move based on that. + coords += screenMoveOffset / renderTargetArea; + + float4 color = tex2D(uImage0, coords); + + // Determine how much downscaling is required to reasonably zoom in on things. + float downscaleFactor = float2(5, 5) / upscaleFactor / max(renderTargetArea.x, renderTargetArea.y) / 2; + float2 backgroundCoords = frac((renderTargetArea * (originalCoords + generalBackgroundOffset * upscaleFactor) + uWorldPosition) * downscaleFactor); + float4 backgroundColor = tex2D(uImage1, backgroundCoords); + + // Equivalent to edgeBorderSize pixels in both the X and Y direction. + float2 edgeOffset = float2(edgeBorderSize, edgeBorderSize) / renderTargetArea; + + // Check if the cardinal directions are not intersecting with any other active parts of the render target. + // If one of them isn't, that means that a border should be rendered. + float4 aboveColor = tex2D(uImage0, coords + float2(0, edgeOffset.y)); + float4 belowColor = tex2D(uImage0, coords - float2(0, edgeOffset.y)); + float4 leftColor = tex2D(uImage0, coords + float2(edgeOffset.x, 0)); + float4 rightColor = tex2D(uImage0, coords - float2(edgeOffset.x, 0)); + + // Invert color check thresholds based on whether the border should be solid when drawing. + float checkThreshold = 0.02; + if (!borderShouldBeSolid) + checkThreshold = 0.95; + + // If any cardinal color is sufficiently close to transparency choose an edge border color. + // Opacity multipliers ensure that this does not affect completely invisible areas of the render target. + if (aboveColor.r < checkThreshold || belowColor.r < checkThreshold || leftColor.r < checkThreshold || rightColor.r < checkThreshold) + { + float borderOpacity = color.a; + + // Use binary opacity if the border should be solid when drawing. + if (borderOpacity > 0 && borderShouldBeSolid) + borderOpacity = 1; + + return float4(edgeBorderColor, 1) * borderOpacity; + } + + return backgroundColor; +} +technique Technique1 +{ + pass ParticlePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb new file mode 100644 index 0000000000..ceff80f4eb Binary files /dev/null and b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb differ diff --git a/Effects/RancorMagicCircle.fx b/Effects/RancorMagicCircle.fx new file mode 100644 index 0000000000..375d8b56c1 --- /dev/null +++ b/Effects/RancorMagicCircle.fx @@ -0,0 +1,80 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity : register(C0); +float uSaturation; +float uCircularRotation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float2 overallImageSize; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float2 Coordinates : TEXCOORD0; + float4 Color : COLOR0; +}; + +struct VertexShaderOutput +{ + float4 Position : POSITION0; + float2 Coordinates : TEXCOORD0; + float4 Color : COLOR0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput) 0; + float2 coords = input.Coordinates - 0.5; + float rotationSine = sin(uSaturation); + float rotationCosine = cos(uSaturation); + float rotationOriginSine = sin(uCircularRotation); + float rotationOriginCosine = cos(uCircularRotation); + float2x2 rotationMatrix = float2x2(rotationCosine, -rotationSine, rotationSine, rotationCosine); + float2x2 circularRotationMatrix = float2x2(rotationOriginCosine, -rotationOriginSine, rotationOriginSine, rotationOriginCosine); + float2x2 scalingMatrix = float2x2(2, 0, 0, 1); + + output.Color = input.Color; + + // Rotate based on direction, squash the result, and then rotate the squashed result by the circular rotation. + output.Coordinates = mul(input.Coordinates - 0.5, rotationMatrix) + 0.5; + output.Coordinates = mul(output.Coordinates - 0.5, scalingMatrix) + 0.5; + output.Coordinates = mul(output.Coordinates - 0.5, circularRotationMatrix) + 0.5; + output.Position = mul(input.Position, uWorldViewProjection); + + return output; +} + +float4 PixelFunction(VertexShaderOutput input) : COLOR0 +{ + float2 updatedCoords = input.Coordinates; + + // Adjust for horizontal rotation. + if (uDirection == -1) + updatedCoords.y = 1 - updatedCoords.y; + + float overallAdjustedYCoord = 0.5 + lerp(-uImageSize0.y / overallImageSize.y, uImageSize0.y / overallImageSize.y, updatedCoords.y) * 0.5; + float4 baseColor = tex2D(uImage0, updatedCoords); + float colorFade = abs(sin(overallAdjustedYCoord + uTime * 0.5)); + float luminosity = (baseColor.r + baseColor.g + baseColor.b) / 3; + float4 endColor = baseColor * float4(lerp(uColor, uSecondaryColor, colorFade), 1); + endColor *= 1 + luminosity * 0.5; + return (endColor * 0.7 + baseColor * 0.5) * baseColor.a * uOpacity; +} + +technique Technique1 +{ + pass ShieldPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelFunction(); + } +} \ No newline at end of file diff --git a/Effects/RancorMagicCircle.xnb b/Effects/RancorMagicCircle.xnb new file mode 100644 index 0000000000..dc60d07484 Binary files /dev/null and b/Effects/RancorMagicCircle.xnb differ diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 33bd251e41..256147d88a 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -97,12 +97,6 @@ namespace CalamityMod.Events #region Loading and Unloading public static void Load() { - BossIDsAfterDeath = new Dictionary() - { - [ModContent.NPCType()] = new int[] { ModContent.NPCType() }, - [ModContent.NPCType()] = new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, - }; - Bosses = new List() { new Boss(NPCID.QueenBee), @@ -297,13 +291,13 @@ namespace CalamityMod.Events new Boss(ModContent.NPCType(), TimeChangeContext.Day, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType() }), - new Boss(ModContent.NPCType(), TimeChangeContext.Day, type => + new Boss(ModContent.NPCType(), TimeChangeContext.Day, type => { Player player = Main.player[ClosestPlayerToWorldCenter]; Main.PlaySound(CalamityMod.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerSpawn"), player.Center); NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, type); - }, usesSpecialSound: true, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType() }) + }, usesSpecialSound: true, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType() }) }; BossDeathEffects = new Dictionary>() @@ -324,7 +318,7 @@ namespace CalamityMod.Events { CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.BossRushTierFourEndText", XerocTextColor); }, - [ModContent.NPCType()] = npc => + [ModContent.NPCType()] = npc => { CalamityUtils.KillAllHostileProjectiles(); CalamityWorld.bossRushHostileProjKillCounter = 3; diff --git a/ExtraTextures/FusableParticleBase.png b/ExtraTextures/FusableParticleBase.png new file mode 100644 index 0000000000..643741e8c9 Binary files /dev/null and b/ExtraTextures/FusableParticleBase.png differ diff --git a/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer1.png b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer1.png new file mode 100644 index 0000000000..6fa91e47c6 Binary files /dev/null and b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer1.png differ diff --git a/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer2.png b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer2.png new file mode 100644 index 0000000000..fa613099bc Binary files /dev/null and b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer2.png differ diff --git a/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer3.png b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer3.png new file mode 100644 index 0000000000..69d693fff4 Binary files /dev/null and b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer3.png differ diff --git a/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer4.png b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer4.png new file mode 100644 index 0000000000..66c8779153 Binary files /dev/null and b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer4.png differ diff --git a/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer5.png b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer5.png new file mode 100644 index 0000000000..cd326c90cd Binary files /dev/null and b/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer5.png differ diff --git a/ExtraTextures/THanosAura.png b/ExtraTextures/THanosAura.png new file mode 100644 index 0000000000..017fb7e25d Binary files /dev/null and b/ExtraTextures/THanosAura.png differ diff --git a/ExtraTextures/ThanatosReticleHead.png b/ExtraTextures/ThanatosReticleHead.png new file mode 100644 index 0000000000..e99eb727fe Binary files /dev/null and b/ExtraTextures/ThanatosReticleHead.png differ diff --git a/ExtraTextures/ThanatosReticleLeft.png b/ExtraTextures/ThanatosReticleLeft.png new file mode 100644 index 0000000000..352f281429 Binary files /dev/null and b/ExtraTextures/ThanatosReticleLeft.png differ diff --git a/ExtraTextures/ThanatosReticleProngLeft.png b/ExtraTextures/ThanatosReticleProngLeft.png new file mode 100644 index 0000000000..cc17cca2bd Binary files /dev/null and b/ExtraTextures/ThanatosReticleProngLeft.png differ diff --git a/ExtraTextures/ThanatosReticleProngRight.png b/ExtraTextures/ThanatosReticleProngRight.png new file mode 100644 index 0000000000..21f2487e14 Binary files /dev/null and b/ExtraTextures/ThanatosReticleProngRight.png differ diff --git a/ExtraTextures/ThanatosReticleRight.png b/ExtraTextures/ThanatosReticleRight.png new file mode 100644 index 0000000000..0cf153056b Binary files /dev/null and b/ExtraTextures/ThanatosReticleRight.png differ diff --git a/ExtraTextures/ThanatosReticleTop.png b/ExtraTextures/ThanatosReticleTop.png new file mode 100644 index 0000000000..8bb8ff0fc5 Binary files /dev/null and b/ExtraTextures/ThanatosReticleTop.png differ diff --git a/Gores/LecherousOrb/LecherousGore1.png b/Gores/LecherousOrb/LecherousGore1.png new file mode 100644 index 0000000000..6f60c2164b Binary files /dev/null and b/Gores/LecherousOrb/LecherousGore1.png differ diff --git a/Gores/LecherousOrb/LecherousGore2.png b/Gores/LecherousOrb/LecherousGore2.png new file mode 100644 index 0000000000..fd566cef6a Binary files /dev/null and b/Gores/LecherousOrb/LecherousGore2.png differ diff --git a/Gores/LecherousOrb/LecherousGore3.png b/Gores/LecherousOrb/LecherousGore3.png new file mode 100644 index 0000000000..1dae099ecd Binary files /dev/null and b/Gores/LecherousOrb/LecherousGore3.png differ diff --git a/Gores/LecherousOrb/LecherousGore4.png b/Gores/LecherousOrb/LecherousGore4.png new file mode 100644 index 0000000000..f5b67a16a9 Binary files /dev/null and b/Gores/LecherousOrb/LecherousGore4.png differ diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index a7b7155fa4..00d622ca45 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -5,6 +5,7 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Ravager; +using CalamityMod.Particles; using CalamityMod.Projectiles; using CalamityMod.Tiles.DraedonStructures; using CalamityMod.World; @@ -17,6 +18,7 @@ using System; using System.Collections.Generic; using System.Reflection; using Terraria; +using Terraria.GameContent.Events; using Terraria.GameInput; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -129,7 +131,7 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.QuickMana += ApplyManaBurnIfNeeded; IL.Terraria.Player.ItemCheck += ApplyManaBurnIfNeeded; IL.Terraria.Player.AddBuff += AllowBuffTimeStackingForManaBurn; - IL.Terraria.Main.UpdateAudio += ManipulateSoundMuffleFactor; + IL.Terraria.Main.DoDraw += DrawFusableParticles; // Ravager platform fall fix On.Terraria.NPC.Collision_DecideFallThroughPlatforms += EnableCalamityBossPlatformCollision; @@ -145,6 +147,10 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.Update += RunSpeedAdjustments; IL.Terraria.Player.Update += ReduceWingHoverVelocities; + // Mana regen balance + IL.Terraria.Player.Update += ManaRegenDelayAdjustment; + IL.Terraria.Player.UpdateManaRegen += ManaRegenAdjustment; + // World generation IL.Terraria.WorldGen.Pyramid += ReplacePharaohSetInPyramids; IL.Terraria.WorldGen.MakeDungeon += PreventDungeonHorizontalCollisions; @@ -157,16 +163,17 @@ namespace CalamityMod.ILEditing // Removal of vanilla stupidity IL.Terraria.Item.Prefix += RelaxPrefixRequirements; On.Terraria.NPC.SlimeRainSpawns += PreventBossSlimeRainSpawns; + IL.Terraria.NPC.SpawnNPC += MakeVoodooDemonDollWork; // Fix vanilla bugs exposed by Calamity mechanics On.Terraria.Main.InitLifeBytes += BossRushLifeBytes; IL.Terraria.NPC.NPCLoot += FixSplittingWormBannerDrops; } - /// - /// Unloads all IL Editing changes in the mod. - /// - internal static void Unload() + /// + /// Unloads all IL Editing changes in the mod. + /// + internal static void Unload() { VanillaSpawnTownNPCs = null; labDoorOpen = labDoorClosed = aLabDoorOpen = aLabDoorClosed = -1; @@ -187,7 +194,7 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.QuickMana -= ApplyManaBurnIfNeeded; IL.Terraria.Player.ItemCheck -= ApplyManaBurnIfNeeded; IL.Terraria.Player.AddBuff -= AllowBuffTimeStackingForManaBurn; - IL.Terraria.Main.UpdateAudio -= ManipulateSoundMuffleFactor; + IL.Terraria.Main.DoDraw -= DrawFusableParticles; // Ravager platform fall fix On.Terraria.NPC.Collision_DecideFallThroughPlatforms -= EnableCalamityBossPlatformCollision; @@ -203,8 +210,12 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.Update -= RunSpeedAdjustments; IL.Terraria.Player.Update -= ReduceWingHoverVelocities; - // World generation - IL.Terraria.WorldGen.Pyramid -= ReplacePharaohSetInPyramids; + // Mana regen balance + IL.Terraria.Player.Update -= ManaRegenDelayAdjustment; + IL.Terraria.Player.UpdateManaRegen -= ManaRegenAdjustment; + + // World generation + IL.Terraria.WorldGen.Pyramid -= ReplacePharaohSetInPyramids; IL.Terraria.WorldGen.MakeDungeon -= PreventDungeonHorizontalCollisions; IL.Terraria.WorldGen.DungeonHalls -= PreventDungeonHallCollisions; IL.Terraria.WorldGen.GrowLivingTree -= BlockLivingTreesNearOcean; @@ -215,6 +226,7 @@ namespace CalamityMod.ILEditing // Removal of vanilla stupidity IL.Terraria.Item.Prefix -= RelaxPrefixRequirements; On.Terraria.NPC.SlimeRainSpawns -= PreventBossSlimeRainSpawns; + IL.Terraria.NPC.SpawnNPC -= MakeVoodooDemonDollWork; // Fix vanilla bugs exposed by Calamity mechanics On.Terraria.Main.InitLifeBytes -= BossRushLifeBytes; @@ -498,33 +510,6 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Brtrue, finalReturn); } - private static void ManipulateSoundMuffleFactor(ILContext il) - { - ILCursor cursor = new ILCursor(il); - cursor.GotoNext(MoveType.After, i => i.MatchStloc(20)); - - cursor.Emit(OpCodes.Ldloc, 20); - cursor.EmitDelegate>(originalMuffleFactor => - { - if (Main.gameMenu || !Main.LocalPlayer.active) - return originalMuffleFactor; - - float playerMuffleFactor = 1f - Main.LocalPlayer.Calamity().MusicMuffleFactor; - float result = MathHelper.Clamp(originalMuffleFactor * playerMuffleFactor, -1f, 1f); - if (result <= 0) - { - for (int i = 0; i < Main.music.Length; i++) - { - if (Main.music[i] != null && Main.music[i].IsPlaying) - Main.music[i].Stop(AudioStopOptions.Immediate); - } - Main.curMusic = 0; - } - return result; - }); - cursor.Emit(OpCodes.Stloc, 20); - } - #region Fire Cursor private static void UseCoolFireCursorEffect(On.Terraria.Main.orig_DrawCursor orig, Vector2 bonus, bool smart) { @@ -620,6 +605,36 @@ namespace CalamityMod.ILEditing Main.spriteBatch.Draw(crosshairTexture, baseDrawPosition, null, cursorColor, 0f, crosshairTexture.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f); } #endregion + + private static void DrawFusableParticles(ILContext il) + { + ILCursor cursor = new ILCursor(il); + + // Over NPCs but before Projectiles. + if (!cursor.TryGotoNext(c => c.MatchCallOrCallvirt
("SortDrawCacheWorms"))) + { + LogFailure("Fusable Particle Rendering", "Could not locate the SortDrawCacheWorms reference method to attach to."); + return; + } + cursor.EmitDelegate(() => FusableParticleManager.RenderAllFusableParticles(FusableParticleRenderLayer.OverNPCsBeforeProjectiles)); + + // Over Players. + if (!cursor.TryGotoNext(MoveType.After, c => c.MatchCallOrCallvirt
("DrawPlayers"))) + { + LogFailure("Fusable Particle Rendering", "Could not locate the DrawPlayers reference method to attach to."); + return; + } + cursor.EmitDelegate(() => FusableParticleManager.RenderAllFusableParticles(FusableParticleRenderLayer.OverPlayers)); + + // Over Water. + if (!cursor.TryGotoNext(c => c.MatchCallOrCallvirt("DrawWhite"))) + { + LogFailure("Fusable Particle Rendering", "Could not locate the DrawWhite reference method to attach to."); + return; + } + cursor.EmitDelegate(() => FusableParticleManager.RenderAllFusableParticles(FusableParticleRenderLayer.OverWater)); + } + #endregion #region Damage and health balance @@ -877,12 +892,57 @@ namespace CalamityMod.ILEditing cursor.Remove(); cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. } - #endregion + #endregion - #region World generation + #region Mana regen balance + private static void ManaRegenDelayAdjustment(ILContext il) + { + // Decrease the max mana regen delay so that mage is less annoying to play without mana regen buffs. + // Decreases the max mana regen delay from a range of 31.5 - 199.5 to 4 - 52. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(45f))) // The flat amount added to max regen delay in the formula. + { + LogFailure("Max Mana Regen Delay Reduction", "Could not locate the max mana regen flat variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 20f); // Decrease to 20f. - // Note: There is no need to replace the other Pharaoh piece, due to how the vanilla code works. - private static void ReplacePharaohSetInPyramids(ILContext il) + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.7f))) // The multiplier for max mana regen delay. + { + LogFailure("Max Mana Regen Delay Reduction", "Could not locate the max mana regen delay multiplier variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 0.2f); // Decrease to 0.2f. + } + + private static void ManaRegenAdjustment(ILContext il) + { + // Increase the base mana regen so that mage is less annoying to play without mana regen buffs. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.8f))) // The multiplier for the mana regen formula: (float)statMana / (float)statManaMax2 * 0.8f + 0.2f. + { + LogFailure("Mana Regen Buff", "Could not locate the mana regen multiplier variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 0.25f); // Decrease to 0.25f. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.2f))) // The flat added mana regen amount. + { + LogFailure("Mana Regen Buff", "Could not locate the flat mana regen variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 0.75f); // Increase to 0.75f. + } + #endregion + + #region World generation + + // Note: There is no need to replace the other Pharaoh piece, due to how the vanilla code works. + private static void ReplacePharaohSetInPyramids(ILContext il) { var cursor = new ILCursor(il); @@ -1094,6 +1154,31 @@ namespace CalamityMod.ILEditing if (!Main.player[plr].Calamity().bossZen) orig(plr); } + + // This may seem absolutely obscene, but vanilla spawn behavior does not occur within the spawn pool that TML provides, only modded + // spawns do. Pretty much everything else is simply a fuckton of manual conditional NPC.NewNPC calls. As such, the only way to bypass + // vanilla spawn behaviors is the IL edit them out of existence. Here, simply replacing the voodoo demon ID with an empty one is performed. + // Something cleaner could probably be done, such as getting rid of the entire NPC.NewNPC call, but this is the easiest solution I can come up with. + private static void MakeVoodooDemonDollWork(ILContext il) + { + var cursor = new ILCursor(il); + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(NPCID.VoodooDemon))) + { + LogFailure("Voodoo Demon Doll Mechanic", "Could not locate the Voodoo Demon ID."); + return; + } + + cursor.Remove(); + cursor.Emit(OpCodes.Ldloc, 6); + cursor.EmitDelegate>(spawnPlayerIndex => + { + if (Main.player[spawnPlayerIndex].active && Main.player[spawnPlayerIndex].Calamity().disableVoodooSpawns) + return NPCID.None; + + return NPCID.VoodooDemon; + }); + } #endregion #region Vanilla bugs exposed by Calamity mechanics diff --git a/Items/Accessories/AlchemicalFlask.cs b/Items/Accessories/AlchemicalFlask.cs index 2623c01dc2..2021cc3987 100644 --- a/Items/Accessories/AlchemicalFlask.cs +++ b/Items/Accessories/AlchemicalFlask.cs @@ -11,9 +11,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Alchemical Flask"); - Tooltip.SetDefault("All attacks inflict the plague\n" + - "Reduces the damage caused to you by the plague\n" + - "Removes the blindness effect caused by the plague\n" + + Tooltip.SetDefault("All attacks inflict the Plague debuff\n" + "Projectiles spawn plague seekers on enemy hits"); } @@ -30,14 +28,13 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.alchFlask = true; - modPlayer.reducedPlagueDmg = true; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); - recipe.AddIngredient(ItemID.Bezoar); + recipe.AddIngredient(ItemID.BeeWax, 5); recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); diff --git a/Items/Accessories/AstralArcanum.cs b/Items/Accessories/AstralArcanum.cs index e1bf06ca35..83e2a21bf6 100644 --- a/Items/Accessories/AstralArcanum.cs +++ b/Items/Accessories/AstralArcanum.cs @@ -28,6 +28,7 @@ namespace CalamityMod.Items.Accessories item.height = 26; item.value = CalamityGlobalItem.Rarity12BuyPrice; item.accessory = true; + item.expert = true; item.Calamity().customRarity = CalamityRarity.Turquoise; } diff --git a/Items/Accessories/PlagueHive.cs b/Items/Accessories/PlagueHive.cs index 2d750bbf8b..c728de6a65 100644 --- a/Items/Accessories/PlagueHive.cs +++ b/Items/Accessories/PlagueHive.cs @@ -13,12 +13,10 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Plague Hive"); - Tooltip.SetDefault("The power of your bees and wasps will rival the Moon Lord himself\n" + - "Summons a damaging plague aura around the player to destroy nearby enemies\n" + - "Releases bees when damaged\n" + - "All of your attacks inflict the plague\n" + - "Reduces the damage caused to you by the plague\n" + - "Projectiles spawn plague seekers on enemy hits"); + Tooltip.SetDefault("The power of bees and wasps will rival the Moon Lord himself\n" + + "All attacks inflict the Plague debuff\n" + + "Releases bees when damaged that inflict the Plague\n" + + "Projectiles spawn plague seekers on enemy hits"); } public override void SetDefaults() @@ -26,7 +24,6 @@ namespace CalamityMod.Items.Accessories item.width = 42; item.height = 48; item.value = CalamityGlobalItem.Rarity9BuyPrice; - item.expert = true; item.rare = ItemRarityID.Cyan; item.accessory = true; } @@ -34,9 +31,7 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.HiveBackpack); recipe.AddIngredient(ItemID.HoneyComb); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); @@ -48,44 +43,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); player.bee = true; modPlayer.uberBees = true; - player.strongBees = true; modPlayer.alchFlask = true; - modPlayer.reducedPlagueDmg = true; - int plagueCounter = 0; - Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0.1f, 2f, 0.2f); - int num = ModContent.BuffType(); - float num2 = 300f; - bool flag = plagueCounter % 60 == 0; - int num3 = (int)(60 * player.AverageDamage()); - int random = Main.rand.Next(10); - if (player.whoAmI == Main.myPlayer) - { - if (random == 0) - { - for (int l = 0; l < 200; l++) - { - NPC nPC = Main.npc[l]; - if (nPC.active && !nPC.friendly && nPC.damage > 0 && !nPC.dontTakeDamage && !nPC.buffImmune[num] && Vector2.Distance(player.Center, nPC.Center) <= num2) - { - if (nPC.FindBuffIndex(num) == -1) - { - nPC.AddBuff(num, 120, false); - } - if (flag) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile p = Projectile.NewProjectileDirect(nPC.Center, Vector2.Zero, ModContent.ProjectileType(), num3, 0f, player.whoAmI, l); - } - } - } - } - } - } - plagueCounter++; - if (plagueCounter >= 180) - { - } } } } diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index 89cb96b407..353a61ae81 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -63,7 +63,9 @@ namespace CalamityMod.Items.Accessories public override void ModifyTooltips(List tooltips) { - if (!CalamityWorld.downedSCal) + bool scal = CalamityWorld.downedSCal; + bool draedon = CalamityWorld.downedExoMechs; + if (!scal || !draedon) { int index = 0; foreach (TooltipLine line in tooltips) @@ -85,8 +87,8 @@ namespace CalamityMod.Items.Accessories } } - - tooltips.Insert(index+1, new TooltipLine(CalamityMod.Instance, "Tooltip1", "[c/f05a5a:The soul within this crystal has been defiled by the powerful magic of a supreme witch]\nMerchants will reject a defiled soul such as this.")); + string rejectionReason = (!draedon) ? "[c/f05a5a:The soul within this crystal has been defiled by overwhelming energy waves from dangerous mechanations]" : "[c/f05a5a:The soul within this crystal has been defiled by the powerful magic of a supreme witch]"; //there might be a better way to word the draedon line, not sure + tooltips.Insert(index+1, new TooltipLine(CalamityMod.Instance, "Tooltip1", rejectionReason + "\nMerchants will reject a defiled soul such as this.")); } else if (Main.player[Main.myPlayer].Calamity().profanedCrystalBuffs) { @@ -99,7 +101,7 @@ namespace CalamityMod.Items.Accessories } } } - if (CalamityWorld.downedSCal) + if (scal && draedon) { if (!CalamityWorld.death) { diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index 2b829f755e..5f8984fdc8 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -18,8 +18,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("Extends the duration of potion buffs by 100% and potion buffs remain active even after you die\n" + "15% increased damage\n" + "Shade rains down when you are hit\n" + - "Nearby enemies receive a variety of debuffs when you are hit\n" + - "You will confuse nearby enemies when you are struck"); + "Nearby enemies receive a variety of debuffs when you are hit"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(9, 6)); } diff --git a/Items/Accessories/TheCamper.cs b/Items/Accessories/TheCamper.cs index e7f04bfd4e..eb65a179e4 100644 --- a/Items/Accessories/TheCamper.cs +++ b/Items/Accessories/TheCamper.cs @@ -33,6 +33,7 @@ namespace CalamityMod.Items.Accessories item.height = 26; item.value = CalamityGlobalItem.Rarity7BuyPrice; item.rare = ItemRarityID.Lime; + item.expert = true; item.accessory = true; item.defense = 10; } diff --git a/Items/Accessories/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index 97f11834ab..88c34164b9 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Typeless; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -12,7 +13,8 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Toxic Heart"); - Tooltip.SetDefault("Summons a damaging plague aura around the player to destroy nearby enemies"); + Tooltip.SetDefault("Summons a plague aura around you that damages nearby enemies\n" + + "Reduces the damage caused by the Plague debuff and removes its blindness effect"); } public override void SetDefaults() @@ -27,12 +29,14 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.reducedPlagueDmg = true; int plagueCounter = 0; Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0.05f, 1f, 0.1f); int num = ModContent.BuffType(); float num2 = 300f; bool flag = plagueCounter % 60 == 0; - int num3 = (int)(30 * player.AverageDamage()); + int num3 = (int)(50 * player.AverageDamage()); int random = Main.rand.Next(10); if (player.whoAmI == Main.myPlayer) { diff --git a/Items/Accessories/Wings/XerocWings.cs b/Items/Accessories/Wings/XerocWings.cs index 73355f2d2f..0c008425e4 100644 --- a/Items/Accessories/Wings/XerocWings.cs +++ b/Items/Accessories/Wings/XerocWings.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Accessories.Wings { DisplayName.SetDefault("Exodus Wings"); Tooltip.SetDefault("Pulsing with an alien heartbeat\n" + - "Horizontal speed: 8.5\n" + - "Acceleration multiplier: 2\n" + + "Horizontal speed: 9.0\n" + + "Acceleration multiplier: 2.5\n" + "Good vertical speed\n" + "Flight time: 180\n" + "5% increased rogue damage and critical strike chance while wearing the Empyrean Armor"); @@ -70,8 +70,8 @@ namespace CalamityMod.Items.Accessories.Wings public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration) { - speed = 8.5f; - acceleration *= 2f; + speed = 9f; + acceleration *= 2.5f; } public override void AddRecipes() diff --git a/Items/Ammo/GodSlayerSlug.cs b/Items/Ammo/GodSlayerSlug.cs index 8e8f2f9eaf..13e30ffe2b 100644 --- a/Items/Ammo/GodSlayerSlug.cs +++ b/Items/Ammo/GodSlayerSlug.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Ammo public override void SetDefaults() { - item.damage = 42; + item.damage = 28; item.ranged = true; item.width = 22; item.height = 22; diff --git a/Items/Armor/SnowRuffianMask.cs b/Items/Armor/SnowRuffianMask.cs index 9081e2e052..57365cdb6f 100644 --- a/Items/Armor/SnowRuffianMask.cs +++ b/Items/Armor/SnowRuffianMask.cs @@ -47,9 +47,9 @@ namespace CalamityMod.Items.Armor { player.noFallDmg = true; player.UpdateJumpHeight(); - if (shouldBoost) + if (shouldBoost && !player.mount.Active) { - player.velocity.X *= 1.3f; + player.velocity.X *= 1.1f; shouldBoost = false; } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index c5229d9deb..93f2ad0c65 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -83,6 +83,8 @@ namespace CalamityMod.Items public bool canFirePointBlankShots = false; public bool trueMelee = false; + public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64); + // See RogueWeapon.cs for rogue modifier shit #region Modifiers public CalamityGlobalItem() @@ -266,7 +268,6 @@ namespace CalamityMod.Items case ItemID.Spear: case ItemID.Trident: case ItemID.PalladiumPike: - case ItemID.ObsidianSwordfish: case ItemID.CobaltDrill: case ItemID.MythrilDrill: case ItemID.AdamantiteDrill: @@ -321,12 +322,100 @@ namespace CalamityMod.Items break; // Set Celestial Sigil stack to 1 because it's not consumable anymore + case ItemID.SlimeCrown: + case ItemID.SuspiciousLookingEye: + case ItemID.WormFood: + case ItemID.BloodySpine: + case ItemID.Abeemination: + case ItemID.MechanicalEye: + case ItemID.MechanicalWorm: + case ItemID.MechanicalSkull: case ItemID.CelestialSigil: item.maxStack = 1; item.consumable = false; break; // True melee weapon adjustments + case ItemID.BladedGlove: + item.damage = 15; + item.useTime = 7; + item.useAnimation = 7; + break; + + case ItemID.IceBlade: + item.damage = 26; + item.useTime = 33; + break; + + case ItemID.EnchantedSword: + item.damage = 42; + item.useAnimation = 20; + item.shootSpeed = 15f; + break; + + case ItemID.Starfury: + item.autoReuse = true; + break; + + case ItemID.WoodYoyo: + case ItemID.Chik: + case ItemID.FormatC: + case ItemID.HelFire: + case ItemID.Amarok: + case ItemID.Gradient: + case ItemID.Code2: + case ItemID.Yelets: + case ItemID.RedsYoyo: + case ItemID.ValkyrieYoyo: + case ItemID.Kraken: + case ItemID.TheEyeOfCthulhu: + item.autoReuse = true; + break; + + case ItemID.Rally: + item.damage = 20; + item.autoReuse = true; + break; + + case ItemID.JungleYoyo: + item.autoReuse = true; + break; + + case ItemID.CrimsonYoyo: + item.damage = 30; + item.autoReuse = true; + break; + + case ItemID.CorruptYoyo: + item.damage = 27; + item.autoReuse = true; + break; + + case ItemID.Code1: + item.damage = 25; + item.autoReuse = true; + break; + + case ItemID.Valor: + item.damage = 32; + item.autoReuse = true; + break; + + case ItemID.ObsidianSwordfish: + item.damage = 45; + trueMelee = true; + break; + + case ItemID.BloodyMachete: + item.damage = 30; + item.autoReuse = true; + break; + + case ItemID.Cascade: + item.damage = 39; + item.autoReuse = true; + break; + case ItemID.SlapHand: item.damage = 120; break; @@ -517,6 +606,7 @@ namespace CalamityMod.Items case ItemID.Terrarian: item.damage = 352; + item.autoReuse = true; break; case ItemID.RainbowRod: @@ -925,7 +1015,7 @@ namespace CalamityMod.Items } #endregion - #region SavingAndLoading + #region Saving And Loading public override bool NeedsSaving(Item item) { return rogue || canFirePointBlankShots || trueMelee || timesUsed != 0 || customRarity != 0 || Charge != 0 || reforgeTier != 0 || AppliedEnchantment.HasValue || DischargeEnchantExhaustion != 0; @@ -1583,6 +1673,15 @@ namespace CalamityMod.Items { switch (item.type) { + case ItemID.MagicHat: + player.magicDamage -= 0.02f; + player.magicCrit -= 2; + break; + + case ItemID.WizardHat: + player.magicDamage -= 0.1f; + break; + case ItemID.GladiatorHelmet: case ItemID.ObsidianHelm: player.Calamity().throwingDamage += 0.03f; diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index 1518bfd1a3..115644510e 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -136,7 +136,7 @@ namespace CalamityMod.Items // The Picksaw always drops if the player doesn't have one in their inventory. Otherwise it has a 25% chance. bool playerHasPicksaw = player.InventoryHas(ItemID.Picksaw); - DropHelper.DropItemChance(player, ItemID.Picksaw, playerHasPicksaw ? 1.0f : 0.25f); + DropHelper.DropItemChance(player, ItemID.Picksaw, playerHasPicksaw ? 0.25f : 1.0f); DropHelper.DropItem(player, ModContent.ItemType(), 8, 13); break; diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index c71b0ab10a..a5f6599574 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -44,20 +44,20 @@ namespace CalamityMod.Items // This is placed between vanilla tooltip edits and mod mechanics because it can apply to vanilla items. StealthGenAccessoryTooltip(item, tooltips); - // If an item has special tags (specifically Ice, Fire, and Nature), show that in the tooltip. - ElementTooltip(item, tooltips); + // Adds "Does extra damage to enemies shot at point-blank range" to weapons capable of it. + if (canFirePointBlankShots) + { + TooltipLine line = new TooltipLine(mod, "PointBlankShot", "Does extra damage to enemies shot at point-blank range"); + tooltips.Add(line); + } + + // If an item has special tags (specifically Ice, Fire, and Nature), show that in the tooltip. + ElementTooltip(item, tooltips); // If an item has an enchantment, show its prefix in the first tooltip line and append its description to the // tooltip list. EnchantmentTooltips(item, tooltips); - // Adds "Does extra damage to enemies shot at point-blank range" to weapons capable of it. - if (canFirePointBlankShots) - { - TooltipLine line = new TooltipLine(mod, "PointBlankShot", "Does extra damage to enemies shot at point-blank range"); - tooltips.Add(line); - } - // Everything below this line can only apply to modded items. If the item is vanilla, stop here for efficiency. if (item.type < ItemID.Count) return; @@ -410,10 +410,10 @@ namespace CalamityMod.Items if (item.type == ItemID.AntlionClaw || item.type == ItemID.BoneSword || item.type == ItemID.BreakerBlade) EditTooltipByName("Knockback", (line) => line.text += "\nIgnores 50% of enemy defense"); - if (item.type == ItemID.LightsBane || item.type == ItemID.NightsEdge || item.type == ItemID.TrueNightsEdge || item.type == ItemID.BallOHurt) + if (item.type == ItemID.LightsBane || item.type == ItemID.NightsEdge || item.type == ItemID.TrueNightsEdge || item.type == ItemID.BallOHurt || item.type == ItemID.CorruptYoyo) EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Shadowflame on hit"); - if (item.type == ItemID.BloodButcherer || item.type == ItemID.TheRottedFork || item.type == ItemID.TheMeatball) + if (item.type == ItemID.BloodButcherer || item.type == ItemID.TheRottedFork || item.type == ItemID.TheMeatball || item.type == ItemID.CrimsonYoyo) EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Burning Blood on hit"); #endregion @@ -493,6 +493,19 @@ namespace CalamityMod.Items // Rebalances to vanilla item stats #region Vanilla Item Rebalance Tooltips + // Magic Power Potion nerf + if (item.type == ItemID.MagicPowerPotion) + EditTooltipByNum(0, (line) => line.text = "10% increased magic damage"); + + // Magic and Wizard Hat nerfs + // Magic Hat + if (item.type == ItemID.MagicHat) + EditTooltipByNum(0, (line) => line.text = "5% increased magic damage and critical strike chance"); + + // Wizard Hat + if (item.type == ItemID.WizardHat) + EditTooltipByNum(0, (line) => line.text = "5% increased magic damage"); + // Reduce DD2 armor piece bonuses because they're overpowered // Squire armor if (item.type == ItemID.SquirePlating) @@ -568,6 +581,14 @@ namespace CalamityMod.Items EditTooltipByNum(0, (line) => line.text = line.text.Replace("40%", "20%")); #endregion + // Non-consumable boss summon items + #region Vanilla Boss Summon Non-consumable Tooltips + if (item.type == ItemID.SlimeCrown || item.type == ItemID.SuspiciousLookingEye || item.type == ItemID.WormFood || + item.type == ItemID.BloodySpine || item.type == ItemID.Abeemination || item.type == ItemID.MechanicalEye || + item.type == ItemID.MechanicalWorm || item.type == ItemID.MechanicalSkull || item.type == ItemID.CelestialSigil) + EditTooltipByNum(0, (line) => line.text += "\nNot consumable"); + #endregion + // Items which provide immunity to either heat or cold in Death Mode, or interact with Lethal Lava #region Lava and Death Mode Environmental Immunity Tooltips string heatProtectionLine = "\nProvides heat protection in Death Mode"; diff --git a/Items/DifficultyItems/Death.cs b/Items/DifficultyItems/Death.cs index 96787d1ae2..0db80c242f 100644 --- a/Items/DifficultyItems/Death.cs +++ b/Items/DifficultyItems/Death.cs @@ -13,18 +13,30 @@ namespace CalamityMod.Items.DifficultyItems public override void SetStaticDefaults() { DisplayName.SetDefault("Death"); - Tooltip.SetDefault("Makes bosses even more EXTREME.\n" + - "Allows certain bosses to spawn naturally.\n" + - "Certain biomes and events have additional weather effects.\n" + - "Lethal lava effects are always enabled.\n" + - "Enemies and bosses buffed by Revengeance Mode are even stronger in this mode.\n" + - "Greatly boosts enemy spawn rates during the blood moon.\n" + - "Nerfs the effectiveness of life steal.\n" + - "Makes the abyss more treacherous to navigate.\n" + - "Nurse no longer heals while a boss is alive.\n" + - "Increases damage done by 50% for several debuffs and all alcohols that reduce life regen.\n" + - "Effect can be toggled on and off.\n" + - "Effect will only work if Revengeance Mode is active."); + Tooltip.SetDefault("Enables/disables Death Mode, can only be used in Revengeance Mode.\n" + + + // Rev Mode line + "All effects from Revengeance Mode are enabled, including the following:\n" + + + // Biome effect lines + "Allows certain bosses to spawn naturally depending on what biome you're in.\n" + + "Certain biomes and events have additional weather effects.\n" + + "Lethal Lava effects are always enabled.\n" + + "Greatly boosts enemy spawn rates during the Blood Moon.\n" + + "Makes the Abyss more treacherous to navigate.\n" + + + // General enemy lines + "Certain non-boss enemies and projectiles deal between 6% and 15% more damage.\n" + + + // Misc lines + "Nerfs the effectiveness of life steal a bit more.\n" + + "The Nurse no longer heals you while a boss is alive.\n" + + "Defense damage is increased by 2.5%.\n" + + "Increases damage done by 50% for several debuffs and all alcohols that reduce life regen.\n" + + + // Boss lines + "Changes all boss AIs and some enemy AIs a bit more.\n" + + "Increases the damage of all bosses a bit more."); } public override void SetDefaults() diff --git a/Items/DifficultyItems/Malice.cs b/Items/DifficultyItems/Malice.cs index 2b31dd30db..540b47936f 100644 --- a/Items/DifficultyItems/Malice.cs +++ b/Items/DifficultyItems/Malice.cs @@ -4,7 +4,6 @@ using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -17,9 +16,22 @@ namespace CalamityMod.Items.DifficultyItems public override void SetStaticDefaults() { DisplayName.SetDefault("Malice"); - Tooltip.SetDefault("Enrages every boss and allows them to drop special items.\n" + - "Nurse no longer heals while a boss is alive.\n" + - "Effect can be toggled on and off."); + Tooltip.SetDefault("Enables/disables Malice Mode.\n" + + + // Misc lines + "Greatly nerfs the effectiveness of life steal.\n" + + "Nerfs the effectiveness of the Titanium Armor set bonus, doesn't stack with Revengeance Mode.\n" + + "The Nurse no longer heals you while a boss is alive.\n" + + "Defense damage is 5% higher than Death Mode.\n" + + "Increases damage done by 50% for several debuffs and all alcohols that reduce life regen.\n" + + + // Boss lines + "All boss minions no longer drop hearts.\n" + + "Gives every boss a new enraged AI and allows them to drop special items.\n" + + "Bosses and their projectiles deal 35% more damage.\n" + + "Most bosses will enter later phases sooner if the fight has gone on for a long time.\n" + + "Increases the velocity of most boss projectiles by 25%, this is increased to 35% during Boss Rush.\n" + + "Boss reactive DR is always active outside of Boss Rush and is increased by 50%."); } public override void SetDefaults() diff --git a/Items/DifficultyItems/Revenge.cs b/Items/DifficultyItems/Revenge.cs index 7603218209..57f3739142 100644 --- a/Items/DifficultyItems/Revenge.cs +++ b/Items/DifficultyItems/Revenge.cs @@ -14,16 +14,27 @@ namespace CalamityMod.Items.DifficultyItems public override void SetStaticDefaults() { DisplayName.SetDefault("Revengeance"); - Tooltip.SetDefault("Enables/disables Revengeance Mode, can only be used in expert mode.\n" + + Tooltip.SetDefault("Enables/disables Revengeance Mode, can only be used in Expert Mode.\n" + + + // Rage and Adrenaline lines "RAGE TOOLTIP LINE HERE\n" + "You gain Rage when in proximity of enemies or by using special items.\n" + "ADRENALINE TOOLTIP LINE HERE\n" + "You gain Adrenaline whenever a boss is alive. Getting hit drops Adrenaline back to 0.\n" + + + // General enemy lines "All enemies drop 50% more coins and spawn 15% more frequently.\n" + - "Certain enemies and projectiles deal between 5% and 25% more damage.\n" + + "Certain non-boss enemies and projectiles deal between 10% and 25% more damage.\n" + "Makes certain enemies block life steal and nerfs the effectiveness of life steal.\n" + - "Nerfs the effectiveness of the Titanium Armor set bonus.\n" + - "Changes ALL boss AIs and some enemy AIs in vanilla and the Calamity Mod.\n" + + + // Misc lines + "Nerfs the effectiveness of the Titanium Armor set bonus.\n" + + "Defense damage is increased by 2.5%.\n" + + + // Boss lines + "All boss minions no longer drop hearts.\n" + + "Changes all boss AIs and some enemy AIs.\n" + + "Increases the health and damage of all bosses.\n" + "Most bosses will enter later phases sooner if the fight has gone on for a long time."); } diff --git a/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs b/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs index f5e161e900..edb2010506 100644 --- a/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs +++ b/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs @@ -11,9 +11,12 @@ namespace CalamityMod.Items.DraedonMisc public override void SetStaticDefaults() { DisplayName.SetDefault("Schematic"); - Tooltip.SetDefault("You can barely make out its text...\n" + - "Finely detailed diagrams of numerous devices and weaponry dance across the holographic screen\n" + - "Picking up this item or holding it in your inventory permanently unlocks new recipes"); + Tooltip.SetDefault("Finely detailed diagrams of numerous devices and weaponry dance across the holographic screen.\n" + + "The weaponry I supply to the workers of the laboratories is weak. Hardly suited for battle.\n" + + "However, they suffice for self defense against any lab mechanisms or creations which may have gone rogue.\n" + + "Addendum: For those who think themselves powerful, search the upper bounds of this planet’s atmosphere for a structure similar to that of the Sunken Seas.\n" + + "I will know by the end if you are worthy of battling my creations.\n" + + "Picking up this item or holding it in your inventory permanently unlocks new recipes"); } public override void SetDefaults() diff --git a/Items/Mounts/DraedonGamerChairMount.cs b/Items/Mounts/DraedonGamerChairMount.cs index bae00c4bad..607131ee27 100644 --- a/Items/Mounts/DraedonGamerChairMount.cs +++ b/Items/Mounts/DraedonGamerChairMount.cs @@ -61,6 +61,7 @@ namespace CalamityMod.Items.Mounts mountData.swimFrameStart = 0; if (Main.netMode != NetmodeID.Server) { + mountData.frontTextureGlow = ModContent.GetTexture("CalamityMod/Items/Mounts/DraedonGamerChairMount_Glowmask"); mountData.textureWidth = mountData.frontTexture.Width; mountData.textureHeight = mountData.frontTexture.Height; } diff --git a/Items/SummonItems/AncientMedallion.cs b/Items/SummonItems/AncientMedallion.cs index 4aa128504c..c0ca016b22 100644 --- a/Items/SummonItems/AncientMedallion.cs +++ b/Items/SummonItems/AncientMedallion.cs @@ -11,19 +11,19 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Death Whistle"); Tooltip.SetDefault("A very old temple whistle\n" + - "Summons the Ravager"); + "Summons the Ravager\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 20; item.height = 20; - item.maxStack = 20; item.rare = ItemRarityID.Yellow; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -49,8 +49,8 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.LunarTabletFragment, 5); - recipe.AddIngredient(ItemID.LihzahrdBrick, 10); + recipe.AddIngredient(ItemID.LunarTabletFragment, 15); + recipe.AddIngredient(ItemID.LihzahrdBrick, 25); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/AstralChunk.cs b/Items/SummonItems/AstralChunk.cs index 09ba7ef44d..9a9e47bfd2 100644 --- a/Items/SummonItems/AstralChunk.cs +++ b/Items/SummonItems/AstralChunk.cs @@ -12,19 +12,19 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Astral Chunk"); - Tooltip.SetDefault("Summons Astrum Aureus"); + Tooltip.SetDefault("Summons Astrum Aureus\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 20; item.height = 20; - item.maxStack = 20; item.rare = ItemRarityID.Lime; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -50,8 +50,8 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ItemID.FallenStar, 10); + recipe.AddIngredient(ModContent.ItemType(), 30); + recipe.AddIngredient(ItemID.FallenStar, 20); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/BirbPheromones.cs b/Items/SummonItems/BirbPheromones.cs index f545640620..3bb1185e25 100644 --- a/Items/SummonItems/BirbPheromones.cs +++ b/Items/SummonItems/BirbPheromones.cs @@ -1,4 +1,5 @@ using CalamityMod.Events; +using CalamityMod.Items.Materials; using CalamityMod.NPCs.Bumblebirb; using Terraria; using Terraria.ID; @@ -10,19 +11,19 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Exotic Pheromones"); - Tooltip.SetDefault("Attracts the failed draconic experiment"); + Tooltip.SetDefault("Attracts the failed draconic experiment\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 18; - item.maxStack = 20; item.rare = ItemRarityID.Red; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -44,8 +45,8 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.LunarBar, 3); - recipe.AddIngredient(ItemID.FragmentSolar, 5); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ItemID.FragmentSolar, 20); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/BloodyWormFood.cs b/Items/SummonItems/BloodyWormFood.cs index 116c0fb345..183ece6d7a 100644 --- a/Items/SummonItems/BloodyWormFood.cs +++ b/Items/SummonItems/BloodyWormFood.cs @@ -12,19 +12,19 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Bloody Worm Food"); - Tooltip.SetDefault("Summons the Perforator Hive"); + Tooltip.SetDefault("Summons the Perforator Hive\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 18; - item.maxStack = 20; item.rare = ItemRarityID.Orange; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -46,9 +46,9 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.Vertebrae, 9); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ItemID.CrimtaneBar, 2); + recipe.AddIngredient(ItemID.Vertebrae, 13); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddIngredient(ItemID.CrimtaneBar, 3); recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/BulbofDoom.cs b/Items/SummonItems/BulbofDoom.cs index b37a60b3d2..4c4725179c 100644 --- a/Items/SummonItems/BulbofDoom.cs +++ b/Items/SummonItems/BulbofDoom.cs @@ -11,19 +11,19 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Portabulb"); - Tooltip.SetDefault("Summons Plantera"); + Tooltip.SetDefault("Summons Plantera\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 18; - item.maxStack = 20; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; item.rare = ItemRarityID.Lime; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) diff --git a/Items/SummonItems/CharredIdol.cs b/Items/SummonItems/CharredIdol.cs index 7b36a235e4..58e655601d 100644 --- a/Items/SummonItems/CharredIdol.cs +++ b/Items/SummonItems/CharredIdol.cs @@ -15,19 +15,18 @@ namespace CalamityMod.Items.SummonItems DisplayName.SetDefault("Charred Idol"); Tooltip.SetDefault("Use in the Brimstone Crag at your own risk\n" + "Summons the Brimstone Elemental\n" + - "The boss enrages outside of her home in the crags"); + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 18; - item.maxStack = 20; item.rare = ItemRarityID.LightPurple; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -50,9 +49,9 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.SoulofNight, 3); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.SoulofNight, 5); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddTile(TileID.AdamantiteForge); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/ChickenEgg.cs b/Items/SummonItems/ChickenEgg.cs index b4b9ab55e0..e462c37eab 100644 --- a/Items/SummonItems/ChickenEgg.cs +++ b/Items/SummonItems/ChickenEgg.cs @@ -1,7 +1,6 @@ using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.NPCs.Yharon; -using CalamityMod.World; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/SummonItems/CosmicWorm.cs b/Items/SummonItems/CosmicWorm.cs index e5f3a08849..a0ae2417a4 100644 --- a/Items/SummonItems/CosmicWorm.cs +++ b/Items/SummonItems/CosmicWorm.cs @@ -6,7 +6,6 @@ using Microsoft.Xna.Framework; using System.Collections.Generic; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.SummonItems @@ -47,7 +46,7 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { - return !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && CalamityWorld.DoGSecondStageCountdown <= 0 && !BossRushEvent.BossRushActive; + return !NPC.AnyNPCs(ModContent.NPCType()) && CalamityWorld.DoGSecondStageCountdown <= 0 && !BossRushEvent.BossRushActive; } public override bool UseItem(Player player) diff --git a/Items/SummonItems/CryoKey.cs b/Items/SummonItems/CryoKey.cs index 5a99c6849e..affa6f602b 100644 --- a/Items/SummonItems/CryoKey.cs +++ b/Items/SummonItems/CryoKey.cs @@ -13,19 +13,18 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Cryo Key"); Tooltip.SetDefault("Summons Cryogen\n" + - "The boss enrages outside of the snowy tundra"); + "The boss enrages outside of the snowy tundra\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 18; - item.maxStack = 20; item.rare = ItemRarityID.Pink; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; } public override bool CanUseItem(Player player) @@ -47,10 +46,10 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddRecipeGroup("AnyIceBlock", 25); - recipe.AddIngredient(ItemID.SoulofNight, 3); - recipe.AddIngredient(ItemID.SoulofLight, 3); - recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddRecipeGroup("AnyIceBlock", 50); + recipe.AddIngredient(ItemID.SoulofNight, 5); + recipe.AddIngredient(ItemID.SoulofLight, 5); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/DecapoditaSprout.cs b/Items/SummonItems/DecapoditaSprout.cs index 3aee02d470..77fe48d395 100644 --- a/Items/SummonItems/DecapoditaSprout.cs +++ b/Items/SummonItems/DecapoditaSprout.cs @@ -10,19 +10,19 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Decapodita Sprout"); - Tooltip.SetDefault("Summons Crabulon"); + Tooltip.SetDefault("Summons Crabulon\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 18; - item.maxStack = 20; item.rare = ItemRarityID.Green; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -48,7 +48,7 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.GlowingMushroom, 25); + recipe.AddIngredient(ItemID.GlowingMushroom, 50); recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/DraedonsRemote.cs b/Items/SummonItems/DraedonsRemote.cs index 99a004c15f..86a4467c8e 100644 --- a/Items/SummonItems/DraedonsRemote.cs +++ b/Items/SummonItems/DraedonsRemote.cs @@ -11,19 +11,19 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Draedon's Remote"); - Tooltip.SetDefault("Mayhem..."); + Tooltip.SetDefault("Mayhem...\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 28; - item.maxStack = 20; item.rare = ItemRarityID.Yellow; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) diff --git a/Items/SummonItems/DriedSeafood.cs b/Items/SummonItems/DriedSeafood.cs index 7b7d8f331b..bd4491a667 100644 --- a/Items/SummonItems/DriedSeafood.cs +++ b/Items/SummonItems/DriedSeafood.cs @@ -14,19 +14,19 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Desert Medallion"); Tooltip.SetDefault("The desert sand stirs...\n" + - "Summons the Desert Scourge"); + "Summons the Desert Scourge\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 28; - item.maxStack = 20; item.rare = ItemRarityID.Green; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -61,10 +61,10 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.SandBlock, 15); - recipe.AddIngredient(ItemID.AntlionMandible, 3); - recipe.AddIngredient(ItemID.Cactus, 10); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.SandBlock, 25); + recipe.AddIngredient(ItemID.Cactus, 15); + recipe.AddIngredient(ItemID.AntlionMandible, 4); + recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/EidolonTablet.cs b/Items/SummonItems/EidolonTablet.cs index 5c9bdb15df..88dcbda00a 100644 --- a/Items/SummonItems/EidolonTablet.cs +++ b/Items/SummonItems/EidolonTablet.cs @@ -11,18 +11,18 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Eidolon Tablet"); - } + Tooltip.SetDefault("Not consumable"); + } public override void SetDefaults() { item.width = 20; item.height = 20; - item.maxStack = 20; item.rare = ItemRarityID.Cyan; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) diff --git a/Items/SummonItems/NecroplasmicBeacon.cs b/Items/SummonItems/NecroplasmicBeacon.cs index e41cf684e2..e9602bb459 100644 --- a/Items/SummonItems/NecroplasmicBeacon.cs +++ b/Items/SummonItems/NecroplasmicBeacon.cs @@ -56,7 +56,8 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 100); + recipe.AddIngredient(ItemID.SpookyWood, 25); + recipe.AddIngredient(ModContent.ItemType(), 50); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/OldPowerCell.cs b/Items/SummonItems/OldPowerCell.cs index 2ca5cdd787..f83eee9f9c 100644 --- a/Items/SummonItems/OldPowerCell.cs +++ b/Items/SummonItems/OldPowerCell.cs @@ -11,33 +11,31 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Old Power Cell"); - Tooltip.SetDefault("Summons the ancient golem when used in the Temple"); + Tooltip.SetDefault("Summons the Golem when used in the Temple\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 18; - item.maxStack = 20; item.rare = ItemRarityID.Lime; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) { bool canSummon = false; - if ((double)player.Center.Y > Main.worldSurface * 16.0) + if (player.Center.Y > Main.worldSurface * 16.0) { int num = (int)player.Center.X / 16; int num2 = (int)player.Center.Y / 16; Tile tile = Framing.GetTileSafely(num, num2); if (tile.wall == 87) - { canSummon = true; - } } return canSummon && !NPC.AnyNPCs(NPCID.Golem) && !BossRushEvent.BossRushActive; } @@ -56,8 +54,8 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.LunarTabletFragment, 10); - recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ItemID.LunarTabletFragment, 20); + recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/OverloadedSludge.cs b/Items/SummonItems/OverloadedSludge.cs index 9d2cb4fbae..1a81ee70d1 100644 --- a/Items/SummonItems/OverloadedSludge.cs +++ b/Items/SummonItems/OverloadedSludge.cs @@ -13,19 +13,19 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Overloaded Sludge"); Tooltip.SetDefault("It looks corrupted\n" + - "Summons the Slime God"); + "Summons the Slime God\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 20; item.height = 20; - item.maxStack = 20; item.rare = ItemRarityID.LightRed; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -48,13 +48,13 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddRecipeGroup("AnyEvilBlock", 25); + recipe.AddIngredient(ModContent.ItemType(), 40); + recipe.AddRecipeGroup("AnyEvilBlock", 40); recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 40); recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/ProfanedShard.cs b/Items/SummonItems/ProfanedShard.cs index 4fb56f2fd9..0215487ca1 100644 --- a/Items/SummonItems/ProfanedShard.cs +++ b/Items/SummonItems/ProfanedShard.cs @@ -14,18 +14,18 @@ namespace CalamityMod.Items.SummonItems DisplayName.SetDefault("Profaned Shard"); Tooltip.SetDefault("A shard of the unholy flame\n" + "Summons the Profaned Guardians\n" + - "Can only be used during daytime"); + "Can only be used during daytime\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 20; item.height = 20; - item.maxStack = 20; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; item.rare = ItemRarityID.Purple; } @@ -48,8 +48,8 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ItemID.LunarBar, 3); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ItemID.LunarBar, 5); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/RuneofCos.cs b/Items/SummonItems/RuneofCos.cs index 64a37ea826..6df3e95a55 100644 --- a/Items/SummonItems/RuneofCos.cs +++ b/Items/SummonItems/RuneofCos.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { return (player.ZoneSkyHeight || player.ZoneUnderworldHeight || player.ZoneDungeon) && - !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && + !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && CalamityWorld.DoGSecondStageCountdown <= 0 && !BossRushEvent.BossRushActive; } diff --git a/Items/SummonItems/SandstormsCore.cs b/Items/SummonItems/SandstormsCore.cs index 00bf9252c3..88f5f894e7 100644 --- a/Items/SummonItems/SandstormsCore.cs +++ b/Items/SummonItems/SandstormsCore.cs @@ -9,19 +9,19 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Sandstorm's Core"); - Tooltip.SetDefault("Summons the Great Sand Shark"); + Tooltip.SetDefault("Summons the Great Sand Shark\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 20; item.height = 20; - item.maxStack = 20; item.rare = ItemRarityID.Lime; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -43,10 +43,10 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 2); - recipe.AddIngredient(ItemID.Ectoplasm, 5); + recipe.AddIngredient(ItemID.Ectoplasm, 10); recipe.AddIngredient(ItemID.HallowedBar, 5); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 3); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/SummonItems/Seafood.cs b/Items/SummonItems/Seafood.cs index 2e33f85676..0da71ae88e 100644 --- a/Items/SummonItems/Seafood.cs +++ b/Items/SummonItems/Seafood.cs @@ -14,19 +14,19 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Seafood"); Tooltip.SetDefault("The sulphuric sand stirs...\n" + - "Summons the Aquatic Scourge"); + "Summons the Aquatic Scourge\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 26; item.height = 24; - item.maxStack = 20; item.rare = ItemRarityID.Pink; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) @@ -49,9 +49,9 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ItemID.Starfish, 5); - recipe.AddIngredient(ItemID.SharkFin); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ItemID.Starfish, 10); + recipe.AddIngredient(ItemID.SharkFin, 5); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/Teratoma.cs b/Items/SummonItems/Teratoma.cs index d257e25088..2afc05b597 100644 --- a/Items/SummonItems/Teratoma.cs +++ b/Items/SummonItems/Teratoma.cs @@ -12,24 +12,24 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Teratoma"); - Tooltip.SetDefault("Summons the Hive Mind"); + Tooltip.SetDefault("Summons the Hive Mind\n" + + "Not consumable"); } public override void SetDefaults() { item.width = 28; item.height = 18; - item.maxStack = 20; item.rare = ItemRarityID.Orange; item.useAnimation = 45; item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = true; + item.consumable = false; } public override bool CanUseItem(Player player) { - return player.ZoneCorrupt && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; + return player.ZoneCorrupt && !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; } public override bool UseItem(Player player) @@ -46,9 +46,9 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.RottenChunk, 9); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ItemID.DemoniteBar, 2); + recipe.AddIngredient(ItemID.RottenChunk, 13); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddIngredient(ItemID.DemoniteBar, 3); recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Tools/FellerofEvergreens.cs b/Items/Tools/FellerofEvergreens.cs index 507c7c98b1..475b0d00a7 100644 --- a/Items/Tools/FellerofEvergreens.cs +++ b/Items/Tools/FellerofEvergreens.cs @@ -13,10 +13,11 @@ namespace CalamityMod.Items.Tools public override void SetDefaults() { - item.damage = 15; + item.damage = 40; item.melee = true; item.width = 36; item.height = 36; + item.scale = 1.5f; item.useTime = 18; item.useAnimation = 25; item.useTurn = true; diff --git a/Items/TreasureBags/DevourerofGodsBag.cs b/Items/TreasureBags/DevourerofGodsBag.cs index 1b9f0d656a..201d3a0436 100644 --- a/Items/TreasureBags/DevourerofGodsBag.cs +++ b/Items/TreasureBags/DevourerofGodsBag.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.TreasureBags { public class DevourerofGodsBag : ModItem { - public override int BossBagNPC => ModContent.NPCType(); + public override int BossBagNPC => ModContent.NPCType(); public override void SetStaticDefaults() { diff --git a/Items/TreasureBags/HiveMindBag.cs b/Items/TreasureBags/HiveMindBag.cs index b6f9979729..893eb675ae 100644 --- a/Items/TreasureBags/HiveMindBag.cs +++ b/Items/TreasureBags/HiveMindBag.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.TreasureBags { public class HiveMindBag : ModItem { - public override int BossBagNPC => ModContent.NPCType(); + public override int BossBagNPC => ModContent.NPCType(); public override void SetStaticDefaults() { diff --git a/Items/TreasureBags/StarterBag.cs b/Items/TreasureBags/StarterBag.cs index 1b9cb7fdc8..9a2c8807d3 100644 --- a/Items/TreasureBags/StarterBag.cs +++ b/Items/TreasureBags/StarterBag.cs @@ -58,9 +58,6 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); - // Speedrun King Slime - DropHelper.DropItem(player, ItemID.SlimeCrown); - // The Lad DropHelper.DropItemCondition(player, ModContent.ItemType(), player.name == "Aleksh" || player.name == "Shark Lad"); diff --git a/Items/TreasureBags/StormWeaverBag.cs b/Items/TreasureBags/StormWeaverBag.cs index df2d8d51a5..37ae215c34 100644 --- a/Items/TreasureBags/StormWeaverBag.cs +++ b/Items/TreasureBags/StormWeaverBag.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.TreasureBags { public class StormWeaverBag : ModItem { - public override int BossBagNPC => ModContent.NPCType(); + public override int BossBagNPC => ModContent.NPCType(); public override void SetStaticDefaults() { diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.cs b/Items/Weapons/DraedonsArsenal/PulseRifle.cs index ce71f5608b..54ec5f25c4 100644 --- a/Items/Weapons/DraedonsArsenal/PulseRifle.cs +++ b/Items/Weapons/DraedonsArsenal/PulseRifle.cs @@ -69,11 +69,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); public override void AddRecipes() { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/Magic/GruesomeEminence.cs b/Items/Weapons/Magic/GruesomeEminence.cs new file mode 100644 index 0000000000..37609baa67 --- /dev/null +++ b/Items/Weapons/Magic/GruesomeEminence.cs @@ -0,0 +1,53 @@ +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class GruesomeEminence : ModItem + { + public const string PoeticTooltipLine = "The spirits of the amalgam could never pass on to their desired afterlife,\n" + + "Tainted and melded by rage as they were."; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gruesome Eminence"); + Tooltip.SetDefault("Summons a gaseous conglomeration of spirits near the cursor\n" + + "At first, the spirits will fly wildly. This can hurt enemies and players\n" + + "However, over time they will begin to accumulate to create a single, controllable monstrosity\n" + + CalamityUtils.ColorMessage(PoeticTooltipLine, CalamityGlobalItem.ExhumedTooltipColor)); + } + + public override void SetDefaults() + { + item.damage = 888; + item.magic = true; + item.noUseGraphic = true; + item.channel = true; + item.mana = 8; + item.width = 42; + item.height = 74; + item.useTime = 27; + item.useAnimation = 27; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 5f; + item.shootSpeed = 9f; + item.shoot = ModContent.ProjectileType(); + + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.Calamity().customRarity = CalamityRarity.Violet; + } + + // This weapon uses a holdout projectile. + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, item.shoot, damage, knockBack, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Magic/GruesomeEminence.png b/Items/Weapons/Magic/GruesomeEminence.png new file mode 100644 index 0000000000..12570acfd6 Binary files /dev/null and b/Items/Weapons/Magic/GruesomeEminence.png differ diff --git a/Items/Weapons/Magic/HadopelagicEcho.cs b/Items/Weapons/Magic/HadopelagicEcho.cs index 4598e96fa7..1725f7fa7b 100644 --- a/Items/Weapons/Magic/HadopelagicEcho.cs +++ b/Items/Weapons/Magic/HadopelagicEcho.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 230; + item.damage = 500; item.magic = true; item.mana = 15; item.width = 60; diff --git a/Items/Weapons/Magic/Heresy.cs b/Items/Weapons/Magic/Heresy.cs index 6d04804a89..cba4b87e94 100644 --- a/Items/Weapons/Magic/Heresy.cs +++ b/Items/Weapons/Magic/Heresy.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 444; + item.damage = 888; item.magic = true; item.mana = 10; item.width = 38; diff --git a/Items/Weapons/Magic/Rancor.cs b/Items/Weapons/Magic/Rancor.cs new file mode 100644 index 0000000000..cbec0ae36f --- /dev/null +++ b/Items/Weapons/Magic/Rancor.cs @@ -0,0 +1,52 @@ +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class Rancor : ModItem + { + public const string PoeticTooltipLine = "Forgiveness can only heal so much,\n" + + "If the recipient has not yet forgiven themselves."; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rancor"); + Tooltip.SetDefault("Casts a magic circle that charges energy and eventually releases a powerful laser burst of controlled maleficent magic\n" + + "The laser causes arms and searing lava to appear on surfaces it touches which harm both you and enemies\n" + + CalamityUtils.ColorMessage(PoeticTooltipLine, CalamityGlobalItem.ExhumedTooltipColor)); + } + + public override void SetDefaults() + { + item.damage = 2222; + item.magic = true; + item.noUseGraphic = true; + item.channel = true; + item.mana = 10; + item.width = 66; + item.height = 82; + item.useTime = 27; + item.useAnimation = 27; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 5f; + item.shootSpeed = 9f; + item.shoot = ModContent.ProjectileType(); + + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.Calamity().customRarity = CalamityRarity.Violet; + } + + // This weapon uses a holdout projectile. + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, item.shoot, damage, knockBack, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Magic/Rancor.png b/Items/Weapons/Magic/Rancor.png new file mode 100644 index 0000000000..53baeb736b Binary files /dev/null and b/Items/Weapons/Magic/Rancor.png differ diff --git a/Items/Weapons/Magic/TheSwarmer.cs b/Items/Weapons/Magic/TheSwarmer.cs index d8eadef0d8..2b66155190 100644 --- a/Items/Weapons/Magic/TheSwarmer.cs +++ b/Items/Weapons/Magic/TheSwarmer.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 30; + item.damage = 44; item.magic = true; item.mana = 7; item.width = 60; diff --git a/Items/Weapons/Melee/AirSpinner.cs b/Items/Weapons/Melee/AirSpinner.cs index dcb9a8fe0c..815054f8bc 100644 --- a/Items/Weapons/Melee/AirSpinner.cs +++ b/Items/Weapons/Melee/AirSpinner.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 28; item.height = 28; item.melee = true; - item.damage = 20; + item.damage = 21; item.knockBack = 4f; item.useTime = 22; item.useAnimation = 22; diff --git a/Items/Weapons/Melee/Aorta.cs b/Items/Weapons/Melee/Aorta.cs index 483b8e163e..13cefbd7a5 100644 --- a/Items/Weapons/Melee/Aorta.cs +++ b/Items/Weapons/Melee/Aorta.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 30; item.height = 26; item.melee = true; - item.damage = 25; + item.damage = 23; item.knockBack = 4.25f; item.useTime = 22; item.useAnimation = 22; diff --git a/Items/Weapons/Melee/BiomeBlade.cs b/Items/Weapons/Melee/BiomeBlade.cs index 2f1a69533e..eb4d414893 100644 --- a/Items/Weapons/Melee/BiomeBlade.cs +++ b/Items/Weapons/Melee/BiomeBlade.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 42; - item.damage = 38; + item.damage = 55; item.melee = true; item.useAnimation = 30; item.useTime = 30; diff --git a/Items/Weapons/Melee/Cnidarian.cs b/Items/Weapons/Melee/Cnidarian.cs index e823e48340..5a207b3725 100644 --- a/Items/Weapons/Melee/Cnidarian.cs +++ b/Items/Weapons/Melee/Cnidarian.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 30; item.height = 26; item.melee = true; - item.damage = 18; + item.damage = 11; item.knockBack = 3f; item.useTime = 25; item.useAnimation = 25; diff --git a/Items/Weapons/Melee/EutrophicShank.cs b/Items/Weapons/Melee/EutrophicShank.cs index 403da8918f..cd7205c3d1 100644 --- a/Items/Weapons/Melee/EutrophicShank.cs +++ b/Items/Weapons/Melee/EutrophicShank.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.useTime = 14; item.width = 42; item.height = 38; - item.damage = 24; + item.damage = 35; item.melee = true; item.knockBack = 4f; item.UseSound = SoundID.Item1; @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee item.value = Item.buyPrice(0, 2, 0, 0); item.rare = ItemRarityID.Green; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 3f; + item.shootSpeed = 10f; } public override void MeleeEffects(Player player, Rectangle hitbox) diff --git a/Items/Weapons/Melee/GoldplumeSpear.cs b/Items/Weapons/Melee/GoldplumeSpear.cs index db98a9b165..c4409dea5e 100644 --- a/Items/Weapons/Melee/GoldplumeSpear.cs +++ b/Items/Weapons/Melee/GoldplumeSpear.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 54; - item.damage = 23; + item.damage = 38; item.melee = true; item.noMelee = true; item.useTurn = true; @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Melee item.value = Item.buyPrice(0, 4, 0, 0); item.rare = ItemRarityID.Orange; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; + item.shootSpeed = 8f; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/Items/Weapons/Melee/PerfectDark.cs b/Items/Weapons/Melee/PerfectDark.cs index 89807177c4..a9c20d6639 100644 --- a/Items/Weapons/Melee/PerfectDark.cs +++ b/Items/Weapons/Melee/PerfectDark.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 50; - item.damage = 22; + item.damage = 38; item.melee = true; item.useAnimation = 25; item.useStyle = ItemUseStyleID.SwingThrow; @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Melee item.value = Item.buyPrice(0, 4, 0, 0); item.rare = ItemRarityID.Orange; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; + item.shootSpeed = 10f; } public override void AddRecipes() diff --git a/Items/Weapons/Melee/PhotonRipper.cs b/Items/Weapons/Melee/PhotonRipper.cs index 5b6bee5630..0d04bfb318 100644 --- a/Items/Weapons/Melee/PhotonRipper.cs +++ b/Items/Weapons/Melee/PhotonRipper.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.height = 134; item.width = 54; - item.damage = 4050; + item.damage = 3725; // Displayed axe% is 1/5th of axePower here because trees have 500% hardness. This corrects for that. item.axe = 6000 / 5; diff --git a/Items/Weapons/Melee/PlagueKeeper.cs b/Items/Weapons/Melee/PlagueKeeper.cs index 068124e44a..0a04f5f440 100644 --- a/Items/Weapons/Melee/PlagueKeeper.cs +++ b/Items/Weapons/Melee/PlagueKeeper.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 74; - item.damage = 75; + item.damage = 80; item.melee = true; item.useAnimation = 20; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/RedtideSword.cs b/Items/Weapons/Melee/RedtideSword.cs index 42630242c5..168a6c34d2 100644 --- a/Items/Weapons/Melee/RedtideSword.cs +++ b/Items/Weapons/Melee/RedtideSword.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 42; - item.damage = 20; + item.damage = 35; item.melee = true; item.useAnimation = 19; item.useStyle = ItemUseStyleID.SwingThrow; @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee item.value = Item.buyPrice(0, 2, 0, 0); item.rare = ItemRarityID.Green; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 6f; + item.shootSpeed = 9f; } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) diff --git a/Items/Weapons/Melee/SeashineSword.cs b/Items/Weapons/Melee/SeashineSword.cs index b2c566e942..cf161bcfc8 100644 --- a/Items/Weapons/Melee/SeashineSword.cs +++ b/Items/Weapons/Melee/SeashineSword.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.CloneDefaults(ItemID.EnchantedSword); + item.useTime = 30; item.damage = 26; item.melee = true; item.value = Item.buyPrice(0, 2, 0, 0); diff --git a/Items/Weapons/Melee/TheGodsGambit.cs b/Items/Weapons/Melee/TheGodsGambit.cs index c9132e44a2..9cefd4e1b1 100644 --- a/Items/Weapons/Melee/TheGodsGambit.cs +++ b/Items/Weapons/Melee/TheGodsGambit.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 40; item.height = 26; item.melee = true; - item.damage = 33; + item.damage = 29; item.knockBack = 3.5f; item.useTime = 21; item.useAnimation = 21; diff --git a/Items/Weapons/Melee/TheLastMourning.cs b/Items/Weapons/Melee/TheLastMourning.cs index b2c126470f..64c914aab2 100644 --- a/Items/Weapons/Melee/TheLastMourning.cs +++ b/Items/Weapons/Melee/TheLastMourning.cs @@ -44,9 +44,7 @@ namespace CalamityMod.Items.Weapons.Melee if (crit) damage /= 2; - bool isDoGSegment = target.type == ModContent.NPCType() || - target.type == ModContent.NPCType() || - target.type == ModContent.NPCType(); + bool isDoGSegment = target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); if (!isDoGSegment || Main.rand.NextBool(3)) { CalamityPlayerOnHit.HorsemansBladeOnHit(player, target.whoAmI, damage, knockback, 0, ModContent.ProjectileType()); diff --git a/Items/Weapons/Melee/UrchinFlail.cs b/Items/Weapons/Melee/UrchinFlail.cs index f0a889e03c..5af85676ab 100644 --- a/Items/Weapons/Melee/UrchinFlail.cs +++ b/Items/Weapons/Melee/UrchinFlail.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - item.damage = 20; + item.damage = 33; item.melee = true; item.width = 44; item.height = 36; diff --git a/Items/Weapons/Melee/UrchinSpear.cs b/Items/Weapons/Melee/UrchinSpear.cs index 0eba891d12..dac472febc 100644 --- a/Items/Weapons/Melee/UrchinSpear.cs +++ b/Items/Weapons/Melee/UrchinSpear.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 56; - item.damage = 17; + item.damage = 28; item.melee = true; item.noMelee = true; item.useTurn = true; diff --git a/Items/Weapons/Melee/VeinBurster.cs b/Items/Weapons/Melee/VeinBurster.cs index 0de7f3b9af..392360c12a 100644 --- a/Items/Weapons/Melee/VeinBurster.cs +++ b/Items/Weapons/Melee/VeinBurster.cs @@ -17,11 +17,11 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 52; - item.damage = 22; + item.damage = 57; item.melee = true; item.useAnimation = 25; item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 25; + item.useTime = 37; item.useTurn = true; item.knockBack = 4.25f; item.UseSound = SoundID.Item1; @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Melee item.value = Item.buyPrice(0, 4, 0, 0); item.rare = ItemRarityID.Orange; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; + item.shootSpeed = 10f; } public override void AddRecipes() diff --git a/Items/Weapons/Melee/Whirlpool.cs b/Items/Weapons/Melee/Whirlpool.cs index 2053668191..147c4e36d2 100644 --- a/Items/Weapons/Melee/Whirlpool.cs +++ b/Items/Weapons/Melee/Whirlpool.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 30; item.height = 44; item.melee = true; - item.damage = 18; + item.damage = 16; item.knockBack = 1f; item.useTime = 25; item.useAnimation = 25; diff --git a/Items/Weapons/Melee/WindBlade.cs b/Items/Weapons/Melee/WindBlade.cs index 3089b52cbb..9850e887ae 100644 --- a/Items/Weapons/Melee/WindBlade.cs +++ b/Items/Weapons/Melee/WindBlade.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 58; - item.damage = 27; + item.damage = 33; item.melee = true; item.useAnimation = 20; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Rogue/KelvinCatalyst.cs b/Items/Weapons/Rogue/KelvinCatalyst.cs index e3b0e95312..4525001cc9 100644 --- a/Items/Weapons/Rogue/KelvinCatalyst.cs +++ b/Items/Weapons/Rogue/KelvinCatalyst.cs @@ -36,6 +36,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.height = 20; item.value = Item.buyPrice(gold: 36); item.rare = ItemRarityID.Pink; + item.expert = true; item.Calamity().donorItem = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 8f; diff --git a/Items/Weapons/Rogue/Plaguenade.cs b/Items/Weapons/Rogue/Plaguenade.cs index 50100950cf..a61e384869 100644 --- a/Items/Weapons/Rogue/Plaguenade.cs +++ b/Items/Weapons/Rogue/Plaguenade.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 20; - item.damage = 60; + item.damage = 63; item.noMelee = true; item.noUseGraphic = true; item.consumable = true; diff --git a/Items/Weapons/Summon/AngryChickenStaff.cs b/Items/Weapons/Summon/AngryChickenStaff.cs index 7502e45db7..c8194c0193 100644 --- a/Items/Weapons/Summon/AngryChickenStaff.cs +++ b/Items/Weapons/Summon/AngryChickenStaff.cs @@ -8,7 +8,8 @@ namespace CalamityMod.Items.Weapons.Summon { public class AngryChickenStaff : ModItem { - public const int Damage = 107; + public const int Damage = 300; + public const float ReboundRamDamageFactor = 6f; public override void SetStaticDefaults() { DisplayName.SetDefault("Yharon's Kindle Staff"); diff --git a/Items/Weapons/Summon/ExhumedVigilance.cs b/Items/Weapons/Summon/CindersOfLament.cs similarity index 79% rename from Items/Weapons/Summon/ExhumedVigilance.cs rename to Items/Weapons/Summon/CindersOfLament.cs index c7ba200da7..efb467b8ab 100644 --- a/Items/Weapons/Summon/ExhumedVigilance.cs +++ b/Items/Weapons/Summon/CindersOfLament.cs @@ -6,14 +6,18 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class ExhumedVigilance : ModItem + public class CindersOfLament : ModItem { + public const string PoeticTooltipLine = "The Witch, a sinner of her own making,\n" + + "Within her mind her demon lies, ever patient, until the end of time."; + public override void SetStaticDefaults() { - DisplayName.SetDefault("Exhumed Vigilance"); + DisplayName.SetDefault("Cinders of Lament"); Tooltip.SetDefault("Summons either Cataclysm or Catastrophe at the mouse position\n" + "They will look at you for a moment before charging at you\n" + - "They can do damage to both you and enemies"); + "They can do damage to both you and enemies\n" + + CalamityUtils.ColorMessage(PoeticTooltipLine, CalamityGlobalItem.ExhumedTooltipColor)); } public override void SetDefaults() diff --git a/Items/Weapons/Summon/ExhumedVigilance.png b/Items/Weapons/Summon/CindersOfLament.png similarity index 100% rename from Items/Weapons/Summon/ExhumedVigilance.png rename to Items/Weapons/Summon/CindersOfLament.png diff --git a/Items/Weapons/Summon/HivePod.cs b/Items/Weapons/Summon/HivePod.cs index bd480246aa..423660b497 100644 --- a/Items/Weapons/Summon/HivePod.cs +++ b/Items/Weapons/Summon/HivePod.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 90; + item.damage = 75; item.mana = 10; item.summon = true; item.sentry = true; diff --git a/Items/Weapons/Summon/StaffoftheMechworm2.cs b/Items/Weapons/Summon/Metastasis.cs similarity index 64% rename from Items/Weapons/Summon/StaffoftheMechworm2.cs rename to Items/Weapons/Summon/Metastasis.cs index 40d5d25904..9a6ba17144 100644 --- a/Items/Weapons/Summon/StaffoftheMechworm2.cs +++ b/Items/Weapons/Summon/Metastasis.cs @@ -6,18 +6,19 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class StaffoftheMechworm2 : ModItem + public class Metastasis : ModItem { - // This is unfinished atm. - public override bool Autoload(ref string name) => false; + public const string PoeticTooltipLine = "A contemplated possible future of the cosmic serpent,\n" + + "A gruesome warning for those blinded by the hunger for power."; public override void SetStaticDefaults() { - DisplayName.SetDefault("Staff of the Mechworm (But Exhumed!)"); + DisplayName.SetDefault("Metastasis"); Tooltip.SetDefault("Summons a sepulcher to fight for you\n" + "While the sepulcher is active brimstone hearts will begin to appear and orbit you\n" + - "The sepulcher will attempt to attack you more and more frequently depending on how many hearts are present\n" + - "The sepulcher takes up 4 minion slots"); + "It will attempt to attack you more and more frequently depending on how many hearts are present\n" + + "It takes up 4 minion slots\n" + + CalamityUtils.ColorMessage(PoeticTooltipLine, CalamityGlobalItem.ExhumedTooltipColor)); } public override void SetDefaults() @@ -30,10 +31,10 @@ namespace CalamityMod.Items.Weapons.Summon item.useStyle = ItemUseStyleID.SwingThrow; item.noMelee = true; item.knockBack = 2f; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Violet; - item.UseSound = SoundID.DD2_BetsySummon; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.UseSound = SoundID.DD2_BetsySummon; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; diff --git a/Items/Weapons/Summon/StaffoftheMechworm2.png b/Items/Weapons/Summon/Metastasis.png similarity index 100% rename from Items/Weapons/Summon/StaffoftheMechworm2.png rename to Items/Weapons/Summon/Metastasis.png diff --git a/Localization/CalamityLocalization.cs b/Localization/CalamityLocalization.cs index b4e0af8fe8..2153941eba 100644 --- a/Localization/CalamityLocalization.cs +++ b/Localization/CalamityLocalization.cs @@ -21,8 +21,6 @@ namespace CalamityMod.Localization new [] { "SteelSkullBossText", "A blood red inferno lingers in the night..." }, - new [] { "BrimmyBossText", "A protective spell has been lifted from the crags! You can now mine Charred Ore." }, - new [] { "WetWormBossText", "The sulphuric sky darkens..." }, new [] { "PlantBossText", "The ocean depths are trembling." }, @@ -115,20 +113,34 @@ namespace CalamityMod.Localization new [] { "CryogenBossText", "Cryogen is derping out!" }, - new [] { "DraedonIntroductionText1", "This is a meeting that has been a long time coming." }, - new [] { "DraedonIntroductionText2", "The machine you constructed, deciphering and incercepting my channels of communication. It is no small feat of ingenuity." }, - new [] { "DraedonIntroductionText3", "I must be upfront, as this is a unique opportunity. Your observations have not been one-sided, and I have grown " + - "interested in your remarkable progression." }, - new [] { "DraedonIntroductionText4", "Humor me, in a battle with the results of my tinkering." }, - new [] { "DraedonIntroductionText5", "You may choose your first opponent." }, - new [] { "DraedonAresEnrageText", "How foolish. You cannot escape." }, + + new [] { "DraedonIntroductionText1", "I have waited long for this moment." }, + new [] { "DraedonIntroductionText2", "Your nature fascinates me, for I do not understand it." }, + new [] { "DraedonIntroductionText3", "You will face my creations which have surpassed gods." }, + new [] { "DraedonIntroductionText4", "And you will show me your disposition through battle." }, + new [] { "DraedonIntroductionText5", "Now, choose." }, + new [] { "DraedonExoPhase1Text1", "Designs improved with time and knowledge are the essence of my work." }, + new [] { "DraedonExoPhase1Text2", "Through no other method can I approach perfection." }, + new [] { "DraedonExoPhase2Text1", "Your performance falls neatly within the margins of error." }, + new [] { "DraedonExoPhase2Text2", "That is quite satisfactory. We will proceed to the next phase of testing." }, + new [] { "DraedonExoPhase3Text1", "Ever since I was alerted to your presence, I have processed your battles in order to make my machines stronger." }, + new [] { "DraedonExoPhase3Text2", "Even now, I monitor your actions. Nothing should escape the bounds of my calculations." }, + new [] { "DraedonExoPhase4Text1", "Curious. Very curious." }, + new [] { "DraedonExoPhase4Text2", "You progress steadily against more difficult challenges." }, + new [] { "DraedonExoPhase5Text1", "Your nature remains unknown to me. This will not do." }, + new [] { "DraedonExoPhase5Text2", "...I sought perfection. Fate must favor irony, for that must have been my first mistake." }, + new [] { "DraedonExoPhase6Text1", "Absurd." }, + new [] { "DraedonExoPhase6Text2", "I will no longer let my calculations impede my observation of this battle." }, + new [] { "DraedonExoPhase6Text3", "I shall show you the full fury of my final machine." }, + new [] { "DraedonAresEnrageText", "How foolish. You cannot escape." }, + new [] { "DraedonResummonText", "Make your choice." }, new [] { "HardmodeOreTier1Text", "Your world has been blessed with Cobalt and Palladium!" }, - new [] { "HardmodeOreTier2Text", "Your world has been blessed with Mythril and Orichalcum!" }, - new [] { "HardmodeOreTier3Text", "Your world has been blessed with Adamantite and Titanium!" }, - new [] { "HardmodeOreTier4Text", "The hallow has been blessed with consecrated stone!" }, + new [] { "HardmodeOreTier2Text", "Your world has been blessed with Mythril and Orichalcum!" }, + new [] { "HardmodeOreTier3Text", "Your world has been blessed with Adamantite and Titanium!" }, + new [] { "HardmodeOreTier4Text", "The hallow has been blessed with consecrated stone!" }, - new [] { "BloodMoonText", "The Blood Moon is rising..." }, + new [] { "BloodMoonText", "The Blood Moon is rising..." }, new [] { "DargonBossText", "The dark sun awaits." }, new [] { "DargonBossText2", "My dragon deems you an unworthy opponent. You must acquire the power of the dark sun to witness his true power." }, diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 2a982e75d2..8b195dc7ab 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -289,13 +289,13 @@ namespace CalamityMod // Hive Mind { BossDifficulty.TryGetValue("HiveMind", out float order); - List phases = new List() { NPCType(), NPCType() }; + int type = NPCType(); int summon = ItemType(); List loot = new List() { ItemType(), ItemType(), ItemID.DemoniteBar, ItemID.RottenChunk, ItemID.CursedFlame, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; string instructions = $"Kill a Cyst in the Corruption or use a [i:{summon}] in the Corruption"; string despawn = CalamityUtils.ColorMessage("The corrupted colony began searching for a new breeding ground.", new Color(0x94, 0x00, 0xD3)); - AddBoss(bossChecklist, calamity, "Hive Mind", order, phases, DownedHiveMind, summon, loot, collection, instructions, despawn); + AddBoss(bossChecklist, calamity, "Hive Mind", order, type, DownedHiveMind, summon, loot, collection, instructions, despawn); } // Perforators @@ -366,7 +366,7 @@ namespace CalamityMod int type = NPCType(); int summon = ItemType(); List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.BrokenHeroSword, ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; string instructions = $"Use an [i:{summon}] at Night"; string despawn = CalamityUtils.ColorMessage("If you wanted a fight, you should've came more prepared.", new Color(0xFF, 0xA5, 0x00)); AddBoss(bossChecklist, calamity, "Calamitas", order, type, DownedCalamitas, summon, loot, collection, instructions, despawn); @@ -389,7 +389,7 @@ namespace CalamityMod BossDifficulty.TryGetValue("Leviathan", out float order); List bosses = new List() { NPCType(), NPCType() }; List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.HotlineFishingHook, ItemID.BottomlessBucket, ItemID.SuperAbsorbantSponge, ItemID.FishingPotion, ItemID.SonarPotion, ItemID.CratePotion, ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; string instructions = "By killing an unknown entity in the Ocean Biome"; string despawn = CalamityUtils.ColorMessage("The aquatic entities sink back beneath the ocean depths.", new Color(0x7F, 0xFF, 0xD4)); string bossLogTex = "CalamityMod/NPCs/Leviathan/SirenandLevi_BossChecklist"; @@ -504,7 +504,7 @@ namespace CalamityMod // Storm Weaver { BossDifficulty.TryGetValue("StormWeaver", out float order); - List segments = new List() { NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType() }; + List segments = new List() { NPCType(), NPCType(), NPCType() }; int summon = ItemType(); List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; List collection = new List() { ItemType(), ItemType(), ItemType() }; @@ -553,7 +553,7 @@ namespace CalamityMod // Devourer of Gods { BossDifficulty.TryGetValue("DevourerOfGods", out float order); - int type = NPCType(); + int type = NPCType(); int summon = ItemType(); List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; List collection = new List() { ItemType(), ItemType(), ItemType() }; diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 8cce28d27a..496aaa8ed9 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -411,7 +411,37 @@ namespace CalamityMod.NPCs.Abyss npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; } - public override bool? CanBeHitByProjectile(Projectile projectile) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } + + if (adultWyrmAlive) + cooldownSlot = 1; + + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= 40f; + } + + public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) { diff --git a/NPCs/Abyss/EidolonWyrmHeadHuge.cs b/NPCs/Abyss/EidolonWyrmHeadHuge.cs index 8d64f1014f..291e425641 100644 --- a/NPCs/Abyss/EidolonWyrmHeadHuge.cs +++ b/NPCs/Abyss/EidolonWyrmHeadHuge.cs @@ -894,7 +894,7 @@ namespace CalamityMod.NPCs.Abyss { calamityGlobalNPC.newAI[2] += 1f; - float spinVelocityDivisor = targetDownDeep ? 180f : 120f; + float spinVelocityDivisor = targetDownDeep ? 120f : 90f; if (rotationDirection == 0) { // Set spin direction @@ -1172,7 +1172,7 @@ namespace CalamityMod.NPCs.Abyss if ((destination - npc.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[1] > 0f) { calamityGlobalNPC.newAI[1] += 1f; - float spinVelocityDivisor = targetDownDeep ? 180f : 120f; + float spinVelocityDivisor = targetDownDeep ? 90f : 60f; if (rotationDirection == 0) { // Set spin direction diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index f633fd921e..938137f84f 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -172,7 +172,9 @@ namespace CalamityMod.NPCs.AquaticScourge public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drops for Aquatic Scourge DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index c96b26ee26..e58d1ab3ac 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -319,7 +319,9 @@ namespace CalamityMod.NPCs.AstrumAureus public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Astrum Aureus DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs index 8a9db4814b..2eec48e262 100644 --- a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs @@ -229,7 +229,9 @@ namespace CalamityMod.NPCs.AstrumDeus otherWormHead.checkDead(); otherWormHead.netUpdate = true; } - } + } + + CalamityGlobalNPC.SetNewBossJustDowned(npc); DropHelper.DropBags(npc); diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index 5028ba34db..ab04092037 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -146,7 +146,9 @@ namespace CalamityMod.NPCs.BrimstoneElemental public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Brimstone Elemental DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); @@ -182,12 +184,6 @@ namespace CalamityMod.NPCs.BrimstoneElemental DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); } - //if brimmy hasn't been killed, you can mine charred ore - string key2 = "Mods.CalamityMod.BrimmyBossText"; - Color messageColor2 = Color.Crimson; - if (!CalamityWorld.downedBrimstoneElemental) - CalamityUtils.DisplayLocalizedText(key2, messageColor2); - // mark brimmy as dead CalamityWorld.downedBrimstoneElemental = true; CalamityNetcode.SyncWorld(); diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index 3ffcfe54aa..aad9d8deb9 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -407,7 +407,9 @@ namespace CalamityMod.NPCs.Bumblebirb public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Dragonfolly DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/Calamitas/CalamitasRun3.cs b/NPCs/Calamitas/CalamitasRun3.cs index d5047b4aee..2d5f4ac82f 100644 --- a/NPCs/Calamitas/CalamitasRun3.cs +++ b/NPCs/Calamitas/CalamitasRun3.cs @@ -151,7 +151,9 @@ namespace CalamityMod.NPCs.Calamitas public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Cal Clone DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 7168d6d218..692d3ff28c 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -81,6 +81,9 @@ namespace CalamityMod.NPCs public int KillTime { get; set; } = 0; + public const int DoGPhase1KillTime = 5400; + public const int DoGPhase2KillTime = 9000; + public bool ShouldFallThroughPlatforms; /// @@ -356,10 +359,7 @@ namespace CalamityMod.NPCs { NPCType(), NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() + NPCType() }; public static List CosmicGuardianIDs = new List @@ -452,9 +452,9 @@ namespace CalamityMod.NPCs public static List StormWeaverIDs = new List { - NPCType(), - NPCType(), - NPCType() + NPCType(), + NPCType(), + NPCType() }; public static List GrenadeResistIDs = new List @@ -744,7 +744,7 @@ namespace CalamityMod.NPCs ResetSavedIndex(ref signus, NPCType()); ResetSavedIndex(ref ghostBossClone, NPCType()); ResetSavedIndex(ref ghostBoss, NPCType()); - ResetSavedIndex(ref DoGHead, NPCType(), NPCType()); + ResetSavedIndex(ref DoGHead, NPCType()); ResetSavedIndex(ref SCalCataclysm, NPCType()); ResetSavedIndex(ref SCalCatastrophe, NPCType()); ResetSavedIndex(ref SCal, NPCType()); @@ -1062,7 +1062,11 @@ namespace CalamityMod.NPCs DR = newDR; } - if (CalamityMod.bossKillTimes.ContainsKey(npc.type)) + if (DevourerOfGodsIDs.Contains(npc.type)) + { + KillTime = DoGPhase1KillTime; + } + else if (CalamityMod.bossKillTimes.ContainsKey(npc.type)) { CalamityMod.bossKillTimes.TryGetValue(npc.type, out int revKillTime); KillTime = revKillTime; @@ -1925,8 +1929,8 @@ namespace CalamityMod.NPCs bool thanatos = ThanatosIDs.Contains(npc.type); // Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac - bool increasedTimedDR = !GetDownedBossVariable(npc.type) || malice || nightProvi || prePlant_Destroyer || prePlant_AS || preML_Deus || preDoG_SW || malice_DS_Perfs || thanatos; - if (KillTime > 0 && AITimer < KillTime && !BossRushEvent.BossRushActive && increasedTimedDR) + bool useTimedDR = !GetDownedBossVariable(npc.type) || malice || nightProvi || prePlant_Destroyer || prePlant_AS || preML_Deus || preDoG_SW || malice_DS_Perfs || thanatos; + if (KillTime > 0 && AITimer < KillTime && !BossRushEvent.BossRushActive && useTimedDR) { bool tenTimes_TimedDR = nightProvi; bool fiveTimes_TimedDR = prePlant_Destroyer || prePlant_AS || preML_Deus || preDoG_SW || malice_DS_Perfs; @@ -2080,7 +2084,8 @@ namespace CalamityMod.NPCs } } - if (npc.type != NPCType()) + bool DoGSentinelPhase = DevourerOfGodsIDs.Contains(npc.type) && npc.life / (float)npc.lifeMax < 0.6f && CalamityWorld.DoGSecondStageCountdown > 60; + if (npc.type != NPCType() && !DoGSentinelPhase) { if (AITimer < KillTime) AITimer++; @@ -3491,12 +3496,34 @@ namespace CalamityMod.NPCs // 25% resist to true melee. if (projectile.Calamity().trueMelee) damage = (int)(damage * 0.75); + + // 20% resist to Eclipse's Fall stealth strike. + else if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.8); + } + else if (npc.type == NPCType() || npc.type == NPCType()) + { + // 10% resist to Eclipse's Fall stealth strike. + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.9); } else if (ThanatosIDs.Contains(npc.type)) { + // 75% resist to Celestus. + if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) + damage = (int)(damage * 0.25); + // 50% resist to true melee. - if (projectile.Calamity().trueMelee) + else if (projectile.Calamity().trueMelee) damage = (int)(damage * 0.5); + + // 40% resist to Wrathwing stealth strike. + else if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.6); + + // 25% resist to Eradicator beams. + else if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.75); } else if (npc.type == NPCType()) { @@ -3953,7 +3980,12 @@ namespace CalamityMod.NPCs int spawnRate = 400; int maxSpawnCount = (int)MaxSpawnsField.GetValue(null); NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount); - for (int i = 0; i < 18; i++) + + // Enforce a limit on the amount of enemies that can appear. + if (player.activeNPCs >= maxSpawnCount) + return; + + for (int i = 0; i < 8; i++) { int checkPositionX = (int)(player.Center.X / 16 + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt()); int checkPositionY = (int)(player.Center.Y / 16 + Main.rand.Next(24, 45) * Main.rand.NextBool(2).ToDirectionInt()); @@ -4101,9 +4133,7 @@ namespace CalamityMod.NPCs } if (spawnInfo.player.Calamity().disableVoodooSpawns && pool.ContainsKey(NPCID.VoodooDemon)) - { pool.Remove(NPCID.VoodooDemon); - } } #endregion @@ -4968,7 +4998,7 @@ namespace CalamityMod.NPCs { return CalamityWorld.downedCrabulon; } - else if (type == NPCType() || type == NPCType()) + else if (type == NPCType()) { return CalamityWorld.downedHiveMind; } @@ -5032,7 +5062,7 @@ namespace CalamityMod.NPCs { return CalamityWorld.downedSentinel1; } - else if (type == NPCType() || type == NPCType() || type == NPCType()) + else if (type == NPCType() || type == NPCType() || type == NPCType()) { return CalamityWorld.downedSentinel2; } @@ -5048,7 +5078,7 @@ namespace CalamityMod.NPCs { return CalamityWorld.downedBoomerDuke; } - else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) + else if (type == NPCType() || type == NPCType() || type == NPCType()) { return CalamityWorld.downedDoG; } @@ -5073,6 +5103,26 @@ namespace CalamityMod.NPCs } #endregion + #region Speedrun Display + public static void SetNewBossJustDowned(NPC npc) + { + if (!GetDownedBossVariable(npc.type)) + { + CalamityLists.bossTypes.TryGetValue(npc.type, out int newBossTypeJustDowned); + + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (!player.active) + continue; + + player.Calamity().bossTypeJustDowned = newBossTypeJustDowned; + player.Calamity().bossTypeJustDownedTime = player.Calamity().speedrunTimer; + } + } + } + #endregion + #region Player Counts public static bool AnyLivingPlayers() { diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 3bb683a376..59db4f5dba 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -43,8 +43,6 @@ namespace CalamityMod.NPCs return false; } - // TODO -- why do we have random enemies dying in the abyss regardless of whether they're underwater - // this just causes multiplayer desyncs if anything if (AbyssLootCancel(npc, mod)) return false; @@ -98,6 +96,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedSlimeKing); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, NPC.downedSlimeKing); + CalamityGlobalNPC.SetNewBossJustDowned(npc); } else if (npc.type == NPCID.EyeofCthulhu) { @@ -106,7 +105,8 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedBoss1); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.Dryad }, NPC.downedBoss1); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss1); + CalamityGlobalNPC.SetNewBossJustDowned(npc); } else if ((npc.boss && (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail)) || npc.type == NPCID.BrainofCthulhu) { @@ -114,7 +114,8 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !WorldGen.crimson && !NPC.downedBoss2); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, WorldGen.crimson && !NPC.downedBoss2); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, WorldGen.crimson && !NPC.downedBoss2); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad }, NPC.downedBoss2); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss2); + CalamityGlobalNPC.SetNewBossJustDowned(npc); } else if (npc.type == NPCID.QueenBee) { @@ -139,6 +140,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedQueenBee); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Dryad }, NPC.downedQueenBee); + CalamityGlobalNPC.SetNewBossJustDowned(npc); } else if (npc.type == NPCID.SkeletronHead) { @@ -148,7 +150,8 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedBoss3); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.Dryad }, NPC.downedBoss3); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss3); + CalamityGlobalNPC.SetNewBossJustDowned(npc); } else if (npc.type == NPCID.WallofFlesh) { @@ -195,6 +198,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.hardMode); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.hardMode); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad, NPCID.Painter, NPCID.WitchDoctor, NPCID.Stylist, NPCID.DyeTrader, NPCID.Demolitionist, NPCID.PartyGirl, NPCID.Clothier, NPCID.SkeletonMerchant, ModContent.NPCType() }, Main.hardMode); + CalamityGlobalNPC.SetNewBossJustDowned(npc); // First kill text (this is not a loot function) if (!Main.hardMode) @@ -232,7 +236,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMechBoss2); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || NPC.downedMechBoss2 || !NPC.downedMechBoss3); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Steampunker }, NPC.downedMechBoss2 || !CalamityConfig.Instance.SellVanillaSummons); + CalamityGlobalNPC.SetNewBossJustDowned(npc); if (!NPC.downedMechBoss2 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) SpawnMechBossHardmodeOres(); @@ -252,7 +256,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMechBoss1); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Steampunker }, NPC.downedMechBoss1 || !CalamityConfig.Instance.SellVanillaSummons); + CalamityGlobalNPC.SetNewBossJustDowned(npc); if (!NPC.downedMechBoss1 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) SpawnMechBossHardmodeOres(); @@ -273,7 +277,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMechBoss3); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || !NPC.downedMechBoss2 || NPC.downedMechBoss3); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Steampunker }, NPC.downedMechBoss3 || !CalamityConfig.Instance.SellVanillaSummons); + CalamityGlobalNPC.SetNewBossJustDowned(npc); if (!NPC.downedMechBoss3 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) SpawnMechBossHardmodeOres(); @@ -310,6 +314,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedPlantBoss); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.WitchDoctor, NPCID.Truffle, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedPlantBoss); + CalamityGlobalNPC.SetNewBossJustDowned(npc); // Spawn Perennial Ore if Plantera has never been killed if (!NPC.downedPlantBoss) @@ -376,6 +381,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedGolemBoss); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Cyborg, NPCID.Steampunker, NPCID.Wizard, NPCID.WitchDoctor, NPCID.DD2Bartender, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedGolemBoss); + CalamityGlobalNPC.SetNewBossJustDowned(npc); // If Golem has never been killed, send a message about the Plague. if (!NPC.downedGolemBoss) @@ -428,7 +434,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedFishron); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, NPC.downedFishron || !CalamityConfig.Instance.SellVanillaSummons); + CalamityGlobalNPC.SetNewBossJustDowned(npc); } else if (npc.type == NPCID.CultistBoss) { @@ -438,6 +444,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedAncientCultist); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, Main.bloodMoon); + CalamityGlobalNPC.SetNewBossJustDowned(npc); // Deus text (this is not a loot function) if (!NPC.downedAncientCultist) @@ -483,7 +490,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMoonlord); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, NPC.downedMoonlord); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Wizard }, NPC.downedMoonlord || !CalamityConfig.Instance.SellVanillaSummons); + CalamityGlobalNPC.SetNewBossJustDowned(npc); string key = "Mods.CalamityMod.MoonBossText"; Color messageColor = Color.Orange; @@ -1361,6 +1368,6 @@ namespace CalamityMod.NPCs } } } - #endregion - } + #endregion + } } diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index e1a26ac05e..c3f9633a97 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -7,7 +7,6 @@ using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.Fountains; using CalamityMod.Items.Placeables.Walls; using CalamityMod.Items.Potions; -using CalamityMod.Items.SummonItems; using CalamityMod.Items.SummonItems.Invasion; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -69,6 +68,8 @@ namespace CalamityMod.NPCs "Verth", "Gormer", // <@!287651204924833795> (Picasso's Bean#2819 -- RIP) "TingFlarg", // <@!185605031716847616> (Smug#7160) + "Driser", // <@!121996994406252544> (Driser#8630) + "Eddie Spaghetti", // <@!466397267407011841> (Eddie Spaghetti#0002) }; private const int GuideVanillaNames = 34; private static readonly string[] GuideNames = @@ -137,6 +138,11 @@ namespace CalamityMod.NPCs { "Emmett", }; + private const int TravelingMerchantVanillaNames = 13; + private static readonly string[] TravelingMerchantNames = + { + "Stan Pines", + }; private const int TruffleVanillaNames = 12; private static readonly string[] TruffleNames = null; private const int WitchDoctorVanillaNames = 10; @@ -189,6 +195,7 @@ namespace CalamityMod.NPCs ResetName(NPCID.Stylist, ref CalamityWorld.stylistName); ResetName(NPCID.DD2Bartender, ref CalamityWorld.tavernkeepName); ResetName(NPCID.TaxCollector, ref CalamityWorld.taxCollectorName); + ResetName(NPCID.TravellingMerchant, ref CalamityWorld.travelingMerchantName); ResetName(NPCID.Truffle, ref CalamityWorld.truffleName); ResetName(NPCID.WitchDoctor, ref CalamityWorld.witchDoctorName); ResetName(NPCID.Wizard, ref CalamityWorld.wizardName); @@ -281,6 +288,9 @@ namespace CalamityMod.NPCs case NPCID.TaxCollector: npc.GivenName = ChooseName(ref CalamityWorld.taxCollectorName, npc.GivenName, TaxCollectorVanillaNames, TaxCollectorNames); break; + case NPCID.TravellingMerchant: + npc.GivenName = ChooseName(ref CalamityWorld.travelingMerchantName, npc.GivenName, TravelingMerchantVanillaNames, TravelingMerchantNames); + break; case NPCID.Truffle: npc.GivenName = ChooseName(ref CalamityWorld.truffleName, npc.GivenName, TruffleVanillaNames, TruffleNames); break; @@ -1183,7 +1193,8 @@ namespace CalamityMod.NPCs if (type == NPCID.Merchant) { - SetShopItem(ref shop, ref nextSlot, ItemID.WormholePotion, true, Item.buyPrice(0, 0, 25, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.Bottle, true, Item.buyPrice(0, 0, 0, 20)); + SetShopItem(ref shop, ref nextSlot, ItemID.WormholePotion, true, Item.buyPrice(0, 0, 25, 0)); SetShopItem(ref shop, ref nextSlot, ItemID.ArcheryPotion, NPC.downedBoss1, Item.buyPrice(0, goldCost, 0, 0)); SetShopItem(ref shop, ref nextSlot, ItemID.HealingPotion, NPC.downedBoss2); SetShopItem(ref shop, ref nextSlot, ItemID.ManaPotion, NPC.downedBoss2); @@ -1262,18 +1273,10 @@ namespace CalamityMod.NPCs SetShopItem(ref shop, ref nextSlot, ItemID.SwiftnessPotion, NPC.downedBoss2, Item.buyPrice(0, goldCost, 0, 0)); SetShopItem(ref shop, ref nextSlot, ItemID.JungleRose, price: Item.buyPrice(0, 2)); SetShopItem(ref shop, ref nextSlot, ItemID.NaturesGift, price: Item.buyPrice(0, 10)); - SetShopItem(ref shop, ref nextSlot, ItemID.SlimeCrown, NPC.downedSlimeKing && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 2)); - SetShopItem(ref shop, ref nextSlot, ItemID.SuspiciousLookingEye, NPC.downedBoss1 && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 3)); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedCrabulon, Item.buyPrice(0, 4)); - SetShopItem(ref shop, ref nextSlot, ItemID.BloodySpine, NPC.downedBoss2 && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 6)); - SetShopItem(ref shop, ref nextSlot, ItemID.WormFood, NPC.downedBoss2 && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 6)); SetShopItem(ref shop, ref nextSlot, WorldGen.crimson ? ItemID.BandofStarpower : ItemID.PanicNecklace, WorldGen.shadowOrbSmashed || NPC.downedBoss2); SetShopItem(ref shop, ref nextSlot, WorldGen.crimson ? ItemID.WormScarf : ItemID.BrainOfConfusion, Main.expertMode && NPC.downedBoss2); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPerforator, Item.buyPrice(0, 10)); SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPerforator && Main.expertMode); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedHiveMind, Item.buyPrice(0, 10)); SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedHiveMind && Main.expertMode); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedSlimeGod, Item.buyPrice(0, 15)); SetShopItem(ref shop, ref nextSlot, ItemType()); } @@ -1317,9 +1320,6 @@ namespace CalamityMod.NPCs if (type == NPCID.Steampunker) { - SetShopItem(ref shop, ref nextSlot, ItemID.MechanicalWorm, NPC.downedMechBoss1 && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 20)); - SetShopItem(ref shop, ref nextSlot, ItemID.MechanicalEye, NPC.downedMechBoss2 && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 20)); - SetShopItem(ref shop, ref nextSlot, ItemID.MechanicalSkull, NPC.downedMechBoss3 && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 20)); SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 0, 5)); } @@ -1329,15 +1329,11 @@ namespace CalamityMod.NPCs SetShopItem(ref shop, ref nextSlot, ItemID.MagicPowerPotion, true, Item.buyPrice(0, goldCost, 0, 0)); SetShopItem(ref shop, ref nextSlot, ItemID.GravitationPotion, true, Item.buyPrice(0, 2, 0, 0)); SetShopItem(ref shop, ref nextSlot, ItemType()); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedBrimstoneElemental, Item.buyPrice(0, 20)); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedAstrageldon, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.MagicMissile, price: Item.buyPrice(0, 5)); SetShopItem(ref shop, ref nextSlot, ItemID.SpectreStaff, NPC.downedGolemBoss, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.InfernoFork, NPC.downedGolemBoss, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.ShadowbeamStaff, NPC.downedGolemBoss, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.MagnetSphere, NPC.downedGolemBoss, Item.buyPrice(0, 25)); - SetShopItem(ref shop, ref nextSlot, ItemID.CelestialSigil, NPC.downedMoonlord && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(3)); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedGuardians, Item.buyPrice(5)); } if (type == NPCID.WitchDoctor) @@ -1350,13 +1346,8 @@ namespace CalamityMod.NPCs SetShopItem(ref shop, ref nextSlot, ItemType()); SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode); SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode); - SetShopItem(ref shop, ref nextSlot, ItemID.Abeemination, CalamityConfig.Instance.SellVanillaSummons, price: Item.buyPrice(0, 8)); - SetShopItem(ref shop, ref nextSlot, ItemType(), NPC.downedPlantBoss && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 20)); SetShopItem(ref shop, ref nextSlot, ItemID.SolarTablet, NPC.downedGolemBoss, Item.buyPrice(0, 25)); - SetShopItem(ref shop, ref nextSlot, ItemID.LihzahrdPowerCell, NPC.downedGolemBoss && CalamityConfig.Instance.SellVanillaSummons, Item.buyPrice(0, 30)); SetShopItem(ref shop, ref nextSlot, ItemID.ButterflyDust, NPC.downedGolemBoss, Item.buyPrice(0, 10)); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedScavenger, Item.buyPrice(0, 50)); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedBumble, Item.buyPrice(5)); } if (type == NPCID.PartyGirl) diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 51309e5ddf..32f0e4c0a1 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -159,6 +159,8 @@ namespace CalamityMod.NPCs.CeaselessVoid bool fullStrength = !CalamityWorld.downedSentinel1 || CalamityWorld.DoGSecondStageCountdown <= 0; if (fullStrength) { + CalamityGlobalNPC.SetNewBossJustDowned(npc); + DropHelper.DropBags(npc); // Legendary drop for Ceaseless Void diff --git a/NPCs/Crabulon/CrabulonIdle.cs b/NPCs/Crabulon/CrabulonIdle.cs index 98f3bea9e3..991ec6027b 100644 --- a/NPCs/Crabulon/CrabulonIdle.cs +++ b/NPCs/Crabulon/CrabulonIdle.cs @@ -665,7 +665,9 @@ namespace CalamityMod.NPCs.Crabulon public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Crabulon DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); @@ -673,8 +675,6 @@ namespace CalamityMod.NPCs.Crabulon DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedCrabulon); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, CalamityWorld.downedCrabulon); - // All other drops are contained in the bag, so they only drop directly on Normal if (!Main.expertMode) { diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 1f89fb60ec..a847a75bc3 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -1089,7 +1089,9 @@ namespace CalamityMod.NPCs.Cryogen public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drops for Cryogen DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 0deb863734..f2b979ec74 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -555,7 +555,9 @@ namespace CalamityMod.NPCs.DesertScourge public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Desert Scourge DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); @@ -564,8 +566,6 @@ namespace CalamityMod.NPCs.DesertScourge DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedDesertScourge); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedDesertScourge); - // All other drops are contained in the bag, so they only drop directly on Normal if (!Main.expertMode) { diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index d3e305b140..7965ef0ce0 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -1,7 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; -using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,13 +9,26 @@ using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.NPCs.DevourerofGods { public class DevourerofGodsBody : ModNPC { - private int invinceTime = 360; + public static int phase2IconIndex; - public override void SetStaticDefaults() + internal static void LoadHeadIcons() + { + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss"; + + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } + + private int invinceTime = 360; + private bool setAlpha = false; + private bool phase2Started = false; + + public override void SetStaticDefaults() { DisplayName.SetDefault("The Devourer of Gods"); } @@ -32,7 +44,7 @@ namespace CalamityMod.NPCs.DevourerofGods CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.925f; global.unbreakableDR = true; - npc.LifeMaxNERB(371250, 445500); + npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -52,26 +64,68 @@ namespace CalamityMod.NPCs.DevourerofGods npc.dontCountMe = true; } - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) + { + if (phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60) + index = phase2IconIndex; + else + index = -1; + } + + public override void BossHeadRotation(ref float rotation) + { + if (phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60) + rotation = npc.rotation; + } + + public override void SendExtraAI(BinaryWriter writer) { - writer.Write(invinceTime); + writer.Write(phase2Started); + writer.Write(invinceTime); writer.Write(npc.dontTakeDamage); - } + writer.Write(setAlpha); + writer.Write(npc.alpha); + } public override void ReceiveExtraAI(BinaryReader reader) { - invinceTime = reader.ReadInt32(); + phase2Started = reader.ReadBoolean(); + invinceTime = reader.ReadInt32(); npc.dontTakeDamage = reader.ReadBoolean(); - } + setAlpha = reader.ReadBoolean(); + npc.alpha = reader.ReadInt32(); + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; } - public override void AI() + public override void AI() { - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0f, 0.2f, 0.25f); + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + if (npc.life / (float)npc.lifeMax < 0.6f) + { + phase2Started = true; + + // 8.833 seconds before DoG spawns, start playing the phase 2 music and set new size + if (CalamityWorld.DoGSecondStageCountdown == 530) + { + music = CalamityMod.Instance.GetMusicFromMusicMod("UniversalCollapse") ?? MusicID.LunarBoss; + + npc.position = npc.Center; + npc.width = 70; + npc.height = 70; + npc.position -= npc.Size * 0.5f; + } + } + + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); if (invinceTime > 0) { @@ -79,14 +133,14 @@ namespace CalamityMod.NPCs.DevourerofGods npc.dontTakeDamage = true; } else - npc.dontTakeDamage = false; + npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (Main.npc[(int)npc.ai[2]].dontTakeDamage) + invinceTime = 240; // Target if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + npc.TargetClosest(); Player player = Main.player[npc.target]; @@ -115,25 +169,17 @@ namespace CalamityMod.NPCs.DevourerofGods npc.active = false; } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - if (player.dead) - npc.TargetClosest(false); + if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) + { + npc.alpha -= 42; + if (npc.alpha <= 0 && invinceTime <= 0) + { + setAlpha = true; + npc.alpha = 0; + } + } + else + npc.alpha = Main.npc[(int)npc.ai[2]].alpha; 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); @@ -179,7 +225,8 @@ namespace CalamityMod.NPCs.DevourerofGods if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; + bool useOtherTextures = phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; + Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS") : Main.npcTexture[npc.type]; Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector43 = npc.Center - Main.screenPosition; @@ -187,21 +234,48 @@ namespace CalamityMod.NPCs.DevourerofGods vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyGlow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + if (!npc.dontTakeDamage) + { + if (useOtherTextures) + { + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow"); + Color color36 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color36, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyGlow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } return false; } public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } + { + cooldownSlot = 1; - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= (phase2Started ? 55f : 40f) && npc.alpha == 0 && invinceTime <= 0; + } + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { return !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); } @@ -216,42 +290,40 @@ namespace CalamityMod.NPCs.DevourerofGods return false; } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - float randomSpread = Main.rand.Next(-100, 100) / 100; - Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoGBody"), 1f); - Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoGBody2"), 1f); - Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoGBody3"), 1f); - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 20; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + float randomSpread = Main.rand.Next(-100, 100) / 100; + Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoGS6"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 50; + npc.height = 50; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 10; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 20; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyS.cs b/NPCs/DevourerofGods/DevourerofGodsBodyS.cs deleted file mode 100644 index 1182e77abd..0000000000 --- a/NPCs/DevourerofGods/DevourerofGodsBodyS.cs +++ /dev/null @@ -1,278 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.NPCs.DevourerofGods -{ - [AutoloadBossHead] - public class DevourerofGodsBodyS : ModNPC - { - private int invinceTime = 360; - private bool setAlpha = false; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Devourer of Gods"); - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 70; - npc.height = 70; - npc.defense = 70; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.925f; - global.unbreakableDR = true; - npc.LifeMaxNERB(517500, 621000, 920000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.chaseable = false; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; - npc.netAlways = true; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("UniversalCollapse") ?? MusicID.LunarBoss; - npc.dontCountMe = true; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(setAlpha); - writer.Write(npc.dontTakeDamage); - writer.Write(npc.alpha); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - setAlpha = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.alpha = reader.ReadInt32(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void BossHeadRotation(ref float rotation) - { - rotation = npc.rotation; - } - - public override void AI() - { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - if (invinceTime > 0) - { - invinceTime--; - npc.dontTakeDamage = true; - } - else - npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - - if (Main.npc[(int)npc.ai[2]].dontTakeDamage) - invinceTime = 240; - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Target - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); - - Player player = Main.player[npc.target]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - - if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) - { - npc.alpha -= 42; - if (npc.alpha <= 0 && invinceTime <= 0) - { - setAlpha = true; - npc.alpha = 0; - } - } - else - npc.alpha = Main.npc[(int)npc.ai[2]].alpha; - - if (player.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 = player.position.X + (float)(player.width / 2); - float num192 = player.position.Y + (float)(player.height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - - if (num191 < 0f) - npc.spriteDirection = -1; - else if (num191 > 0f) - npc.spriteDirection = 1; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - if (!npc.dontTakeDamage) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow2"); - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return npc.alpha == 0 && invinceTime <= 0; - } - - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - return !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); - } - - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return false; - } - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - float randomSpread = (float)(Main.rand.Next(-100, 100) / 100); - Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoGS6"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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; - } - } - for (int num623 = 0; num623 < 20; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 240, true); - player.AddBuff(ModContent.BuffType(), 300, true); - } - } -} diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 4adfc6b129..9f5c187c2f 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -1,7 +1,22 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.CalPlayer; using CalamityMod.Dusts; +using CalamityMod.Events; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.LoreItems; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Mounts; +using CalamityMod.Items.Placeables.Furniture.Trophies; +using CalamityMod.Items.Placeables.FurnitureCosmilite; using CalamityMod.Items.Potions; +using CalamityMod.Items.TreasureBags; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -15,9 +30,26 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DevourerofGods { - [AutoloadBossHead] public class DevourerofGodsHead : ModNPC { + public static int phase1IconIndex; + public static int phase2IconIndex; + + internal static void LoadHeadIcons() + { + string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss"; + + CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); + phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); + + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } + + // Phase 1 variables + + // Enums private enum LaserWallType { DiagonalRight = 0, @@ -26,6 +58,7 @@ namespace CalamityMod.NPCs.DevourerofGods DiagonalCross = 3 } + // Laser spread variables private const int shotSpacingMax = 750; private int shotSpacing = shotSpacingMax; private const int spacingVar = 250; @@ -33,14 +66,55 @@ namespace CalamityMod.NPCs.DevourerofGods private int laserWallType = 0; private const float laserWallSpacingOffset = 16f; + // Spawn variables private bool tail = false; - private const int minLength = 80; - private const int maxLength = 81; - private bool halfLife = false; - private bool halfLife2 = false; - private int spawnDoGCountdown = 0; + private const int minLength = 100; + private const int maxLength = 101; - public override void SetStaticDefaults() + // Phase variables + private bool spawnedGuardians = false; + private bool spawnedGuardians2 = false; + private int spawnDoGCountdown = 0; + private bool phase2Started = false; + + // Phase 2 variables + + // Enums + private enum LaserWallPhase + { + SetUp = 0, + FireLaserWalls = 1, + End = 2 + } + private enum LaserWallType_Phase2 + { + Normal = 0, + Offset = 1, + MultiLayered = 2, + DiagonalHorizontal = 3, + DiagonalVertical = 4 + } + + // Laser wall variables + private const int shotSpacingMax_Phase2 = 1050; + private int[] shotSpacing_Phase2 = new int[4] { shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2 }; + private const int spacingVar_Phase2 = 105; + private const int diagonalSpacingVar = 350; + private const int totalShots_Phase2 = 20; + private const int totalDiagonalShots = 6; + private int laserWallType_Phase2 = 0; + public int laserWallPhase = 0; + + // Phase variables + private const int idleCounterMax = 360; + private int idleCounter = idleCounterMax; + private int postTeleportTimer = 0; + private int teleportTimer = -1; + private bool spawnedGuardians3 = false; + private int preventBullshitHitsAtStartofFinalPhaseTimer = 0; + private const float alphaGateValue = 669f; + + public override void SetStaticDefaults() { DisplayName.SetDefault("The Devourer of Gods"); } @@ -53,7 +127,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.width = 104; npc.height = 104; npc.defense = 50; - npc.LifeMaxNERB(371250, 445500); + npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.takenDamageMultiplier = 1.1f; @@ -61,7 +135,7 @@ namespace CalamityMod.NPCs.DevourerofGods aiType = -1; npc.knockBackResist = 0f; npc.boss = true; - npc.value = Item.buyPrice(0, 40, 0, 0); + npc.value = Item.buyPrice(1, 20, 0, 0); npc.alpha = 255; npc.behindTiles = true; npc.noGravity = true; @@ -69,29 +143,80 @@ namespace CalamityMod.NPCs.DevourerofGods npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - } + bossBag = ModContent.ItemType(); + } - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) + { + if (phase2Started && CalamityWorld.DoGSecondStageCountdown > 60) + index = -1; + else if (phase2Started) + index = phase2IconIndex; + else + index = phase1IconIndex; + } + + public override void BossHeadRotation(ref float rotation) + { + if (phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60) + rotation = npc.rotation; + } + + public override void SendExtraAI(BinaryWriter writer) { - writer.Write(halfLife); - writer.Write(halfLife2); - writer.Write(spawnDoGCountdown); + // Phase 1 syncs + writer.Write(npc.dontTakeDamage); + writer.Write(spawnedGuardians); + writer.Write(spawnedGuardians2); + writer.Write(spawnedGuardians3); + writer.Write(phase2Started); + writer.Write(spawnDoGCountdown); writer.Write(shotSpacing); writer.Write(laserWallType); for (int i = 0; i < 4; i++) writer.Write(npc.Calamity().newAI[i]); - } + + // Phase 2 syncs + writer.Write(shotSpacing_Phase2[0]); + writer.Write(shotSpacing_Phase2[1]); + writer.Write(shotSpacing_Phase2[2]); + writer.Write(shotSpacing_Phase2[3]); + writer.Write(idleCounter); + writer.Write(laserWallPhase); + writer.Write(laserWallType_Phase2); + writer.Write(postTeleportTimer); + writer.Write(preventBullshitHitsAtStartofFinalPhaseTimer); + writer.Write(teleportTimer); + writer.Write(npc.alpha); + } public override void ReceiveExtraAI(BinaryReader reader) { - halfLife = reader.ReadBoolean(); - halfLife2 = reader.ReadBoolean(); - spawnDoGCountdown = reader.ReadInt32(); + // Phase 1 syncs + npc.dontTakeDamage = reader.ReadBoolean(); + spawnedGuardians = reader.ReadBoolean(); + spawnedGuardians2 = reader.ReadBoolean(); + spawnedGuardians3 = reader.ReadBoolean(); + phase2Started = reader.ReadBoolean(); + spawnDoGCountdown = reader.ReadInt32(); shotSpacing = reader.ReadInt32(); laserWallType = reader.ReadInt32(); for (int i = 0; i < 4; i++) npc.Calamity().newAI[i] = reader.ReadSingle(); - } + + // Phase 2 syncs + shotSpacing_Phase2[0] = reader.ReadInt32(); + shotSpacing_Phase2[1] = reader.ReadInt32(); + shotSpacing_Phase2[2] = reader.ReadInt32(); + shotSpacing_Phase2[3] = reader.ReadInt32(); + idleCounter = reader.ReadInt32(); + laserWallPhase = reader.ReadInt32(); + laserWallType_Phase2 = reader.ReadInt32(); + postTeleportTimer = reader.ReadInt32(); + preventBullshitHitsAtStartofFinalPhaseTimer = reader.ReadInt32(); + teleportTimer = reader.ReadInt32(); + npc.alpha = reader.ReadInt32(); + } public override void AI() { @@ -106,10 +231,12 @@ namespace CalamityMod.NPCs.DevourerofGods // Variables Vector2 vector = npc.Center; bool flies = npc.ai[3] == 0f; - bool malice = CalamityWorld.malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || malice; bool revenge = CalamityWorld.revenge || malice; bool death = CalamityWorld.death || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -121,10 +248,16 @@ namespace CalamityMod.NPCs.DevourerofGods lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; } - bool phase2 = lifeRatio < 0.75f; - bool phase3 = lifeRatio < 0.2f; + // Phase 1 phases + bool phase2 = lifeRatio < 0.9f; + bool phase3 = lifeRatio < 0.68f; + bool summonSentinels = npc.life / (float)npc.lifeMax < 0.6f; - npc.Calamity().CurrentlyEnraged = malice; + // Phase 2 phases + bool phase4 = lifeRatio < 0.48f; + bool phase5 = lifeRatio < 0.36f; + bool phase6 = lifeRatio < 0.18f; + bool phase7 = lifeRatio < 0.09f; // Light Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); @@ -156,718 +289,1761 @@ namespace CalamityMod.NPCs.DevourerofGods else npc.takenDamageMultiplier = 1.1f; - // Spawn Guardians - if (phase3) - { - if (!halfLife) - { - if (revenge) - spawnDoGCountdown = 10; - - string key = "Mods.CalamityMod.EdgyBossText"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - npc.TargetClosest(); - halfLife = true; - } - if (spawnDoGCountdown > 0) - { - spawnDoGCountdown--; - if (spawnDoGCountdown == 0 && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); - - for (int i = 0; i < 2; i++) - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - } - } - } - else if (phase2) - { - if (!halfLife2) - { - if (revenge) - spawnDoGCountdown = 10; - - halfLife2 = true; - } - if (spawnDoGCountdown > 0) - { - spawnDoGCountdown--; - if (spawnDoGCountdown == 0 && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); - - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - } - } - } - - // Spawn dust - if (npc.alpha != 0) - { - for (int spawnDust = 0; spawnDust < 2; spawnDust++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - - // Alpha - npc.alpha -= 12; - if (npc.alpha < 0) - npc.alpha = 0; - - // Spawn segments - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tail && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - for (int segmentSpawn = 0; segmentSpawn < maxLength; segmentSpawn++) - { - int segment; - if (segmentSpawn >= 0 && segmentSpawn < minLength) - segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - else - segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - - Main.npc[segment].realLife = npc.whoAmI; - Main.npc[segment].ai[2] = npc.whoAmI; - Main.npc[segment].ai[1] = Previous; - Main.npc[Previous].ai[0] = segment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment, 0f, 0f, 0f, 0); - Previous = segment; - } - tail = true; - } - - if (phase2) + // Start sentinel phases, only run things that have to happen once in here + if (summonSentinels) + { + if (!phase2Started) { - float speed = 12f; - float spawnOffset = 1500f; - float divisor = malice ? 240f : death ? 360f : 480f; + phase2Started = true; - if (calamityGlobalNPC.newAI[1] % divisor == 0f) - { - Main.PlaySound(SoundID.Item12, player.position); + // Timed DR and aggression + calamityGlobalNPC.KillTime = CalamityGlobalNPC.DoGPhase2KillTime; + calamityGlobalNPC.AITimer = 0; + calamityGlobalNPC.AIIncreasedAggressionTimer = 0; + calamityGlobalNPC.killTimeRatio_IncreasedAggression = 0f; - // Side walls - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 start = default; - Vector2 velocity = default; - Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; - Vector2 aimClone = aim; - - switch (laserWallType) - { - case (int)LaserWallType.DiagonalRight: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode) - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); - - laserWallType = (int)LaserWallType.DiagonalLeft; - break; - - case (int)LaserWallType.DiagonalLeft: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode) - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); - - laserWallType = expertMode ? (int)LaserWallType.DiagonalHorizontal : (int)LaserWallType.DiagonalRight; - break; - - case (int)LaserWallType.DiagonalHorizontal: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode) - { - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); - } - - laserWallType = revenge ? (int)LaserWallType.DiagonalCross : (int)LaserWallType.DiagonalRight; - break; - - case (int)LaserWallType.DiagonalCross: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing, player.position.Y + spawnOffset); - aimClone.X += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aimClone - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing, player.position.Y - spawnOffset); - velocity = Vector2.Normalize(aimClone - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode) - { - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); - } - - laserWallType = (int)LaserWallType.DiagonalRight; - break; - } - shotSpacing = shotSpacingMax; - } - - calamityGlobalNPC.newAI[1] += 1f; - } - else + // Reset important shit + npc.ai[3] = 0f; calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + + // Skip the sentinel phase entirely if DoG has already been killed + CalamityWorld.DoGSecondStageCountdown = (CalamityWorld.downedDoG || CalamityWorld.downedSecondSentinels) ? 600 : 21600; + + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); + netMessage.Write(CalamityWorld.DoGSecondStageCountdown); + netMessage.Send(); + } + } + + // 8.833 seconds before DoG spawns, start playing the phase 2 music and set new size + if (CalamityWorld.DoGSecondStageCountdown == 530) + { + music = CalamityMod.Instance.GetMusicFromMusicMod("UniversalCollapse") ?? MusicID.LunarBoss; + + npc.position = npc.Center; + npc.width = 186; + npc.height = 186; + npc.position -= npc.Size * 0.5f; + } + + // Dialogue the moment the second phase starts + if (CalamityWorld.DoGSecondStageCountdown == 60) + { + string key = "Mods.CalamityMod.EdgyBossText10"; + Color messageColor = Color.Cyan; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } } - // Despawn - if (player.dead) - { - npc.TargetClosest(false); - flies = true; - - npc.velocity.Y -= 3f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 3f; - - int bodyType = ModContent.NPCType(); - int tailType = ModContent.NPCType(); - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type != npc.type && Main.npc[a].type != bodyType && Main.npc[a].type != tailType) - continue; - - Main.npc[a].active = false; - Main.npc[a].netUpdate = true; - } - } - } - - // Movement - int num180 = (int)(npc.position.X / 16f) - 1; - int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num182 = (int)(npc.position.Y / 16f) - 1; - int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; - - if (num180 < 0) - num180 = 0; - if (num181 > Main.maxTilesX) - num181 = Main.maxTilesX; - if (num182 < 0) - num182 = 0; - if (num183 > Main.maxTilesY) - num183 = Main.maxTilesY; - - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - // Flight - if (npc.ai[3] == 0f) - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - - // Flying movement - npc.localAI[1] = 0f; - - float phaseChangeRate = 1f + (expertMode ? 9f * (1f - lifeRatio) : 0f); - calamityGlobalNPC.newAI[2] += phaseChangeRate; - - float speed = malice ? 18f : death ? 16.5f : 15f; - float turnSpeed = malice ? 0.36f : death ? 0.33f : 0.3f; - float homingSpeed = malice ? 27f : death ? 22.5f : 18f; - float homingTurnSpeed = malice ? 0.48f : death ? 0.405f : 0.33f; - - if (expertMode) + // Begin phase 2 once all sentinels are down + if (phase2Started) + { + // Go immune and invisible if sentinels are alive + if (CalamityWorld.DoGSecondStageCountdown > 60) { - speed += 3f * (1f - lifeRatio); - turnSpeed += 0.06f * (1f - lifeRatio); - homingSpeed += 9f * (1f - lifeRatio); - homingTurnSpeed += 0.15f * (1f - lifeRatio); + // Don't take damage + npc.dontTakeDamage = true; + + // Go invisible + npc.alpha += 5; + if (npc.alpha > 255) + npc.alpha = 255; + + // Fly below the target + if (!player.dead) + { + // Increase velocity if velocity is ever zero + if (npc.velocity == Vector2.Zero) + npc.velocity = Vector2.Normalize(player.Center - npc.Center).SafeNormalize(Vector2.Zero) * 20f; + + // Acceleration + Vector2 destination = new Vector2(player.Center.X, player.Center.Y + 800f); + if (!((destination - npc.Center).Length() < 400f)) + { + float targetAngle = npc.AngleTo(destination); + float f = npc.velocity.ToRotation().AngleTowards(targetAngle, 2.5f); + npc.velocity = f.ToRotationVector2() * 20f; + } + } + else + { + // Despawn + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type != npc.type && Main.npc[a].type != bodyType && Main.npc[a].type != tailType) + continue; + + Main.npc[a].active = false; + Main.npc[a].netUpdate = true; + } + } + } + + // Velocity upper limit + if (npc.velocity.Length() > 20f) + npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * 20f; } - // Go to ground phase sooner - if (increaseSpeedMore) - calamityGlobalNPC.newAI[2] += 10f; - else if (increaseSpeed) - calamityGlobalNPC.newAI[2] += 2f; - - float num188 = speed; - float num189 = turnSpeed; - 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); - - 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 = num42 - 800; - if (player.position.Y > num47) - { - num192 = num47; - if (Math.Abs(npc.Center.X - player.Center.X) < 500f) - { - if (npc.velocity.X > 0f) - num191 = player.Center.X + 600f; - else - num191 = player.Center.X - 600f; - } - } - } - else - { - num188 = homingSpeed; - num189 = homingTurnSpeed; - } - - if (expertMode) + // Phase 2 + else { - num188 += distanceFromTarget * 0.005f * (1f - lifeRatio); - num189 += distanceFromTarget * 0.0001f * (1f - lifeRatio); - } + // Immunity after teleport + npc.dontTakeDamage = postTeleportTimer > 0 || preventBullshitHitsAtStartofFinalPhaseTimer > 0; - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } + // Teleport + if (teleportTimer >= 0) + { + teleportTimer--; + if (teleportTimer == 0) + Teleport(player, malice, death, revenge, expertMode, phase5); + } - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; + // Laser walls + if (phase4 && !phase6 && postTeleportTimer <= 0) + { + if (laserWallPhase == (int)LaserWallPhase.SetUp) + { + // Increment next laser wall phase timer + calamityGlobalNPC.newAI[3] += 1f; - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189; - else - { - if (npc.velocity.X > num191) - npc.velocity.X -= num189; - } + // Set alpha value prior to firing laser walls + if (calamityGlobalNPC.newAI[3] > alphaGateValue) + { + // Disable teleports + if (teleportTimer >= 0) + { + GetRiftLocation(false); + teleportTimer = -1; + } - if (npc.velocity.Y < num192) - npc.velocity.Y += num189; - else - { - if (npc.velocity.Y > num192) - npc.velocity.Y -= num189; - } + npc.alpha = (int)MathHelper.Clamp((calamityGlobalNPC.newAI[3] - alphaGateValue) * 5f, 0f, 255f); + } - if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num189 * 2f; - else - npc.velocity.Y -= num189 * 2f; - } + // Fire laser walls every 12 seconds after a laser wall phase ends + if (calamityGlobalNPC.newAI[3] >= 720f) + { + npc.alpha = 255; - if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num189 * 2f; - else - npc.velocity.X -= num189 * 2f; - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189 * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189 * 1.1f; + // Reset laser wall timer to 0 + calamityGlobalNPC.newAI[1] = 0f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num189; - else - npc.velocity.Y -= num189; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y += num189 * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= num189 * 1.1f; + calamityGlobalNPC.newAI[3] = 0f; + laserWallPhase = (int)LaserWallPhase.FireLaserWalls; + } + } + else if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + { + // Remain in laser wall firing phase for 6 seconds + idleCounter--; + if (idleCounter <= 0) + { + SpawnTeleportLocation(player); + laserWallPhase = (int)LaserWallPhase.End; + idleCounter = idleCounterMax; + } + } + else if (laserWallPhase == (int)LaserWallPhase.End) + { + // End laser wall phase after 4.25 seconds + npc.alpha -= 1; + if (npc.alpha <= 0) + { + npc.alpha = 0; + laserWallPhase = (int)LaserWallPhase.SetUp; + } + } + } + else + { + // Set alpha after teleport + if (postTeleportTimer > 0) + { + postTeleportTimer--; + if (postTeleportTimer < 0) + postTeleportTimer = 0; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num189; - else - npc.velocity.X -= num189; - } - } - } + npc.alpha = postTeleportTimer; + } + else + { + npc.alpha -= 6; + if (npc.alpha < 0) + npc.alpha = 0; + } - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + // This exists so that DoG doesn't sometimes instantly kill the player when he goes to final phase + if (preventBullshitHitsAtStartofFinalPhaseTimer > 0) + { + preventBullshitHitsAtStartofFinalPhaseTimer--; - if (calamityGlobalNPC.newAI[2] > 900f) - { - npc.ai[3] = 1f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } + if (npc.alpha < 1) + npc.alpha = 1; + } - // Ground - else - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } + // Reset laser wall phase + if (laserWallPhase > (int)LaserWallPhase.SetUp) + laserWallPhase = (int)LaserWallPhase.SetUp; - calamityGlobalNPC.newAI[2] += 1f; + // Enter final phase + if (!spawnedGuardians3 && phase6) + { + SpawnTeleportLocation(player); - float fallSpeed = malice ? 19.5f : death ? 17.75f : 16f; - float speed = malice ? 0.26f : death ? 0.22f : 0.18f; - float turnSpeed = malice ? 0.24f : death ? 0.18f : 0.12f; + preventBullshitHitsAtStartofFinalPhaseTimer = 180; - if (expertMode) - { - fallSpeed += 3.5f * (1f - lifeRatio); - speed += 0.08f * (1f - lifeRatio); - turnSpeed += 0.12f * (1f - lifeRatio); - speed += distanceFromTarget * 0.00005f * (1f - lifeRatio); - turnSpeed += distanceFromTarget * 0.00005f * (1f - lifeRatio); - } + // Anger message + string key = "Mods.CalamityMod.EdgyBossText11"; + Color messageColor = Color.Cyan; + CalamityUtils.DisplayLocalizedText(key, messageColor); - // Enrage - if (increaseSpeedMore) - { - fallSpeed *= 3f; - speed *= 4f; - turnSpeed *= 6f; - } - else if (increaseSpeed) - { - fallSpeed *= 1.5f; - speed *= 2f; - turnSpeed *= 3f; - } + // Summon Thots + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); - if (!flies) - { - for (int num952 = num180; num952 < num181; num952++) - { - for (int num953 = num182; num953 < num183; num953++) - { - if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[Main.tile[num952, num953].type] || (Main.tileSolidTop[Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64)) - { - Vector2 vector105; - vector105.X = num952 * 16; - vector105.Y = num953 * 16; - if (npc.position.X + npc.width > vector105.X && npc.position.X < vector105.X + 16f && npc.position.Y + npc.height > vector105.Y && npc.position.Y < vector105.Y + 16f) - { - flies = true; - break; - } - } - } - } - } + for (int i = 0; i < 3; i++) + NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + } - if (!flies) - { - npc.localAI[1] = 1f; - Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + spawnedGuardians3 = true; + } + } + + // Spawn segments and fire projectiles + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Fireballs + if (npc.alpha <= 0 && distanceFromTarget > 500f) + { + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] >= 150f && calamityGlobalNPC.newAI[0] % (phase7 ? 60f : 120f) == 0f) + { + Vector2 vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num427 = player.position.X + (player.width / 2) - vector44.X; + float num428 = player.position.Y + (player.height / 2) - vector44.Y; + float num430 = 8f; + float num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); + num429 = num430 / num429; + num427 *= num429; + num428 *= num429; + num428 += npc.velocity.Y * 0.5f; + num427 += npc.velocity.X * 0.5f; + vector44.X -= num427; + vector44.Y -= num428; + + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(vector44.X, vector44.Y, num427, num428, type, damage, 0f, Main.myPlayer); + } + } + else if (distanceFromTarget < 250f) + calamityGlobalNPC.newAI[0] = 0f; + + // Laser walls + if (!phase6 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + { + float speed = 12f; + float spawnOffset = 1500f; + float divisor = enraged ? 80f : malice ? 100f : 120f; + + if (calamityGlobalNPC.newAI[1] % divisor == 0f) + { + Main.PlaySound(SoundID.Item12, player.position); + + // Side walls + float targetPosY = player.position.Y; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + int halfTotalDiagonalShots = totalDiagonalShots / 2; + Vector2 start = default; + Vector2 velocity = default; + Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; + + switch (laserWallType_Phase2) + { + case (int)LaserWallType_Phase2.Normal: + + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], speed, 0f, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[0] -= spacingVar_Phase2; + } + + if (expertMode) + { + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); + } + + laserWallType_Phase2 = (int)LaserWallType_Phase2.Offset; + break; + + case (int)LaserWallType_Phase2.Offset: + + targetPosY += 50f; + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], speed, 0f, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[0] -= spacingVar_Phase2; + } + + if (expertMode) + { + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); + } + + laserWallType_Phase2 = revenge ? (int)LaserWallType_Phase2.MultiLayered : expertMode ? (int)LaserWallType_Phase2.DiagonalHorizontal : (int)LaserWallType_Phase2.Normal; + break; + + case (int)LaserWallType_Phase2.MultiLayered: + + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], speed, 0f, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[0] -= spacingVar_Phase2; + } + + int totalBonusLasers = totalShots_Phase2 / 2; + for (int x = 0; x < totalBonusLasers; x++) + { + Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[3], -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[3], speed, 0f, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[3] -= Main.rand.NextBool(2) ? 180 : 200; + } + + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); + + laserWallType_Phase2 = (int)LaserWallType_Phase2.DiagonalHorizontal; + break; + + case (int)LaserWallType_Phase2.DiagonalHorizontal: + + for (int x = 0; x < totalDiagonalShots + 1; x++) + { + start = new Vector2(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0]); + aim.Y += laserWallSpacingOffset * (x - halfTotalDiagonalShots); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0]); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing_Phase2[0] -= diagonalSpacingVar; + } + + Projectile.NewProjectile(player.Center.X, targetPosY + spawnOffset, 0f, -speed, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.Center.X, targetPosY - spawnOffset, 0f, speed, type, damage, 0f, Main.myPlayer); + + laserWallType_Phase2 = revenge ? (int)LaserWallType_Phase2.DiagonalVertical : (int)LaserWallType_Phase2.Normal; + break; + + case (int)LaserWallType_Phase2.DiagonalVertical: + + for (int x = 0; x < totalDiagonalShots + 1; x++) + { + start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY + spawnOffset); + aim.X += laserWallSpacingOffset * (x - halfTotalDiagonalShots); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY - spawnOffset); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing_Phase2[0] -= diagonalSpacingVar; + } + + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); + + laserWallType_Phase2 = (int)LaserWallType_Phase2.Normal; + break; + } + + // Lower wall + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + shotSpacing_Phase2[1], player.position.Y + spawnOffset, 0f, -speed, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[1] -= spacingVar_Phase2; + } + + // Upper wall + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + shotSpacing_Phase2[2], player.position.Y - spawnOffset, 0f, speed, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[2] -= spacingVar_Phase2; + } + + for (int i = 0; i < shotSpacing_Phase2.Length; i++) + shotSpacing_Phase2[i] = shotSpacingMax_Phase2; + } + + calamityGlobalNPC.newAI[1] += 1f; + } + } + + float fallSpeed = enraged ? 21f : malice ? 19.5f : death ? 17.75f : 16f; - int num954 = death ? 1100 : 1175; if (expertMode) - num954 -= (int)(150f * (1f - lifeRatio)); - if (num954 < 1025) - num954 = 1025; + fallSpeed += 3.5f * (1f - lifeRatio); - bool flag95 = true; - if (npc.position.Y > player.position.Y) - { - for (int num955 = 0; num955 < 255; num955++) - { - if (Main.player[num955].active) - { - Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); - if (rectangle12.Intersects(rectangle13)) - { - flag95 = false; - break; - } - } - } - if (flag95) - flies = true; - } - } - else - npc.localAI[1] = 0f; + if (player.dead) + { + flies = true; - Vector2 vector3 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num20 = player.position.X + (player.width / 2); - float num21 = player.position.Y + (player.height / 2); - num20 = (int)(num20 / 16f) * 16; - num21 = (int)(num21 / 16f) * 16; - vector3.X = (int)(vector3.X / 16f) * 16; - vector3.Y = (int)(vector3.Y / 16f) * 16; - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + { + npc.velocity.Y -= 1f; + fallSpeed = 32f; + } - if (!flies) - { - npc.velocity.Y += turnSpeed; - if (npc.velocity.Y > fallSpeed) - npc.velocity.Y = fallSpeed; + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type != npc.type && Main.npc[a].type != bodyType && Main.npc[a].type != tailType) + continue; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 1.8) - { - if (npc.velocity.X < 0f) - npc.velocity.X -= speed * 1.1f; - else - npc.velocity.X += speed * 1.1f; - } - else if (npc.velocity.Y == fallSpeed) - { - if (npc.velocity.X < num20) - npc.velocity.X += speed; - else if (npc.velocity.X > num20) - npc.velocity.X -= speed; - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - npc.velocity.X += speed * 0.9f; - else - npc.velocity.X -= speed * 0.9f; - } - } - else - { + Main.npc[a].active = false; + Main.npc[a].netUpdate = true; + } + } + } - double maximumSpeed1 = malice ? 0.48 : death ? 0.44 : 0.4; - double maximumSpeed2 = malice ? 1.16 : death ? 1.08 : 1D; + // Movement + int num180 = (int)(npc.position.X / 16f) - 1; + int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; + int num182 = (int)(npc.position.Y / 16f) - 1; + int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; + if (num180 < 0) + num180 = 0; + if (num181 > Main.maxTilesX) + num181 = Main.maxTilesX; + if (num182 < 0) + num182 = 0; + if (num183 > Main.maxTilesY) + num183 = Main.maxTilesY; + + if (npc.velocity.X < 0f) + npc.spriteDirection = -1; + else if (npc.velocity.X > 0f) + npc.spriteDirection = 1; + + int phaseLimit = death ? 600 : 900; + + // Flight + if (npc.ai[3] == 0f) + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + + // Charge in a direction for a second until the timer is back at 0 + if (postTeleportTimer > 0) + { + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + return; + } + + calamityGlobalNPC.newAI[2] += 1f; + + npc.localAI[1] = 0f; + + float speed = enraged ? 20f : malice ? 18f : death ? 16.5f : 15f; + float turnSpeed = enraged ? 0.4f : malice ? 0.36f : death ? 0.33f : 0.3f; + float homingSpeed = enraged ? 40f : malice ? 36f : death ? 30f : 24f; + float homingTurnSpeed = enraged ? 0.55f : malice ? 0.48f : death ? 0.405f : 0.33f; + + if (expertMode) + { + phaseLimit /= 1 + (int)(5f * (1f - lifeRatio)); + + if (phaseLimit < 180) + phaseLimit = 180; + + speed += 3f * (1f - lifeRatio); + turnSpeed += 0.06f * (1f - lifeRatio); + homingSpeed += 12f * (1f - lifeRatio); + homingTurnSpeed += 0.15f * (1f - lifeRatio); + } + + // Go to ground phase sooner + if (increaseSpeedMore) + { + if (laserWallPhase == (int)LaserWallPhase.SetUp && calamityGlobalNPC.newAI[3] <= alphaGateValue) + SpawnTeleportLocation(player); + else + calamityGlobalNPC.newAI[2] += 10f; + } + else + calamityGlobalNPC.newAI[2] += 2f; + + float num188 = speed; + float num189 = turnSpeed; + Vector2 vector18 = npc.Center; + float num191 = player.Center.X; + float num192 = player.Center.Y; + int num42 = -1; + int num43 = (int)(player.Center.X / 16f); + int num44 = (int)(player.Center.Y / 16f); + + // Charge at target for 1.5 seconds + bool flyAtTarget = (!phase4 || phase6) && calamityGlobalNPC.newAI[2] > phaseLimit - 90 && revenge; + + 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 (!flyAtTarget) + { + if (num42 > 0) + { + num42 *= 16; + float num47 = num42 - 800; + if (player.position.Y > num47) + { + num192 = num47; + if (Math.Abs(npc.Center.X - player.Center.X) < 500f) + { + if (npc.velocity.X > 0f) + num191 = player.Center.X + 600f; + else + num191 = player.Center.X - 600f; + } + } + } + } + else + { + num188 = homingSpeed; + num189 = homingTurnSpeed; + } + + if (expertMode) + { + num188 += Vector2.Distance(player.Center, npc.Center) * 0.005f * (1f - lifeRatio); + num189 += Vector2.Distance(player.Center, npc.Center) * 0.0001f * (1f - lifeRatio); + } + + float num48 = num188 * 1.3f; + float num49 = num188 * 0.7f; + float num50 = npc.velocity.Length(); + if (num50 > 0f) + { + if (num50 > num48) + { + npc.velocity.Normalize(); + npc.velocity *= num48; + } + else if (num50 < num49) + { + npc.velocity.Normalize(); + npc.velocity *= num49; + } + } + + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); + float num198 = num188 / num193; + num191 *= num198; + num192 *= num198; + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189; + else + { + if (npc.velocity.X > num191) + npc.velocity.X -= num189; + } + + if (npc.velocity.Y < num192) + npc.velocity.Y += num189; + else + { + if (npc.velocity.Y > num192) + npc.velocity.Y -= num189; + } + + if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num189 * 2f; + else + npc.velocity.Y -= num189 * 2f; + } + + if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num189 * 2f; + else + npc.velocity.X -= num189 * 2f; + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189 * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num189; + else + npc.velocity.Y -= num189; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y += num189 * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num189; + else + npc.velocity.X -= num189; + } + } + } + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (calamityGlobalNPC.newAI[2] > phaseLimit) + { + npc.ai[3] = 1f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Ground + else + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + + // Charge in a direction for a second until the timer is back at 0 + if (postTeleportTimer > 0) + { + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + return; + } + + calamityGlobalNPC.newAI[2] += 1f; + + float turnSpeed = enraged ? 0.36f : malice ? 0.3f : death ? 0.24f : 0.18f; + + if (expertMode) + { + turnSpeed += 0.1f * (1f - lifeRatio); + turnSpeed += Vector2.Distance(player.Center, npc.Center) * 0.00005f * (1f - lifeRatio); + } + + // Enrage + if (increaseSpeedMore) + { + if (laserWallPhase == (int)LaserWallPhase.SetUp && calamityGlobalNPC.newAI[3] <= alphaGateValue) + SpawnTeleportLocation(player); + else + { + fallSpeed *= 3f; + turnSpeed *= 6f; + } + } + else if (increaseSpeed) + { + fallSpeed *= 1.5f; + turnSpeed *= 3f; + } + + if (!flies) + { + for (int num952 = num180; num952 < num181; num952++) + { + for (int num953 = num182; num953 < num183; num953++) + { + if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[Main.tile[num952, num953].type] || (Main.tileSolidTop[Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64)) + { + Vector2 vector105; + vector105.X = num952 * 16; + vector105.Y = num953 * 16; + if (npc.position.X + npc.width > vector105.X && npc.position.X < vector105.X + 16f && npc.position.Y + npc.height > vector105.Y && npc.position.Y < vector105.Y + 16f) + { + flies = true; + break; + } + } + } + } + } + + if (!flies) + { + npc.localAI[1] = 1f; + + Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + + int num954 = death ? 1125 : 1200; + if (lifeRatio < 0.8f && lifeRatio > 0.2f && !death) + num954 = 1400; + + if (expertMode) + num954 -= (int)(150f * (1f - lifeRatio)); + + if (num954 < 1050) + num954 = 1050; + + bool flag95 = true; + if (npc.position.Y > player.position.Y) + { + for (int num955 = 0; num955 < Main.maxPlayers; num955++) + { + if (Main.player[num955].active) + { + Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); + if (rectangle12.Intersects(rectangle13)) + { + flag95 = false; + break; + } + } + } + if (flag95) + flies = true; + } + } + else + npc.localAI[1] = 0f; + + float num189 = turnSpeed; + Vector2 vector18 = npc.Center; + float num191 = player.Center.X; + float num192 = player.Center.Y; + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + + if (!flies) + { + npc.velocity.Y += turnSpeed; + if (npc.velocity.Y > fallSpeed) + npc.velocity.Y = fallSpeed; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 2.2) + { + if (npc.velocity.X < 0f) + npc.velocity.X -= num189 * 1.1f; + else + npc.velocity.X += num189 * 1.1f; + } + else if (npc.velocity.Y == fallSpeed) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189; + else if (npc.velocity.X > num191) + npc.velocity.X -= num189; + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + npc.velocity.X += num189 * 0.9f; + else + npc.velocity.X -= num189 * 0.9f; + } + } + else + { + double maximumSpeed1 = enraged ? 0.6 : malice ? 0.52 : death ? 0.46 : 0.4; + double maximumSpeed2 = enraged ? 1.4 : malice ? 1.25 : death ? 1.125 : 1D; + + if (increaseSpeedMore) + { + maximumSpeed1 *= 4; + maximumSpeed2 *= 4; + } + if (increaseSpeed) + { + maximumSpeed1 *= 2; + maximumSpeed2 *= 2; + } + + if (expertMode) + { + maximumSpeed1 += 0.1f * (1f - lifeRatio); + maximumSpeed2 += 0.2f * (1f - lifeRatio); + } + + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num25 = Math.Abs(num191); + float num26 = Math.Abs(num192); + float num27 = fallSpeed / num193; + num191 *= num27; + num192 *= num27; + + if (((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f)) && ((npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f))) + { + if (npc.velocity.X < num191) + npc.velocity.X += turnSpeed * 1.5f; + else if (npc.velocity.X > num191) + npc.velocity.X -= turnSpeed * 1.5f; + + if (npc.velocity.Y < num192) + npc.velocity.Y += turnSpeed * 1.5f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= turnSpeed * 1.5f; + } + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + npc.velocity.X += turnSpeed; + else if (npc.velocity.X > num191) + npc.velocity.X -= turnSpeed; + + if (npc.velocity.Y < num192) + npc.velocity.Y += turnSpeed; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= turnSpeed; + + if (Math.Abs(num192) < fallSpeed * maximumSpeed1 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += turnSpeed * 2f; + else + npc.velocity.Y -= turnSpeed * 2f; + } + + if (Math.Abs(num191) < fallSpeed * maximumSpeed1 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X += turnSpeed * 2f; + else + npc.velocity.X -= turnSpeed * 2f; + } + } + else if (num25 > num26) + { + if (npc.velocity.X < num191) + npc.velocity.X += turnSpeed * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X -= turnSpeed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += turnSpeed; + else + npc.velocity.Y -= turnSpeed; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y += turnSpeed * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= turnSpeed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) + { + if (npc.velocity.X > 0f) + npc.velocity.X += turnSpeed; + else + npc.velocity.X -= turnSpeed; + } + } + } + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (flies) + { + if (npc.localAI[0] != 1f) + npc.netUpdate = true; + + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + npc.netUpdate = true; + + npc.localAI[0] = 0f; + } + + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + npc.netUpdate = true; + + if (calamityGlobalNPC.newAI[2] > phaseLimit) + { + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + } + } + else + { + // Spawn Guardians + if (phase3) + { + if (!spawnedGuardians) + { + if (revenge) + spawnDoGCountdown = 10; + + string key = "Mods.CalamityMod.EdgyBossText"; + Color messageColor = Color.Cyan; + CalamityUtils.DisplayLocalizedText(key, messageColor); + + npc.TargetClosest(); + spawnedGuardians = true; + } + + if (spawnDoGCountdown > 0) + { + spawnDoGCountdown--; + if (spawnDoGCountdown == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); + + for (int i = 0; i < 2; i++) + NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + } + } + } + else if (phase2) + { + if (!spawnedGuardians2) + { + if (revenge) + spawnDoGCountdown = 10; + + spawnedGuardians2 = true; + } + + if (spawnDoGCountdown > 0) + { + spawnDoGCountdown--; + if (spawnDoGCountdown == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); + + NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + } + } + } + + // Alpha + npc.alpha -= 12; + if (npc.alpha < 0) + npc.alpha = 0; + + // Spawn segments + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!tail && npc.ai[0] == 0f) + { + int Previous = npc.whoAmI; + for (int segmentSpawn = 0; segmentSpawn < maxLength; segmentSpawn++) + { + int segment; + if (segmentSpawn >= 0 && segmentSpawn < minLength) + segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + else + segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + + Main.npc[segment].realLife = npc.whoAmI; + Main.npc[segment].ai[2] = npc.whoAmI; + Main.npc[segment].ai[1] = Previous; + Main.npc[Previous].ai[0] = segment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment, 0f, 0f, 0f, 0); + Previous = segment; + } + tail = true; + } + + if (phase2) + { + float speed = 12f; + float spawnOffset = 1500f; + float divisor = malice ? 240f : death ? 360f : 480f; + + if (calamityGlobalNPC.newAI[1] % divisor == 0f) + { + Main.PlaySound(SoundID.Item12, player.position); + + // Side walls + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 start = default; + Vector2 velocity = default; + Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; + Vector2 aimClone = aim; + + switch (laserWallType) + { + case (int)LaserWallType.DiagonalRight: + + for (int x = 0; x < totalShots + 1; x++) + { + start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); + aim.Y += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing -= spacingVar; + } + + if (expertMode) + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); + + laserWallType = (int)LaserWallType.DiagonalLeft; + break; + + case (int)LaserWallType.DiagonalLeft: + + for (int x = 0; x < totalShots + 1; x++) + { + start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); + aim.Y += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing -= spacingVar; + } + + if (expertMode) + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); + + laserWallType = expertMode ? (int)LaserWallType.DiagonalHorizontal : (int)LaserWallType.DiagonalRight; + break; + + case (int)LaserWallType.DiagonalHorizontal: + + for (int x = 0; x < totalShots + 1; x++) + { + start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); + aim.Y += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing -= spacingVar; + } + + if (expertMode) + { + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); + } + + laserWallType = revenge ? (int)LaserWallType.DiagonalCross : (int)LaserWallType.DiagonalRight; + break; + + case (int)LaserWallType.DiagonalCross: + + for (int x = 0; x < totalShots + 1; x++) + { + start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); + aim.Y += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); + velocity = Vector2.Normalize(aim - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X + shotSpacing, player.position.Y + spawnOffset); + aimClone.X += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aimClone - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X + shotSpacing, player.position.Y - spawnOffset); + velocity = Vector2.Normalize(aimClone - start) * speed; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing -= spacingVar; + } + + if (expertMode) + { + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); + } + + laserWallType = (int)LaserWallType.DiagonalRight; + break; + } + shotSpacing = shotSpacingMax; + } + + calamityGlobalNPC.newAI[1] += 1f; + } + else + calamityGlobalNPC.newAI[1] = 0f; + } + + // Despawn + if (player.dead) + { + flies = true; + + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type != npc.type && Main.npc[a].type != bodyType && Main.npc[a].type != tailType) + continue; + + Main.npc[a].active = false; + Main.npc[a].netUpdate = true; + } + } + } + + // Movement + int num180 = (int)(npc.position.X / 16f) - 1; + int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; + int num182 = (int)(npc.position.Y / 16f) - 1; + int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; + + if (num180 < 0) + num180 = 0; + if (num181 > Main.maxTilesX) + num181 = Main.maxTilesX; + if (num182 < 0) + num182 = 0; + if (num183 > Main.maxTilesY) + num183 = Main.maxTilesY; + + if (npc.velocity.X < 0f) + npc.spriteDirection = -1; + else if (npc.velocity.X > 0f) + npc.spriteDirection = 1; + + // Flight + if (npc.ai[3] == 0f) + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + + // Flying movement + npc.localAI[1] = 0f; + + float phaseChangeRate = 1f + (expertMode ? 9f * (1f - lifeRatio) : 0f); + calamityGlobalNPC.newAI[2] += phaseChangeRate; + + float speed = malice ? 18f : death ? 16.5f : 15f; + float turnSpeed = malice ? 0.36f : death ? 0.33f : 0.3f; + float homingSpeed = malice ? 27f : death ? 22.5f : 18f; + float homingTurnSpeed = malice ? 0.48f : death ? 0.405f : 0.33f; + + if (expertMode) + { + speed += 3f * (1f - lifeRatio); + turnSpeed += 0.06f * (1f - lifeRatio); + homingSpeed += 9f * (1f - lifeRatio); + homingTurnSpeed += 0.15f * (1f - lifeRatio); + } + + // Go to ground phase sooner + if (increaseSpeedMore) + calamityGlobalNPC.newAI[2] += 10f; + else if (increaseSpeed) + calamityGlobalNPC.newAI[2] += 2f; + + float num188 = speed; + float num189 = turnSpeed; + 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); + + 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 = num42 - 800; + if (player.position.Y > num47) + { + num192 = num47; + if (Math.Abs(npc.Center.X - player.Center.X) < 500f) + { + if (npc.velocity.X > 0f) + num191 = player.Center.X + 600f; + else + num191 = player.Center.X - 600f; + } + } + } + else + { + num188 = homingSpeed; + num189 = homingTurnSpeed; + } + + if (expertMode) + { + num188 += distanceFromTarget * 0.005f * (1f - lifeRatio); + num189 += distanceFromTarget * 0.0001f * (1f - lifeRatio); + } + + float num48 = num188 * 1.3f; + float num49 = num188 * 0.7f; + float num50 = npc.velocity.Length(); + if (num50 > 0f) + { + if (num50 > num48) + { + npc.velocity.Normalize(); + npc.velocity *= num48; + } + else if (num50 < num49) + { + npc.velocity.Normalize(); + npc.velocity *= num49; + } + } + + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); + float num198 = num188 / num193; + num191 *= num198; + num192 *= num198; + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189; + else + { + if (npc.velocity.X > num191) + npc.velocity.X -= num189; + } + + if (npc.velocity.Y < num192) + npc.velocity.Y += num189; + else + { + if (npc.velocity.Y > num192) + npc.velocity.Y -= num189; + } + + if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num189 * 2f; + else + npc.velocity.Y -= num189 * 2f; + } + + if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num189 * 2f; + else + npc.velocity.X -= num189 * 2f; + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189 * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num189; + else + npc.velocity.Y -= num189; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y += num189 * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num189; + else + npc.velocity.X -= num189; + } + } + } + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (calamityGlobalNPC.newAI[2] > 900f) + { + npc.ai[3] = 1f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Ground + else + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + + calamityGlobalNPC.newAI[2] += 1f; + + float fallSpeed = malice ? 19.5f : death ? 17.75f : 16f; + float speed = malice ? 0.26f : death ? 0.22f : 0.18f; + float turnSpeed = malice ? 0.24f : death ? 0.18f : 0.12f; + + if (expertMode) + { + fallSpeed += 3.5f * (1f - lifeRatio); + speed += 0.08f * (1f - lifeRatio); + turnSpeed += 0.12f * (1f - lifeRatio); + speed += distanceFromTarget * 0.00005f * (1f - lifeRatio); + turnSpeed += distanceFromTarget * 0.00005f * (1f - lifeRatio); + } + + // Enrage if (increaseSpeedMore) { - maximumSpeed1 *= 4; - maximumSpeed2 *= 4; + fallSpeed *= 3f; + speed *= 4f; + turnSpeed *= 6f; } - if (increaseSpeed) + else if (increaseSpeed) { - maximumSpeed1 *= 2; - maximumSpeed2 *= 2; + fallSpeed *= 1.5f; + speed *= 2f; + turnSpeed *= 3f; } - if (expertMode) + if (!flies) { - maximumSpeed1 += 0.08f * (1f - lifeRatio); - maximumSpeed2 += 0.16f * (1f - lifeRatio); + for (int num952 = num180; num952 < num181; num952++) + { + for (int num953 = num182; num953 < num183; num953++) + { + if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[Main.tile[num952, num953].type] || (Main.tileSolidTop[Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64)) + { + Vector2 vector105; + vector105.X = num952 * 16; + vector105.Y = num953 * 16; + if (npc.position.X + npc.width > vector105.X && npc.position.X < vector105.X + 16f && npc.position.Y + npc.height > vector105.Y && npc.position.Y < vector105.Y + 16f) + { + flies = true; + break; + } + } + } + } } - num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = fallSpeed / num22; - num20 *= num27; - num21 *= num27; + if (!flies) + { + npc.localAI[1] = 1f; + Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) - { - if (npc.velocity.X < num20) - npc.velocity.X += turnSpeed * 1.3f; - else if (npc.velocity.X > num20) - npc.velocity.X -= turnSpeed * 1.3f; + int num954 = death ? 1100 : 1175; + if (expertMode) + num954 -= (int)(150f * (1f - lifeRatio)); + if (num954 < 1025) + num954 = 1025; - if (npc.velocity.Y < num21) - npc.velocity.Y += turnSpeed * 1.3f; - else if (npc.velocity.Y > num21) - npc.velocity.Y -= turnSpeed * 1.3f; - } + bool flag95 = true; + if (npc.position.Y > player.position.Y) + { + for (int num955 = 0; num955 < 255; num955++) + { + if (Main.player[num955].active) + { + Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); + if (rectangle12.Intersects(rectangle13)) + { + flag95 = false; + break; + } + } + } + if (flag95) + flies = true; + } + } + else + npc.localAI[1] = 0f; - if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) - { - if (npc.velocity.X < num20) - npc.velocity.X += speed; - else if (npc.velocity.X > num20) - npc.velocity.X -= speed; - if (npc.velocity.Y < num21) - npc.velocity.Y += speed; - else if (npc.velocity.Y > num21) - npc.velocity.Y -= speed; + Vector2 vector3 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num20 = player.position.X + (player.width / 2); + float num21 = player.position.Y + (player.height / 2); + num20 = (int)(num20 / 16f) * 16; + num21 = (int)(num21 / 16f) * 16; + vector3.X = (int)(vector3.X / 16f) * 16; + vector3.Y = (int)(vector3.Y / 16f) * 16; + num20 -= vector3.X; + num21 -= vector3.Y; + float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); - if (Math.Abs(num21) < fallSpeed * maximumSpeed1 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += speed * 2f; - else - npc.velocity.Y -= speed * 2f; - } - if (Math.Abs(num20) < fallSpeed * maximumSpeed1 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += speed * 2f; - else - npc.velocity.X -= speed * 2f; - } - } - else if (num25 > num26) - { - if (npc.velocity.X < num20) - npc.velocity.X += speed * 1.1f; - else if (npc.velocity.X > num20) - npc.velocity.X -= speed * 1.1f; + if (!flies) + { + npc.velocity.Y += turnSpeed; + if (npc.velocity.Y > fallSpeed) + npc.velocity.Y = fallSpeed; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += speed; - else - npc.velocity.Y -= speed; - } - } - else - { - if (npc.velocity.Y < num21) - npc.velocity.Y += speed * 1.1f; - else if (npc.velocity.Y > num21) - npc.velocity.Y -= speed * 1.1f; + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 1.8) + { + if (npc.velocity.X < 0f) + npc.velocity.X -= speed * 1.1f; + else + npc.velocity.X += speed * 1.1f; + } + else if (npc.velocity.Y == fallSpeed) + { + if (npc.velocity.X < num20) + npc.velocity.X += speed; + else if (npc.velocity.X > num20) + npc.velocity.X -= speed; + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + npc.velocity.X += speed * 0.9f; + else + npc.velocity.X -= speed * 0.9f; + } + } + else + { - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) - { - if (npc.velocity.X > 0f) - npc.velocity.X += speed; - else - npc.velocity.X -= speed; - } - } - } + double maximumSpeed1 = malice ? 0.48 : death ? 0.44 : 0.4; + double maximumSpeed2 = malice ? 1.16 : death ? 1.08 : 1D; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + if (increaseSpeedMore) + { + maximumSpeed1 *= 4; + maximumSpeed2 *= 4; + } + if (increaseSpeed) + { + maximumSpeed1 *= 2; + maximumSpeed2 *= 2; + } - if (flies) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; + if (expertMode) + { + maximumSpeed1 += 0.08f * (1f - lifeRatio); + maximumSpeed2 += 0.16f * (1f - lifeRatio); + } - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; + num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); + float num25 = Math.Abs(num20); + float num26 = Math.Abs(num21); + float num27 = fallSpeed / num22; + num20 *= num27; + num21 *= num27; - npc.localAI[0] = 0f; - } + if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) + { + if (npc.velocity.X < num20) + npc.velocity.X += turnSpeed * 1.3f; + else if (npc.velocity.X > num20) + npc.velocity.X -= turnSpeed * 1.3f; - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; + if (npc.velocity.Y < num21) + npc.velocity.Y += turnSpeed * 1.3f; + else if (npc.velocity.Y > num21) + npc.velocity.Y -= turnSpeed * 1.3f; + } - if (calamityGlobalNPC.newAI[2] > 900f) - { - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - } + if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) + { + if (npc.velocity.X < num20) + npc.velocity.X += speed; + else if (npc.velocity.X > num20) + npc.velocity.X -= speed; + if (npc.velocity.Y < num21) + npc.velocity.Y += speed; + else if (npc.velocity.Y > num21) + npc.velocity.Y -= speed; + + if (Math.Abs(num21) < fallSpeed * maximumSpeed1 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += speed * 2f; + else + npc.velocity.Y -= speed * 2f; + } + if (Math.Abs(num20) < fallSpeed * maximumSpeed1 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X += speed * 2f; + else + npc.velocity.X -= speed * 2f; + } + } + else if (num25 > num26) + { + if (npc.velocity.X < num20) + npc.velocity.X += speed * 1.1f; + else if (npc.velocity.X > num20) + npc.velocity.X -= speed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += speed; + else + npc.velocity.Y -= speed; + } + } + else + { + if (npc.velocity.Y < num21) + npc.velocity.Y += speed * 1.1f; + else if (npc.velocity.Y > num21) + npc.velocity.Y -= speed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) + { + if (npc.velocity.X > 0f) + npc.velocity.X += speed; + else + npc.velocity.X -= speed; + } + } + } + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (flies) + { + if (npc.localAI[0] != 1f) + npc.netUpdate = true; + + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + npc.netUpdate = true; + + npc.localAI[0] = 0f; + } + + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + npc.netUpdate = true; + + if (calamityGlobalNPC.newAI[2] > 900f) + { + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + } + + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + } + + private void SpawnTeleportLocation(Player player) + { + if (teleportTimer > -1 || player.dead || !player.active) + return; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int randomRange = 48; + float distance = 640f; + Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); + Main.PlaySound(SoundID.Item109, player.Center); + Projectile.NewProjectile(targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI); + } + + teleportTimer = (CalamityWorld.death || CalamityWorld.malice) ? 120 : CalamityWorld.revenge ? 140 : Main.expertMode ? 160 : 180; + } + + private void Teleport(Player player, bool malice, bool death, bool revenge, bool expertMode, bool phase5) + { + Vector2 newPosition = GetRiftLocation(true); + + if (player.dead || !player.active || newPosition == default) + return; + + if (phase5) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float finalVelocity = 10f; + int totalSpreads = revenge ? 6 : 3; + float mult = revenge ? 1.5f : 3f; + for (int i = 0; i < totalSpreads; i++) + { + int totalProjectiles = malice ? 18 : 12; + float radians = MathHelper.TwoPi / totalProjectiles; + float newVelocity = finalVelocity - i * mult; + float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = i < 3 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); + float finalVelocityReduction = (float)Math.Pow(1.25, i) - 1f; + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(newPosition, vector255, type, damage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); + } + } + } + } + + npc.TargetClosest(); + npc.position = newPosition; + float chargeVelocity = malice ? 30f : death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; + float maxChargeDistance = 1600f; + postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); + npc.alpha = postTeleportTimer; + npc.velocity = Vector2.Normalize(player.Center + player.velocity * 40f - npc.Center) * chargeVelocity; + npc.netUpdate = true; + + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) + { + Main.npc[i].position = newPosition; + + if (Main.npc[i].type == ModContent.NPCType()) + ((DevourerofGodsTail)Main.npc[i].modNPC).setInvulTime(720); + + Main.npc[i].netUpdate = true; + } + } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), player.Center); + } + + private Vector2 GetRiftLocation(bool spawnDust) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type == ModContent.ProjectileType()) + { + if (!spawnDust) + Main.projectile[i].ai[0] = -1f; + + Main.projectile[i].Kill(); + return Main.projectile[i].Center; + } + } + return default; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -875,7 +2051,8 @@ namespace CalamityMod.NPCs.DevourerofGods if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; + bool useOtherTextures = phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; + Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS") : Main.npcTexture[npc.type]; Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector43 = npc.Center - Main.screenPosition; @@ -883,44 +2060,130 @@ namespace CalamityMod.NPCs.DevourerofGods vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + if (!npc.dontTakeDamage) + { + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow"); + Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow2"); - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow2"); + color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } return false; } public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } + { + potionType = ModContent.ItemType(); + } - // DoG phase 1 does not drop loot, but starts the sentinel phase of the fight. - public override void NPCLoot() - { - // Skip the sentinel phase entirely if DoG has already been killed - CalamityWorld.DoGSecondStageCountdown = (CalamityWorld.downedDoG || CalamityWorld.downedSecondSentinels) ? 600 : 21600; + public override bool SpecialNPCLoot() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(npc, + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType()); + npc.position = Main.npc[closestSegmentID].position; + return false; + } - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - } + public override void NPCLoot() + { + // Stop the countdown -- if you kill DoG in less than 60 frames, this will stop another one from spawning. + CalamityWorld.DoGSecondStageCountdown = 0; - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); + + // Legendary drops for DoG + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); + + DropHelper.DropItem(npc, ModContent.ItemType(), 5, 15); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedDoG); + + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedDoG); + + // Mount + CalamityPlayer mp = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Calamity(); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, mp.fabsolVodka); + + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) + { + // Materials + DropHelper.DropItem(npc, ModContent.ItemType(), 25, 35); + DropHelper.DropItem(npc, ModContent.ItemType(), 150, 250); + + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); + + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + if (Main.rand.NextBool(5)) + { + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + } + } + + // If DoG has not been killed yet, notify players that the holiday moons are buffed + if (!CalamityWorld.downedDoG) + { + string key = "Mods.CalamityMod.DoGBossText"; + Color messageColor = Color.Cyan; + string key2 = "Mods.CalamityMod.DoGBossText2"; + Color messageColor2 = Color.Orange; + string key3 = "Mods.CalamityMod.DargonBossText"; + + CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.DisplayLocalizedText(key2, messageColor2); + CalamityUtils.DisplayLocalizedText(key3, messageColor2); + } + + // Mark DoG as dead + CalamityWorld.downedDoG = true; + CalamityNetcode.SyncWorld(); + } + + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= (phase2Started ? 80f : 55f) && (npc.alpha <= 0 || postTeleportTimer > 0) && preventBullshitHitsAtStartofFinalPhaseTimer <= 0; + } public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { @@ -936,7 +2199,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { - scale = 1.5f; + scale = 2f; return null; } @@ -945,53 +2208,55 @@ namespace CalamityMod.NPCs.DevourerofGods return false; } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - } - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGHead"), 1f); - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 15; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 30; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + if (npc.soundDelay == 0) + { + npc.soundDelay = 8; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); + } + if (npc.life <= 0) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS5"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 50; + npc.height = 50; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 15; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 30; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 300, true); - player.AddBuff(ModContent.BuffType(), 420, true); - /*if (CalamityWorld.death && !player.Calamity().lol) + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 300, true); + player.AddBuff(ModContent.BuffType(), 420, true); + /*if ((CalamityWorld.death || BossRushEvent.BossRushActive) && (npc.alpha <= 0 || postTeleportTimer > 0) && !player.Calamity().lol && preventBullshitHitsAtStartofFinalPhaseTimer <= 0) { player.KillMe(PlayerDeathReason.ByCustomReason(player.name + "'s essence was consumed by the devourer."), 1000.0, 0, false); }*/ @@ -1011,6 +2276,6 @@ namespace CalamityMod.NPCs.DevourerofGods CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); player.Calamity().dogTextCooldown = 60; } - } - } + } + } } diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs deleted file mode 100644 index 34b668db1a..0000000000 --- a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs +++ /dev/null @@ -1,1397 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.LoreItems; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Mounts; -using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.Placeables.FurnitureCosmilite; -using CalamityMod.Items.Potions; -using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.TownNPCs; -using CalamityMod.Projectiles.Boss; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.DevourerofGods -{ - [AutoloadBossHead] - public class DevourerofGodsHeadS : ModNPC - { - private enum LaserWallPhase - { - SetUp = 0, - FireLaserWalls = 1, - End = 2 - } - - private enum LaserWallType - { - Normal = 0, - Offset = 1, - MultiLayered = 2, - DiagonalHorizontal = 3, - DiagonalVertical = 4 - } - - private bool tail = false; - private const int minLength = 100; - private const int maxLength = 101; - private bool halfLife = false; - - private const int shotSpacingMax = 1050; - private int[] shotSpacing = new int[4] { shotSpacingMax, shotSpacingMax, shotSpacingMax, shotSpacingMax }; - private const int spacingVar = 105; - private const int diagonalSpacingVar = 350; - private const int totalShots = 20; - private const int totalDiagonalShots = 6; - private const float laserWallSpacingOffset = 16f; - private int laserWallType = 0; - public int laserWallPhase = 0; - - private const int idleCounterMax = 360; - private int idleCounter = idleCounterMax; - private int postTeleportTimer = 0; - private int teleportTimer = -1; - - private int preventBullshitHitsAtStartofFinalPhaseTimer = 0; - - private const float alphaGateValue = 669f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Devourer of Gods"); - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 186; - npc.height = 186; - npc.defense = 50; - npc.LifeMaxNERB(517500, 621000, 920000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.takenDamageMultiplier = 1.1f; - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.boss = true; - npc.value = Item.buyPrice(0, 80, 0, 0); - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.DeathSound = SoundID.NPCDeath14; - npc.netAlways = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("UniversalCollapse") ?? MusicID.LunarBoss; - bossBag = ModContent.ItemType(); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - writer.Write(halfLife); - writer.Write(shotSpacing[0]); - writer.Write(shotSpacing[1]); - writer.Write(shotSpacing[2]); - writer.Write(shotSpacing[3]); - writer.Write(idleCounter); - writer.Write(laserWallPhase); - writer.Write(postTeleportTimer); - writer.Write(preventBullshitHitsAtStartofFinalPhaseTimer); - writer.Write(laserWallType); - writer.Write(teleportTimer); - writer.Write(npc.alpha); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - halfLife = reader.ReadBoolean(); - shotSpacing[0] = reader.ReadInt32(); - shotSpacing[1] = reader.ReadInt32(); - shotSpacing[2] = reader.ReadInt32(); - shotSpacing[3] = reader.ReadInt32(); - idleCounter = reader.ReadInt32(); - laserWallPhase = reader.ReadInt32(); - postTeleportTimer = reader.ReadInt32(); - preventBullshitHitsAtStartofFinalPhaseTimer = reader.ReadInt32(); - laserWallType = reader.ReadInt32(); - teleportTimer = reader.ReadInt32(); - npc.alpha = reader.ReadInt32(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void BossHeadRotation(ref float rotation) - { - rotation = npc.rotation; - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // whoAmI variable - CalamityGlobalNPC.DoGHead = npc.whoAmI; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Variables - Vector2 vector = npc.Center; - bool flies = npc.ai[3] == 0f; - bool enraged = calamityGlobalNPC.enraged > 0; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || malice; - bool revenge = CalamityWorld.revenge || malice; - bool death = CalamityWorld.death || malice; - - if (revenge) - { - // Increase aggression if player is taking a long time to kill the boss - if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) - lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - } - - bool phase2 = lifeRatio < 0.8f; - bool phase3 = lifeRatio < 0.6f; - bool phase4 = lifeRatio < 0.3f; - bool phase5 = lifeRatio < 0.15f; - - npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - - // Light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - // Worm shit again - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - float distanceFromTarget = Vector2.Distance(player.Center, vector); - bool increaseSpeed = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance350Tiles; - - float takeLessDamageDistance = 1600f; - if (distanceFromTarget > takeLessDamageDistance) - { - float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); - npc.takenDamageMultiplier = MathHelper.Lerp(1f, 1.1f, damageTakenScalar); - } - else - npc.takenDamageMultiplier = 1.1f; - - // Immunity after teleport - npc.dontTakeDamage = postTeleportTimer > 0 || preventBullshitHitsAtStartofFinalPhaseTimer > 0; - - // Teleport - if (teleportTimer >= 0) - { - teleportTimer--; - if (teleportTimer == 0) - Teleport(player, malice, death, revenge, expertMode, phase3); - } - - // Laser walls - if (phase2 && !phase4 && postTeleportTimer <= 0) - { - if (laserWallPhase == (int)LaserWallPhase.SetUp) - { - // Increment next laser wall phase timer - calamityGlobalNPC.newAI[3] += 1f; - - // Set alpha value prior to firing laser walls - if (calamityGlobalNPC.newAI[3] > alphaGateValue) - { - // Disable teleports - if (teleportTimer >= 0) - { - GetRiftLocation(false); - teleportTimer = -1; - } - - npc.alpha = (int)MathHelper.Clamp((calamityGlobalNPC.newAI[3] - alphaGateValue) * 5f, 0f, 255f); - } - - // Fire laser walls every 12 seconds after a laser wall phase ends - if (calamityGlobalNPC.newAI[3] >= 720f) - { - npc.alpha = 255; - - // Reset laser wall timer to 0 - calamityGlobalNPC.newAI[1] = 0f; - - calamityGlobalNPC.newAI[3] = 0f; - laserWallPhase = (int)LaserWallPhase.FireLaserWalls; - } - } - else if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls) - { - // Remain in laser wall firing phase for 6 seconds - idleCounter--; - if (idleCounter <= 0) - { - SpawnTeleportLocation(player); - laserWallPhase = (int)LaserWallPhase.End; - idleCounter = idleCounterMax; - } - } - else if (laserWallPhase == (int)LaserWallPhase.End) - { - // End laser wall phase after 4.25 seconds - npc.alpha -= 1; - if (npc.alpha <= 0) - { - npc.alpha = 0; - laserWallPhase = (int)LaserWallPhase.SetUp; - } - } - } - else - { - // Set alpha after teleport - if (postTeleportTimer > 0) - { - postTeleportTimer--; - if (postTeleportTimer < 0) - postTeleportTimer = 0; - - npc.alpha = postTeleportTimer; - } - else - { - npc.alpha -= 6; - if (npc.alpha < 0) - npc.alpha = 0; - } - - // This exists so that DoG doesn't sometimes instantly kill the player when he goes to final phase - if (preventBullshitHitsAtStartofFinalPhaseTimer > 0) - { - preventBullshitHitsAtStartofFinalPhaseTimer--; - - if (npc.alpha < 1) - npc.alpha = 1; - } - - // Reset laser wall phase - if (laserWallPhase > (int)LaserWallPhase.SetUp) - laserWallPhase = (int)LaserWallPhase.SetUp; - - // Enter final phase - if (!halfLife && phase4) - { - SpawnTeleportLocation(player); - - preventBullshitHitsAtStartofFinalPhaseTimer = 180; - - // Anger message - string key = "Mods.CalamityMod.EdgyBossText11"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - // Summon Thots - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); - - for (int i = 0; i < 3; i++) - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - } - - halfLife = true; - } - } - - // Spawn segments and fire projectiles - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Segments - if (!tail && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - for (int segmentSpawn = 0; segmentSpawn < maxLength; segmentSpawn++) - { - int segment; - if (segmentSpawn >= 0 && segmentSpawn < minLength) - segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - else - segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - - Main.npc[segment].realLife = npc.whoAmI; - Main.npc[segment].ai[2] = npc.whoAmI; - Main.npc[segment].ai[1] = Previous; - Main.npc[Previous].ai[0] = segment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment, 0f, 0f, 0f, 0); - Previous = segment; - } - tail = true; - } - - // Fireballs - if (npc.alpha <= 0 && distanceFromTarget > 500f) - { - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= 150f && calamityGlobalNPC.newAI[0] % (phase5 ? 60f : 120f) == 0f) - { - Vector2 vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num427 = player.position.X + (player.width / 2) - vector44.X; - float num428 = player.position.Y + (player.height / 2) - vector44.Y; - float num430 = 8f; - float num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); - num429 = num430 / num429; - num427 *= num429; - num428 *= num429; - num428 += npc.velocity.Y * 0.5f; - num427 += npc.velocity.X * 0.5f; - vector44.X -= num427; - vector44.Y -= num428; - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(vector44.X, vector44.Y, num427, num428, type, damage, 0f, Main.myPlayer); - } - } - else if (distanceFromTarget < 250f) - calamityGlobalNPC.newAI[0] = 0f; - - // Laser walls - if (!phase4 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) - { - float speed = 12f; - float spawnOffset = 1500f; - float divisor = enraged ? 80f : malice ? 100f : 120f; - - if (calamityGlobalNPC.newAI[1] % divisor == 0f) - { - Main.PlaySound(SoundID.Item12, player.position); - - // Side walls - float targetPosY = player.position.Y; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int halfTotalDiagonalShots = totalDiagonalShots / 2; - Vector2 start = default; - Vector2 velocity = default; - Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; - - switch (laserWallType) - { - case (int)LaserWallType.Normal: - - for (int x = 0; x < totalShots; x++) - { - Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing[0], -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing[0], speed, 0f, type, damage, 0f, Main.myPlayer); - shotSpacing[0] -= spacingVar; - } - - if (expertMode) - { - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); - } - - laserWallType = (int)LaserWallType.Offset; - break; - - case (int)LaserWallType.Offset: - - targetPosY += 50f; - for (int x = 0; x < totalShots; x++) - { - Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing[0], -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing[0], speed, 0f, type, damage, 0f, Main.myPlayer); - shotSpacing[0] -= spacingVar; - } - - if (expertMode) - { - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); - } - - laserWallType = revenge ? (int)LaserWallType.MultiLayered : expertMode ? (int)LaserWallType.DiagonalHorizontal : (int)LaserWallType.Normal; - break; - - case (int)LaserWallType.MultiLayered: - - for (int x = 0; x < totalShots; x++) - { - Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing[0], -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing[0], speed, 0f, type, damage, 0f, Main.myPlayer); - shotSpacing[0] -= spacingVar; - } - - int totalBonusLasers = totalShots / 2; - for (int x = 0; x < totalBonusLasers; x++) - { - Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing[3], -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing[3], speed, 0f, type, damage, 0f, Main.myPlayer); - shotSpacing[3] -= Main.rand.NextBool(2) ? 180 : 200; - } - - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); - - laserWallType = (int)LaserWallType.DiagonalHorizontal; - break; - - case (int)LaserWallType.DiagonalHorizontal: - - for (int x = 0; x < totalDiagonalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, targetPosY + shotSpacing[0]); - aim.Y += laserWallSpacingOffset * (x - halfTotalDiagonalShots); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, targetPosY + shotSpacing[0]); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing[0] -= diagonalSpacingVar; - } - - Projectile.NewProjectile(player.Center.X, targetPosY + spawnOffset, 0f, -speed, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.Center.X, targetPosY - spawnOffset, 0f, speed, type, damage, 0f, Main.myPlayer); - - laserWallType = revenge ? (int)LaserWallType.DiagonalVertical : (int)LaserWallType.Normal; - break; - - case (int)LaserWallType.DiagonalVertical: - - for (int x = 0; x < totalDiagonalShots + 1; x++) - { - start = new Vector2(player.position.X + shotSpacing[0], targetPosY + spawnOffset); - aim.X += laserWallSpacingOffset * (x - halfTotalDiagonalShots); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing[0], targetPosY - spawnOffset); - velocity = Vector2.Normalize(aim - start) * speed; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing[0] -= diagonalSpacingVar; - } - - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -speed, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, speed, 0f, type, damage, 0f, Main.myPlayer); - - laserWallType = (int)LaserWallType.Normal; - break; - } - - // Lower wall - for (int x = 0; x < totalShots; x++) - { - Projectile.NewProjectile(player.position.X + shotSpacing[1], player.position.Y + spawnOffset, 0f, -speed, type, damage, 0f, Main.myPlayer); - shotSpacing[1] -= spacingVar; - } - - // Upper wall - for (int x = 0; x < totalShots; x++) - { - Projectile.NewProjectile(player.position.X + shotSpacing[2], player.position.Y - spawnOffset, 0f, speed, type, damage, 0f, Main.myPlayer); - shotSpacing[2] -= spacingVar; - } - - for (int i = 0; i < shotSpacing.Length; i++) - shotSpacing[i] = shotSpacingMax; - } - - calamityGlobalNPC.newAI[1] += 1f; - } - } - - float fallSpeed = enraged ? 21f : malice ? 19.5f : death ? 17.75f : 16f; - - if (expertMode) - fallSpeed += 3.5f * (1f - lifeRatio); - - if (player.dead) - { - npc.TargetClosest(false); - flies = true; - npc.velocity.Y -= 3f; - if ((double)npc.position.Y < Main.topWorld + 16f) - { - npc.velocity.Y -= 3f; - fallSpeed = 32f; - } - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - } - - // Movement - int num180 = (int)(npc.position.X / 16f) - 1; - int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num182 = (int)(npc.position.Y / 16f) - 1; - int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; - - if (num180 < 0) - num180 = 0; - if (num181 > Main.maxTilesX) - num181 = Main.maxTilesX; - if (num182 < 0) - num182 = 0; - if (num183 > Main.maxTilesY) - num183 = Main.maxTilesY; - - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - int phaseLimit = death ? 600 : 900; - - // Flight - if (npc.ai[3] == 0f) - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - - // Charge in a direction for a second until the timer is back at 0 - if (postTeleportTimer > 0) - { - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - return; - } - - calamityGlobalNPC.newAI[2] += 1f; - - npc.localAI[1] = 0f; - - float speed = enraged ? 20f : malice ? 18f : death ? 16.5f : 15f; - float turnSpeed = enraged ? 0.4f : malice ? 0.36f : death ? 0.33f : 0.3f; - float homingSpeed = enraged ? 40f : malice ? 36f : death ? 30f : 24f; - float homingTurnSpeed = enraged ? 0.55f : malice ? 0.48f : death ? 0.405f : 0.33f; - - if (expertMode) - { - phaseLimit /= 1 + (int)(5f * (1f - lifeRatio)); - - if (phaseLimit < 180) - phaseLimit = 180; - - speed += 3f * (1f - lifeRatio); - turnSpeed += 0.06f * (1f - lifeRatio); - homingSpeed += 12f * (1f - lifeRatio); - homingTurnSpeed += 0.15f * (1f - lifeRatio); - } - - // Go to ground phase sooner - if (increaseSpeedMore) - { - if (laserWallPhase == (int)LaserWallPhase.SetUp && calamityGlobalNPC.newAI[3] <= alphaGateValue) - SpawnTeleportLocation(player); - else - calamityGlobalNPC.newAI[2] += 10f; - } - else - calamityGlobalNPC.newAI[2] += 2f; - - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = npc.Center; - float num191 = player.Center.X; - float num192 = player.Center.Y; - int num42 = -1; - int num43 = (int)(player.Center.X / 16f); - int num44 = (int)(player.Center.Y / 16f); - - // Charge at target for 1.5 seconds - bool flyAtTarget = (!phase2 || phase4) && calamityGlobalNPC.newAI[2] > phaseLimit - 90 && revenge; - - 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 (!flyAtTarget) - { - if (num42 > 0) - { - num42 *= 16; - float num47 = num42 - 800; - if (player.position.Y > num47) - { - num192 = num47; - if (Math.Abs(npc.Center.X - player.Center.X) < 500f) - { - if (npc.velocity.X > 0f) - num191 = player.Center.X + 600f; - else - num191 = player.Center.X - 600f; - } - } - } - } - else - { - num188 = homingSpeed; - num189 = homingTurnSpeed; - } - - if (expertMode) - { - num188 += Vector2.Distance(player.Center, npc.Center) * 0.005f * (1f - lifeRatio); - num189 += Vector2.Distance(player.Center, npc.Center) * 0.0001f * (1f - lifeRatio); - } - - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } - - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189; - else - { - if (npc.velocity.X > num191) - npc.velocity.X -= num189; - } - - if (npc.velocity.Y < num192) - npc.velocity.Y += num189; - else - { - if (npc.velocity.Y > num192) - npc.velocity.Y -= num189; - } - - if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num189 * 2f; - else - npc.velocity.Y -= num189 * 2f; - } - - if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num189 * 2f; - else - npc.velocity.X -= num189 * 2f; - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189 * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num189; - else - npc.velocity.Y -= num189; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y += num189 * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num189; - else - npc.velocity.X -= num189; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - if (calamityGlobalNPC.newAI[2] > phaseLimit) - { - npc.ai[3] = 1f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Ground - else - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - - // Charge in a direction for a second until the timer is back at 0 - if (postTeleportTimer > 0) - { - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - return; - } - - calamityGlobalNPC.newAI[2] += 1f; - - float turnSpeed = enraged ? 0.36f : malice ? 0.3f : death ? 0.24f : 0.18f; - - if (expertMode) - { - turnSpeed += 0.1f * (1f - lifeRatio); - turnSpeed += Vector2.Distance(player.Center, npc.Center) * 0.00005f * (1f - lifeRatio); - } - - // Enrage - if (increaseSpeedMore) - { - if (laserWallPhase == (int)LaserWallPhase.SetUp && calamityGlobalNPC.newAI[3] <= alphaGateValue) - SpawnTeleportLocation(player); - else - { - fallSpeed *= 3f; - turnSpeed *= 6f; - } - } - else if (increaseSpeed) - { - fallSpeed *= 1.5f; - turnSpeed *= 3f; - } - - if (!flies) - { - for (int num952 = num180; num952 < num181; num952++) - { - for (int num953 = num182; num953 < num183; num953++) - { - if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[Main.tile[num952, num953].type] || (Main.tileSolidTop[Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64)) - { - Vector2 vector105; - vector105.X = num952 * 16; - vector105.Y = num953 * 16; - if (npc.position.X + npc.width > vector105.X && npc.position.X < vector105.X + 16f && npc.position.Y + npc.height > vector105.Y && npc.position.Y < vector105.Y + 16f) - { - flies = true; - break; - } - } - } - } - } - - if (!flies) - { - npc.localAI[1] = 1f; - - Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - - int num954 = death ? 1125 : 1200; - if (lifeRatio < 0.8f && lifeRatio > 0.2f && !death) - num954 = 1400; - - if (expertMode) - num954 -= (int)(150f * (1f - lifeRatio)); - - if (num954 < 1050) - num954 = 1050; - - bool flag95 = true; - if (npc.position.Y > player.position.Y) - { - for (int num955 = 0; num955 < Main.maxPlayers; num955++) - { - if (Main.player[num955].active) - { - Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); - if (rectangle12.Intersects(rectangle13)) - { - flag95 = false; - break; - } - } - } - if (flag95) - flies = true; - } - } - else - npc.localAI[1] = 0f; - - float num189 = turnSpeed; - Vector2 vector18 = npc.Center; - float num191 = player.Center.X; - float num192 = player.Center.Y; - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - - if (!flies) - { - npc.velocity.Y += turnSpeed; - if (npc.velocity.Y > fallSpeed) - npc.velocity.Y = fallSpeed; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 2.2) - { - if (npc.velocity.X < 0f) - npc.velocity.X -= num189 * 1.1f; - else - npc.velocity.X += num189 * 1.1f; - } - else if (npc.velocity.Y == fallSpeed) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189; - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - npc.velocity.X += num189 * 0.9f; - else - npc.velocity.X -= num189 * 0.9f; - } - } - else - { - double maximumSpeed1 = enraged ? 0.6 : malice ? 0.52 : death ? 0.46 : 0.4; - double maximumSpeed2 = enraged ? 1.4 : malice ? 1.25 : death ? 1.125 : 1D; - - if (increaseSpeedMore) - { - maximumSpeed1 *= 4; - maximumSpeed2 *= 4; - } - if (increaseSpeed) - { - maximumSpeed1 *= 2; - maximumSpeed2 *= 2; - } - - if (expertMode) - { - maximumSpeed1 += 0.1f * (1f - lifeRatio); - maximumSpeed2 += 0.2f * (1f - lifeRatio); - } - - num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num25 = Math.Abs(num191); - float num26 = Math.Abs(num192); - float num27 = fallSpeed / num193; - num191 *= num27; - num192 *= num27; - - if (((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f)) && ((npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f))) - { - if (npc.velocity.X < num191) - npc.velocity.X += turnSpeed * 1.5f; - else if (npc.velocity.X > num191) - npc.velocity.X -= turnSpeed * 1.5f; - - if (npc.velocity.Y < num192) - npc.velocity.Y += turnSpeed * 1.5f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= turnSpeed * 1.5f; - } - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - npc.velocity.X += turnSpeed; - else if (npc.velocity.X > num191) - npc.velocity.X -= turnSpeed; - - if (npc.velocity.Y < num192) - npc.velocity.Y += turnSpeed; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= turnSpeed; - - if (Math.Abs(num192) < fallSpeed * maximumSpeed1 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += turnSpeed * 2f; - else - npc.velocity.Y -= turnSpeed * 2f; - } - - if (Math.Abs(num191) < fallSpeed * maximumSpeed1 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += turnSpeed * 2f; - else - npc.velocity.X -= turnSpeed * 2f; - } - } - else if (num25 > num26) - { - if (npc.velocity.X < num191) - npc.velocity.X += turnSpeed * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= turnSpeed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += turnSpeed; - else - npc.velocity.Y -= turnSpeed; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y += turnSpeed * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= turnSpeed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) - { - if (npc.velocity.X > 0f) - npc.velocity.X += turnSpeed; - else - npc.velocity.X -= turnSpeed; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - if (flies) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; - - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; - - npc.localAI[0] = 0f; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - - if (calamityGlobalNPC.newAI[2] > phaseLimit) - { - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - } - - private void SpawnTeleportLocation(Player player) - { - if (teleportTimer > -1 || player.dead || !player.active) - return; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int randomRange = 48; - float distance = 640f; - Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); - Main.PlaySound(SoundID.Item109, player.Center); - Projectile.NewProjectile(targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI); - } - - teleportTimer = (CalamityWorld.death || CalamityWorld.malice) ? 120 : CalamityWorld.revenge ? 140 : Main.expertMode ? 160 : 180; - } - - private void Teleport(Player player, bool malice, bool death, bool revenge, bool expertMode, bool phase3) - { - Vector2 newPosition = GetRiftLocation(true); - - if (player.dead || !player.active || newPosition == default) - return; - - if (phase3) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float finalVelocity = 10f; - int totalSpreads = revenge ? 6 : 3; - float mult = revenge ? 1.5f : 3f; - for (int i = 0; i < totalSpreads; i++) - { - int totalProjectiles = malice ? 18 : 12; - float radians = MathHelper.TwoPi / totalProjectiles; - float newVelocity = finalVelocity - i * mult; - float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = i < 3 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); - float finalVelocityReduction = (float)Math.Pow(1.25, i) - 1f; - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(newPosition, vector255, type, damage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); - } - } - } - } - - npc.TargetClosest(); - npc.position = newPosition; - float chargeVelocity = malice ? 30f : death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; - float maxChargeDistance = 1600f; - postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); - npc.alpha = postTeleportTimer; - npc.velocity = Vector2.Normalize(player.Center + player.velocity * 40f - npc.Center) * chargeVelocity; - npc.netUpdate = true; - - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) - { - Main.npc[i].position = newPosition; - - if (Main.npc[i].type == ModContent.NPCType()) - ((DevourerofGodsTailS)Main.npc[i].modNPC).setInvulTime(720); - - Main.npc[i].netUpdate = true; - } - } - - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), player.Center); - } - - private Vector2 GetRiftLocation(bool spawnDust) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].type == ModContent.ProjectileType()) - { - if (!spawnDust) - Main.projectile[i].ai[0] = -1f; - - Main.projectile[i].Kill(); - return Main.projectile[i].Center; - } - } - return default; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - if (!npc.dontTakeDamage) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow2"); - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - - return false; - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } - - public override bool SpecialNPCLoot() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(npc, - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType()); - npc.position = Main.npc[closestSegmentID].position; - return false; - } - - public override void NPCLoot() - { - // Stop the countdown -- if you kill DoG in less than 60 frames, this will stop another one from spawning. - CalamityWorld.DoGSecondStageCountdown = 0; - - DropHelper.DropBags(npc); - - // Legendary drops for DoG - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); - - DropHelper.DropItem(npc, ModContent.ItemType(), 5, 15); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedDoG); - - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedDoG); - - // Mount - CalamityPlayer mp = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Calamity(); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, mp.fabsolVodka); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), 25, 35); - DropHelper.DropItem(npc, ModContent.ItemType(), 150, 250); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - if (Main.rand.NextBool(5)) - { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - } - } - - // If DoG has not been killed yet, notify players that the holiday moons are buffed - if (!CalamityWorld.downedDoG) - { - string key = "Mods.CalamityMod.DoGBossText"; - Color messageColor = Color.Cyan; - string key2 = "Mods.CalamityMod.DoGBossText2"; - Color messageColor2 = Color.Orange; - string key3 = "Mods.CalamityMod.DargonBossText"; - - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); - CalamityUtils.DisplayLocalizedText(key3, messageColor2); - } - - // Mark DoG as dead - CalamityWorld.downedDoG = true; - CalamityNetcode.SyncWorld(); - } - - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 80f && (npc.alpha <= 0 || postTeleportTimer > 0) && preventBullshitHitsAtStartofFinalPhaseTimer <= 0; - } - - 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)) - { - string key = "Mods.CalamityMod.EdgyBossText2"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - return false; - } - return true; - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 2f; - return null; - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - } - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS5"), 1f); - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 15; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 30; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 300, true); - player.AddBuff(ModContent.BuffType(), 420, true); - /*if ((CalamityWorld.death || BossRushEvent.BossRushActive) && (npc.alpha <= 0 || postTeleportTimer > 0) && !player.Calamity().lol && preventBullshitHitsAtStartofFinalPhaseTimer <= 0) - { - player.KillMe(PlayerDeathReason.ByCustomReason(player.name + "'s essence was consumed by the devourer."), 1000.0, 0, false); - }*/ - - if (player.Calamity().dogTextCooldown <= 0) - { - string text = Utils.SelectRandom(Main.rand, new string[] - { - "Mods.CalamityMod.EdgyBossText3", - "Mods.CalamityMod.EdgyBossText4", - "Mods.CalamityMod.EdgyBossText5", - "Mods.CalamityMod.EdgyBossText6", - "Mods.CalamityMod.EdgyBossText7" - }); - Color messageColor = Color.Cyan; - Rectangle location = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); - player.Calamity().dogTextCooldown = 60; - } - } - } -} diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index 3030d818fd..653d2c6298 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -1,8 +1,10 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System.IO; using Terraria; using Terraria.ID; using Terraria.Localization; @@ -10,15 +12,38 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DevourerofGods { - [AutoloadBossHead] public class DevourerofGodsTail : ModNPC { - public override void SetStaticDefaults() + public static int phase1IconIndex; + public static int phase2IconIndex; + + internal static void LoadHeadIcons() + { + string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss"; + + CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); + phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); + + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } + + private int invinceTime = 720; + private bool setAlpha = false; + private bool phase2Started = false; + + public override void SetStaticDefaults() { DisplayName.SetDefault("The Devourer of Gods"); } - public override void SetDefaults() + internal void setInvulTime(int time) + { + invinceTime = time; + } + + public override void SetDefaults() { npc.Calamity().canBreakPlayerDefense = true; npc.GetNPCDamage(); @@ -26,7 +51,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.width = 66; npc.height = 66; npc.defense = 50; - npc.LifeMaxNERB(371250, 445500); + npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -45,21 +70,85 @@ namespace CalamityMod.NPCs.DevourerofGods npc.dontCountMe = true; } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + public override void BossHeadSlot(ref int index) + { + if (phase2Started && CalamityWorld.DoGSecondStageCountdown > 60) + index = -1; + else if (phase2Started) + index = phase2IconIndex; + else + index = phase1IconIndex; + } + + public override void BossHeadRotation(ref float rotation) + { + if (phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60) + rotation = npc.rotation; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(phase2Started); + writer.Write(invinceTime); + writer.Write(setAlpha); + writer.Write(npc.dontTakeDamage); + writer.Write(npc.alpha); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + phase2Started = reader.ReadBoolean(); + invinceTime = reader.ReadInt32(); + setAlpha = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.alpha = reader.ReadInt32(); + } + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; } public override void AI() { - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + if (npc.life / (float)npc.lifeMax < 0.6f) + { + phase2Started = true; + + // 8.833 seconds before DoG spawns, start playing the phase 2 music and set new size + if (CalamityWorld.DoGSecondStageCountdown == 530) + { + music = CalamityMod.Instance.GetMusicFromMusicMod("UniversalCollapse") ?? MusicID.LunarBoss; + + npc.position = npc.Center; + npc.width = 80; + npc.height = 140; + npc.position -= npc.Size * 0.5f; + } + } + + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + + if (invinceTime > 0) + { + invinceTime--; + npc.dontTakeDamage = true; + } + else + npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; + + if (Main.npc[(int)npc.ai[2]].dontTakeDamage) + invinceTime = 240; // Target if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + npc.TargetClosest(); Player player = Main.player[npc.target]; @@ -98,50 +187,42 @@ namespace CalamityMod.NPCs.DevourerofGods npc.active = false; } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } + if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) + { + npc.alpha -= 42; + if (npc.alpha <= 0 && invinceTime <= 0) + { + setAlpha = true; + npc.alpha = 0; + } + } + else + npc.alpha = Main.npc[(int)npc.ai[2]].alpha; - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - if (player.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 = player.position.X + (float)(player.width / 2); - float num192 = player.position.Y + (float)(player.height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = player.position.X + (player.width / 2); + float num192 = player.position.Y + (player.height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -161,71 +242,92 @@ namespace CalamityMod.NPCs.DevourerofGods if (npc.spriteDirection == 1) 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)); + bool useOtherTextures = phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; + Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); 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, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + if (!npc.dontTakeDamage) + { + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow"); + Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow2"); - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow2"); + color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } return false; } public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } + { + cooldownSlot = 1; - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - } - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGTail"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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; - } - } - for (int num623 = 0; num623 < 20; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } + Rectangle targetHitbox = target.Hitbox; - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= (phase2Started ? 70f : 35f) && npc.alpha == 0; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.soundDelay == 0) + { + npc.soundDelay = 8; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); + } + if (npc.life <= 0) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS4"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 50; + npc.height = 50; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 10; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 20; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { return !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); } @@ -259,7 +361,7 @@ namespace CalamityMod.NPCs.DevourerofGods "Mods.CalamityMod.EdgyBossText9" }); Color messageColor = Color.Cyan; - Rectangle location = new Microsoft.Xna.Framework.Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + Rectangle location = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); player.Calamity().dogTextCooldown = 60; } diff --git a/NPCs/DevourerofGods/DevourerofGodsTailS.cs b/NPCs/DevourerofGods/DevourerofGodsTailS.cs deleted file mode 100644 index a5516cbf0a..0000000000 --- a/NPCs/DevourerofGods/DevourerofGodsTailS.cs +++ /dev/null @@ -1,343 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.DevourerofGods -{ - [AutoloadBossHead] - public class DevourerofGodsTailS : ModNPC - { - private int invinceTime = 720; - private bool setAlpha = false; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Devourer of Gods"); - } - - internal void setInvulTime(int time) - { - invinceTime = time; - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 80; - npc.height = 140; - npc.defense = 50; - npc.LifeMaxNERB(517500, 621000, 920000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.takenDamageMultiplier = 1.25f; - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.DeathSound = SoundID.NPCDeath14; - npc.netAlways = true; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("UniversalCollapse") ?? MusicID.LunarBoss; - npc.dontCountMe = true; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(setAlpha); - writer.Write(npc.dontTakeDamage); - writer.Write(npc.alpha); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - setAlpha = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.alpha = reader.ReadInt32(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void BossHeadRotation(ref float rotation) - { - rotation = npc.rotation; - } - - public override void AI() - { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - if (invinceTime > 0) - { - invinceTime--; - npc.dontTakeDamage = true; - } - else - npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - - if (Main.npc[(int)npc.ai[2]].dontTakeDamage) - invinceTime = 240; - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Target - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); - - Player player = Main.player[npc.target]; - - float distanceFromTarget = Vector2.Distance(player.Center, npc.Center); - float takeLessDamageDistance = 1600f; - if (distanceFromTarget > takeLessDamageDistance) - { - float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); - npc.takenDamageMultiplier = MathHelper.Lerp(1f, 1.25f, damageTakenScalar); - } - else - npc.takenDamageMultiplier = 1.25f; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - - if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) - { - npc.alpha -= 42; - if (npc.alpha <= 0 && invinceTime <= 0) - { - setAlpha = true; - npc.alpha = 0; - } - } - else - npc.alpha = Main.npc[(int)npc.ai[2]].alpha; - - if (player.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 = player.position.X + (float)(player.width / 2); - float num192 = player.position.Y + (float)(player.height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - - if (num191 < 0f) - npc.spriteDirection = -1; - else if (num191 > 0f) - npc.spriteDirection = 1; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - if (!npc.dontTakeDamage) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow2"); - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - - return false; - } - - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 70f && npc.alpha == 0; - } - - // Projectiles can only hit within certain distance - /*public override bool? CanBeHitByProjectile(Projectile projectile) - { - Rectangle projectileHitbox = projectile.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, projectileHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, projectileHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, projectileHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, projectileHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) minDist = dist2; - if (dist3 < minDist) minDist = dist3; - if (dist4 < minDist) minDist = dist4; - - return minDist <= 70f; - }*/ - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - } - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS4"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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; - } - } - for (int num623 = 0; num623 < 20; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - return !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); - } - - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return false; - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 180, true); - player.AddBuff(ModContent.BuffType(), 240, true); - - if (player.Calamity().dogTextCooldown <= 0) - { - string text = Utils.SelectRandom(Main.rand, new string[] - { - "Mods.CalamityMod.EdgyBossText8", - "Mods.CalamityMod.EdgyBossText9" - }); - Color messageColor = Color.Cyan; - Rectangle location = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); - player.Calamity().dogTextCooldown = 60; - } - } - } -} diff --git a/NPCs/DevourerofGods/DoGSCreenShaderDataS.cs b/NPCs/DevourerofGods/DoGSCreenShaderDataS.cs deleted file mode 100644 index aef4291f04..0000000000 --- a/NPCs/DevourerofGods/DoGSCreenShaderDataS.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.DevourerofGods -{ - public class DoGScreenShaderDataS : ScreenShaderData - { - private int DoGIndex; - - public DoGScreenShaderDataS(string passName) - : base(passName) - { - } - - private void UpdateDoGIndex() - { - int DoGType = ModContent.NPCType(); - if (DoGIndex >= 0 && Main.npc[DoGIndex].active && Main.npc[DoGIndex].type == DoGType) - { - return; - } - DoGIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == DoGType) - { - DoGIndex = i; - break; - } - } - } - - public override void Apply() - { - UpdateDoGIndex(); - if (DoGIndex != -1) - { - UseTargetPosition(Main.npc[DoGIndex].Center); - } - base.Apply(); - } - } -} diff --git a/NPCs/DevourerofGods/DoGSky.cs b/NPCs/DevourerofGods/DoGSky.cs index 3dcbc3a28c..38ecaabddf 100644 --- a/NPCs/DevourerofGods/DoGSky.cs +++ b/NPCs/DevourerofGods/DoGSky.cs @@ -31,12 +31,13 @@ namespace CalamityMod.NPCs.DevourerofGods { float x = 0f; if (DoGIndex != -1) - { x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[DoGIndex].Center); - } - return (1f - Utils.SmoothStep(3000f, 6000f, x)) * 0.5f; + + bool sentinelsPhase = Main.npc[DoGIndex].life / (float)Main.npc[DoGIndex].lifeMax < 0.6f && CalamityWorld.DoGSecondStageCountdown > 60; + float intensityScalar = sentinelsPhase ? 0f : 0.5f; + return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar; } - return 0.5f; + return 0f; } public override Color OnTileColor(Color inColor) @@ -70,8 +71,10 @@ namespace CalamityMod.NPCs.DevourerofGods { if (Main.npc[DoGIndex].active) { - float intensity = GetIntensity(); - if (Main.npc[DoGIndex].life < Main.npc[DoGIndex].lifeMax * 0.15 || CalamityWorld.death || CalamityWorld.malice) + float intensity = GetIntensity(); + float lifeRatio = Main.npc[DoGIndex].life / (float)Main.npc[DoGIndex].lifeMax; + double blackScreenLife_GateValue = lifeRatio < 0.6f ? 0.09 : 0.66; + if (Main.npc[DoGIndex].life < Main.npc[DoGIndex].lifeMax * blackScreenLife_GateValue || CalamityWorld.death || CalamityWorld.malice) { spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * (intensity + 0.5f)); diff --git a/NPCs/DevourerofGods/DoGSkyS.cs b/NPCs/DevourerofGods/DoGSkyS.cs deleted file mode 100644 index 3be57d9454..0000000000 --- a/NPCs/DevourerofGods/DoGSkyS.cs +++ /dev/null @@ -1,113 +0,0 @@ -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Effects; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.DevourerofGods -{ - public class DoGSkyS : CustomSky - { - private bool isActive = false; - private float intensity = 0f; - private int DoGIndex = -1; - - public override void Update(GameTime gameTime) - { - if (isActive && intensity < 1f) - { - intensity += 0.01f; - } - else if (!isActive && intensity > 0f) - { - intensity -= 0.01f; - } - } - - private float GetIntensity() - { - if (this.UpdateDoGIndex()) - { - float x = 0f; - if (this.DoGIndex != -1) - { - x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this.DoGIndex].Center); - } - return (1f - Utils.SmoothStep(3000f, 6000f, x)) * 0.5f; - } - return 0.5f; - } - - public override Color OnTileColor(Color inColor) - { - float intensity = this.GetIntensity(); - return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); - } - - private bool UpdateDoGIndex() - { - int DoGType = ModContent.NPCType(); - if (DoGIndex >= 0 && Main.npc[DoGIndex].active && Main.npc[DoGIndex].type == DoGType) - { - return true; - } - DoGIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == DoGType) - { - DoGIndex = i; - break; - } - } - return DoGIndex != -1; - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - if (maxDepth >= 0 && minDepth < 0 && DoGIndex != -1) - { - if (Main.npc[DoGIndex].active) - { - float intensity = this.GetIntensity(); - if ((double)Main.npc[DoGIndex].life < (double)Main.npc[DoGIndex].lifeMax * 0.15 || CalamityWorld.death || CalamityWorld.malice) - { - spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), - Color.Black * (intensity + 0.5f)); - } - else - { - spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), - (Main.npc[DoGIndex].ai[3] == 0f ? Color.Cyan : Color.Fuchsia) * intensity); - } - } - } - } - - public override float GetCloudAlpha() - { - return 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - isActive = true; - } - - public override void Deactivate(params object[] args) - { - isActive = false; - } - - public override void Reset() - { - isActive = false; - } - - public override bool IsActive() - { - return isActive || intensity > 0f; - } - } -} diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index c01975ffba..b57e959ef0 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -64,6 +64,7 @@ namespace CalamityMod.NPCs.DraedonLabThings npc.knockBackResist = 0f; npc.noGravity = true; npc.noTileCollide = false; + npc.friendly = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath44; } @@ -108,9 +109,8 @@ namespace CalamityMod.NPCs.DraedonLabThings public void WalkAroundOnGround() { // Fall onto the ground if mid-air. - npc.frameCounter += npc.velocity.Length() + 0.4f; - Tile tileBelow = CalamityUtils.ParanoidTileRetrieval((int)(npc.Bottom.X / 16), (int)(npc.Bottom.Y / 16) + 1); + Tile tileBelow = CalamityUtils.ParanoidTileRetrieval((int)(npc.Bottom.X / 16f), (int)(npc.Bottom.Y / 16f)); bool onSolidGround = WorldGen.SolidTile(tileBelow) || (tileBelow.active() && Main.tileSolidTop[tileBelow.type]); float directionSign = Math.Sign(npc.velocity.X); if (directionSign == 0f) @@ -118,6 +118,13 @@ namespace CalamityMod.NPCs.DraedonLabThings if (Math.Abs(npc.velocity.X) > 0.5f && onSolidGround) npc.velocity.X = MathHelper.Lerp(npc.velocity.X, directionSign * 5f, 0.05f); + // Using walking frames if on solid ground. + // If not on solid ground, use the first frame. + if (onSolidGround) + npc.frameCounter += npc.velocity.Length() + 0.4f; + else + CurrentFrame = 0f; + // Enforce gravity. npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + Gravity, -15f, 15f); @@ -127,26 +134,34 @@ namespace CalamityMod.NPCs.DraedonLabThings // Attempt to jump over gaps if they aren't too big. Vector2 checkPosition = npc.Bottom + new Vector2(Math.Sign(npc.velocity.X) * 24f, 12f); + float? distanceToAheadBelowTile = CalamityUtils.DistanceToTileCollisionHit(checkPosition, Vector2.UnitX * directionSign); - if (onSolidGround && distanceToAheadBelowTile.HasValue && distanceToAheadBelowTile.Value >= 2 && distanceToAheadBelowTile.Value < 9) + if (onSolidGround && distanceToAheadBelowTile.HasValue && distanceToAheadBelowTile.Value >= 2 && distanceToAheadBelowTile.Value < 9 && npc.velocity.Y == Gravity) { - Vector2 jumpDestination = npc.Center + Vector2.UnitX * npc.spriteDirection * (distanceToAheadBelowTile.Value * 16f + 8f); - npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 8.5f); + Vector2 jumpDestination = npc.Center + Vector2.UnitX * npc.spriteDirection * (distanceToAheadBelowTile.Value * 16f + 12f); + npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 10f); } // Attempt to jump over vertical obstacles. - bool obstacleInWay = !Collision.CanHit(npc.Center - Vector2.UnitX * directionSign * 8f, 2, 2, npc.Center + Vector2.UnitX * directionSign * 80f, 8, 8); + bool obstacleInWay = !Collision.CanHit(npc.Center - Vector2.UnitX * directionSign * 8f, 2, 2, npc.Center + Vector2.UnitX * directionSign * 50f, 8, 8); if (onSolidGround && obstacleInWay) { Vector2 jumpDestination = npc.Center + Vector2.UnitX * npc.spriteDirection * 132f; float? distanceToObstacle = CalamityUtils.DistanceToTileCollisionHit(npc.Center, Vector2.UnitX * directionSign); float obstacleHeight = 0f; - for (int i = 0; i < 15; i++) + for (int i = 0; i < 10; i++) { if (WorldGen.SolidTile((int)(npc.Center.X / 16 + (distanceToObstacle ?? 0) * npc.spriteDirection), (int)(npc.Center.Y / 16) - i)) obstacleHeight++; } - npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 9f + StuckCount * 0.7f + obstacleHeight * 0.4f); + + // Just turn back if the obstacle is ridiculously tall. + if (obstacleHeight >= 10) + npc.velocity.X = -npc.spriteDirection * 3f; + + // Otherwise try to jump over it. + else + npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 9f + StuckCount * 0.7f + obstacleHeight * 0.4f); if (MathHelper.Distance(npc.position.X, npc.oldPosition.X) < 0.2f) { @@ -230,7 +245,7 @@ namespace CalamityMod.NPCs.DraedonLabThings float distanceToCollisionRight = CalamityUtils.DistanceToTileCollisionHit(npc.Center - currentDirection.RotatedBy(-MathHelper.PiOver2) * 5f, currentDirection.RotatedBy(-MathHelper.PiOver2)) ?? 10000f; float steerRotation = distanceToCollisionLeft > distanceToCollisionRight ? MathHelper.PiOver2 : -MathHelper.PiOver2; Vector2 idealVelocity = npc.velocity.RotatedBy(steerRotation); - npc.velocity = npc.velocity.MoveTowards(idealVelocity, 0.95f); + npc.velocity = npc.velocity.MoveTowards(idealVelocity, 0.15f); } else npc.velocity = npc.velocity.RotatedBy(offsetAngle); diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index 6d8c6de22a..f4197c141a 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -63,6 +63,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo set => npc.Calamity().newAI[1] = value; } + // Used for Draedon's text + public static readonly Color TextColor = new Color(155, 255, 255); + // Number of frames on the X and Y axis private const int maxFramesX = 10; private const int maxFramesY = 9; @@ -368,7 +371,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo predictionAmt *= 0.5f; // Gate values - float attackPhaseGateValue = lastMechAlive ? 320f : 480f; + float attackPhaseGateValue = lastMechAlive ? 360f : 480f; float timeToLineUpAttack = 30f; // Distance where Apollo stops moving @@ -558,6 +561,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (Main.netMode != NetmodeID.MultiplayerClient) { + // Draedon text for the start of phase 2 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase2Text1", TextColor); + // Spawn the fuckers NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); @@ -599,6 +605,13 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo chargeLocations[i] = default; npc.TargetClosest(); + + // Phase 6, when 1 mech goes berserk and the other one leaves + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 6 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase6Text1", TextColor); + } } } @@ -642,6 +655,16 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Never be passive if berserk SecondaryAIState = (float)SecondaryPhase.Nothing; + + // Phase 4, when 1 mech goes berserk and the other 2 leave + if (exoWormAlive && exoPrimeAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 4 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase4Text1", TextColor); + } + } } break; @@ -667,6 +690,16 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo chargeLocations[i] = default; npc.TargetClosest(); + + // Phase 3, when all 3 mechs attack at the same time + if (exoWormAlive && exoPrimeAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 3 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase3Text1", TextColor); + } + } } if (berserk) @@ -726,7 +759,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (firingPlasma) { // Fire plasma - int numPlasmaOrbs = lastMechAlive ? 16 : nerfedAttacks ? 8 : 12; + int numPlasmaOrbs = nerfedAttacks ? 8 : 12; float divisor = attackPhaseGateValue / numPlasmaOrbs; float plasmaTimer = calamityGlobalNPC.newAI[3] - 2f; if (plasmaTimer % divisor == 0f && canFire) @@ -1382,19 +1415,30 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo public override void NPCLoot() { // Check if the other exo mechs are alive - bool otherExoMechsAlive = false; + bool exoWormAlive = false; + bool exoPrimeAlive = false; if (CalamityGlobalNPC.draedonExoMechWorm != -1) { if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - otherExoMechsAlive = true; + exoWormAlive = true; } if (CalamityGlobalNPC.draedonExoMechPrime != -1) { if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - otherExoMechsAlive = true; + exoPrimeAlive = true; } - if (!otherExoMechsAlive) + // Phase 5, when 1 mech dies and the other 2 return to fight + if (exoWormAlive && exoPrimeAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 5 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase5Text1", TextColor); + } + } + + if (!exoWormAlive && !exoPrimeAlive) AresBody.DropExoMechLoot(npc, (int)AresBody.MechType.ArtemisAndApollo); } diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index dae7da08f8..e5fee22b8f 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -72,6 +72,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares set => npc.localAI[1] = value; } + // Used for Draedon's text + public static readonly Color TextColor = new Color(155, 255, 255); + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); // Spawn rate for enrage steam @@ -454,6 +457,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (Main.netMode != NetmodeID.MultiplayerClient) { + // Draedon text for the start of phase 2 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase2Text1", TextColor); + // Spawn the fuckers NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); @@ -480,6 +486,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Reset everything SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; npc.TargetClosest(); + + // Phase 6, when 1 mech goes berserk and the other one leaves + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 6 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase6Text1", TextColor); + } } } @@ -504,6 +517,16 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Never be passive if berserk SecondaryAIState = (float)SecondaryPhase.Nothing; + + // Phase 4, when 1 mech goes berserk and the other 2 leave + if (exoWormAlive && exoTwinsAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 4 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase4Text1", TextColor); + } + } } break; @@ -518,6 +541,16 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Return to normal phases if one or more mechs have been downed SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; npc.TargetClosest(); + + // Phase 3, when all 3 mechs attack at the same time + if (exoWormAlive && exoTwinsAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 3 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase3Text1", TextColor); + } + } } if (berserk) @@ -798,20 +831,31 @@ namespace CalamityMod.NPCs.ExoMechs.Ares public override void NPCLoot() { // Check if the other exo mechs are alive - bool otherExoMechsAlive = false; + bool exoWormAlive = false; + bool exoTwinsAlive = false; if (CalamityGlobalNPC.draedonExoMechWorm != -1) { if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - otherExoMechsAlive = true; + exoWormAlive = true; } if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) { if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - otherExoMechsAlive = true; + exoTwinsAlive = true; + } + + // Phase 5, when 1 mech dies and the other 2 return to fight + if (exoWormAlive && exoTwinsAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 5 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase5Text1", TextColor); + } } // Mark Exo Mechs as dead - if (!otherExoMechsAlive) + if (!exoWormAlive && !exoTwinsAlive) DropExoMechLoot(npc, (int)MechType.Ares); } @@ -854,6 +898,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares break; } + CalamityGlobalNPC.SetNewBossJustDowned(npc); + DropHelper.DropBags(npc); // All other drops are contained in the bag, so they only drop directly on Normal diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs index e2480ad939..ab4904bdbe 100644 --- a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -352,17 +352,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } else { - // Despawn any active Tesla Orbs - if (calamityGlobalNPC.newAI[2] == teslaOrbTelegraphDuration && !enraged) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile projectile = Main.projectile[i]; - if (projectile.active && projectile.type == ModContent.ProjectileType()) - projectile.Kill(); - } - } - // Fire tesla orbs int numTeslaOrbs = lastMechAlive ? 6 : berserk ? 5 : nerfedAttacks ? 3 : 4; float divisor = teslaOrbDuration / numTeslaOrbs; @@ -376,7 +365,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); Vector2 offset = Vector2.Normalize(teslaOrbVelocity) * 40f + Vector2.UnitY * 8f; - float identity = (calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) / divisor; + float identity = fireMoreOrbs ? -2f : calamityGlobalNPC.newAI[3] + (calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) / divisor; Projectile.NewProjectile(npc.Center + offset, teslaOrbVelocity, type, damage, 0f, Main.myPlayer, identity); } } @@ -386,6 +375,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { AIState = (float)Phase.Nothing; calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] += 10f; } break; diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index 4f39799c0a..d43644e913 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -229,6 +229,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Check if the other exo mechs are alive int otherExoMechsAlive = 0; + bool exoTwinGreenAlive = false; bool exoWormAlive = false; bool exoPrimeAlive = false; if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) @@ -241,6 +242,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Link the HP of both twins if (npc.life > Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life) npc.life = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life; + + exoTwinGreenAlive = true; } } if (CalamityGlobalNPC.draedonExoMechWorm != -1) @@ -292,6 +295,14 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (exoPrimeAlive) nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] != (float)AresBody.SecondaryPhase.PassiveAndImmune; + // Used to nerf Artemis laser shotgun if Apollo is in charging phase + bool nerfedLaserShotgun = false; + if (exoTwinGreenAlive) + { + nerfedLaserShotgun = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[0] == (float)Apollo.Apollo.Phase.LineUpChargeCombo || + Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[0] == (float)Apollo.Apollo.Phase.ChargeCombo; + } + // Check if any of the other mechs were spawned first bool exoWormWasFirst = false; bool exoPrimeWasFirst = false; @@ -377,13 +388,15 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Predictiveness float predictionAmt = malice ? 20f : death ? 15f : revenge ? 12.5f : expertMode ? 10f : 5f; + if (AIState == (float)Phase.LaserShotgun) + predictionAmt *= 1.5f; if (nerfedAttacks) predictionAmt *= 0.5f; if (SecondaryAIState == (float)SecondaryPhase.Passive) predictionAmt *= 0.5f; // Gate values - float attackPhaseGateValue = lastMechAlive ? 320f : 480f; + float attackPhaseGateValue = lastMechAlive ? 360f : 480f; float timeToLineUpAttack = phase2 ? 30f : 45f; // Spin variables @@ -750,7 +763,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (firingLasers) { // Fire lasers - int numLasers = lastMechAlive ? 16 : nerfedAttacks ? 8 : 12; + int numLasers = nerfedAttacks ? 8 : 12; float divisor = attackPhaseGateValue / numLasers; float laserTimer = calamityGlobalNPC.newAI[3] - 2f; if (laserTimer % divisor == 0f && canFire) @@ -915,8 +928,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis * normal = 16, 20, 24 * nerfedAttacks = 12, 15, 18 */ - int numLasersPerSpread = lastMechAlive ? 8 : nerfedAttacks ? 4 : 6; - int baseSpread = lastMechAlive ? 20 : nerfedAttacks ? 12 : 16; + int numLasersPerSpread = (nerfedAttacks || nerfedLaserShotgun) ? 4 : lastMechAlive ? 8 : 6; + int baseSpread = (nerfedAttacks || nerfedLaserShotgun) ? 12 : lastMechAlive ? 20 : 16; int spread = baseSpread + (int)(calamityGlobalNPC.newAI[2] / divisor2) * (baseSpread / 4); float rotation = MathHelper.ToRadians(spread); float distanceFromTarget = Vector2.Distance(npc.Center, player.Center + predictionVector); diff --git a/NPCs/ExoMechs/Draedon.cs b/NPCs/ExoMechs/Draedon.cs index 881a982bab..3c998649a6 100644 --- a/NPCs/ExoMechs/Draedon.cs +++ b/NPCs/ExoMechs/Draedon.cs @@ -127,6 +127,13 @@ namespace CalamityMod.NPCs.ExoMechs if (TalkTimer == TeleportFadeinTime + 5f) ShouldStartStandingUp = true; + // Gloss over the arbitrary details and just get to the Exo Mech selection if Draedon has already been talked to. + if (CalamityWorld.TalkedToDraedon && TalkTimer > 70 && TalkTimer < TalkDelay * 4f - 25f) + { + TalkTimer = TalkDelay * 4f - 25f; + npc.netUpdate = true; + } + if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay) { CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText1", TextColor); @@ -154,7 +161,18 @@ namespace CalamityMod.NPCs.ExoMechs // Inform the player who summoned draedon they may choose the first mech and cause a selection UI to appear over their head. if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine * 4f) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText5", TextColorEdgy); + if (CalamityWorld.TalkedToDraedon) + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonResummonText", TextColorEdgy); + else + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText5", TextColorEdgy); + + // Mark Draedon as talked to. + if (!CalamityWorld.TalkedToDraedon) + { + CalamityWorld.TalkedToDraedon = true; + CalamityNetcode.SyncWorld(); + } + npc.netUpdate = true; } @@ -165,10 +183,6 @@ namespace CalamityMod.NPCs.ExoMechs TalkTimer = ExoMechChooseDelay; } - // Disable music before talking. - if (TalkTimer <= 50f) - Main.LocalPlayer.Calamity().MusicMuffleFactor = 1f; - // Fly around once the exo mechs have been spawned. if (ExoMechIsPresent || DefeatTimer > 0f) { @@ -303,7 +317,7 @@ namespace CalamityMod.NPCs.ExoMechs // Stand up in awe after a small amount of time has passed. if (DefeatTimer > DelayBeforeDefeatStandup) ShouldStartStandingUp = true; - + // TODO - This needs to be changed. if (DefeatTimer == DelayBeforeDefeatStandup + 10f) Main.NewText("Wait, what? How?", TextColor); diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index ff641fe504..27b1801ec6 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -18,7 +18,7 @@ using CalamityMod.Skies; namespace CalamityMod.NPCs.ExoMechs.Thanatos { public class ThanatosHead : ModNPC - { + { public static int normalIconIndex; public static int vulnerableIconIndex; @@ -60,6 +60,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos set => npc.Calamity().newAI[1] = value; } + // Used for Draedon's text + public static readonly Color TextColor = new Color(155, 255, 255); + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); // Timer to prevent Thanatos from dealing contact damage for a bit @@ -91,10 +94,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Length variables public const int minLength = 100; - private const int maxLength = 101; + private const int maxLength = 101; // Variable used to stop the segment spawning loop - private bool tailSpawned = false; + private bool tailSpawned = false; // Used in the lerp to smoothly scale velocity up and down private float chargeVelocityScalar = 0f; @@ -104,36 +107,39 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Total duration of the deathray private const float deathrayDuration = 180f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("XM-05 Thanatos"); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XM-05 Thanatos"); Main.npcFrameCount[npc.type] = 5; + + // Ensure that the reticle is not culled due to the player being very far from Thanatos. + NPCID.Sets.MustAlwaysDraw[npc.type] = true; } - public override void SetDefaults() - { + public override void SetDefaults() + { npc.Calamity().canBreakPlayerDefense = true; npc.npcSlots = 5f; npc.GetNPCDamage(); npc.width = 164; - npc.height = 164; - npc.defense = 80; + npc.height = 164; + npc.defense = 80; npc.DR_NERD(0.9999f); npc.Calamity().unbreakableDR = true; npc.LifeMaxNERB(1000000, 1150000, 500000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; - aiType = -1; + aiType = -1; npc.Opacity = 0f; - npc.knockBackResist = 0f; - npc.value = Item.buyPrice(3, 33, 0, 0); - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.DeathSound = SoundID.NPCDeath14; - npc.netAlways = true; + npc.knockBackResist = 0f; + npc.value = Item.buyPrice(3, 33, 0, 0); + npc.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; npc.boss = true; npc.chaseable = false; music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; @@ -156,9 +162,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } public override void SendExtraAI(BinaryWriter writer) - { + { writer.Write(npc.chaseable); - writer.Write(npc.dontTakeDamage); + writer.Write(npc.dontTakeDamage); writer.Write(noContactDamageTimer); writer.Write(chargeVelocityScalar); writer.Write(vulnerable); @@ -170,8 +176,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos writer.Write(npc.Calamity().newAI[i]); } - public override void ReceiveExtraAI(BinaryReader reader) - { + public override void ReceiveExtraAI(BinaryReader reader) + { npc.chaseable = reader.ReadBoolean(); npc.dontTakeDamage = reader.ReadBoolean(); noContactDamageTimer = reader.ReadInt32(); @@ -185,8 +191,39 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npc.Calamity().newAI[i] = reader.ReadSingle(); } + public float GetSlowdownAreaEdgeRadius(bool lastMechAlive) => lastMechAlive ? 640f : 800f; + + public int CheckForOtherMechs(ref Player target, out bool exoPrimeAlive, out bool exoTwinsAlive) + { + exoPrimeAlive = false; + exoTwinsAlive = false; + int otherExoMechsAlive = 0; + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + // Set target to Ares' target if Ares is alive. + target = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + otherExoMechsAlive++; + exoPrimeAlive = true; + } + } + + // There is no need in checking for the other twin because they have linked HP. + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } + return otherExoMechsAlive; + } + public override void AI() - { + { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); CalamityGlobalNPC.draedonExoMechWorm = npc.whoAmI; @@ -212,30 +249,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos Player player = Main.player[npc.target]; // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoPrimeAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - // Set target to Ares' target if Ares is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - - otherExoMechsAlive++; - exoPrimeAlive = true; - } - } - - // There is no need in checking for the other twin because they have linked HP - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } + int otherExoMechsAlive = CheckForOtherMechs(ref player, out bool exoPrimeAlive, out bool exoTwinsAlive); // These are 5 by default to avoid triggering passive phases after the other mechs are dead float exoPrimeLifeRatio = defaultLifeRatio; @@ -280,7 +294,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + npc.realLife = (int)npc.ai[2]; // Spawn segments if (Main.netMode != NetmodeID.MultiplayerClient) @@ -490,6 +504,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (Main.netMode != NetmodeID.MultiplayerClient) { + // Draedon text for the start of phase 2 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase2Text1", TextColor); + // Spawn the fuckers NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); @@ -526,6 +543,13 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos calamityGlobalNPC.newAI[3] = 0f; chargeVelocityScalar = 0f; npc.TargetClosest(); + + // Phase 6, when 1 mech goes berserk and the other one leaves + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 6 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase6Text1", TextColor); + } } } @@ -564,6 +588,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Never be passive if berserk SecondaryAIState = (float)SecondaryPhase.Nothing; + + // Phase 4, when 1 mech goes berserk and the other 2 leave + if (exoTwinsAlive && exoPrimeAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 4 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase4Text1", TextColor); + } + } } break; @@ -586,6 +620,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos calamityGlobalNPC.newAI[3] = 0f; chargeVelocityScalar = 0f; npc.TargetClosest(); + + // Phase 3, when all 3 mechs attack at the same time + if (exoPrimeAlive && exoTwinsAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 3 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase3Text1", TextColor); + } + } } if (berserk) @@ -704,7 +748,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos vulnerable = true; // If close enough to the target, prepare to fire deathray - float slowDownDistance = lastMechAlive ? 640f : 800f; + float slowDownDistance = GetSlowdownAreaEdgeRadius(lastMechAlive); bool readyToFireDeathray = distanceFromTarget < slowDownDistance; if (readyToFireDeathray) npc.localAI[2] = 1f; @@ -961,6 +1005,79 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos SmokeDrawer.DrawSet(npc.Center); + // Draw a white indicator aura and reticle before and while a death ray is being fired. + // This is done to give a visual indicator that players should move near the head (which results in slower movement and thus easier dodging capabilities). + if (AIState == (int)Phase.Deathray && SecondaryAIState != (int)SecondaryPhase.PassiveAndImmune) + { + spriteBatch.SetBlendState(BlendState.Additive); + + // A large, faded circle. Is rescaled to fit the radius of the slowdown area. + Texture2D auraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/THanosAura"); + + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Yes, this is bizarre as fuck. + Player completelyUseless = null; + int otherExoMechsAlive = CheckForOtherMechs(ref completelyUseless, out _, out _); + + // A general factor for the aura. + // Used to cause fade-ins/outs as the attack starts/stops. + float auraGeneralPower = Utils.InverseLerp(0f, deathrayTelegraphDuration * 0.333f, npc.Calamity().newAI[2], true); + auraGeneralPower *= Utils.InverseLerp(deathrayTelegraphDuration + deathrayDuration, deathrayTelegraphDuration + deathrayDuration - 40f, npc.Calamity().newAI[2], true); + + // Determine the characteristics of the aura. This requires intermediate computations to determine if Thanatos is in its final phase as well as for pulsing. + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + float pulse = Main.GlobalTime * 0.72f % 1f; + float auraRadius = GetSlowdownAreaEdgeRadius(lastMechAlive) * auraGeneralPower * 1.25f; + Vector2 outerAuraScale = Vector2.One * auraRadius / auraTexture.Size(); + Vector2 innerAuraScale = outerAuraScale * pulse * 1.2f; + Color outerAuraColor = Color.White * auraGeneralPower * 0.6f; + Color innerAuraColor = outerAuraColor * (float)Math.Sqrt(1f - pulse); + + // Draw the aura. + spriteBatch.Draw(auraTexture, center, null, outerAuraColor, 0f, auraTexture.Size() * 0.5f, outerAuraScale, SpriteEffects.None, 0f); + spriteBatch.Draw(auraTexture, center, null, innerAuraColor, 0f, auraTexture.Size() * 0.5f, innerAuraScale, SpriteEffects.None, 0f); + + spriteBatch.SetBlendState(BlendState.AlphaBlend); + + // Draw the reticle depending on how close the player is. This drawcode terminates early if Thanatos has no target. + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + return false; + + Player target = Main.player[npc.target]; + + Texture2D leftReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleLeft"); + Texture2D rightReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleRight"); + Texture2D topReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleTop"); + Texture2D bottomReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleHead"); + Texture2D leftReticleProngTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleProngLeft"); + Texture2D rightReticleProngTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleProngRight"); + + // The reticle fades away and moves farther away from the target the closer they are to the aura. + // Once far away, the reticle will flash between red and white as an indicator. + float targetHeadDistance = npc.Distance(target.Center); + float reticleOpacity = Utils.InverseLerp(auraRadius * 0.5f - 40f, auraRadius * 0.5f + 100f, targetHeadDistance, true); + float reticleOffsetDistance = MathHelper.SmoothStep(300f, 0f, reticleOpacity); + float reticleFadeToWhite = ((float)Math.Cos(Main.GlobalTime * 6.8f) * 0.5f + 0.5f) * reticleOpacity * 0.67f; + Color reticleBaseColor = new Color(255, 0, 0, 127) * reticleOpacity; + Color reticleFlashBaseColor = Color.Lerp(reticleBaseColor, new Color(255, 255, 255, 0), reticleFadeToWhite) * reticleOpacity; + Vector2 origin = leftReticleTexture.Size() * 0.5f; + + Vector2 playerDrawPosition = target.Center - Main.screenPosition; + spriteBatch.Draw(leftReticleTexture, playerDrawPosition - Vector2.UnitX * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); + spriteBatch.Draw(rightReticleTexture, playerDrawPosition + Vector2.UnitX * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); + + for (int i = 0; i < 3; i++) + { + float scale = 1f + i * 0.125f; + spriteBatch.Draw(leftReticleProngTexture, playerDrawPosition - Vector2.UnitX * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(rightReticleProngTexture, playerDrawPosition + Vector2.UnitX * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(bottomReticleTexture, playerDrawPosition + Vector2.UnitY * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + spriteBatch.Draw(topReticleTexture, playerDrawPosition - Vector2.UnitY * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); + } + return false; } @@ -981,21 +1098,32 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } public override void NPCLoot() - { + { // Check if the other exo mechs are alive - bool otherExoMechsAlive = false; + bool exoTwinsAlive = false; + bool exoPrimeAlive = false; if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) { if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - otherExoMechsAlive = true; + exoTwinsAlive = true; } if (CalamityGlobalNPC.draedonExoMechPrime != -1) { if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - otherExoMechsAlive = true; + exoPrimeAlive = true; } - if (!otherExoMechsAlive) + // Phase 5, when 1 mech dies and the other 2 return to fight + if (exoTwinsAlive && exoPrimeAlive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Draedon text for the start of phase 5 + //CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonExoPhase5Text1", TextColor); + } + } + + if (!exoTwinsAlive && !exoPrimeAlive) AresBody.DropExoMechLoot(npc, (int)AresBody.MechType.Thanatos); } @@ -1043,5 +1171,5 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); } - } + } } diff --git a/NPCs/HiveMind/HiveCyst.cs b/NPCs/HiveMind/HiveCyst.cs index 48f29899a5..5f60cdf973 100644 --- a/NPCs/HiveMind/HiveCyst.cs +++ b/NPCs/HiveMind/HiveCyst.cs @@ -43,7 +43,7 @@ namespace CalamityMod.NPCs.HiveMind if (spawnInfo.player.Calamity().disableHiveCystSpawns) return 0f; - bool anyBossElements = NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()); + bool anyBossElements = NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()); bool corrupt = TileID.Sets.Corrupt[spawnInfo.spawnTileType] || spawnInfo.spawnTileType == TileID.Demonite && spawnInfo.player.ZoneCorrupt; if (anyBossElements || spawnInfo.playerSafe || !corrupt) return 0f; diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index fc52dfc390..4d20808854 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -1,17 +1,79 @@ -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.LoreItems; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; +using CalamityMod.Items.Placeables.Furniture.Trophies; +using CalamityMod.Items.TreasureBags; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Tiles.Ores; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; +/* states: + * 0 = slow drift + * 1 = reelback and teleport after spawn enemy + * 2 = reelback for spin lunge + death legacy + * 3 = spin lunge + * 4 = semicircle spawn arc + * 5 = raindash + * 6 = deceleration + */ + namespace CalamityMod.NPCs.HiveMind { - [AutoloadBossHead] public class HiveMind : ModNPC { - int burrowTimer = 420; + public static int normalIconIndex; + public static int phase2IconIndex; + + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/HiveMind/HiveMind_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/HiveMind/HiveMindP2_Head_Boss"; + + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } + + // This block of values can be modified in SetDefaults() based on difficulty mode or something + private int burrowTimer = 420; + private int minimumDriftTime = 300; + private int teleportRadius = 300; + private int decelerationTime = 30; + private int reelbackFade = 2; // Divide 255 by this for duration of reelback in ticks + private float arcTime = 45f; // Ticks needed to complete movement for spawn and rain attacks (DEATH ONLY) + private float driftSpeed = 1f; // Default speed when slowly floating at player + private float driftBoost = 1f; // Max speed added as health decreases + private int lungeDelay = 90; // # of ticks long hive mind spends sliding to a stop before lunging + private int lungeTime = 33; + private int lungeFade = 15; // Divide 255 by this for duration of hive mind spin before slowing for lunge + private double lungeRots = 0.2; // Number of revolutions made while spinning/fading in for lunge + private bool dashStarted = false; + private int phase2timer = 360; + private int rotationDirection; + private double rotation; + private double rotationIncrement; + private int state = 0; + private int previousState = 0; + private int nextState = 0; + private int reelCount = 0; + private Vector2 deceleration; + private int counter = 0; + private bool initialised = false; public override void SetStaticDefaults() { @@ -21,44 +83,285 @@ namespace CalamityMod.NPCs.HiveMind public override void SetDefaults() { - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 5f; npc.GetNPCDamage(); - npc.width = 150; - npc.height = 120; - npc.defense = 10; - npc.LifeMaxNERB(1200, 1800, 35000); + npc.width = 178; + npc.height = 122; + npc.defense = 8; + npc.LifeMaxNERB(7000, 9360, 350000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; + npc.value = Item.buyPrice(0, 6, 0, 0); npc.boss = true; - npc.value = 0f; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; music = CalamityMod.Instance.GetMusicFromMusicMod("HiveMind") ?? MusicID.Boss2; + bossBag = ModContent.ItemType(); + NPCID.Sets.TrailCacheLength[npc.type] = 8; + NPCID.Sets.TrailingMode[npc.type] = 1; + + if (Main.expertMode) + { + minimumDriftTime = 120; + reelbackFade = 4; + } + + if (CalamityWorld.revenge) + { + lungeRots = 0.3; + minimumDriftTime = 90; + reelbackFade = 5; + lungeTime = 28; + driftSpeed = 2f; + driftBoost = 2f; + } + + if (CalamityWorld.death) + { + lungeRots = 0.4; + minimumDriftTime = 60; + reelbackFade = 6; + lungeTime = 23; + driftSpeed = 3f; + driftBoost = 1f; + } + + if (CalamityWorld.malice) + { + lungeRots = 0.4; + minimumDriftTime = 40; + reelbackFade = 10; + lungeTime = 16; + driftSpeed = 6f; + driftBoost = 1f; + } + + phase2timer = minimumDriftTime; + rotationIncrement = 0.0246399424 * lungeRots * lungeFade; } - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) + { + if (npc.life / (float)npc.lifeMax < 0.8f) + index = phase2IconIndex; + else + index = normalIconIndex; + } + + public override void SendExtraAI(BinaryWriter writer) { - writer.Write(npc.dontTakeDamage); + writer.Write(npc.dontTakeDamage); + writer.Write(npc.noTileCollide); + writer.Write(npc.noGravity); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[3]); + writer.Write(burrowTimer); + writer.Write(state); + writer.Write(nextState); + writer.Write(phase2timer); + writer.Write(dashStarted); + writer.Write(rotationDirection); + writer.Write(rotation); + writer.Write(previousState); + writer.Write(reelCount); + writer.Write(counter); + writer.Write(initialised); } public override void ReceiveExtraAI(BinaryReader reader) { - npc.dontTakeDamage = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.noTileCollide = reader.ReadBoolean(); + npc.noGravity = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + burrowTimer = reader.ReadInt32(); + state = reader.ReadInt32(); + nextState = reader.ReadInt32(); + phase2timer = reader.ReadInt32(); + dashStarted = reader.ReadBoolean(); + rotationDirection = reader.ReadInt32(); + rotation = reader.ReadDouble(); + previousState = reader.ReadInt32(); + reelCount = reader.ReadInt32(); + counter = reader.ReadInt32(); + initialised = reader.ReadBoolean(); } public override void FindFrame(int frameHeight) { - npc.frameCounter += 1f / 6f; - npc.frameCounter %= Main.npcFrameCount[npc.type]; - int frame = (int)npc.frameCounter; - npc.frame.Y = frame * frameHeight; + // When Hive Mind starts flying around + bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; + + if (phase2) + { + int width = npc.width; + int height = npc.height; + + if (!initialised) + { + Main.npcFrameCount[npc.type] = 8; + counter = 8; + npc.frameCounter = 6; + initialised = true; + } + + // Ensure width and height are set + npc.frame.Width = width; + npc.frame.Height = height; + + npc.frameCounter++; + if (npc.frameCounter >= 6) + { + npc.frame.X = counter >= 8 ? width + 3 : 0; + + if (counter == 8) + npc.frame.Y = 0; + else + npc.frame.Y += height; + + npc.frameCounter = 0; + counter++; + } + + if (counter == 16) + { + counter = 1; + npc.frame.Y = 0; + npc.frame.X = 0; + } + } + else + { + npc.frameCounter += 1f / 6f; + npc.frameCounter %= Main.npcFrameCount[npc.type]; + int frame = (int)npc.frameCounter; + npc.frame.Y = frame * frameHeight; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + // When Hive Mind starts flying around + bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; + + if (phase2) + { + SpriteEffects spriteEffects = SpriteEffects.None; + Color color24 = lightColor; + color24 = npc.GetAlpha(color24); + Color color25 = Lighting.GetColor((int)((double)npc.position.X + (double)npc.width * 0.5) / 16, (int)(((double)npc.position.Y + (double)npc.height * 0.5) / 16.0)); + Texture2D texture2D3 = ModContent.GetTexture("CalamityMod/NPCs/HiveMind/HiveMindP2"); + int num156 = texture2D3.Height / 8; + Rectangle rectangle = new Rectangle(npc.frame.X, npc.frame.Y, npc.frame.X, num156); + Vector2 origin2 = rectangle.Size() / 2f; + int num157 = 8; + int num158 = 2; + int num159 = 1; + float num160 = 0f; + int num161 = num159; + while (state != 0 && CalamityConfig.Instance.Afterimages && ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157))) + { + Color color26 = color25; + color26 = npc.GetAlpha(color26); + { + goto IL_6899; + } + IL_6881: + num161 += num158; + continue; + IL_6899: + float num164 = (float)(num157 - num161); + if (num158 < 0) + { + num164 = (float)(num159 - num161); + } + color26 *= num164 / ((float)NPCID.Sets.TrailCacheLength[npc.type] * 1.5f); + Vector2 value4 = npc.oldPos[num161]; + float num165 = npc.rotation; + SpriteEffects effects = spriteEffects; + Main.spriteBatch.Draw(texture2D3, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, npc.scale, effects, 0f); + goto IL_6881; + } + + var something = npc.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(texture2D3, npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, color24, npc.rotation, npc.frame.Size() / 2, npc.scale, something, 0); + return false; + } + + return true; + } + + private void SpawnStuff() + { + int maxSpawns = (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) ? 5 : CalamityWorld.revenge ? 4 : Main.expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); + for (int i = 0; i < maxSpawns; i++) + { + int type = NPCID.EaterofSouls; + int choice = -1; + do + { + choice++; + switch (choice) + { + case 0: + case 1: + type = NPCID.EaterofSouls; + break; + case 2: + type = NPCID.DevourerHead; + break; + case 3: + case 4: + type = ModContent.NPCType(); + break; + default: + break; + } + } + while (NPC.AnyNPCs(type) && choice < 5); + + if (choice < 5) + NPC.NewNPC((int)npc.position.X + Main.rand.Next(npc.width), (int)npc.position.Y + Main.rand.Next(npc.height), type); + } + } + + private void ReelBack() + { + npc.alpha = 0; + phase2timer = 0; + deceleration = npc.velocity / 255f * reelbackFade; + + if (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice) + { + state = 2; + Main.PlaySound(SoundID.ForceRoar, (int)npc.Center.X, (int)npc.Center.Y, -1, 1f, 0f); + } + else + { + if (Main.netMode != NetmodeID.MultiplayerClient) + SpawnStuff(); + + state = nextState; + nextState = 0; + + if (state == 2) + Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); + else + Main.PlaySound(SoundID.ForceRoar, (int)npc.Center.X, (int)npc.Center.Y, -1, 1f, 0f); + } } public override void AI() { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); @@ -68,212 +371,636 @@ namespace CalamityMod.NPCs.HiveMind npc.TargetClosest(); Player player = Main.player[npc.target]; - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - if (npc.timeLeft > 60) - npc.timeLeft = 60; - if (npc.localAI[3] < 120f) - { - float[] aiArray = npc.localAI; - int number = 3; - float num244 = aiArray[number]; - aiArray[number] = num244 + 1f; - } - if (npc.localAI[3] > 60f) - { - npc.velocity.Y += (npc.localAI[3] - 60f) * 0.5f; - npc.noGravity = true; - npc.noTileCollide = true; - if (burrowTimer > 30) - burrowTimer = 30; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - if (npc.localAI[3] > 0f) - { - float[] aiArray = npc.localAI; - int number = 3; - float num244 = aiArray[number]; - aiArray[number] = num244 - 1f; - return; - } - - npc.noGravity = false; - npc.noTileCollide = false; + bool enraged = calamityGlobalNPC.enraged > 0; bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || malice; - bool revenge = CalamityWorld.revenge || malice; + bool revenge = CalamityWorld.revenge || malice; bool death = CalamityWorld.death || malice; - CalamityGlobalNPC.hiveMind = npc.whoAmI; - float enrageScale = 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - if (!player.ZoneCorrupt || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - if (BossRushEvent.BossRushActive) - enrageScale += 1f; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - int maxBlobs = death ? 15 : revenge ? 7 : expertMode ? 6 : 5; - for (int i = 0; i < maxBlobs; i++) - { - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); - } - } - } - - if (expertMode) - { - if (NPC.AnyNPCs(ModContent.NPCType())) - { - npc.Calamity().DR = 0.9999f; - npc.Calamity().unbreakableDR = true; - } - else - { - npc.Calamity().DR = 0f; - npc.Calamity().unbreakableDR = false; - } + if (revenge) + { + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) + lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; } - if (npc.ai[3] == 0f && npc.life > 0) + float enrageScale = 0f; + if ((npc.position.Y / 16f) < Main.worldSurface || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (!player.ZoneCorrupt || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (BossRushEvent.BossRushActive) + { + enrageScale += 1f; + } + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } + + // When Hive Mind starts flying around + bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; + + // Phase 2 settings + if (phase2) + { + // Spawn gores, play sound and reset every crucial variable at the start + if (npc.localAI[1] == 0f) + { + npc.localAI[1] = 1f; + + int goreAmount = 7; + for (int i = 1; i <= goreAmount; i++) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HiveMindGores/HiveMindGore" + i), 1f); + + Main.PlaySound(SoundID.NPCDeath1, (int)npc.Center.X, (int)npc.Center.Y); + + npc.frame.Y = 0; + npc.noGravity = true; + npc.noTileCollide = true; + npc.Calamity().DR = 0f; + npc.Calamity().unbreakableDR = false; + npc.scale = 1f; + npc.alpha = 0; + npc.dontTakeDamage = false; + npc.damage = npc.defDamage; + } + } + else + { + CalamityGlobalNPC.hiveMind = npc.whoAmI; + + if (!player.active || player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead) + { + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + if (npc.localAI[3] < 120f) + npc.localAI[3] += 1f; + + if (npc.localAI[3] > 60f) + { + npc.velocity.Y += (npc.localAI[3] - 60f) * 0.5f; + + npc.noGravity = true; + npc.noTileCollide = true; + + if (burrowTimer > 30) + burrowTimer = 30; + } + + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; + + if (npc.localAI[3] > 0f) + { + npc.localAI[3] -= 1f; + return; + } + + npc.noGravity = false; + npc.noTileCollide = false; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.localAI[0] == 0f) + { + npc.localAI[0] = 1f; + int maxBlobs = death ? 15 : revenge ? 7 : expertMode ? 6 : 5; + for (int i = 0; i < maxBlobs; i++) + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); + } + } + + if (expertMode) + { + if (NPC.AnyNPCs(ModContent.NPCType())) + { + npc.Calamity().DR = 0.9999f; + npc.Calamity().unbreakableDR = true; + } + else + { + npc.Calamity().DR = 0f; + npc.Calamity().unbreakableDR = false; + } + } + + if (npc.ai[3] == 0f && npc.life > 0) + npc.ai[3] = npc.lifeMax; + + if (npc.life > 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int num660 = (int)(npc.lifeMax * 0.05); + if ((npc.life + num660) < npc.ai[3]) + { + npc.ai[3] = npc.life; + + int maxSpawns = malice ? 10 : death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); + int maxDankSpawns = malice ? 4 : death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; + + for (int num662 = 0; num662 < maxSpawns; num662++) + { + int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); + int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); + + int type = ModContent.NPCType(); + if (NPC.CountNPCS(ModContent.NPCType()) < maxDankSpawns) + type = ModContent.NPCType(); + + int num664 = NPC.NewNPC(x, y, type); + Main.npc[num664].SetDefaults(type); + if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + } + + return; + } + } + } + + burrowTimer--; + if (burrowTimer < -120) + { + burrowTimer = (death ? 180 : revenge ? 300 : expertMode ? 360 : 420) - (int)enrageScale * 55; + npc.scale = 1f; + npc.alpha = 0; + npc.dontTakeDamage = false; + npc.damage = npc.defDamage; + } + else if (burrowTimer < -60) + { + npc.scale += 0.0165f; + npc.alpha -= 4; + + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); + Main.dust[num622].velocity *= 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + + for (int i = 0; i < 2; i++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 3.5f * npc.scale); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 3.5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); + Main.dust[num624].velocity *= 1f; + } + } + else if (burrowTimer == -60) + { + npc.scale = 0.01f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.Center = player.Center; + npc.position.Y = player.position.Y - npc.height; + int tilePosX = (int)npc.Center.X / 16; + int tilePosY = (int)(npc.position.Y + npc.height) / 16 + 1; + + if (Main.tile[tilePosX, tilePosY] == null) + Main.tile[tilePosX, tilePosY] = new Tile(); + + while (!(Main.tile[tilePosX, tilePosY].nactive() && Main.tileSolid[Main.tile[tilePosX, tilePosY].type])) + { + tilePosY++; + npc.position.Y += 16; + if (Main.tile[tilePosX, tilePosY] == null) + Main.tile[tilePosX, tilePosY] = new Tile(); + } + } + npc.netUpdate = true; + } + else if (burrowTimer < 0) + { + npc.scale -= 0.0165f; + npc.alpha += 4; + + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); + Main.dust[num622].velocity *= 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + + for (int i = 0; i < 2; i++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 3.5f * npc.scale); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 3.5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); + Main.dust[num624].velocity *= 1f; + } + } + else if (burrowTimer == 0) + { + if (!player.active || player.dead) + { + burrowTimer = 30; + } + else + { + npc.TargetClosest(); + npc.dontTakeDamage = true; + npc.damage = 0; + } + } + + return; + } + + if (npc.alpha != 0) { - npc.ai[3] = npc.lifeMax; + if (npc.damage != 0) + npc.damage = 0; } - if (npc.life > 0) + else + npc.damage = npc.defDamage; + + switch (state) { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num660 = (int)(npc.lifeMax * 0.25); - if ((npc.life + num660) < npc.ai[3]) + case 0: // Slowdrift + + if (npc.alpha > 0) + npc.alpha -= 3; + + if (nextState == 0) { - npc.ai[3] = npc.life; - int maxSpawns = malice ? 10 : death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); - int maxDankSpawns = malice ? 4 : death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; - for (int num662 = 0; num662 < maxSpawns; num662++) + npc.TargetClosest(); + if (revenge && lifeRatio < 0.53f) { - int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); - int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); - int type = ModContent.NPCType(); - if (NPC.CountNPCS(ModContent.NPCType()) < maxDankSpawns) + if (death) + { + do + nextState = Main.rand.Next(3, 6); + while (nextState == previousState); + previousState = nextState; + } + else if (lifeRatio < 0.27f) + { + do + nextState = Main.rand.Next(3, 6); + while (nextState == previousState); + previousState = nextState; + } + else + { + do + nextState = Main.rand.Next(3, 5); + while (nextState == previousState); + previousState = nextState; + } + } + else + { + if ((CalamityWorld.revenge || malice) && (Main.rand.NextBool(3) || reelCount == 2)) { - type = ModContent.NPCType(); + reelCount = 0; + nextState = 2; } - int num664 = NPC.NewNPC(x, y, type); - Main.npc[num664].SetDefaults(type); - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) + else { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + reelCount++; + if (Main.expertMode && reelCount == 2) + { + reelCount = 0; + nextState = 2; + } + else + nextState = 1; + + npc.ai[1] = 0f; + npc.ai[2] = 0f; } } + + if (nextState == 3) + rotation = MathHelper.ToRadians(Main.rand.Next(360)); + + npc.netUpdate = true; + } + + if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 5000f) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 5000f) + { + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + if (npc.localAI[3] < 120f) + npc.localAI[3] += 1f; + + if (npc.localAI[3] > 60f) + npc.velocity.Y += (npc.localAI[3] - 60f) * 0.5f; + + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; + + if (npc.localAI[3] > 0f) + { + npc.localAI[3] -= 1f; return; } - } - } - burrowTimer--; - if (burrowTimer < -120) - { - burrowTimer = (death ? 180 : revenge ? 300 : expertMode ? 360 : 420) - (int)enrageScale * 55; - npc.scale = 1f; - npc.alpha = 0; - npc.dontTakeDamage = false; - npc.damage = npc.defDamage; - } - else if (burrowTimer < -60) - { - npc.scale += 0.0165f; - npc.alpha -= 4; - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); - Main.dust[num622].velocity *= 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - for (int i = 0; i < 2; i++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 3.5f * npc.scale); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 3.5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); - Main.dust[num624].velocity *= 1f; - } - } - else if (burrowTimer == -60) - { - npc.scale = 0.01f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Center = player.Center; - npc.position.Y = player.position.Y - npc.height; - int tilePosX = (int)npc.Center.X / 16; - int tilePosY = (int)(npc.position.Y + npc.height) / 16 + 1; - if (Main.tile[tilePosX, tilePosY] == null) - Main.tile[tilePosX, tilePosY] = new Tile(); - while (!(Main.tile[tilePosX, tilePosY].nactive() && Main.tileSolid[Main.tile[tilePosX, tilePosY].type])) + npc.velocity = player.Center - npc.Center; + + phase2timer--; + if (phase2timer <= -180) // No stalling drift mode forever { - tilePosY++; - npc.position.Y += 16; - if (Main.tile[tilePosX, tilePosY] == null) - Main.tile[tilePosX, tilePosY] = new Tile(); + npc.velocity *= 2f / 255f * (reelbackFade + 2 * (int)enrageScale); + ReelBack(); + npc.netUpdate = true; } - } + else + { + npc.velocity.Normalize(); + if (Main.expertMode || malice) // Variable velocity in expert and up + npc.velocity *= driftSpeed + enrageScale + driftBoost * lifeRatio; + else + npc.velocity *= driftSpeed + enrageScale; + } + + break; + + case 1: // Reelback and teleport + + npc.alpha += reelbackFade + 2 * (int)enrageScale; + npc.velocity -= deceleration; + + if (npc.alpha >= 255) + { + npc.alpha = 255; + npc.velocity = Vector2.Zero; + state = 0; + + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] != 0f && npc.ai[2] != 0f) + { + npc.position.X = npc.ai[1] * 16 - npc.width / 2; + npc.position.Y = npc.ai[2] * 16 - npc.height / 2; + } + + phase2timer = minimumDriftTime + Main.rand.Next(121); + npc.netUpdate = true; + } + else if (npc.ai[1] == 0f && npc.ai[2] == 0f) + { + for (int i = 0; i < 10; i++) + { + int posX = (int)player.Center.X / 16 + Main.rand.Next(15, 46) * (Main.rand.NextBool(2) ? -1 : 1); + int posY = (int)player.Center.Y / 16 + Main.rand.Next(15, 46) * (Main.rand.NextBool(2) ? -1 : 1); + if (!WorldGen.SolidTile(posX, posY) && Collision.CanHit(new Vector2(posX * 16, posY * 16), 1, 1, player.position, player.width, player.height)) + { + npc.ai[1] = posX; + npc.ai[2] = posY; + npc.netUpdate = true; + break; + } + } + } + + break; + + case 2: // Reelback for lunge + death legacy + + npc.alpha += reelbackFade + 2 * (int)enrageScale; + npc.velocity -= deceleration; + + if (npc.alpha >= 255) + { + npc.alpha = 255; + npc.velocity = Vector2.Zero; + dashStarted = false; + + if ((CalamityWorld.revenge || malice) && lifeRatio < 0.53f) + { + state = nextState; + nextState = 0; + previousState = state; + } + else + state = 3; + + if (player.velocity.X > 0) + rotationDirection = 1; + else if (player.velocity.X < 0) + rotationDirection = -1; + else + rotationDirection = player.direction; + } + + break; + + case 3: // Lunge + + npc.netUpdate = true; + if (npc.alpha > 0) + { + npc.alpha -= lungeFade; + + if (Main.netMode != NetmodeID.MultiplayerClient) + npc.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); + + rotation += rotationIncrement * rotationDirection; + phase2timer = lungeDelay; + } + else + { + phase2timer--; + if (!dashStarted) + { + if (phase2timer <= 0) + { + phase2timer = lungeTime - 4 * (int)enrageScale; + npc.velocity = player.Center + (malice ? player.velocity * 20f : Vector2.Zero) - npc.Center; + npc.velocity.Normalize(); + npc.velocity *= teleportRadius / (lungeTime - (int)enrageScale); + dashStarted = true; + Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); + } + else + { + if (Main.netMode != NetmodeID.MultiplayerClient) + npc.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); + + rotation += rotationIncrement * rotationDirection * phase2timer / lungeDelay; + } + } + else + { + if (phase2timer <= 0) + { + state = 6; + phase2timer = 0; + deceleration = npc.velocity / decelerationTime; + } + } + } + + break; + + case 4: // Enemy spawn arc + + if (npc.alpha > 0) + { + npc.alpha -= 5; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.Center = player.Center; + npc.position.Y += teleportRadius; + } + npc.netUpdate = true; + } + else + { + if (!dashStarted) + { + dashStarted = true; + Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); + npc.velocity.X = MathHelper.Pi * teleportRadius / arcTime; + npc.velocity *= rotationDirection; + npc.netUpdate = true; + } + else + { + npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); + + phase2timer++; + if (phase2timer == (int)arcTime / 6) + { + phase2timer = 0; + npc.ai[0]++; + if (Main.netMode != NetmodeID.MultiplayerClient && Collision.CanHit(npc.Center, 1, 1, player.position, player.width, player.height)) + { + if (npc.ai[0] == 2 || npc.ai[0] == 4) + { + if ((Main.expertMode || malice) && !NPC.AnyNPCs(ModContent.NPCType())) + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); + } + else if (!NPC.AnyNPCs(NPCID.EaterofSouls)) + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, NPCID.EaterofSouls); + } + + if (npc.ai[0] == 6) + { + npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); + SpawnStuff(); + state = 6; + npc.ai[0] = 0; + deceleration = npc.velocity / decelerationTime; + } + } + } + } + + break; + + case 5: // Rain dash + + if (npc.alpha > 0) + { + npc.alpha -= 5; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.Center = player.Center; + npc.position.Y -= teleportRadius; + npc.position.X += teleportRadius * rotationDirection; + } + npc.netUpdate = true; + } + else + { + if (!dashStarted) + { + dashStarted = true; + Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); + npc.velocity.X = teleportRadius / arcTime * 3; + npc.velocity *= -rotationDirection; + npc.netUpdate = true; + } + else + { + phase2timer++; + if (phase2timer == (int)arcTime / 20) + { + phase2timer = 0; + npc.ai[0]++; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height), 0, 0, type, damage, 0, Main.myPlayer, 11, 0); + } + + if (npc.ai[0] == 10) + { + state = 6; + npc.ai[0] = 0; + deceleration = npc.velocity / decelerationTime; + } + } + } + } + + break; + + case 6: // Deceleration + + npc.velocity -= deceleration; + phase2timer++; + if (phase2timer == decelerationTime) + { + phase2timer = minimumDriftTime + Main.rand.Next(121); + state = 0; + npc.netUpdate = true; + } + + break; + } + } + + public override bool? CanHitNPC(NPC target) => npc.alpha == 0; // Can only be hit while fully visible + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => npc.alpha == 0 && npc.scale == 1f; // No damage while not fully visible or shrunk + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => npc.scale == 1f; // Only draw HP bar while at full size + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + if (phase2timer < 0 && damage > 1) + { + npc.velocity *= -4f; + ReelBack(); npc.netUpdate = true; } - else if (burrowTimer < 0) - { - npc.scale -= 0.0165f; - npc.alpha += 4; - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); - Main.dust[num622].velocity *= 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - for (int i = 0; i < 2; i++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 3.5f * npc.scale); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 3.5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); - Main.dust[num624].velocity *= 1f; - } - } - else if (burrowTimer == 0) - { - if (!player.active || player.dead) - { - burrowTimer = 30; - } - else - { - npc.TargetClosest(); - npc.dontTakeDamage = true; - npc.damage = 0; - } - } + return true; } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) @@ -284,57 +1011,133 @@ namespace CalamityMod.NPCs.HiveMind public override void HitEffect(int hitDirection, double damage) { - if (npc.life > 0) + for (int k = 0; k < damage / npc.lifeMax * 100.0; k++) + Dust.NewDust(npc.position, npc.width, npc.height, 14, hitDirection, -1f, 0, default, 1f); + + // When Hive Mind starts flying around + bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; + + if (phase2) + { + if (Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(15) && NPC.CountNPCS(ModContent.NPCType()) < 2) + { + Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); + NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); + } + } + else + { + if (NPC.CountNPCS(NPCID.EaterofSouls) < 3 && NPC.CountNPCS(NPCID.DevourerHead) < 1) + { + if (Main.rand.NextBool(60) && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); + NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.EaterofSouls); + } + + if (Main.rand.NextBool(150) && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); + NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.DevourerHead); + } + } + } + + if (npc.life <= 0) { - if (NPC.CountNPCS(NPCID.EaterofSouls) < 3 && NPC.CountNPCS(NPCID.DevourerHead) < 1) - { - if (Main.rand.NextBool(60) && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.EaterofSouls); - } - if (Main.rand.NextBool(150) && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.DevourerHead); - } - } - int num285 = 0; - while (num285 < damage / npc.lifeMax * 100.0) - { - Dust.NewDust(npc.position, npc.width, npc.height, 14, hitDirection, -1f, 0, default, 1f); - num285++; - } - } - else - { - int goreAmount = 7; + int goreAmount = 10; for (int i = 1; i <= goreAmount; i++) - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HiveMindGores/HiveMindGore" + i), 1f); - if (Main.netMode != NetmodeID.MultiplayerClient) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HiveMindGores/HiveMindP2Gore" + i), 1f); + + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 200; + npc.height = 150; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 40; num621++) { - if (NPC.CountNPCS(ModContent.NPCType()) < 1) + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 14, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) { - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, npc.target); - Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } + for (int num623 = 0; num623 < 70; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 14, 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, 14, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override void BossLoot(ref string name, ref int potionType) { - return npc.scale == 1f; //no damage when shrunk + potionType = ItemID.HealingPotion; } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + public override void NPCLoot() { - return npc.scale == 1f; - } + CalamityGlobalNPC.SetNewBossJustDowned(npc); - public override bool PreNPCLoot() - { - return false; + DropHelper.DropBags(npc); + + // Legendary drop for Evil boss tier 2 + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); + + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedHiveMind); + + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, CalamityWorld.downedHiveMind); + + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) + { + // Materials + DropHelper.DropItemSpray(npc, ModContent.ItemType(), 25, 30, 5); + DropHelper.DropItemSpray(npc, ItemID.DemoniteBar, 8, 12, 2); + DropHelper.DropItemSpray(npc, ItemID.RottenChunk, 9, 15, 3); + if (Main.hardMode) + DropHelper.DropItemSpray(npc, ItemID.CursedFlame, 10, 20, 2); + + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w, 30, 50) + ); + + //Equipment + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + } + + // If neither The Hive Mind nor The Perforator Hive have been killed yet, notify players of Aerialite Ore + if (!CalamityWorld.downedHiveMind && !CalamityWorld.downedPerforator) + { + string key = "Mods.CalamityMod.SkyOreText"; + Color messageColor = Color.Cyan; + CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.4f, 0.6f, 3, 8); + + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + + // Mark The Hive Mind as dead + CalamityWorld.downedHiveMind = true; + CalamityNetcode.SyncWorld(); } } } diff --git a/NPCs/HiveMind/HiveMindP2.cs b/NPCs/HiveMind/HiveMindP2.cs deleted file mode 100644 index 4b824a1762..0000000000 --- a/NPCs/HiveMind/HiveMindP2.cs +++ /dev/null @@ -1,817 +0,0 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Events; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.LoreItems; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Items.Weapons.Summon; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Tiles.Ores; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -/* states: - * 0 = slow drift - * 1 = reelback and teleport after spawn enemy - * 2 = reelback for spin lunge + death legacy - * 3 = spin lunge - * 4 = semicircle spawn arc - * 5 = raindash - * 6 = deceleration - */ - -namespace CalamityMod.NPCs.HiveMind -{ - [AutoloadBossHead] - public class HiveMindP2 : ModNPC - { - //this block of values can be modified in SetDefaults() based on difficulty mode or something - int minimumDriftTime = 300; - int teleportRadius = 300; - int decelerationTime = 30; - int reelbackFade = 2; //divide 255 by this for duration of reelback in ticks - float arcTime = 45f; //ticks needed to complete movement for spawn and rain attacks (DEATH ONLY) - float driftSpeed = 1f; //default speed when slowly floating at player - float driftBoost = 1f; //max speed added as health decreases - int lungeDelay = 90; //# of ticks long hive mind spends sliding to a stop before lunging - int lungeTime = 33; - int lungeFade = 15; //divide 255 by this for duration of hive mind spin before slowing for lunge - double lungeRots = 0.2; //number of revolutions made while spinning/fading in for lunge - bool dashStarted = false; - int phase2timer = 360; - int rotationDirection; - double rotation; - double rotationIncrement; - int state = 0; - int previousState = 0; - int nextState = 0; - int reelCount = 0; - Vector2 deceleration; - int counter = 0; - bool initialised = false; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Hive Mind"); - Main.npcFrameCount[npc.type] = 8; - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 5f; - npc.GetNPCDamage(); - npc.width = 177; - npc.height = 142; - npc.defense = 5; - npc.LifeMaxNERB(5800, 7560, 300000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.value = Item.buyPrice(0, 6, 0, 0); - npc.boss = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath1; - music = CalamityMod.Instance.GetMusicFromMusicMod("HiveMind") ?? MusicID.Boss2; - bossBag = ModContent.ItemType(); - NPCID.Sets.TrailCacheLength[npc.type] = 8; - NPCID.Sets.TrailingMode[npc.type] = 1; - if (Main.expertMode) - { - minimumDriftTime = 120; - reelbackFade = 4; - } - if (CalamityWorld.revenge) - { - lungeRots = 0.3; - minimumDriftTime = 90; - reelbackFade = 5; - lungeTime = 28; - driftSpeed = 2f; - driftBoost = 2f; - } - if (CalamityWorld.death) - { - lungeRots = 0.4; - minimumDriftTime = 60; - reelbackFade = 6; - lungeTime = 23; - driftSpeed = 3f; - driftBoost = 1f; - } - if (CalamityWorld.malice) - { - lungeRots = 0.4; - minimumDriftTime = 40; - reelbackFade = 10; - lungeTime = 16; - driftSpeed = 6f; - driftBoost = 1f; - } - phase2timer = minimumDriftTime; - rotationIncrement = 0.0246399424 * lungeRots * lungeFade; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(state); - writer.Write(nextState); - writer.Write(phase2timer); - writer.Write(dashStarted); - writer.Write(rotationDirection); - writer.Write(rotation); - writer.Write(previousState); - writer.Write(reelCount); - writer.Write(counter); - writer.Write(initialised); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - state = reader.ReadInt32(); - nextState = reader.ReadInt32(); - phase2timer = reader.ReadInt32(); - dashStarted = reader.ReadBoolean(); - rotationDirection = reader.ReadInt32(); - rotation = reader.ReadDouble(); - previousState = reader.ReadInt32(); - reelCount = reader.ReadInt32(); - counter = reader.ReadInt32(); - initialised = reader.ReadBoolean(); - } - - public override void FindFrame(int frameHeight) - { - int width = npc.width; - int height = npc.height; - - if (!initialised) - { - counter = 8; - npc.frameCounter = 6; - initialised = true; - } - - //ensure width and height are set. - npc.frame.Width = width; - npc.frame.Height = height; - npc.frameCounter++; - if (npc.frameCounter >= 6) - { - npc.frame.X = counter >= 8 ? width + 3 : 0; - if (counter == 8) - npc.frame.Y = 0; - else - npc.frame.Y += height; - npc.frameCounter = 0; - counter++; - } - if (counter == 16) - { - counter = 1; - npc.frame.Y = 0; - npc.frame.X = 0; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - Color color24 = lightColor; - color24 = npc.GetAlpha(color24); - Color color25 = Lighting.GetColor((int)((double)npc.position.X + (double)npc.width * 0.5) / 16, (int)(((double)npc.position.Y + (double)npc.height * 0.5) / 16.0)); - Texture2D texture2D3 = ModContent.GetTexture("CalamityMod/NPCs/HiveMind/HiveMindP2"); - int num156 = Main.npcTexture[npc.type].Height / 8; - Rectangle rectangle = new Rectangle(npc.frame.X, npc.frame.Y, npc.frame.X, num156); - Vector2 origin2 = rectangle.Size() / 2f; - int num157 = 8; - int num158 = 2; - int num159 = 1; - float num160 = 0f; - int num161 = num159; - while (state != 0 && CalamityConfig.Instance.Afterimages && ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157))) - { - Color color26 = color25; - color26 = npc.GetAlpha(color26); - { - goto IL_6899; - } - IL_6881: - num161 += num158; - continue; - IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) - { - num164 = (float)(num159 - num161); - } - color26 *= num164 / ((float)NPCID.Sets.TrailCacheLength[npc.type] * 1.5f); - Vector2 value4 = npc.oldPos[num161]; - float num165 = npc.rotation; - SpriteEffects effects = spriteEffects; - Main.spriteBatch.Draw(texture2D3, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, npc.scale, effects, 0f); - goto IL_6881; - } - - var something = npc.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(Main.npcTexture[npc.type], npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, color24, npc.rotation, npc.frame.Size() / 2, npc.scale, something, 0); - return false; - } - - private void SpawnStuff() - { - int maxSpawns = (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) ? 5 : CalamityWorld.revenge ? 4 : Main.expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); - for (int i = 0; i < maxSpawns; i++) - { - int type = NPCID.EaterofSouls; - int choice = -1; - do - { - choice++; - switch (choice) - { - case 0: - case 1: - type = NPCID.EaterofSouls; - break; - case 2: - type = NPCID.DevourerHead; - break; - case 3: - case 4: - type = ModContent.NPCType(); - break; - default: - break; - } - } - while (NPC.AnyNPCs(type) && choice < 5); - - if (choice < 5) - NPC.NewNPC((int)npc.position.X + Main.rand.Next(npc.width), (int)npc.position.Y + Main.rand.Next(npc.height), type); - } - } - - private void ReelBack() - { - npc.alpha = 0; - phase2timer = 0; - deceleration = npc.velocity / 255f * reelbackFade; - if (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice) - { - state = 2; - Main.PlaySound(SoundID.ForceRoar, (int)npc.Center.X, (int)npc.Center.Y, -1, 1f, 0f); - } - else - { - if (Main.netMode != NetmodeID.MultiplayerClient) - SpawnStuff(); - state = nextState; - nextState = 0; - if (state == 2) - { - Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); - } - else - { - Main.PlaySound(SoundID.ForceRoar, (int)npc.Center.X, (int)npc.Center.Y, -1, 1f, 0f); - } - } - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - if (CalamityWorld.malice || CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - // Increase aggression if player is taking a long time to kill the boss - if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) - lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - } - - bool enraged = calamityGlobalNPC.enraged > 0; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - - float enrageScale = 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - if (!player.ZoneCorrupt || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - if (BossRushEvent.BossRushActive) - enrageScale += 1f; - if (enraged) - { - npc.Calamity().CurrentlyEnraged = true; - enrageScale += 1f; - } - - if (npc.alpha != 0) - { - if (npc.damage != 0) - npc.damage = 0; - } - else - npc.damage = npc.defDamage; - - switch (state) - { - case 0: //slowdrift - if (npc.alpha > 0) - npc.alpha -= 3; - if (nextState == 0) - { - npc.TargetClosest(); - if ((CalamityWorld.revenge || malice) && lifeRatio < 0.66f) - { - if (CalamityWorld.death || malice) - { - do - nextState = Main.rand.Next(3, 6); - while (nextState == previousState); - previousState = nextState; - } - else if (lifeRatio < 0.33f) - { - do - nextState = Main.rand.Next(3, 6); - while (nextState == previousState); - previousState = nextState; - } - else - { - do - nextState = Main.rand.Next(3, 5); - while (nextState == previousState); - previousState = nextState; - } - } - else - { - if ((CalamityWorld.revenge || malice) && (Main.rand.NextBool(3) || reelCount == 2)) - { - reelCount = 0; - nextState = 2; - } - else - { - reelCount++; - if (Main.expertMode && reelCount == 2) - { - reelCount = 0; - nextState = 2; - } - else - nextState = 1; - - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - } - if (nextState == 3) - rotation = MathHelper.ToRadians(Main.rand.Next(360)); - npc.netUpdate = true; - } - - if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 5000f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 5000f) - { - if (npc.timeLeft > 60) - npc.timeLeft = 60; - if (npc.localAI[3] < 120f) - { - float[] aiArray = npc.localAI; - int number = 3; - float num244 = aiArray[number]; - aiArray[number] = num244 + 1f; - } - if (npc.localAI[3] > 60f) - { - npc.velocity.Y += (npc.localAI[3] - 60f) * 0.5f; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - if (npc.localAI[3] > 0f) - { - float[] aiArray = npc.localAI; - int number = 3; - float num244 = aiArray[number]; - aiArray[number] = num244 - 1f; - return; - } - - npc.velocity = player.Center - npc.Center; - phase2timer--; - if (phase2timer <= -180) //no stalling drift mode forever - { - npc.velocity *= 2f / 255f * (reelbackFade + 2 * (int)enrageScale); - ReelBack(); - npc.netUpdate = true; - } - else - { - npc.velocity.Normalize(); - if (Main.expertMode || malice) //variable velocity in expert and up - { - npc.velocity *= driftSpeed + enrageScale + driftBoost * lifeRatio; - } - else - { - npc.velocity *= driftSpeed + enrageScale; - } - } - break; - case 1: //reelback and teleport - npc.alpha += reelbackFade + 2 * (int)enrageScale; - npc.velocity -= deceleration; - if (npc.alpha >= 255) - { - npc.alpha = 255; - npc.velocity = Vector2.Zero; - state = 0; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] != 0f && npc.ai[2] != 0f) - { - npc.position.X = npc.ai[1] * 16 - npc.width / 2; - npc.position.Y = npc.ai[2] * 16 - npc.height / 2; - } - phase2timer = minimumDriftTime + Main.rand.Next(121); - npc.netUpdate = true; - } - else if (npc.ai[1] == 0f && npc.ai[2] == 0f) - { - for (int i = 0; i < 10; i++) - { - int posX = (int)player.Center.X / 16 + Main.rand.Next(15, 46) * (Main.rand.NextBool(2) ? -1 : 1); - int posY = (int)player.Center.Y / 16 + Main.rand.Next(15, 46) * (Main.rand.NextBool(2) ? -1 : 1); - if (!WorldGen.SolidTile(posX, posY) && Collision.CanHit(new Vector2(posX * 16, posY * 16), 1, 1, player.position, player.width, player.height)) - { - npc.ai[1] = posX; - npc.ai[2] = posY; - npc.netUpdate = true; - break; - } - } - } - break; - case 2: //reelback for lunge + death legacy - npc.alpha += reelbackFade + 2 * (int)enrageScale; - npc.velocity -= deceleration; - if (npc.alpha >= 255) - { - npc.alpha = 255; - npc.velocity = Vector2.Zero; - dashStarted = false; - if ((CalamityWorld.revenge || malice) && lifeRatio < 0.66f) - { - state = nextState; - nextState = 0; - previousState = state; - } - else - { - state = 3; - } - if (player.velocity.X > 0) - rotationDirection = 1; - else if (player.velocity.X < 0) - rotationDirection = -1; - else - rotationDirection = player.direction; - } - break; - case 3: //lunge - npc.netUpdate = true; - if (npc.alpha > 0) - { - npc.alpha -= lungeFade; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); - } - rotation += rotationIncrement * rotationDirection; - phase2timer = lungeDelay; - } - else - { - phase2timer--; - if (!dashStarted) - { - if (phase2timer <= 0) - { - phase2timer = lungeTime - 4 * (int)enrageScale; - npc.velocity = player.Center + (malice ? player.velocity * 20f : Vector2.Zero) - npc.Center; - npc.velocity.Normalize(); - npc.velocity *= teleportRadius / (lungeTime - (int)enrageScale); - dashStarted = true; - Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); - } - else - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); - } - rotation += rotationIncrement * rotationDirection * phase2timer / lungeDelay; - } - } - else - { - if (phase2timer <= 0) - { - state = 6; - phase2timer = 0; - deceleration = npc.velocity / decelerationTime; - } - } - } - break; - case 4: //enemy spawn arc - if (npc.alpha > 0) - { - npc.alpha -= 5; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Center = player.Center; - npc.position.Y += teleportRadius; - } - npc.netUpdate = true; - } - else - { - if (!dashStarted) - { - dashStarted = true; - Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); - npc.velocity.X = MathHelper.Pi * teleportRadius / arcTime; - npc.velocity *= rotationDirection; - npc.netUpdate = true; - } - else - { - npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); - phase2timer++; - if (phase2timer == (int)arcTime / 6) - { - phase2timer = 0; - npc.ai[0]++; - if (Main.netMode != NetmodeID.MultiplayerClient && Collision.CanHit(npc.Center, 1, 1, player.position, player.width, player.height)) //draw line of sight - { - if (npc.ai[0] == 2 || npc.ai[0] == 4) - { - if ((Main.expertMode || malice) && !NPC.AnyNPCs(ModContent.NPCType())) - { - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); - } - } - else if (!NPC.AnyNPCs(NPCID.EaterofSouls)) - { - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, NPCID.EaterofSouls); - } - } - if (npc.ai[0] == 6) - { - npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); - SpawnStuff(); - state = 6; - npc.ai[0] = 0; - deceleration = npc.velocity / decelerationTime; - } - } - } - } - break; - case 5: //raindash - if (npc.alpha > 0) - { - npc.alpha -= 5; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Center = player.Center; - npc.position.Y -= teleportRadius; - npc.position.X += teleportRadius * rotationDirection; - } - npc.netUpdate = true; - } - else - { - if (!dashStarted) - { - dashStarted = true; - Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0); - npc.velocity.X = teleportRadius / arcTime * 3; - npc.velocity *= -rotationDirection; - npc.netUpdate = true; - } - else - { - phase2timer++; - if (phase2timer == (int)arcTime / 20) - { - phase2timer = 0; - npc.ai[0]++; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height), 0, 0, type, damage, 0, Main.myPlayer, 11, 0); - } - if (npc.ai[0] == 10) - { - state = 6; - npc.ai[0] = 0; - deceleration = npc.velocity / decelerationTime; - } - } - } - } - break; - case 6: //deceleration - npc.velocity -= deceleration; - phase2timer++; - if (phase2timer == decelerationTime) - { - phase2timer = minimumDriftTime + Main.rand.Next(121); - state = 0; - npc.netUpdate = true; - } - break; - } - } - - public override bool? CanHitNPC(NPC target) - { - if (npc.alpha > 0) - return false; - return null; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - return npc.alpha <= 0; //no damage when not fully visible - } - - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - if (phase2timer < 0 && damage > 1) - { - npc.velocity *= -4f; - ReelBack(); - npc.netUpdate = true; - } - return true; - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < damage / npc.lifeMax * 100.0; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 14, hitDirection, -1f, 0, default, 1f); - } - if (Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(15) && NPC.CountNPCS(ModContent.NPCType()) < 2) - { - Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); - } - if (npc.life <= 0) - { - int goreAmount = 10; - for (int i = 1; i <= goreAmount; i++) - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HiveMindGores/HiveMindP2Gore" + i), 1f); - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 200; - npc.height = 150; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 40; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 14, 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 + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 70; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 14, 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, 14, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ItemID.HealingPotion; - } - - public override void NPCLoot() - { - DropHelper.DropBags(npc); - - // Legendary drop for Evil boss tier 2 - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); - - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedHiveMind); - - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, CalamityWorld.downedHiveMind); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Materials - DropHelper.DropItemSpray(npc, ModContent.ItemType(), 25, 30, 5); - DropHelper.DropItemSpray(npc, ItemID.DemoniteBar, 8, 12, 2); - DropHelper.DropItemSpray(npc, ItemID.RottenChunk, 9, 15, 3); - if (Main.hardMode) - DropHelper.DropItemSpray(npc, ItemID.CursedFlame, 10, 20, 2); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w, 30, 50) - ); - - //Equipment - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - } - - // If neither The Hive Mind nor The Perforator Hive have been killed yet, notify players of Aerialite Ore - if (!CalamityWorld.downedHiveMind && !CalamityWorld.downedPerforator) - { - string key = "Mods.CalamityMod.SkyOreText"; - Color messageColor = Color.Cyan; - CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.4f, 0.6f, 3, 8); - - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - - // Mark The Hive Mind as dead - CalamityWorld.downedHiveMind = true; - CalamityNetcode.SyncWorld(); - } - } -} diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index fa1c08064a..52270b2e0c 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -726,7 +726,9 @@ namespace CalamityMod.NPCs.Leviathan // This loot code is shared with Anahita. public static void DropSirenLeviLoot(NPC npc) { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Leviathan and Anahita DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index 9459854e2b..c17cb309c9 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -370,7 +370,9 @@ namespace CalamityMod.NPCs.OldDuke public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Old Duke DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/Other/BrimstoneOrb.png b/NPCs/Other/BrimstoneOrb.png deleted file mode 100644 index 680009c5da..0000000000 Binary files a/NPCs/Other/BrimstoneOrb.png and /dev/null differ diff --git a/NPCs/Other/DemonPortal.cs b/NPCs/Other/DemonPortal.cs index 449d20441b..da5d79cec3 100644 --- a/NPCs/Other/DemonPortal.cs +++ b/NPCs/Other/DemonPortal.cs @@ -61,12 +61,22 @@ namespace CalamityMod.NPCs.Other int demon = Projectile.NewProjectile(npc.Center, Main.rand.NextVector2CircularEdge(4f, 4f), ModContent.ProjectileType(), 17000, 0f, npc.target); if (Main.projectile.IndexInRange(demon)) { + Main.projectile[demon].ai[1] = Main.rand.Next(-40, 0); Main.projectile[demon].friendly = friendly; Main.projectile[demon].hostile = !friendly; + Main.projectile[demon].netUpdate = true; } } } + public override bool? CanBeHitByProjectile(Projectile projectile) + { + if (projectile.type == ModContent.ProjectileType()) + return false; + + return null; + } + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { bool wouldDie = npc.life - (damage * (crit ? 2D : 1D)) <= 0; diff --git a/NPCs/Other/ExhumedHeart.cs b/NPCs/Other/ExhumedHeart.cs index 5b75574529..40ba3635fa 100644 --- a/NPCs/Other/ExhumedHeart.cs +++ b/NPCs/Other/ExhumedHeart.cs @@ -1,4 +1,8 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +22,7 @@ namespace CalamityMod.NPCs.Other } } public override void SetStaticDefaults() - { + { DisplayName.SetDefault("Exhumed Brimstone Heart"); Main.npcFrameCount[npc.type] = 6; } @@ -49,17 +53,41 @@ namespace CalamityMod.NPCs.Other npc.Center = Owner.Center + (MathHelper.TwoPi * Time / 540f).ToRotationVector2() * 350f; npc.velocity = Vector2.Zero; + if (!Owner.active || Owner.dead || + Owner.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + { + npc.life = 0; + npc.HitEffect(); + npc.checkDead(); + npc.active = false; + } + Time++; } - public override void FindFrame(int frameHeight) - { + public float PrimitiveWidthFunction(float completionRatio) + { + float widthInterpolant = Utils.InverseLerp(0f, 0.16f, completionRatio, true) * Utils.InverseLerp(1f, 0.84f, completionRatio, true); + widthInterpolant = (float)Math.Pow(widthInterpolant, 8D); + float baseWidth = MathHelper.Lerp(4f, 1f, widthInterpolant); + float pulseWidth = MathHelper.Lerp(0f, 3.2f, (float)Math.Pow(Math.Sin(Main.GlobalTime * 2.6f + npc.whoAmI * 1.3f + completionRatio), 16D)); + return baseWidth + pulseWidth; + } + + public Color PrimitiveColorFunction(float completionRatio) + { + float colorInterpolant = MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, 0.34f, completionRatio, true) * Utils.InverseLerp(1.07f, 0.66f, completionRatio, true)); + return Color.Lerp(Color.DarkRed * 0.7f, Color.Red, colorInterpolant) * 0.425f; + } + + public override void FindFrame(int frameHeight) + { npc.frameCounter++; npc.frame.Y = (int)(npc.frameCounter / 5) % Main.npcFrameCount[npc.type] * frameHeight; - } + } - public override Color? GetAlpha(Color drawColor) - { + public override Color? GetAlpha(Color drawColor) + { Color color = Color.Purple * npc.Opacity; color.A = 127; return color; diff --git a/NPCs/Other/BrimstoneOrb.cs b/NPCs/Other/LecherousOrb.cs similarity index 61% rename from NPCs/Other/BrimstoneOrb.cs rename to NPCs/Other/LecherousOrb.cs index 1938c4dac5..86b5d5a138 100644 --- a/NPCs/Other/BrimstoneOrb.cs +++ b/NPCs/Other/LecherousOrb.cs @@ -1,13 +1,16 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Other { - public class BrimstoneOrb : ModNPC + public class LecherousOrb : ModNPC { public ref float Time => ref npc.ai[0]; + public ref float Frame => ref npc.localAI[0]; public Player Owner { get @@ -17,7 +20,7 @@ namespace CalamityMod.NPCs.Other return Main.player[npc.target]; } } - public override void SetStaticDefaults() => DisplayName.SetDefault("Brimstone Orb"); + public override void SetStaticDefaults() => DisplayName.SetDefault("Lecherous Orb"); public override void SetDefaults() { @@ -28,7 +31,7 @@ namespace CalamityMod.NPCs.Other npc.noGravity = true; npc.noTileCollide = true; npc.value = 0f; - npc.HitSound = SoundID.NPCHit5; + npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath7; npc.knockBackResist = 0f; npc.netAlways = true; @@ -51,6 +54,9 @@ namespace CalamityMod.NPCs.Other if (!Owner.Calamity().lecherousOrbEnchant) { npc.active = false; + npc.life = 0; + npc.HitEffect(); + npc.checkDead(); npc.netUpdate = true; } @@ -70,6 +76,15 @@ namespace CalamityMod.NPCs.Other npc.SyncMotionToServer(); } + // Randomly start animations. + if (Frame == 0f && Main.rand.NextBool(150)) + Frame = 1f; + if (Frame == 0f && Main.rand.NextBool(300)) + Frame = 8f; + + // Face the owner. + npc.spriteDirection = (Owner.Center.X > npc.Center.X).ToDirectionInt(); + Time++; } @@ -96,9 +111,59 @@ namespace CalamityMod.NPCs.Other magic.scale = Main.rand.NextFloat(1.2f, 1.56f); magic.noGravity = true; } + + for (int i = 1; i <= 4; i++) + Gore.NewGoreDirect(npc.Center, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/LecherousOrb/LecherousGore{i}")); } } + public override void FindFrame(int frameHeight) + { + if (Frame != 0f) + npc.frameCounter++; + else + npc.frameCounter = 0f; + + // Perform the blink animation. + if (Frame >= 1f && Frame < 8f && npc.frameCounter % 6f == 5f) + { + Frame++; + if (Frame >= 8f) + Frame = 0f; + } + + // Perform the turning inside-out animation. + if (Frame >= 8f && Frame < 25f && npc.frameCounter % 5f == 4f) + { + Frame++; + if (Frame >= 25f) + Frame = 0f; + } + + int verticalFrame = (int)Frame % 22; + int horizontalFrame = (int)Frame / 22; + npc.frame.X = horizontalFrame * 64; + npc.frame.Y = verticalFrame * 90; + npc.frame.Width = 64; + npc.frame.Height = 90; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 drawPosition = npc.Center - Main.screenPosition; + SpriteEffects direction = npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + // Draw a faded version of the heart behind the main one that pulses. + float pulse = Main.GlobalTime * 1.9f % 1f; + float pulseScale = npc.scale * (1f + pulse * 0.33f); + Color pulseColor = npc.GetAlpha(Color.Red) * (1f - pulse) * 0.44f; + spriteBatch.Draw(texture, drawPosition, npc.frame, pulseColor, npc.rotation, npc.frame.Size() * 0.5f, pulseScale, direction, 0f); + + spriteBatch.Draw(texture, drawPosition, npc.frame, npc.GetAlpha(drawColor), npc.rotation, npc.frame.Size() * 0.5f, npc.scale, direction, 0f); + return false; + } + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { if (Main.myPlayer == npc.target) diff --git a/NPCs/Other/LecherousOrb.png b/NPCs/Other/LecherousOrb.png new file mode 100644 index 0000000000..b8e2dc6765 Binary files /dev/null and b/NPCs/Other/LecherousOrb.png differ diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 999291e97e..2c8849a4d5 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -450,7 +450,9 @@ namespace CalamityMod.NPCs.Perforator public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Evil boss tier 2 DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index ea64fd0eba..2b0d3441bf 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -1215,7 +1215,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for PBG DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); @@ -1223,8 +1225,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedPlaguebringer); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.WitchDoctor }, CalamityWorld.downedPlaguebringer); - // All other drops are contained in the bag, so they only drop directly on Normal if (!Main.expertMode) { diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index 2e03fb5649..bf5d196850 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -142,7 +142,7 @@ namespace CalamityMod.NPCs.Polterghast } // Predictiveness - float chargePredictionAmt = 10f + 20f * (tileEnrageMult - 1f); + float chargePredictionAmt = 5f + 20f * (tileEnrageMult - 1f); Vector2 predictionVector = chargePhase && revenge ? player.velocity * chargePredictionAmt : Vector2.Zero; Vector2 lookAt = player.Center + predictionVector; Vector2 rotationVector = lookAt - vector; diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index b2ecdcde54..26241e62f1 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -366,7 +366,7 @@ namespace CalamityMod.NPCs.Polterghast baseProjectileVelocity *= 1.25f; // Predictiveness - float chargePredictionAmt = 10f + 20f * (tileEnrageMult - 1f); + float chargePredictionAmt = 5f + 20f * (tileEnrageMult - 1f); Vector2 predictionVector = chargePhase && revenge ? player.velocity * chargePredictionAmt : Vector2.Zero; Vector2 lookAt = player.Center + predictionVector; Vector2 rotationVector = lookAt - vector; @@ -975,7 +975,9 @@ namespace CalamityMod.NPCs.Polterghast public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Polterghast DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs index ad3f0d6531..8fb195a90f 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs @@ -435,15 +435,15 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void NPCLoot() { - // Profaned Guardians have no actual drops and no treasure bag - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + // Profaned Guardians have no actual drops and no treasure bag + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedGuardians); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Wizard }, CalamityWorld.downedGuardians); - // Mark the Profaned Guardians as dead CalamityWorld.downedGuardians = true; CalamityNetcode.SyncWorld(); diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 7677a9bb9f..70cf6178d3 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -1339,7 +1339,9 @@ namespace CalamityMod.NPCs.Providence public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Providence DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice || !hasTakenDaytimeDamage); diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index 8d39a3bcfb..46e1084675 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -701,7 +701,9 @@ namespace CalamityMod.NPCs.Ravager public override void NPCLoot() { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for Ravager DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); @@ -709,8 +711,6 @@ namespace CalamityMod.NPCs.Ravager DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedScavenger); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.WitchDoctor }, CalamityWorld.downedScavenger); - // All other drops are contained in the bag, so they only drop directly on Normal if (!Main.expertMode) { diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 9c5fe321e7..5d55e3f7a3 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -765,6 +765,8 @@ namespace CalamityMod.NPCs.Signus bool fullStrength = !CalamityWorld.downedSentinel3 || CalamityWorld.DoGSecondStageCountdown <= 0; if (fullStrength) { + CalamityGlobalNPC.SetNewBossJustDowned(npc); + DropHelper.DropBags(npc); // Legendary drop for Signus diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index e1aa80fef9..a3acedf869 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -657,12 +657,14 @@ namespace CalamityMod.NPCs.SlimeGod // This loot code is shared with every other Slime God component. public static void DropSlimeGodLoot(NPC npc) { - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedSlimeGod); - CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Dryad, ModContent.NPCType() }, CalamityWorld.downedSlimeGod); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedSlimeGod); // Purified Jam is once per player, but drops for all players. CalamityPlayer mp = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Calamity(); diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index b8d40642a5..2485ce30a3 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -1,18 +1,24 @@ +using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { - public class StormWeaverBody : ModNPC + public class StormWeaverBody : ModNPC { + private int invinceTime = 180; + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -20,35 +26,39 @@ namespace CalamityMod.NPCs.StormWeaver npc.npcSlots = 5f; npc.width = 40; npc.height = 40; - npc.defense = 0; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.999999f; - global.unbreakableDR = true; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; // If fought as a DoG interlude, keep the DoG music playing else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + // Phase one settings + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + npc.chaseable = false; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; npc.alpha = 255; - npc.boss = true; npc.behindTiles = true; npc.noGravity = true; + npc.boss = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - npc.chaseable = false; npc.dontCountMe = true; if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) @@ -59,6 +69,20 @@ namespace CalamityMod.NPCs.StormWeaver npc.scale = 1.1f; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(invinceTime); + writer.Write(npc.dontTakeDamage); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + invinceTime = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; @@ -66,13 +90,47 @@ namespace CalamityMod.NPCs.StormWeaver public override void AI() { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + if (invinceTime > 0) + { + invinceTime--; + npc.damage = 0; + npc.dontTakeDamage = true; + } + else + { + npc.damage = npc.defDamage; + npc.dontTakeDamage = false; + } - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - npc.TargetClosest(true); + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + // Shed armor + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + + // Update armored settings to naked settings + if (shedArmor) + { + // Spawn armor gore and set other crucial variables + if (!npc.chaseable) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody3"), 1f); + + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0f; + global.unbreakableDR = false; + npc.chaseable = true; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + } + } + + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); // Check if other segments are still alive, if not, die bool shouldDespawn = true; @@ -116,33 +174,32 @@ namespace CalamityMod.NPCs.StormWeaver 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); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + + float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -156,13 +213,64 @@ namespace CalamityMod.NPCs.StormWeaver } } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverBodyNaked") : Main.npcTexture[npc.type]; + 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; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + 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, 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); + + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; } - public override bool CheckActive() + public override void OnHitPlayer(Player player, int damage, bool crit) + { + int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 180 : 90; + player.AddBuff(BuffID.Electrified, buffDuration, true); + } + + public override bool CheckActive() { return false; } @@ -172,55 +280,52 @@ namespace CalamityMod.NPCs.StormWeaver return false; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) + public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x) && npc.life / (float)npc.lifeMax >= 0.9f) { if (projectile.penetrate == -1 && !projectile.minion) - { projectile.penetrate = 1; - } else if (projectile.penetrate >= 1) - { projectile.penetrate = 1; - } } - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Electrified, 90, true); } public override void HitEffect(int hitDirection, double damage) { - if (npc.life <= 0) + for (int k = 0; k < 3; k++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); + + if (npc.life <= 0) { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody3"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody3"), 1f); + + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; - 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 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 < 40; num623++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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, 173, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } @@ -231,5 +336,6 @@ namespace CalamityMod.NPCs.StormWeaver npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); } + } } diff --git a/NPCs/StormWeaver/StormWeaverBodyNaked.cs b/NPCs/StormWeaver/StormWeaverBodyNaked.cs deleted file mode 100644 index 97006260ab..0000000000 --- a/NPCs/StormWeaver/StormWeaverBodyNaked.cs +++ /dev/null @@ -1,294 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.StormWeaver -{ - public class StormWeaverBodyNaked : ModNPC - { - private int invinceTime = 180; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 40; - npc.height = 40; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 760500 : 126750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); - - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) - music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; - // If fought as a DoG interlude, keep the DoG music playing - else - music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.boss = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.netAlways = true; - npc.dontCountMe = true; - - if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - npc.damage = 0; - npc.dontTakeDamage = true; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } catch - { - } - - npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - - if (num191 < 0f) - npc.spriteDirection = -1; - else if (num191 > 0f) - npc.spriteDirection = 1; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - 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; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - 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, 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); - - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 180 : 90; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } - - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return false; - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody3"), 1f); - - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 30; - npc.height = 30; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - - for (int num621 = 0; num621 < 20; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; - } - } - - for (int num623 = 0; num623 < 40; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - - } -} diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index b2e79ec7ef..f2c8c43c06 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -1,7 +1,17 @@ using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.LoreItems; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; +using CalamityMod.Items.Placeables.Furniture.Trophies; +using CalamityMod.Items.Potions; +using CalamityMod.Items.TreasureBags; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; @@ -10,19 +20,37 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { - [AutoloadBossHead] public class StormWeaverHead : ModNPC { - private const float BoltAngleSpread = 170; - private int BoltCountdown = 0; - private const float speed = 10f; - private const float turnSpeed = 0.3f; - private bool tail = false; + public static int normalIconIndex; + public static int vulnerableIconIndex; - public override void SetStaticDefaults() + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/StormWeaver/StormWeaverHead_Head_Boss"; + string vulnerableIconPath = "CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked_Head_Boss"; + + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + + CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); + vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); + } + + private const float BoltAngleSpread = 280; + private bool tail = false; + private int invinceTime = 180; + + // Lightning flash variables + public float lightning = 0f; + private float lightningDecay = 1f; + private float lightningSpeed = 0f; + + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -31,21 +59,31 @@ namespace CalamityMod.NPCs.StormWeaver npc.npcSlots = 5f; npc.width = 74; npc.height = 74; - npc.defense = 0; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.999999f; - global.unbreakableDR = true; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) + { + npc.value = Item.buyPrice(0, 35, 0, 0); music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; + } // If fought as a DoG interlude, keep the DoG music playing else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + // Phase one settings + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + npc.chaseable = false; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -55,10 +93,8 @@ namespace CalamityMod.NPCs.StormWeaver npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; - npc.chaseable = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; + bossBag = ModContent.ItemType(); if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) npc.scale = 1.2f; @@ -68,28 +104,103 @@ namespace CalamityMod.NPCs.StormWeaver npc.scale = 1.1f; } - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) + { + if (npc.life / (float)npc.lifeMax < 0.9f) + index = vulnerableIconIndex; + else + index = normalIconIndex; + } + + public override void SendExtraAI(BinaryWriter writer) { - writer.Write(BoltCountdown); - } + writer.Write(npc.chaseable); + writer.Write(invinceTime); + writer.Write(npc.dontTakeDamage); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - BoltCountdown = reader.ReadInt32(); - } + npc.chaseable = reader.ReadBoolean(); + invinceTime = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { - bool enraged = npc.Calamity().enraged > 0; + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + bool enraged = calamityGlobalNPC.enraged > 0; bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || malice; - bool revenge = CalamityWorld.revenge || malice; bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - if (!Main.raining && !BossRushEvent.BossRushActive && CalamityWorld.DoGSecondStageCountdown <= 0) + if (invinceTime > 0) + { + invinceTime--; + npc.damage = 0; + npc.dontTakeDamage = true; + } + else + { + npc.damage = npc.defDamage; + npc.dontTakeDamage = false; + } + + if (!Main.raining) CalamityUtils.StartRain(); + float lifeRatio = npc.life / (float)npc.lifeMax; + + if (revenge) + { + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) + lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; + } + + // Shed armor + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + + // Start charging at the target + bool phase2 = lifeRatio < 0.7f; + + // Lightning strike flash phase + bool phase3 = lifeRatio < 0.4f; + + // Become weak and cancel the storm + bool phase4 = npc.life / (float)npc.lifeMax < 0.05f; + + // Update armored settings to naked settings + if (shedArmor) + { + // Spawn armor gore, roar and set other crucial variables + if (!npc.chaseable) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorHead1"), 1f); + Main.PlaySound(SoundID.NPCDeath14, (int)npc.Center.X, (int)npc.Center.Y); + + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0f; + global.unbreakableDR = false; + npc.chaseable = true; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + } + } + + int boltProjectiles = (phase3 || death) ? 4 : phase2 ? 3 : 2; + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); if (npc.ai[2] > 0f) @@ -127,13 +238,10 @@ namespace CalamityMod.NPCs.StormWeaver { int lol; if (num36 >= 0 && num36 < totalLength - 1) - { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } else - { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } + Main.npc[lol].realLife = npc.whoAmI; Main.npc[lol].ai[2] = npc.whoAmI; Main.npc[lol].ai[1] = Previous; @@ -141,66 +249,44 @@ namespace CalamityMod.NPCs.StormWeaver npc.netUpdate = true; Previous = lol; } + tail = true; } - if (expertMode) + if (expertMode && !phase4) { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 360f) + npc.localAI[0] += enraged ? 2f : malice ? 1.5f : 1f; + float spawnOrbGateValue = shedArmor ? 450f : 360f; + if (npc.localAI[0] >= spawnOrbGateValue) { npc.localAI[0] = 0f; - npc.TargetClosest(); npc.netUpdate = true; - float xPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.X + 375f : Main.player[npc.target].position.X - 375f; - float yPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.Y + 375f : Main.player[npc.target].position.Y - 375f; + + float orbDistance = shedArmor ? 250f : 350f; + float xPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.X + orbDistance : Main.player[npc.target].position.X - orbDistance; + float yPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.Y + orbDistance : Main.player[npc.target].position.Y - orbDistance; Vector2 spawnPos = new Vector2(xPos, yPos); + int type = ProjectileID.CultistBossLightningOrb; int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(spawnPos, Vector2.Zero, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(spawnPos, Vector2.Zero, type, damage, 0f, Main.myPlayer); } } - - if (BoltCountdown == 0) - { - BoltCountdown = malice ? 480 : 600; - } - if (BoltCountdown > 0) - { - BoltCountdown--; - if (BoltCountdown == 0) - { - int speed2 = enraged ? 10 : revenge ? 8 : 7; - float spawnX2 = Main.rand.Next(2001) - 1000f + Main.player[npc.target].Center.X; - float spawnY2 = -1000f + Main.player[npc.target].Center.Y; - Vector2 baseSpawn = new Vector2(spawnX2, spawnY2); - Vector2 baseVelocity = Main.player[npc.target].Center - baseSpawn; - baseVelocity.Normalize(); - baseVelocity *= speed2; - int BoltProjectiles = 1; - for (int i = 0; i < BoltProjectiles; i++) - { - Vector2 source = baseSpawn; - source.X += i * 30 - (BoltProjectiles * 15); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / BoltProjectiles))); - velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; - Vector2 vector94 = Main.player[npc.target].Center - source; - float ai = Main.rand.Next(100); - int type = ProjectileID.CultistBossLightningOrbArc; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(source, velocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); - } - } - } } - if (Main.player[npc.target].dead) + + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + + if (Main.player[npc.target].dead && npc.life > 0) { - npc.TargetClosest(false); - npc.velocity.Y = npc.velocity.Y - 10f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + npc.TargetClosest(false); + + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - { - npc.velocity.Y = npc.velocity.Y - 10f; - } + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) { CalamityWorld.DoGSecondStageCountdown = 0; @@ -211,9 +297,10 @@ namespace CalamityMod.NPCs.StormWeaver netMessage.Write(CalamityWorld.DoGSecondStageCountdown); netMessage.Send(); } + for (int num957 = 0; num957 < Main.maxNPCs; num957++) { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() + if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType())) { @@ -222,7 +309,8 @@ namespace CalamityMod.NPCs.StormWeaver } } } - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 10000f) + + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 10000f && npc.life > 0) { CalamityWorld.DoGSecondStageCountdown = 0; if (Main.netMode == NetmodeID.Server) @@ -232,72 +320,91 @@ namespace CalamityMod.NPCs.StormWeaver netMessage.Write(CalamityWorld.DoGSecondStageCountdown); netMessage.Send(); } + for (int num957 = 0; num957 < Main.maxNPCs; num957++) { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType())) + if (Main.npc[num957].type == ModContent.NPCType() + || Main.npc[num957].type == ModContent.NPCType() + || Main.npc[num957].type == ModContent.NPCType()) { Main.npc[num957].active = false; } } } + if (npc.velocity.X < 0f) - { npc.spriteDirection = -1; - } else if (npc.velocity.X > 0f) - { npc.spriteDirection = 1; - } - float num188 = speed; - float num189 = turnSpeed; - 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 - 800); - if (Main.player[npc.target].position.Y > num47) - { - num192 = num47; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 500f) - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 600f; - } - else - { - num191 = Main.player[npc.target].Center.X - 600f; - } - } - } - } - else - { - num188 = enraged ? 15f : malice ? 13f : revenge ? 11f : 10f; - num189 = enraged ? 0.45f : malice ? 0.38f : revenge ? 0.31f : 0.28f; - } + + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + float num188 = (shedArmor ? 12f : 10f) + (enraged ? 5f : malice ? 3f : revenge ? 1.5f : expertMode ? 1f : 0f); + float num189 = (shedArmor ? 0.24f : 0.2f) + (enraged ? 0.18f : malice ? 0.12f : revenge ? 0.08f : expertMode ? 0.04f : 0f); + + // Start charging at the player when in phase 2 + if (phase2 && !phase4) + { + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] >= 400f) + { + if (npc.localAI[1] == 0f) + npc.localAI[1] = 1f; + + if (calamityGlobalNPC.newAI[0] >= 500f) + { + npc.TargetClosest(); + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + + if (revenge) + { + if (npc.localAI[1] == 2f) + { + num188 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio); + num189 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.0001f * (0.7f - lifeRatio); + num188 *= 2f; + num189 *= 0.85f; + + float stopChargeDistance = 800f * npc.localAI[2]; + if (stopChargeDistance < 0) + { + if (npc.Center.X < Main.player[npc.target].Center.X + stopChargeDistance) + { + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + else + { + if (npc.Center.X > Main.player[npc.target].Center.X + stopChargeDistance) + { + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + } + + int dustAmt = 5; + 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)MathHelper.Pi / (float)dustAmt) + npc.Center; + Vector2 value18 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 206, value18.X, value18.Y, 100, default, 3f); + Main.dust[num1475].noGravity = true; + Main.dust[num1475].noLight = true; + Main.dust[num1475].velocity /= 4f; + Main.dust[num1475].velocity -= npc.velocity; + } + } + } + else if (revenge) + calamityGlobalNPC.newAI[0] += malice ? 4f : death ? 2f : 2f * (0.7f - lifeRatio); + } + float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); @@ -314,52 +421,88 @@ namespace CalamityMod.NPCs.StormWeaver npc.velocity *= num49; } } - if (num42 > 0) - { - for (int num51 = 0; num51 < Main.maxNPCs; 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 < Main.maxNPCs; 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); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + + if (phase2 && !phase4) + { + if (npc.localAI[1] == 1f) + { + // Play lightning sound on the target if not in phase 3 + Vector2 soundCenter = Main.player[npc.target].Center; + + // Play lightning sound on all nearby players if in phase 3 + if (phase3) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < 2800f) + { + soundCenter = Main.player[Main.myPlayer].Center; + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); + + if (Main.netMode != NetmodeID.Server) + { + // Set how quickly the lightning flash dissipates + lightningDecay = Main.rand.NextFloat() * 0.05f + 0.008f; + + // Set how quickly the lightning flash intensifies + lightningSpeed = Main.rand.NextFloat() * 0.05f + 0.05f; + } + } + } + else + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); + + npc.localAI[1] = 2f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int speed2 = enraged ? 10 : revenge ? 8 : 7; + float spawnX2 = npc.Center.X > Main.player[npc.target].Center.X ? 1000f : -1000f; + float spawnY2 = -1000f + Main.player[npc.target].Center.Y; + Vector2 baseSpawn = new Vector2(spawnX2 + Main.player[npc.target].Center.X, spawnY2); + Vector2 baseVelocity = Main.player[npc.target].Center - baseSpawn; + baseVelocity.Normalize(); + baseVelocity *= speed2; + + for (int i = 0; i < boltProjectiles; i++) + { + Vector2 source = baseSpawn; + source.X += i * 30f - (boltProjectiles * 15f); + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / boltProjectiles))); + velocity.X = velocity.X + 3f * Main.rand.NextFloat() - 1.5f; + Vector2 vector94 = Main.player[npc.target].Center - source; + float ai = Main.rand.Next(100); + int type = ProjectileID.CultistBossLightningOrbArc; + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(source, velocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); + } + } + + if (revenge) + npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num188 + Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio)) * 2f; + + float chargeDirection = 0; + if (npc.velocity.X < 0f) + chargeDirection = -1f; + else if (npc.velocity.X > 0f) + chargeDirection = 1f; + + npc.localAI[2] = chargeDirection; + } + } + + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); float num198 = num188 / num193; num191 *= num198; num192 *= num198; + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) { if (npc.velocity.X < num191) @@ -369,10 +512,9 @@ namespace CalamityMod.NPCs.StormWeaver else { if (npc.velocity.X > num191) - { npc.velocity.X = npc.velocity.X - num189; - } } + if (npc.velocity.Y < num192) { npc.velocity.Y = npc.velocity.Y + num189; @@ -380,31 +522,23 @@ namespace CalamityMod.NPCs.StormWeaver else { if (npc.velocity.Y > num192) - { npc.velocity.Y = npc.velocity.Y - num189; - } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + + if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) { if (npc.velocity.Y > 0f) - { npc.velocity.Y = npc.velocity.Y + num189 * 2f; - } else - { npc.velocity.Y = npc.velocity.Y - num189 * 2f; - } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + + if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) { if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num189 * 2f; //changed from 2 - } + npc.velocity.X = npc.velocity.X + num189 * 2f; else - { - npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 - } + npc.velocity.X = npc.velocity.X - num189 * 2f; } } else @@ -412,49 +546,114 @@ namespace CalamityMod.NPCs.StormWeaver if (num196 > num197) { if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 - } + npc.velocity.X = npc.velocity.X + num189 * 1.1f; else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + npc.velocity.X = npc.velocity.X - num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) { if (npc.velocity.Y > 0f) - { npc.velocity.Y = npc.velocity.Y + num189; - } else - { npc.velocity.Y = npc.velocity.Y - num189; - } } } else { if (npc.velocity.Y < num192) - { npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; - } else if (npc.velocity.Y > num192) - { npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) { if (npc.velocity.X > 0f) - { npc.velocity.X = npc.velocity.X + num189; - } else - { npc.velocity.X = npc.velocity.X - num189; - } } } } - npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + MathHelper.PiOver2; + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (phase4) + { + // Become weak and stop the storm when in phase 4 + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + CalamityMod.StopRain(); + } + else if (phase3) + { + // Adjust lightning flash variables when in phase 3 + if (Main.netMode != NetmodeID.Server) + { + if (lightningSpeed > 0f) + { + lightning += lightningSpeed; + if (lightning >= 1f) + { + lightning = 1f; + lightningSpeed = 0f; + } + } + else if (lightning > 0f) + lightning -= lightningDecay; + } + + // Start a storm when in third phase + if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu) || calamityGlobalNPC.newAI[1] > 0f) + return; + + CalamityUtils.StartRain(true, true); + calamityGlobalNPC.newAI[1] = 1f; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked") : Main.npcTexture[npc.type]; + 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; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + + if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + 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, 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); + + if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -463,31 +662,34 @@ namespace CalamityMod.NPCs.StormWeaver return true; } - public override bool CheckActive() + public override void OnHitPlayer(Player player, int damage, bool crit) + { + int buffDuration = npc.Calamity().newAI[0] >= 400f ? 360 : 180; + player.AddBuff(BuffID.Electrified, buffDuration, true); + } + + public override bool CheckActive() { return false; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Electrified, 180, true); - } - - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - } + if (npc.life <= 0) { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorHead1"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead2"), 1f); + + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; - 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 < 20; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); @@ -495,9 +697,10 @@ namespace CalamityMod.NPCs.StormWeaver 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 < 40; num623++) { int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); @@ -511,23 +714,94 @@ namespace CalamityMod.NPCs.StormWeaver public override bool CheckDead() { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) + for (int num569 = 0; num569 < Main.maxNPCs; num569++) { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType())) - { - Main.npc[num957].life = 0; - } - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.SpawnOnPlayer(Main.LocalPlayer.whoAmI, ModContent.NPCType()); + if (Main.npc[num569].active && (Main.npc[num569].type == ModContent.NPCType() || Main.npc[num569].type == ModContent.NPCType())) + Main.npc[num569].life = 0; } + return true; } - public override bool PreNPCLoot() => false; + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override bool SpecialNPCLoot() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(npc, + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType()); + npc.position = Main.npc[closestSegmentID].position; + return false; + } + + public override void NPCLoot() + { + // Only drop items if fought at full strength + bool fullStrength = !CalamityWorld.downedSentinel2 || CalamityWorld.DoGSecondStageCountdown <= 0; + if (fullStrength) + { + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); + + // Legendary drop for Storm Weaver + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); + + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + bool lastSentinelKilled = CalamityWorld.downedSentinel1 && !CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); + + if (!Main.expertMode) + { + // Materials + DropHelper.DropItem(npc, ModContent.ItemType(), true, 5, 8); + + // Weapons + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + + // Light pet. + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + if (Main.rand.NextBool(20)) + { + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + } + } + } + + // If DoG's fight is active, set the timer for Signus' phase + if (CalamityWorld.DoGSecondStageCountdown > 7260) + { + CalamityWorld.DoGSecondStageCountdown = 7260; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); + netMessage.Write(CalamityWorld.DoGSecondStageCountdown); + netMessage.Send(); + } + } + + // Mark Storm Weaver as dead + if (fullStrength) + { + CalamityWorld.downedSentinel2 = true; + CalamityNetcode.SyncWorld(); + } + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); } diff --git a/NPCs/StormWeaver/StormWeaverHeadNaked.cs b/NPCs/StormWeaver/StormWeaverHeadNaked.cs deleted file mode 100644 index aef2f2945c..0000000000 --- a/NPCs/StormWeaver/StormWeaverHeadNaked.cs +++ /dev/null @@ -1,750 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.LoreItems; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.Potions; -using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.StormWeaver -{ - [AutoloadBossHead] - public class StormWeaverHeadNaked : ModNPC - { - private const float BoltAngleSpread = 280; - private const float speed = 13f; - private const float turnSpeed = 0.35f; - private bool tail = false; - private int invinceTime = 180; - - // Lightning flash variables - public float lightning = 0f; - private float lightningDecay = 1f; - private float lightningSpeed = 0f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 74; - npc.height = 74; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 760500 : 126750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); - - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) - { - npc.value = Item.buyPrice(0, 35, 0, 0); - music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; - } - // If fought as a DoG interlude, keep the DoG music playing - else - music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.boss = true; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.netAlways = true; - bossBag = ModContent.ItemType(); - - if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - bool enraged = calamityGlobalNPC.enraged > 0; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || malice; - bool revenge = CalamityWorld.revenge || malice; - bool expertMode = Main.expertMode || malice; - npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - - if (invinceTime > 0) - { - invinceTime--; - npc.damage = 0; - npc.dontTakeDamage = true; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - if (!Main.raining) - CalamityUtils.StartRain(); - - float lifeRatio = npc.life / (float)npc.lifeMax; - - if (revenge) - { - // Increase aggression if player is taking a long time to kill the boss - if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) - lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - } - - // Start charging at the target - bool phase2 = lifeRatio < 0.7f; - - // Lightning strike flash phase - bool phase3 = lifeRatio < 0.4f; - - // Become weak and cancel the storm - bool phase4 = npc.life / (float)npc.lifeMax < 0.05f; - - int boltProjectiles = (phase3 || death) ? 4 : phase2 ? 3 : 2; - - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - - npc.alpha -= 12; - if (npc.alpha < 0) - npc.alpha = 0; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tail && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - int totalLength = death ? 60 : revenge ? 50 : expertMode ? 40 : 30; - for (int num36 = 0; num36 < totalLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < totalLength - 1) - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - npc.netUpdate = true; - Previous = lol; - } - tail = true; - } - - if (expertMode && !phase4) - { - npc.localAI[0] += enraged ? 2f : malice ? 1.5f : 1f; - if (npc.localAI[0] >= 450f) - { - npc.localAI[0] = 0f; - npc.netUpdate = true; - - float xPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.X + 250f : Main.player[npc.target].position.X - 250f; - float yPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.Y + 250f : Main.player[npc.target].position.Y - 250f; - Vector2 spawnPos = new Vector2(xPos, yPos); - - int type = ProjectileID.CultistBossLightningOrb; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(spawnPos, Vector2.Zero, type, damage, 0f, Main.myPlayer); - } - } - } - - if (Main.player[npc.target].dead && npc.life > 0) - { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - npc.TargetClosest(false); - - npc.velocity.Y = npc.velocity.Y - 10f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y = npc.velocity.Y - 10f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - CalamityWorld.DoGSecondStageCountdown = 0; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - for (int num957 = 0; num957 < Main.maxNPCs; num957++) - { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType())) - { - Main.npc[num957].active = false; - } - } - } - } - - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 10000f && npc.life > 0) - { - CalamityWorld.DoGSecondStageCountdown = 0; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - for (int num957 = 0; num957 < Main.maxNPCs; num957++) - { - if (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType()) - { - Main.npc[num957].active = false; - } - } - } - - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - float num188 = enraged ? 17f : malice ? 15f : revenge ? 13f : 12f; - float num189 = enraged ? 0.41f : malice ? 0.36f : revenge ? 0.31f : 0.28f; - - // Start charging at the player when in phase 2 - if (phase2 && !phase4) - { - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= 400f) - { - if (npc.localAI[1] == 0f) - npc.localAI[1] = 1f; - - if (calamityGlobalNPC.newAI[0] >= 500f) - { - npc.TargetClosest(); - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - - if (revenge) - { - if (npc.localAI[1] == 2f) - { - num188 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio); - num189 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.0001f * (0.7f - lifeRatio); - num188 *= 2f; - num189 *= 0.85f; - - float stopChargeDistance = 800f * npc.localAI[2]; - if (stopChargeDistance < 0) - { - if (npc.Center.X < Main.player[npc.target].Center.X + stopChargeDistance) - { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - else - { - if (npc.Center.X > Main.player[npc.target].Center.X + stopChargeDistance) - { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - } - - int dustAmt = 5; - 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)MathHelper.Pi / (float)dustAmt) + npc.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 206, value18.X, value18.Y, 100, default, 3f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= npc.velocity; - } - } - } - else if (revenge) - calamityGlobalNPC.newAI[0] += malice ? 4f : death ? 2f : 2f * (0.7f - lifeRatio); - } - - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } - - if (phase2 && !phase4) - { - if (npc.localAI[1] == 1f) - { - // Play lightning sound on the target if not in phase 3 - Vector2 soundCenter = Main.player[npc.target].Center; - - // Play lightning sound on all nearby players if in phase 3 - if (phase3) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < 2800f) - { - soundCenter = Main.player[Main.myPlayer].Center; - - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); - - if (Main.netMode != NetmodeID.Server) - { - // Set how quickly the lightning flash dissipates - lightningDecay = Main.rand.NextFloat() * 0.05f + 0.008f; - - // Set how quickly the lightning flash intensifies - lightningSpeed = Main.rand.NextFloat() * 0.05f + 0.05f; - } - } - } - else - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); - - npc.localAI[1] = 2f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int speed2 = enraged ? 10 : revenge ? 8 : 7; - float spawnX2 = npc.Center.X > Main.player[npc.target].Center.X ? 1000f : -1000f; - float spawnY2 = -1000f + Main.player[npc.target].Center.Y; - Vector2 baseSpawn = new Vector2(spawnX2 + Main.player[npc.target].Center.X, spawnY2); - Vector2 baseVelocity = Main.player[npc.target].Center - baseSpawn; - baseVelocity.Normalize(); - baseVelocity *= speed2; - - for (int i = 0; i < boltProjectiles; i++) - { - Vector2 source = baseSpawn; - source.X += i * 30f - (boltProjectiles * 15f); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / boltProjectiles))); - velocity.X = velocity.X + 3f * Main.rand.NextFloat() - 1.5f; - Vector2 vector94 = Main.player[npc.target].Center - source; - float ai = Main.rand.Next(100); - int type = ProjectileID.CultistBossLightningOrbArc; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(source, velocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); - } - } - - if (revenge) - npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num188 + Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio)) * 2f; - - float chargeDirection = 0; - if (npc.velocity.X < 0f) - chargeDirection = -1f; - else if (npc.velocity.X > 0f) - chargeDirection = 1f; - - npc.localAI[2] = chargeDirection; - } - } - - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189; - } - else - { - if (npc.velocity.X > num191) - npc.velocity.X = npc.velocity.X - num189; - } - - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else - { - if (npc.velocity.Y > num192) - npc.velocity.Y = npc.velocity.Y - num189; - } - - if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + num189 * 2f; - else - npc.velocity.Y = npc.velocity.Y - num189 * 2f; - } - - if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + num189 * 2f; - else - npc.velocity.X = npc.velocity.X - num189 * 2f; - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - npc.velocity.X = npc.velocity.X + num189 * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X = npc.velocity.X - num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + num189; - else - npc.velocity.Y = npc.velocity.Y - num189; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + num189; - else - npc.velocity.X = npc.velocity.X - num189; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - if (phase4) - { - // Become weak and stop the storm when in phase 4 - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - CalamityMod.StopRain(); - } - else if (phase3) - { - // Adjust lightning flash variables when in phase 3 - if (Main.netMode != NetmodeID.Server) - { - if (lightningSpeed > 0f) - { - lightning += lightningSpeed; - if (lightning >= 1f) - { - lightning = 1f; - lightningSpeed = 0f; - } - } - else if (lightning > 0f) - lightning -= lightningDecay; - } - - // Start a storm when in third phase - if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu) || calamityGlobalNPC.newAI[1] > 0f) - return; - - CalamityUtils.StartRain(true, true); - calamityGlobalNPC.newAI[1] = 1f; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - 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; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - - if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - 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, 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); - - if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = npc.Calamity().newAI[0] >= 400f ? 360 : 180; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 5; k++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead2"), 1f); - - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 30; - npc.height = 30; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - - for (int num621 = 0; num621 < 20; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; - } - } - - for (int num623 = 0; num623 < 40; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override bool CheckDead() - { - for (int num569 = 0; num569 < Main.maxNPCs; num569++) - { - if (Main.npc[num569].active && (Main.npc[num569].type == ModContent.NPCType() || Main.npc[num569].type == ModContent.NPCType())) - Main.npc[num569].life = 0; - } - - return true; - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } - - public override bool SpecialNPCLoot() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(npc, - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType()); - npc.position = Main.npc[closestSegmentID].position; - return false; - } - - public override void NPCLoot() - { - // Only drop items if fought at full strength - bool fullStrength = !CalamityWorld.downedSentinel2 || CalamityWorld.DoGSecondStageCountdown <= 0; - if (fullStrength) - { - DropHelper.DropBags(npc); - - // Legendary drop for Storm Weaver - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); - - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - bool lastSentinelKilled = CalamityWorld.downedSentinel1 && !CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); - - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), true, 5, 8); - - // Weapons - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - - // Light pet. - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - } - } - } - - // If DoG's fight is active, set the timer for Signus' phase - if (CalamityWorld.DoGSecondStageCountdown > 7260) - { - CalamityWorld.DoGSecondStageCountdown = 7260; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - } - - // Mark Storm Weaver as dead - if (fullStrength) - { - CalamityWorld.downedSentinel2 = true; - CalamityNetcode.SyncWorld(); - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - } - } -} diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index 5b5fd26d44..ba106b8918 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -1,20 +1,24 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { - public class StormWeaverTail : ModNPC + public class StormWeaverTail : ModNPC { + private int invinceTime = 180; + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -22,31 +26,35 @@ namespace CalamityMod.NPCs.StormWeaver npc.npcSlots = 5f; npc.width = 48; npc.height = 80; - npc.defense = 0; - npc.takenDamageMultiplier = 3f; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; // If fought as a DoG interlude, keep the DoG music playing else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + // Phase one settings + npc.takenDamageMultiplier = 3f; + npc.HitSound = SoundID.NPCHit53; + npc.DeathSound = SoundID.NPCDeath14; + + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; npc.alpha = 255; - npc.boss = true; npc.behindTiles = true; npc.noGravity = true; + npc.boss = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit53; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; @@ -58,6 +66,18 @@ namespace CalamityMod.NPCs.StormWeaver npc.scale = 1.1f; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(invinceTime); + writer.Write(npc.dontTakeDamage); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + invinceTime = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; @@ -65,13 +85,43 @@ namespace CalamityMod.NPCs.StormWeaver public override void AI() { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + if (invinceTime > 0) + { + invinceTime--; + npc.damage = 0; + npc.dontTakeDamage = true; + } + else + { + npc.damage = npc.defDamage; + npc.dontTakeDamage = false; + } - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - npc.TargetClosest(true); + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + // Shed armor + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + + // Update armored settings to naked settings + if (shedArmor) + { + // Spawn armor gore and set other crucial variables + if (npc.takenDamageMultiplier == 3f) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail2"), 1f); + + npc.takenDamageMultiplier = 1f; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + } + } + + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); // Check if other segments are still alive, if not, die bool shouldDespawn = true; @@ -115,33 +165,32 @@ namespace CalamityMod.NPCs.StormWeaver 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); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + + float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -155,7 +204,60 @@ namespace CalamityMod.NPCs.StormWeaver } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailNaked") : Main.npcTexture[npc.type]; + 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; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + 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, 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); + + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (!shedArmor) + { + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailGlow"); + Color rainbowBecauseWhyTheFuckNot = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); + Color color37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + return false; + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; @@ -163,25 +265,27 @@ namespace CalamityMod.NPCs.StormWeaver public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Electrified, 60, true); + int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 120 : 60; + player.AddBuff(BuffID.Electrified, buffDuration, true); } public override void HitEffect(int hitDirection, double damage) { - for (int k = 0; k < 5; k++) - { + for (int k = 0; k < 3; k++) Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - } + if (npc.life <= 0) { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail2"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail2"), 1f); + + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; - 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 < 20; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); @@ -189,9 +293,10 @@ namespace CalamityMod.NPCs.StormWeaver 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 < 40; num623++) { int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); @@ -203,30 +308,7 @@ namespace CalamityMod.NPCs.StormWeaver } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailGlow"); - Color rainbowBecauseWhyTheFuckNot = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - Color color37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override bool CheckActive() + public override bool CheckActive() { return false; } diff --git a/NPCs/StormWeaver/StormWeaverTailNaked.cs b/NPCs/StormWeaver/StormWeaverTailNaked.cs deleted file mode 100644 index 4716088ed3..0000000000 --- a/NPCs/StormWeaver/StormWeaverTailNaked.cs +++ /dev/null @@ -1,292 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.StormWeaver -{ - public class StormWeaverTailNaked : ModNPC - { - private int invinceTime = 180; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 48; - npc.height = 80; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 760500 : 126750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); - - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) - music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; - // If fought as a DoG interlude, keep the DoG music playing - else - music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.boss = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.netAlways = true; - npc.dontCountMe = true; - - if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - npc.damage = 0; - npc.dontTakeDamage = true; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } catch - { - } - - npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - - if (num191 < 0f) - npc.spriteDirection = -1; - else if (num191 > 0f) - npc.spriteDirection = 1; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - 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; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - 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, 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); - - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 120 : 60; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail2"), 1f); - - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 30; - npc.height = 30; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - - for (int num621 = 0; num621 < 20; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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 + Main.rand.Next(10) * 0.1f; - } - } - - for (int num623 = 0; num623 < 40; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 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.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return false; - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - } -} diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index d9d481021c..895bb567a0 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -2734,7 +2734,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas Dust.QuickDustLine(npc.Center, initialRitualPosition, 500f, Color.Red); npc.Center = initialRitualPosition; - DropHelper.DropBags(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); // Legendary drop for SCal DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); diff --git a/NPCs/TownNPCs/DILF.cs b/NPCs/TownNPCs/DILF.cs index 7f10c46580..547dec2ccd 100644 --- a/NPCs/TownNPCs/DILF.cs +++ b/NPCs/TownNPCs/DILF.cs @@ -168,9 +168,6 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(5, 0, 0, 0); nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 15, 0, 0); - nextSlot++; if (Main.LocalPlayer.HasItem(ModContent.ItemType())) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); diff --git a/NPCs/TownNPCs/SEAHOE.cs b/NPCs/TownNPCs/SEAHOE.cs index 14748d79a4..281b4a2311 100644 --- a/NPCs/TownNPCs/SEAHOE.cs +++ b/NPCs/TownNPCs/SEAHOE.cs @@ -372,34 +372,22 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].SetDefaults(ItemID.FlipperPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); nextSlot++; - if (CalamityWorld.downedDesertScourge) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); - nextSlot++; - } if (CalamityWorld.downedEoCAcidRain) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(gold: 3); nextSlot++; } - if (CalamityWorld.downedAquaticScourge) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 20, 0, 0); - nextSlot++; - } - if (NPC.downedFishron && CalamityConfig.Instance.SellVanillaSummons) + if (NPC.downedFishron) { shop.item[nextSlot].SetDefaults(ItemID.TruffleWorm); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 40, 0, 0); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 10, 0, 0); nextSlot++; } if (CalamityWorld.downedBoomerDuke) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(8, 0, 0, 0); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(2, 0, 0, 0); nextSlot++; } } diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 205f510b30..ad53a348f8 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -2876,6 +2876,8 @@ namespace CalamityMod.NPCs.Yharon { CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedYharon); + CalamityGlobalNPC.SetNewBossJustDowned(npc); + // Bags occur in either phase 1 or 2, as they don't contain phase 2 only drops DropHelper.DropBags(npc); diff --git a/Particles/BaseFusableParticleSet.cs b/Particles/BaseFusableParticleSet.cs new file mode 100644 index 0000000000..d1570da734 --- /dev/null +++ b/Particles/BaseFusableParticleSet.cs @@ -0,0 +1,103 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Particles +{ + public abstract class BaseFusableParticleSet + { + public class FusableParticleRenderCollection + { + public BaseFusableParticleSet ParticleSet; + public List BackgroundTargets; + public FusableParticleRenderCollection(BaseFusableParticleSet set, List backgroundTargets) + { + ParticleSet = set; + BackgroundTargets = backgroundTargets; + } + } + + public class FusableParticle + { + public Vector2 Center; + public float Size; + public Vector2 TopLeft => Center + new Vector2(-1f, -1f) * Size * 0.5f; + public Vector2 TopRight => Center + new Vector2(1f, -1f) * Size * 0.5f; + public Vector2 BottomLeft => Center + new Vector2(-1f, 1f) * Size * 0.5f; + public Vector2 BottomRight => Center + new Vector2(1f, 1f) * Size * 0.5f; + + public FusableParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + } + + public int LayerCount + { + get + { + // Not doing this will result in inevitable crashes down the line as the graphics engine fails. + if (BackgroundShaders.Count != BackgroundTextures.Count) + throw new InvalidOperationException("The number of texture maps and shaders are not equivalent."); + + return BackgroundShaders.Count; + } + } + + public List Particles = new List(); + + public FusableParticleRenderCollection RenderCollection => FusableParticleManager.GetParticleRenderCollectionByType(GetType()); + + public List GetBackgroundTargets => RenderCollection.BackgroundTargets; + + public virtual float BorderSize => 0f; + public virtual bool BorderShouldBeSolid => false; + public virtual Color BorderColor => Color.Transparent; + public virtual void PrepareOptionalShaderData(Effect effect, int index) { } + public abstract FusableParticleRenderLayer RenderLayer { get; } + public abstract List BackgroundShaders { get; } + public abstract List BackgroundTextures { get; } + public abstract FusableParticle SpawnParticle(Vector2 center, float sizeStrength); + public abstract void UpdateBehavior(FusableParticle particle); + public abstract void DrawParticles(); + + /// + /// Temporarily moves from the backbuffer to a specialized render target, draws all particles, and caches the resulting render target for drawing later. + /// + internal void PrepareRenderTargetForDrawing() + { + // Don't bother doing anything if this method is called serverside. + if (Main.netMode == NetmodeID.Server) + return; + + // Don't bother doing anything if the set has no particles to render at the moment, for the sake of optimization. + if (Particles.Count <= 0) + return; + + // Go through each background render target in the set and clear the entire thing to use a base of transparent pixels. + foreach (RenderTarget2D backgroundTarget in GetBackgroundTargets) + { + Main.instance.GraphicsDevice.SetRenderTarget(backgroundTarget); + Main.instance.GraphicsDevice.Clear(Color.Transparent); + + // Clear away any particles that shouldn't exist anymore. + Particles.RemoveAll(p => p.Size <= 5f); + + // Prepare the sprite batch for specialized drawing in prepration that the graphics device will to new render targets. + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); + + // Draw the surviving particles. + DrawParticles(); + + Main.spriteBatch.End(); + } + + // Return to using the backbuffer after done drawing everything to the background targets. + Main.instance.GraphicsDevice.SetRenderTarget(null); + } + } +} diff --git a/Particles/FusableParticleManager.cs b/Particles/FusableParticleManager.cs new file mode 100644 index 0000000000..1dbcdd27aa --- /dev/null +++ b/Particles/FusableParticleManager.cs @@ -0,0 +1,173 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; + +using static CalamityMod.Particles.BaseFusableParticleSet; + +namespace CalamityMod.Particles +{ + // NOTE: A lot of the functionalities within this system cannot under really any circumstance be used serverside. + // This system is entirely visual. However, servers do not have drawing capabilities, nor even a proper GraphicsDevice + // instance. This system utilizes many things that require both of these things, such as shaders and render targets. + // As such, it is littered with many netMode checks. While some may be overprotective in their nature it is critical that + // failsafes exist there, as visual failures tend to result in engine crashes, which will kill a lot of MP servers. + // If someone other than me for any reason attempts to notably expand upon this system you must keep this in mind. -Dominic + public static class FusableParticleManager + { + internal static List ParticleSets = new List(); + + /// + /// Loads all render sets. + /// + internal static void LoadParticleRenderSets() + { + // Redefine the particle set list in case the mod was reloaded and this field was nullified during that. + ParticleSets = new List(); + + // Look through every type in the mod, and check if it's derived from BaseFusableParticleSet. + // If it is, create a default instance of said particle, save it, and create a RenderTarget2D for each individual texture/shader. + foreach (Type type in typeof(CalamityMod).Assembly.GetTypes()) + { + // Don't load abstract classes; they cannot have instances. + if (type.IsAbstract) + continue; + + if (type.IsSubclassOf(typeof(BaseFusableParticleSet))) + { + BaseFusableParticleSet instance = Activator.CreateInstance(type) as BaseFusableParticleSet; + List backgroundTargets = new List(); + + // Only generate render targets to use if this isn't called serverside. + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < instance.LayerCount; i++) + backgroundTargets.Add(new RenderTarget2D(Main.instance.GraphicsDevice, Main.screenWidth, Main.screenHeight, false, default, default, 0, RenderTargetUsage.PreserveContents)); + } + + FusableParticleRenderCollection particleRenderCollection = new FusableParticleRenderCollection(instance, backgroundTargets); + ParticleSets.Add(particleRenderCollection); + } + } + } + + /// + /// Unloads all render sets, disposing any created s in the process. + /// + internal static void UnloadParticleRenderSets() + { + // Go through each render collection and manually clear away any render targets. + foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets) + { + particleRenderSet.ParticleSet = null; + foreach (RenderTarget2D target in particleRenderSet.BackgroundTargets) + target?.Dispose(); + } + ParticleSets = null; + } + + /// + /// Prepares the render targets of each cached instance in advance. + /// + internal static void PrepareFusableParticleTargets() + { + // Don't attempt to prepare anything serverside or if the particle sets are unloaded. + if (Main.netMode == NetmodeID.Server || ParticleSets is null) + return; + + // Prepare the render target for all fusable particles. + foreach (FusableParticleRenderCollection particleSet in ParticleSets) + particleSet.ParticleSet.PrepareRenderTargetForDrawing(); + } + + /// + /// Renders each cached instance with its connecting shader. + /// + internal static void RenderAllFusableParticles(FusableParticleRenderLayer renderLayer) + { + // Don't attempt to render anything serverside. + if (Main.netMode == NetmodeID.Server) + return; + + foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets) + { + BaseFusableParticleSet particleSet = particleRenderSet.ParticleSet; + + // Don't bother rendering if the set has no particles to render at the moment, for the sake of optimization. + if (particleSet.Particles.Count <= 0) + continue; + + // Ignore particle sets of incompatible render layers. + // They will be drawn later when appropriate. + if (renderLayer != particleSet.RenderLayer) + continue; + + bool needsRestartAtEnd = renderLayer == FusableParticleRenderLayer.OverWater; + List backgroundTargets = particleSet.GetBackgroundTargets; + + if (needsRestartAtEnd) + Main.spriteBatch.End(); + + // Restart the sprite batch. This must be done with an immediate sort mode since a shader is going to be applied. + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + for (int i = 0; i < particleSet.LayerCount; i++) + { + Effect shader = particleSet.BackgroundShaders[i]; + Texture2D backgroundTexture = particleSet.BackgroundTextures[i]; + + // Draw the current target with the specified shader. + shader.Parameters["edgeBorderSize"].SetValue(particleSet.BorderSize); + shader.Parameters["borderShouldBeSolid"].SetValue(particleSet.BorderShouldBeSolid); + shader.Parameters["edgeBorderColor"].SetValue(particleSet.BorderColor.ToVector3()); + shader.Parameters["screenArea"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight) / Main.GameViewMatrix.Zoom); + shader.Parameters["screenMoveOffset"].SetValue(Main.screenPosition - Main.screenLastPosition); + shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition); + shader.Parameters["renderTargetArea"].SetValue(new Vector2(backgroundTargets[i].Width, backgroundTargets[i].Height)); + shader.Parameters["invertedScreen"].SetValue(Main.LocalPlayer.gravDir == -1f); + shader.Parameters["upscaleFactor"].SetValue(Vector2.One); + shader.Parameters["generalBackgroundOffset"].SetValue(Vector2.Zero); + + // Prepare the background texture for loading. + Main.graphics.GraphicsDevice.Textures[1] = backgroundTexture; + shader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size()); + + // Do any optional shader operations prior to applying the shader. + particleSet.PrepareOptionalShaderData(shader, i); + + // Apply the shader. This is what is used to connect separated blobs together. + shader.CurrentTechnique.Passes[0].Apply(); + + // And draw the particle set's render target with said shader. + Main.spriteBatch.Draw(backgroundTargets[i], Vector2.Zero, Color.White); + } + + Main.spriteBatch.End(); + + if (needsRestartAtEnd) + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } + } + + /// + /// Obtains the instance from a given if it is a . + /// + /// The type to check. + internal static FusableParticleRenderCollection GetParticleRenderCollectionByType(Type type) + { + return ParticleSets.First(s => s.ParticleSet.GetType() == type); + } + + /// + /// Obtains the cached singleton instance of a given . + /// + /// The type to check. + public static T GetParticleSetByType() where T : BaseFusableParticleSet + { + return ParticleSets.First(s => s.ParticleSet.GetType() == typeof(T)).ParticleSet as T; + } + } +} diff --git a/Particles/FusableParticleRenderLayer.cs b/Particles/FusableParticleRenderLayer.cs new file mode 100644 index 0000000000..d208264b7c --- /dev/null +++ b/Particles/FusableParticleRenderLayer.cs @@ -0,0 +1,11 @@ +namespace CalamityMod.Particles +{ + // The order of entries in this enumeration are in line with draw order + // e.g. the first entry is the first drawn thing, the last entry is the last drawn thing. + public enum FusableParticleRenderLayer + { + OverNPCsBeforeProjectiles, + OverPlayers, + OverWater + } +} diff --git a/Particles/GruesomeEminenceParticleSet.cs b/Particles/GruesomeEminenceParticleSet.cs new file mode 100644 index 0000000000..7410dc2d7c --- /dev/null +++ b/Particles/GruesomeEminenceParticleSet.cs @@ -0,0 +1,100 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class GruesomeEminenceParticleSet : BaseFusableParticleSet + { + public override float BorderSize => 3f; + public override bool BorderShouldBeSolid => false; + public override Color BorderColor => Color.Lerp(Color.Fuchsia, Color.Black, 0.55f) * 0.85f; + public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; + + // Cached for efficiency when loading textures and shaders. + private static readonly List _backgroundShaders = new List() + { + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + }; + public override List BackgroundShaders => _backgroundShaders; + public override List BackgroundTextures => new List() + { + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer1"), + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer2"), + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer3"), + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer4"), + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer5"), + }; + public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) + { + Particles.Add(new FusableParticle(center, sizeStrength)); + return Particles.Last(); + } + + public override void UpdateBehavior(FusableParticle particle) + { + particle.Size = MathHelper.Clamp(particle.Size - 2.5f, 0f, 400f) * 0.97f; + } + + public override void PrepareOptionalShaderData(Effect effect, int index) + { + switch (index) + { + // Background. + case 0: + Vector2 offset = Vector2.UnitX * Main.GlobalTime * 0.03f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; + + // Gaseous skulls. + case 1: + offset = Vector2.One * (float)Math.Cos(Main.GlobalTime * 0.041f) * 2f; + offset = offset.RotatedBy((float)Math.Cos(Main.GlobalTime * 0.08f) * 0.97f); + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; + + // Spooky faces 1. + case 2: + offset = (Main.GlobalTime * 2.02f).ToRotationVector2() * 0.036f; + offset.Y += (float)Math.Cos(Main.GlobalTime * 0.161f) * 0.5f + 0.5f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; + + // Spooky faces 2. + case 3: + offset = Vector2.UnitX * Main.GlobalTime * -0.04f + (Main.GlobalTime * 1.89f).ToRotationVector2() * 0.03f; + offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTime * 0.187f, Main.GlobalTime * 0.193f, 2, 466920161) * 0.025f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; + + // Spooky faces 3. + case 4: + offset = Vector2.UnitX * Main.GlobalTime * 0.037f + (Main.GlobalTime * 1.77f).ToRotationVector2() * 0.04725f; + offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTime * 0.187f, Main.GlobalTime * 0.193f, 2, 577215664) * 0.05f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; + } + } + + public override void DrawParticles() + { + Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); + foreach (FusableParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = fusableParticleBase.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); + Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Particles/RancorGroundLavaParticleSet.cs b/Particles/RancorGroundLavaParticleSet.cs new file mode 100644 index 0000000000..96fa1b6cc0 --- /dev/null +++ b/Particles/RancorGroundLavaParticleSet.cs @@ -0,0 +1,52 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class RancorGroundLavaParticleSet : BaseFusableParticleSet + { + public override float BorderSize => 18f; + public override bool BorderShouldBeSolid => false; + public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; + public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverWater; + + public override List BackgroundShaders => new List() + { + GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, + }; + public override List BackgroundTextures => new List() + { + ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"), + }; + public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) + { + Particles.Add(new FusableParticle(center, sizeStrength)); + return Particles.Last(); + } + + public override void UpdateBehavior(FusableParticle particle) + { + particle.Size = MathHelper.Clamp(particle.Size - 0.15f, 0f, 200f) * 0.997f; + if (particle.Size < 20f) + particle.Size = particle.Size * 0.95f - 0.9f; + } + + public override void DrawParticles() + { + Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); + foreach (FusableParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = fusableParticleBase.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size() * new Vector2(1f, 0.5f); + Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.InverseLerp(120f, 135f, particle.Size, true) * 0.1f) * 1.4f; + Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Particles/RancorLavaParticleSet.cs b/Particles/RancorLavaParticleSet.cs new file mode 100644 index 0000000000..c190b256d6 --- /dev/null +++ b/Particles/RancorLavaParticleSet.cs @@ -0,0 +1,51 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class RancorLavaParticleSet : BaseFusableParticleSet + { + public override float BorderSize => 18f; + public override bool BorderShouldBeSolid => false; + public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; + public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; + + public override List BackgroundShaders => new List() + { + GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, + }; + public override List BackgroundTextures => new List() + { + ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"), + }; + public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) + { + Particles.Add(new FusableParticle(center, sizeStrength)); + return Particles.Last(); + } + + public override void UpdateBehavior(FusableParticle particle) + { + particle.Size = MathHelper.Clamp(particle.Size - 0.24f, 0f, 200f) * 0.9956f; + if (particle.Size < 15f) + particle.Size = particle.Size * 0.95f - 0.9f; + } + + public override void DrawParticles() + { + Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); + foreach (FusableParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = fusableParticleBase.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); + Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, BorderColor * 1.2f, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Projectiles/Boss/AresDeathBeamStart.cs b/Projectiles/Boss/AresDeathBeamStart.cs index 00671796de..3ca322c9b7 100644 --- a/Projectiles/Boss/AresDeathBeamStart.cs +++ b/Projectiles/Boss/AresDeathBeamStart.cs @@ -8,6 +8,7 @@ using System; using System.IO; using System.Linq; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss @@ -211,7 +212,13 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.OnFire, 360); + target.AddBuff(BuffID.Frostburn, 360); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { target.Calamity().lastProjectileHit = projectile; } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 5736414aa1..5c4f436b2a 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -235,6 +235,32 @@ namespace CalamityMod.Projectiles projectile.extraUpdates = 1; break; + case ProjectileID.CorruptYoyo: + ProjectileID.Sets.YoyosMaximumRange[projectile.type] = 190f; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + break; + + case ProjectileID.Valor: + ProjectileID.Sets.YoyosMaximumRange[projectile.type] = 384f; + ProjectileID.Sets.YoyosTopSpeed[projectile.type] = 16f; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + break; + + case ProjectileID.JungleYoyo: + ProjectileID.Sets.YoyosTopSpeed[projectile.type] = 14f; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + break; + + case ProjectileID.Code1: + ProjectileID.Sets.YoyosMaximumRange[projectile.type] = 240f; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + break; + case ProjectileID.BlueMoon: case ProjectileID.Flamarang: projectile.extraUpdates = 2; @@ -291,16 +317,12 @@ namespace CalamityMod.Projectiles break; case ProjectileID.WoodYoyo: - case ProjectileID.CorruptYoyo: case ProjectileID.CrimsonYoyo: - case ProjectileID.JungleYoyo: case ProjectileID.RedsYoyo: case ProjectileID.ValkyrieYoyo: case ProjectileID.Kraken: case ProjectileID.Rally: - case ProjectileID.Code1: case ProjectileID.Code2: - case ProjectileID.Valor: case ProjectileID.Cascade: case ProjectileID.Chik: case ProjectileID.FormatC: diff --git a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs index cca960c8ab..ad16e2d76b 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs @@ -91,7 +91,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // Angles are wrapped to be 0 to 2pi instead of -pi to pi for convenience with absolute values. float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; float oldRotationAdjusted = MathHelper.WrapAngle(projectile.oldRot[1]) + MathHelper.Pi; - float deltaAngle = Math.Abs(rotationAdjusted - oldRotationAdjusted); + float deltaAngle = Math.Abs(MathHelper.WrapAngle(rotationAdjusted - oldRotationAdjusted)); // Frame 1 effect: Prevent the sword from instantly firing a sword beam. if (projectile.localAI[1] == 0f) @@ -285,7 +285,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; float oldRotationAdjusted = MathHelper.WrapAngle(projectile.oldRot[1]) + MathHelper.Pi; - deltaAngle = Math.Abs(rotationAdjusted - oldRotationAdjusted); + deltaAngle = Math.Abs(MathHelper.WrapAngle(rotationAdjusted - oldRotationAdjusted)); if (deltaAngle < 0.04f) opacity = 0f; @@ -293,7 +293,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return Color.Lerp(Color.Red, Color.PaleVioletRed * completionRatio, MathHelper.Clamp(completionRatio * 0.8f, 0f, 1f)) * opacity; } - internal float WidthFunction(float completionRatio) => (IsSmall ? 101f : 127f) * (1f - completionRatio); + internal float WidthFunction(float completionRatio) => (IsSmall ? 101f : 127f) * (1f - completionRatio) * 0.8f; public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -301,7 +301,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Texture2D hiltTexture = ModContent.GetTexture(Texture); if (IsSmall) bladeTexture = ModContent.GetTexture("CalamityMod/Projectiles/DraedonsArsenal/PhaseslayerBladeSmall"); - Vector2 bladeOffset = projectile.rotation.ToRotationVector2() * (IsSmall ? 90f : 132f) * projectile.scale; + + float bladeLength = (IsSmall ? 90f : 132f) * projectile.scale; + Vector2 bladeOffset = projectile.rotation.ToRotationVector2() * bladeLength; Vector2 origin = bladeTexture.Size() * 0.5f; origin /= IsSmall ? new Vector2(1f, 3f) : new Vector2(3f, 7f); @@ -313,26 +315,22 @@ namespace CalamityMod.Projectiles.DraedonsArsenal GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/SwordSlashTexture")); Player player = Main.player[projectile.owner]; - List positions = new List(); + float swingAngularDirection = Math.Sign(MathHelper.WrapAngle(projectile.rotation - projectile.oldRot[1])); - float swingAngularDirection = Math.Sign(projectile.rotation - projectile.oldRot[1]); - projectile.oldRot[0] += swingAngularDirection * 0.1f; - for (int i = 0; i < projectile.oldPos.Length; i++) + Vector2[] drawPoints = new Vector2[projectile.oldPos.Length]; + Vector2 perpendicularDirection = bladeOffset.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2); + for (int i = 0; i < drawPoints.Length; i++) { if (projectile.oldPos[i] == Vector2.Zero) continue; - // Skip over any very points going in the wrong direction, to prevent "nets" from the primitive. - if (i > 1 && Math.Sign(projectile.oldRot[i - 1] - projectile.oldRot[i]) != swingAngularDirection) - continue; - - Vector2 position = projectile.position + projectile.oldRot[i].ToRotationVector2() * (IsSmall ? 90f : 132f) * projectile.scale; - - positions.Add(position); + float swingFactor = MathHelper.Min(1f, AngularDamageFactor); + float offsetFactor = i * -swingAngularDirection * MathHelper.Min(0.8f, swingFactor) * 100f; + float angularTurn = i * swingAngularDirection * -0.09f; + drawPoints[i] = projectile.position + perpendicularDirection.RotatedBy(angularTurn) * offsetFactor; } - projectile.oldRot[0] -= swingAngularDirection * 0.1f; - TrailDrawer.Draw(positions, projectile.Size * 0.5f - Main.screenPosition, 50); + TrailDrawer.Draw(drawPoints, projectile.Size * 0.5f + bladeOffset - Main.screenPosition, 50); spriteBatch.Draw(bladeTexture, projectile.Center + bladeOffset - Main.screenPosition, frame, Color.White, projectile.rotation + MathHelper.PiOver2, origin, projectile.scale, SpriteEffects.None, 0f); spriteBatch.Draw(hiltTexture, projectile.Center - Main.screenPosition, null, lightColor, projectile.rotation + MathHelper.PiOver2, hiltTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); diff --git a/Projectiles/Healing/CactusHealOrb.cs b/Projectiles/Healing/CactusHealOrb.cs index 72dbf6c96e..73fc1f8bcb 100644 --- a/Projectiles/Healing/CactusHealOrb.cs +++ b/Projectiles/Healing/CactusHealOrb.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Healing { projectile.velocity.Y *= 0.98f; - projectile.HealingProjectile(15, projectile.owner, 12f, 15f); + projectile.HealingProjectile(15, projectile.owner, 12f, 15f, false); int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 200, 0), 1.5f); Dust dust = Main.dust[dusty]; dust.noGravity = true; diff --git a/Projectiles/Magic/EventHorizonStar.cs b/Projectiles/Magic/EventHorizonStar.cs index 5b030cb318..91dcd7fa77 100644 --- a/Projectiles/Magic/EventHorizonStar.cs +++ b/Projectiles/Magic/EventHorizonStar.cs @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Magic if (projectile.localAI[0] >= 100) { Vector2 center = projectile.Center; - float homingRange = 250f; + float homingRange = 325f; bool homeIn = false; float inertia = 25f; float homingSpeed = 23f; diff --git a/Projectiles/Magic/GruesomeEminenceHoldout.cs b/Projectiles/Magic/GruesomeEminenceHoldout.cs new file mode 100644 index 0000000000..523fb0f8e0 --- /dev/null +++ b/Projectiles/Magic/GruesomeEminenceHoldout.cs @@ -0,0 +1,88 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class GruesomeEminenceHoldout : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public override void SetStaticDefaults() => DisplayName.SetDefault("Gruesome Eminence"); + + public override void SetDefaults() + { + projectile.width = 26; + projectile.height = 32; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + StickToOwner(); + + // Die if the owner is no longer channeling the item. + int congregationType = ModContent.ProjectileType(); + if (!Owner.channel) + projectile.Kill(); + + // Summon a congregation of spirits if the player doesn't have one already. + else if (Owner.ownedProjectileCounts[congregationType] <= 0) + { + if (Main.myPlayer == projectile.owner) + { + Vector2 spiritSpawnPosition = projectile.Center - Vector2.UnitY * 12f; + Projectile.NewProjectile(spiritSpawnPosition, -Vector2.UnitY * 10f, congregationType, projectile.damage, projectile.knockBack, projectile.owner); + } + Main.PlaySound(SoundID.DD2_EtherianPortalOpen, projectile.Center); + } + + // Emit light. + Lighting.AddLight(projectile.Center, 0.13f, 0f, 0.05f); + + // Also emit dust. + Dust ghostlyMagic = Dust.NewDustPerfect(projectile.Top + Main.rand.NextVector2Circular(5f, 5f) + Vector2.UnitX * projectile.direction * 7f, 267); + ghostlyMagic.color = Color.Lerp(Color.DarkRed, Color.Fuchsia, Main.rand.NextFloat(0.7f)); + ghostlyMagic.color = Color.Lerp(ghostlyMagic.color, Color.Black, 0.5f); + ghostlyMagic.velocity = -Vector2.UnitY.RotatedBy(0.44f) * Main.rand.NextFloat(0.8f, 2f); + ghostlyMagic.noGravity = true; + if (Main.rand.NextBool(8)) + ghostlyMagic.velocity *= 1.7f; + } + + public void StickToOwner() + { + projectile.rotation = 0f; + projectile.spriteDirection = projectile.direction; + projectile.timeLeft = 2; + Owner.ChangeDir(projectile.direction); + + Vector2 centerDelta = Main.OffsetsPlayerOnhand[Owner.bodyFrame.Y / 56] * 2f; + if (Owner.direction != 1) + centerDelta.X = Owner.bodyFrame.Width - centerDelta.X; + + if (Owner.gravDir != 1f) + centerDelta.Y = Owner.bodyFrame.Height - centerDelta.Y; + + if (Owner.heldProj == -1) + Owner.heldProj = projectile.whoAmI; + centerDelta -= new Vector2(Owner.bodyFrame.Width - Owner.width, Owner.bodyFrame.Height - 42) / 2f; + projectile.Center = Owner.RotatedRelativePoint(Owner.position + centerDelta, true) - projectile.velocity; + if (projectile.spriteDirection == 1) + projectile.position.X += 4f; + + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemLocation = projectile.Center; + Owner.itemRotation = MathHelper.PiOver4 * -projectile.direction; + } + + // This is just a casting item. It should not do contact damage. + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Magic/GruesomeEminenceHoldout.png b/Projectiles/Magic/GruesomeEminenceHoldout.png new file mode 100644 index 0000000000..a0c114f03e Binary files /dev/null and b/Projectiles/Magic/GruesomeEminenceHoldout.png differ diff --git a/Projectiles/Magic/RancorArm.cs b/Projectiles/Magic/RancorArm.cs new file mode 100644 index 0000000000..f2a8525f2e --- /dev/null +++ b/Projectiles/Magic/RancorArm.cs @@ -0,0 +1,165 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.World.Generation; + +namespace CalamityMod.Projectiles.Magic +{ + public class RancorArm : ModProjectile + { + public Vector2 IdealPosition; + public Player Owner => Main.player[projectile.owner]; + public float RotationDirection => projectile.rotation + projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Vengeful Arm"); + Main.projFrames[projectile.type] = 6; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 4; + projectile.friendly = true; + projectile.hostile = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.timeLeft = 240; + projectile.hide = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 12; + projectile.ignoreWater = true; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.frame); + writer.Write(projectile.rotation); + writer.WriteVector2(IdealPosition); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.frame = reader.ReadInt32(); + projectile.rotation = reader.ReadSingle(); + IdealPosition = reader.ReadVector2(); + } + + public override void AI() + { + // Decide a frame to use and adjust the hitbox based on it. + if (projectile.localAI[0] == 0f) + { + // Play a wraith death sound. + Main.PlaySound(SoundID.NPCDeath52, projectile.Center); + + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + + Vector2 newSize; + switch (projectile.frame) + { + case 0: + newSize = new Vector2(16f, 48f); + break; + case 1: + newSize = new Vector2(28f, 120f); + break; + case 2: + newSize = new Vector2(30f, 82f); + break; + case 3: + newSize = new Vector2(22f, 90f); + break; + case 4: + newSize = new Vector2(36f, 110f); + break; + case 5: + default: + newSize = new Vector2(28f, 50f); + break; + } + + // Find the lowest point. + Vector2 idealCenter = projectile.Center; + if (WorldUtils.Find(idealCenter.ToTileCoordinates(), Searches.Chain(new Searches.Down(25), new CustomConditions.SolidOrPlatform()), out Point result)) + { + idealCenter = result.ToWorldCoordinates(); + } + idealCenter.Y += 36f; + + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)newSize.X, (int)newSize.Y); + + // Sometimes use a slanted rotation. + if (Main.rand.NextBool(3)) + projectile.rotation = Main.rand.NextFloatDirection() * 0.3f; + + IdealPosition = idealCenter; + projectile.localAI[0] = 1f; + projectile.netUpdate = true; + } + + // Rise from underneath the ideal position and fade in. + // At the end of the projectile's lifetime the arm sinks back into the ground and withers away. + float descendCompletion = Utils.InverseLerp(0f, 24f, projectile.timeLeft, true); + float riseCompletion = Utils.InverseLerp(0f, 30f, Time, true); + float heightOffset = -58f; + if (projectile.height > 90f) + heightOffset += 22f; + + projectile.Bottom = IdealPosition + Vector2.UnitY.RotatedBy(RotationDirection) * ((1f - riseCompletion * descendCompletion) * 64f + heightOffset); + projectile.Opacity = (float)Math.Pow(riseCompletion, 2.4) * descendCompletion; + projectile.scale = descendCompletion; + + Time++; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float _ = 0f; + Vector2 bottom = projectile.Bottom; + Vector2 top = projectile.Bottom - Vector2.UnitY.RotatedBy(RotationDirection) * projectile.height; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), bottom, top, projectile.width * projectile.scale, ref _); + } + + public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) + { + drawCacheProjsBehindNPCsAndTiles.Add(index); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + damage = Main.rand.Next(80, 90); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + Vector2 drawPosition = projectile.Center - Main.screenPosition; + Color light = Lighting.GetColor((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16); + Color drawColor = light * projectile.Opacity; + Color fadedColor = Color.Red * projectile.Opacity * projectile.scale * 0.4f; + fadedColor.A = 0; + + Vector2 scale = new Vector2(projectile.scale, 1f); + float afterimageOffset = projectile.Opacity * projectile.scale * 5f; + + for (int i = 0; i < 6; i++) + { + Vector2 afterimageOffsetVector = (MathHelper.TwoPi * i / 6f).ToRotationVector2() * afterimageOffset; + spriteBatch.Draw(texture, drawPosition + afterimageOffsetVector, frame, fadedColor, RotationDirection, origin, scale, SpriteEffects.None, 0f); + } + + spriteBatch.Draw(texture, drawPosition, frame, drawColor, RotationDirection, origin, scale, SpriteEffects.None, 0f); + return false; + } + } +} diff --git a/Projectiles/Magic/RancorArm.png b/Projectiles/Magic/RancorArm.png new file mode 100644 index 0000000000..22668af8ef Binary files /dev/null and b/Projectiles/Magic/RancorArm.png differ diff --git a/Projectiles/Magic/RancorFog.cs b/Projectiles/Magic/RancorFog.cs new file mode 100644 index 0000000000..ab1bc1c460 --- /dev/null +++ b/Projectiles/Magic/RancorFog.cs @@ -0,0 +1,66 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RancorFog : ModProjectile + { + public ref float LightPower => ref projectile.ai[0]; + public override void SetStaticDefaults() => DisplayName.SetDefault("Fog"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 184; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.timeLeft = 210; + projectile.hide = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + // Decide scale and initial rotation on the first frame this projectile exists. + if (projectile.localAI[0] == 0f) + { + projectile.scale = Main.rand.NextFloat(1f, 1.7f); + projectile.rotation = Main.rand.NextFloat(MathHelper.TwoPi); + projectile.localAI[0] = 1f; + } + + // Calculate light power. This checks below the position of the fog to check if this fog is underground. + // Without this, it may render over the fullblack that the game renders for obscured tiles. + float lightPowerBelow = Lighting.GetColor((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); + LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); + projectile.Opacity = Utils.InverseLerp(210f, 195f, projectile.timeLeft, true) * Utils.InverseLerp(0f, 90f, projectile.timeLeft, true); + projectile.rotation += projectile.velocity.X * 0.004f; + projectile.velocity *= 0.985f; + } + + public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) + { + drawCacheProjsBehindNPCsAndTiles.Add(index); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 origin = texture.Size() * 0.5f; + Vector2 drawPosition = projectile.Center - Main.screenPosition; + float opacity = Utils.InverseLerp(0f, 0.08f, LightPower, true) * projectile.Opacity * 0.5f; + Color drawColor = new Color(236, 0, 68) * opacity; + Vector2 scale = projectile.Size / texture.Size() * projectile.scale; + spriteBatch.Draw(texture, drawPosition, null, drawColor, projectile.rotation, origin, scale, SpriteEffects.None, 0f); + + spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; + } + } +} diff --git a/Projectiles/Magic/RancorFog.png b/Projectiles/Magic/RancorFog.png new file mode 100644 index 0000000000..eefd134f10 Binary files /dev/null and b/Projectiles/Magic/RancorFog.png differ diff --git a/Projectiles/Magic/RancorHoldout.cs b/Projectiles/Magic/RancorHoldout.cs new file mode 100644 index 0000000000..38cb815bb4 --- /dev/null +++ b/Projectiles/Magic/RancorHoldout.cs @@ -0,0 +1,77 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RancorHoldout : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public ref float Time => ref projectile.ai[0]; + public const int ManaConsumeRate = 12; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rancor"); + Main.projFrames[projectile.type] = 16; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 34; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + projectile.hide = true; + } + + public override void AI() + { + projectile.Center = Owner.Center + Vector2.UnitX * Owner.direction * 8f; + + // CheckMana returns true if the mana cost can be paid. If mana isn't consumed this frame, the CheckMana short-circuits out of being evaluated. + bool allowContinuedUse = Time % ManaConsumeRate != ManaConsumeRate - 1f || Owner.CheckMana(Owner.ActiveItem(), -1, true, false); + bool bookStillInUse = Owner.channel && allowContinuedUse && !Owner.noItems && !Owner.CCed; + + // If the owner is no longer able to hold the book, kill it. + if (!bookStillInUse) + { + projectile.Kill(); + return; + } + + Time++; + + // Cast the magic circle on the first frame. + if (Main.myPlayer == projectile.owner && Time == 1f) + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + + // Handle frames. + projectile.frameCounter++; + if (projectile.frameCounter >= 4) + { + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + projectile.frameCounter = 0; + } + + AdjustPlayerHoldValues(); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => false; + + public void AdjustPlayerHoldValues() + { + projectile.spriteDirection = projectile.direction = Owner.direction; + projectile.timeLeft = 2; + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = 0f; + } + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Magic/RancorHoldout.png b/Projectiles/Magic/RancorHoldout.png new file mode 100644 index 0000000000..43686adfda Binary files /dev/null and b/Projectiles/Magic/RancorHoldout.png differ diff --git a/Projectiles/Magic/RancorLargeCinder.cs b/Projectiles/Magic/RancorLargeCinder.cs new file mode 100644 index 0000000000..8baff72124 --- /dev/null +++ b/Projectiles/Magic/RancorLargeCinder.cs @@ -0,0 +1,59 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RancorLargeCinder : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public ref float Lifetime => ref projectile.ai[1]; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetStaticDefaults() => DisplayName.SetDefault("Lava Cinder"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 36; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.friendly = true; + projectile.hostile = true; + projectile.timeLeft = 300; + projectile.ignoreWater = true; + } + + public override void AI() + { + // Make a decision for the lifetime for the cinder if one has not yet been made. + if (Lifetime == 0f) + { + Lifetime = Main.rand.Next(45, 150); + projectile.netUpdate = true; + } + + // Calculate the scale of the cinder. + else + { + projectile.scale = Utils.InverseLerp(0f, 20f, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - 20f, Time, true); + projectile.scale *= MathHelper.Lerp(0.5f, 1f, projectile.identity % 6f / 6f); + } + + // Fall down. + projectile.velocity.Y += 0.04f; + + // Create lava particles. + FusableParticleManager.GetParticleSetByType().SpawnParticle(projectile.Center + Main.rand.NextVector2Circular(6f, 6f), projectile.scale * 36f); + + Time++; + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + damage = Main.rand.Next(80, 90); + } + + public override Color? GetAlpha(Color lightColor) => Color.White * projectile.Opacity; + } +} diff --git a/Projectiles/Magic/RancorLaserbeam.cs b/Projectiles/Magic/RancorLaserbeam.cs new file mode 100644 index 0000000000..c157e31b61 --- /dev/null +++ b/Projectiles/Magic/RancorLaserbeam.cs @@ -0,0 +1,192 @@ +using CalamityMod.Particles; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; +using Terraria.World.Generation; + +namespace CalamityMod.Projectiles.Magic +{ + public class RancorLaserbeam : ModProjectile + { + public PrimitiveTrail RayDrawer = null; + public Player Owner => Main.player[projectile.owner]; + public Projectile MagicCircle + { + get + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].identity != projectile.ai[0] || !Main.projectile[i].active || Main.projectile[i].owner != projectile.owner) + continue; + + return Main.projectile[i]; + } + return null; + } + } + public ref float LaserLength => ref projectile.ai[1]; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public const float MaxLaserLength = 3330f; + + public override void SetStaticDefaults() => DisplayName.SetDefault("The Angy Beam"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 32; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 5; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.hide = true; + } + + public override void AI() + { + // If the owner is no longer able to cast the beam, kill it. + if (!Owner.channel || Owner.noItems || Owner.CCed || MagicCircle is null) + { + projectile.Kill(); + return; + } + + // Grow bigger up to a point. + projectile.scale = MathHelper.Clamp(projectile.scale + 0.15f, 0.05f, 2f); + + // Decide where to position the laserbeam. + Vector2 circlePointDirection = projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction); + projectile.Center = MagicCircle.Center + projectile.velocity * projectile.scale * -12f + Owner.velocity; + + // Update the laser length. + float[] laserLengthSamplePoints = new float[24]; + Collision.LaserScan(projectile.Center, projectile.velocity, projectile.scale * 8f, MaxLaserLength, laserLengthSamplePoints); + LaserLength = laserLengthSamplePoints.Average(); + + // Update aim. + UpdateAim(); + + // Adjust damage every frame. This is necessary to ensure that mana sickness and such are applied. + projectile.damage = (int)(MagicCircle.damage * Owner.MagicDamage()); + + // Create arms on surfaces. + if (Main.myPlayer == projectile.owner && Main.rand.NextBool(8)) + CreateArmsOnSurfaces(); + + // Create hit effects at the end of the beam. + if (Main.myPlayer == projectile.owner) + CreateTileHitEffects(); + + // Make the beam cast light along its length. The brightness of the light is reliant on the scale of the beam. + DelegateMethods.v3_1 = Color.DarkViolet.ToVector3() * projectile.scale * 0.4f; + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * LaserLength, projectile.width * projectile.scale, DelegateMethods.CastLight); + } + + public void UpdateAim() + { + // Only execute the aiming code for the owner. + if (Main.myPlayer != projectile.owner) + return; + + Vector2 newAimDirection = MagicCircle.velocity.SafeNormalize(Vector2.UnitY); + + // Sync if the direction is different from the old one. + // Spam caps are ignored due to the frequency of this happening. + if (newAimDirection != projectile.velocity) + { + projectile.netUpdate = true; + projectile.netSpam = 0; + } + + projectile.velocity = newAimDirection; + } + + public void CreateArmsOnSurfaces() + { + Vector2 endOfLaser = projectile.Center + projectile.velocity * LaserLength + Main.rand.NextVector2Circular(80f, 8f); + Vector2 idealCenter = endOfLaser; + if (WorldUtils.Find(idealCenter.ToTileCoordinates(), Searches.Chain(new Searches.Down(5), new CustomConditions.SolidOrPlatform()), out Point result)) + { + idealCenter = result.ToWorldCoordinates(); + } + Point endOfLaserTileCoords = idealCenter.ToTileCoordinates(); + Tile endTile = CalamityUtils.ParanoidTileRetrieval(endOfLaserTileCoords.X, endOfLaserTileCoords.Y); + + if (endTile.nactive() && (Main.tileSolid[endTile.type] || Main.tileSolidTop[endTile.type]) && !endTile.halfBrick() && endTile.slope() == 0) + { + Vector2 armSpawnPosition = endOfLaserTileCoords.ToWorldCoordinates(); + Projectile.NewProjectile(armSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), projectile.damage * 2 / 3, 0f, projectile.owner); + } + } + + public void CreateTileHitEffects() + { + Vector2 endOfLaser = projectile.Center + projectile.velocity * (LaserLength - Main.rand.NextFloat(12f, 72f)); + Projectile.NewProjectile(endOfLaser, Main.rand.NextVector2Circular(4f, 8f), ModContent.ProjectileType(), 0, 0f, projectile.owner); + + if (Main.rand.NextBool(2)) + { + int type = ModContent.ProjectileType(); + int damage = 0; + float cinderSpeed = Main.rand.NextFloat(2f, 6f); + if (Main.rand.NextBool(11)) + { + type = ModContent.ProjectileType(); + damage = projectile.damage / 3; + cinderSpeed *= 1.2f; + } + Vector2 cinderVelocity = Vector2.Lerp(-projectile.velocity, -Vector2.UnitY, 0.45f).RotatedByRandom(0.72f) * cinderSpeed; + Projectile.NewProjectile(endOfLaser, cinderVelocity, type, damage, 0f, projectile.owner); + } + + FusableParticleManager.GetParticleSetByType().SpawnParticle(endOfLaser + Main.rand.NextVector2Circular(10f, 10f) + projectile.velocity * 40f, 135f); + } + + private float PrimitiveWidthFunction(float completionRatio) => projectile.scale * 20f; + + private Color PrimitiveColorFunction(float completionRatio) + { + Color vibrantColor = Color.Lerp(Color.Blue, Color.Red, (float)Math.Cos(Main.GlobalTime * 0.67f - completionRatio / LaserLength * 29f) * 0.5f + 0.5f); + float opacity = projectile.Opacity * Utils.InverseLerp(0.97f, 0.9f, completionRatio, true) * + Utils.InverseLerp(0f, MathHelper.Clamp(15f / LaserLength, 0f, 0.5f), completionRatio, true) * + (float)Math.Pow(Utils.InverseLerp(60f, 270f, LaserLength, true), 3D); + return Color.Lerp(vibrantColor, Color.White, 0.5f) * opacity * 2f; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (RayDrawer is null) + RayDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:Flame"]); + + GameShaders.Misc["CalamityMod:Flame"].UseImage("Images/Misc/Perlin"); + + Vector2[] basePoints = new Vector2[12]; + for (int i = 0; i < basePoints.Length; i++) + basePoints[i] = projectile.Center + projectile.velocity * i / (basePoints.Length - 1f) * LaserLength; + + Vector2 overallOffset = projectile.Size * 0.5f - Main.screenPosition; + RayDrawer.Draw(basePoints, overallOffset, 92); + return false; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * LaserLength); + } + + public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) + { + drawCacheProjsOverWiresUI.Add(index); + } + + public override bool ShouldUpdatePosition() => false; + } +} diff --git a/Projectiles/Magic/RancorMagicCircle.cs b/Projectiles/Magic/RancorMagicCircle.cs new file mode 100644 index 0000000000..52e4af83a2 --- /dev/null +++ b/Projectiles/Magic/RancorMagicCircle.cs @@ -0,0 +1,214 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RancorMagicCircle : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public ref float Time => ref projectile.ai[0]; + public ref float PulseLoopSoundSlot => ref projectile.localAI[0]; + public ActiveSound PulseLoopSound => Main.GetActiveSound(SlotId.FromFloat(PulseLoopSoundSlot)); + public float ChargeupCompletion => MathHelper.Clamp(Time / ChargeupTime, 0f, 1f); + public const int ChargeupTime = 240; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Magic Circle"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 114; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + // If the owner is no longer able to cast the circle, kill it. + if (!Owner.channel || Owner.noItems || Owner.CCed) + { + projectile.Kill(); + return; + } + + if (Time >= 1f && Owner.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + { + projectile.Kill(); + return; + } + + // Adjust visual values such as scale and opacity when charging. + AdjustVisualValues(); + + // Update aim. + UpdateAim(); + + // Decide where to position the magic circle. + Vector2 circlePointDirection = projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction); + projectile.Center = Owner.Center + Vector2.UnitX * Owner.direction * 30f + circlePointDirection * projectile.scale * 56f; + + // Adjust the owner's direction. + Owner.ChangeDir(projectile.direction); + + // Do animation stuff. + DoPrettyDustEffects(); + + // Handle charge stuff. + if (Time < ChargeupTime) + HandleChargeEffects(); + + // Create an idle ominous sound once the laser has appeared. + else if (Main.GetActiveSound(SlotId.FromFloat(PulseLoopSoundSlot)) is null) + PulseLoopSoundSlot = Main.PlayTrackedSound(SoundID.DD2_EtherianPortalIdleLoop, projectile.Center).ToFloat(); + + // Make a cast sound effect soon after the circle appears. + if (Time == 15f) + Main.PlaySound(SoundID.Item117, projectile.Center); + + Time++; + } + + public void AdjustVisualValues() + { + projectile.scale = Utils.InverseLerp(0f, 35f, Time, true) * 1.4f; + projectile.Opacity = (float)Math.Pow(projectile.scale / 1.4f, 2D); + projectile.rotation -= MathHelper.ToRadians(projectile.scale * 4f); + } + + public void UpdateAim() + { + // Only execute the aiming code for the owner since Main.MouseWorld is a client-side variable. + if (Main.myPlayer != projectile.owner) + return; + + Vector2 idealDirection = Owner.SafeDirectionTo(Main.MouseWorld, Vector2.UnitX * Owner.direction); + Vector2 newAimDirection = projectile.velocity.MoveTowards(idealDirection, 0.05f); + + // Sync if the direction is different from the old one. + // Spam caps are ignored due to the frequency of this happening. + if (newAimDirection != projectile.velocity) + { + projectile.netUpdate = true; + projectile.netSpam = 0; + } + + projectile.velocity = newAimDirection; + projectile.direction = (projectile.velocity.X > 0f).ToDirectionInt(); + } + + public void DoPrettyDustEffects() + { + int dustSpawnChance = (int)MathHelper.SmoothStep(16f, 4f, ChargeupCompletion); + for (int i = 0; i < 2; i++) + { + if (!Main.rand.NextBool(dustSpawnChance)) + continue; + + float dustSpawnOffsetFactor = Main.rand.NextFloat(projectile.width * 0.375f, projectile.width * 0.485f); + Vector2 dustSpawnOffsetDirection = Main.rand.NextVector2CircularEdge(0.5f, 1f).RotatedBy(projectile.velocity.ToRotation()); + Vector2 dustSpawnOffset = dustSpawnOffsetDirection * dustSpawnOffsetFactor; + Vector2 dustVelocity = (-dustSpawnOffset.SafeNormalize(Vector2.UnitY)).RotatedBy(MathHelper.PiOver2 * Main.rand.NextFloatDirection()); + dustVelocity *= Main.rand.NextFloat(2f, 6f); + + Dust magic = Dust.NewDustPerfect(projectile.Center + dustSpawnOffset, 264); + magic.color = Color.Lerp(Color.Red, Color.Blue, Main.rand.NextFloat()); + magic.velocity = dustVelocity; + magic.scale *= Main.rand.NextFloat(1f, 1.4f); + magic.noLight = true; + magic.noGravity = true; + } + } + + public void HandleChargeEffects() + { + // Create dust that fires parallel to the direction of the circle. + if (Main.rand.NextBool(3)) + { + float dustSpeed = MathHelper.Lerp(3.5f, 8f, ChargeupCompletion) * Main.rand.NextFloat(0.65f, 1f); + float dustSpawnOffsetFactor = Main.rand.NextFloat(projectile.width * 0.375f, projectile.width * 0.485f); + Vector2 dustVelocity = projectile.velocity * dustSpeed; + Vector2 dustSpawnOffsetDirection = Main.rand.NextVector2CircularEdge(0.5f, 1f).RotatedBy(projectile.velocity.ToRotation()); + Vector2 dustSpawnOffset = dustSpawnOffsetDirection * dustSpawnOffsetFactor; + + Dust magic = Dust.NewDustPerfect(projectile.Center + dustSpawnOffset, 264); + magic.color = Color.Lerp(Color.Red, Color.Blue, Main.rand.NextFloat()); + magic.velocity = dustVelocity; + magic.scale *= Main.rand.NextFloat(1f, 1.05f + ChargeupCompletion * 0.55f); + magic.noLight = true; + magic.noGravity = true; + } + + // Create the laser once the charge animation is complete. + if (Time == ChargeupTime - 1f) + { + // Play a laserbeam deathray sound. Should probably be replaced some day + Main.PlaySound(SoundID.Zombie, projectile.Center, 104); + + if (Main.myPlayer == projectile.owner) + Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, projectile.identity); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D outerCircleTexture = ModContent.GetTexture(Texture); + Texture2D outerCircleGlowmask = ModContent.GetTexture(Texture + "Glowmask"); + Texture2D innerCircleTexture = ModContent.GetTexture(Texture + "Inner"); + Texture2D innerCircleGlowmask = ModContent.GetTexture(Texture + "InnerGlowmask"); + Vector2 drawPosition = projectile.Center - Main.screenPosition; + + float directionRotation = projectile.velocity.ToRotation(); + Color startingColor = Color.Red; + Color endingColor = Color.Blue; + + void restartShader(Texture2D texture, float opacity, float circularRotation, BlendState blendMode) + { + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, blendMode, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + CalamityUtils.CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix); + + GameShaders.Misc["CalamityMod:RancorMagicCircle"].UseColor(startingColor); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].UseSecondaryColor(endingColor); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].UseSaturation(directionRotation); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].Shader.Parameters["uDirection"].SetValue((float)projectile.direction); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].Shader.Parameters["uCircularRotation"].SetValue(circularRotation); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].Shader.Parameters["uImageSize0"].SetValue(texture.Size()); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].Shader.Parameters["overallImageSize"].SetValue(outerCircleTexture.Size()); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].Shader.Parameters["uWorldViewProjection"].SetValue(viewMatrix * projectionMatrix); + GameShaders.Misc["CalamityMod:RancorMagicCircle"].Apply(); + } + + restartShader(outerCircleGlowmask, projectile.Opacity, projectile.rotation, BlendState.Additive); + spriteBatch.Draw(outerCircleGlowmask, drawPosition, null, Color.White, 0f, outerCircleGlowmask.Size() * 0.5f, projectile.scale * 1.075f, SpriteEffects.None, 0f); + + restartShader(outerCircleTexture, projectile.Opacity * 0.7f, projectile.rotation, BlendState.AlphaBlend); + spriteBatch.Draw(outerCircleTexture, drawPosition, null, Color.White, 0f, outerCircleTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + + restartShader(innerCircleGlowmask, projectile.Opacity * 0.5f, 0f, BlendState.Additive); + spriteBatch.Draw(innerCircleGlowmask, drawPosition, null, Color.White, 0f, innerCircleGlowmask.Size() * 0.5f, projectile.scale * 1.075f, SpriteEffects.None, 0f); + + restartShader(innerCircleTexture, projectile.Opacity * 0.7f, 0f, BlendState.AlphaBlend); + spriteBatch.Draw(innerCircleTexture, drawPosition, null, Color.White, 0f, innerCircleTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + spriteBatch.ExitShaderRegion(); + + return false; + } + + public override void Kill(int timeLeft) => PulseLoopSound?.Stop(); + + public override bool ShouldUpdatePosition() => false; + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Magic/RancorMagicCircle.png b/Projectiles/Magic/RancorMagicCircle.png new file mode 100644 index 0000000000..df0121cf40 Binary files /dev/null and b/Projectiles/Magic/RancorMagicCircle.png differ diff --git a/Projectiles/Magic/RancorMagicCircleGlowmask.png b/Projectiles/Magic/RancorMagicCircleGlowmask.png new file mode 100644 index 0000000000..6d9061928b Binary files /dev/null and b/Projectiles/Magic/RancorMagicCircleGlowmask.png differ diff --git a/Projectiles/Magic/RancorMagicCircleInner.png b/Projectiles/Magic/RancorMagicCircleInner.png new file mode 100644 index 0000000000..ac1d451541 Binary files /dev/null and b/Projectiles/Magic/RancorMagicCircleInner.png differ diff --git a/Projectiles/Magic/RancorMagicCircleInnerGlowmask.png b/Projectiles/Magic/RancorMagicCircleInnerGlowmask.png new file mode 100644 index 0000000000..bdf0827fcd Binary files /dev/null and b/Projectiles/Magic/RancorMagicCircleInnerGlowmask.png differ diff --git a/Projectiles/Magic/RancorSmallCinder.cs b/Projectiles/Magic/RancorSmallCinder.cs new file mode 100644 index 0000000000..3344d45742 --- /dev/null +++ b/Projectiles/Magic/RancorSmallCinder.cs @@ -0,0 +1,55 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RancorSmallCinder : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public ref float Lifetime => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cinder"); + Main.projFrames[projectile.type] = 3; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 4; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.timeLeft = 300; + projectile.ignoreWater = true; + } + + public override void AI() + { + // Decide a frame to use on the first frame this projectile exists. + if (projectile.localAI[0] == 0f) + { + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + projectile.localAI[0] = 1f; + } + + // Make a decision for the lifetime for the cinder if one has not yet been made. + if (Lifetime == 0f) + { + Lifetime = Main.rand.Next(60, 210); + projectile.netUpdate = true; + } + + // Calculate scale of the cinder. + else + { + projectile.scale = Utils.InverseLerp(0f, 20f, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - 20f, Time, true); + projectile.scale *= MathHelper.Lerp(0.5f, 1f, projectile.identity % 6f / 6f); + } + + Time++; + } + + public override Color? GetAlpha(Color lightColor) => Color.White * projectile.Opacity; + } +} diff --git a/Projectiles/Magic/RancorSmallCinder.png b/Projectiles/Magic/RancorSmallCinder.png new file mode 100644 index 0000000000..9982b677ce Binary files /dev/null and b/Projectiles/Magic/RancorSmallCinder.png differ diff --git a/Projectiles/Magic/SmallSpirit.cs b/Projectiles/Magic/SmallSpirit.cs new file mode 100644 index 0000000000..4a0b5b8997 --- /dev/null +++ b/Projectiles/Magic/SmallSpirit.cs @@ -0,0 +1,128 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class SmallSpirit : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public Projectile ProjectileOwner + { + get + { + int spiritType = ModContent.ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != spiritType || Main.projectile[i].identity != projectile.ai[0] || + Main.projectile[i].owner != projectile.owner) + { + continue; + } + + return Main.projectile[i]; + } + return null; + } + } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Small Angry Spirit"); + Main.projFrames[projectile.type] = 3; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 28; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 360; + } + + public override void AI() + { + float radius = MathHelper.SmoothStep(84f, 44f, (float)Math.Sqrt(1f - projectile.timeLeft / 360f)); + + // Handle frames. + projectile.frameCounter++; + projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type]; + + float maxOpacity = 1f; + + // Fly around towards a target. + Entity target = Owner; + float flySpeed = 8f; + float flyInertia = 54f; + + projectile.hostile = true; + projectile.friendly = false; + if (ProjectileOwner != null && (ProjectileOwner.ModProjectile().CurrentPower > 0.97f || projectile.timeLeft < 95)) + { + projectile.hostile = false; + + radius += 54f; + + target = ProjectileOwner; + flySpeed = 29f; + flyInertia = 5f; + + // Die if close to the owner projectile, effectively being absorbed. + projectile.Center = projectile.Center.MoveTowards(target.Center, 8.5f); + if (projectile.WithinRange(target.Center, 80f)) + projectile.Kill(); + + // Become translucent when returning to the projectile owner. + maxOpacity = 0.4f; + } + + // Die if no valid target exists or the projectile owner is absent. + if (target is null || ProjectileOwner is null || !ProjectileOwner.active) + { + projectile.Kill(); + return; + } + + // If not close to the target, redirect towards them. + if (!projectile.WithinRange(target.Center, 260f)) + { + Vector2 idealVelocity = projectile.SafeDirectionTo(target.Center) * flySpeed; + projectile.velocity = (projectile.velocity * (flyInertia - 1f) + idealVelocity) / flyInertia; + } + + // Otherwise accelerate. + else + projectile.velocity *= 1.01f; + + // Rapidly fade in. + projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.075f, 0f, maxOpacity); + + // Decide rotation. + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + + // Emit particles. + Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Circular(5f, 5f) * radius / 130f; + FusableParticleManager.GetParticleSetByType().SpawnParticle(spawnPosition, radius); + } + + public override Color? GetAlpha(Color lightColor) => Color.White * projectile.Opacity; + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 6; i++) + { + Dust phantoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(12f, 12f), 261); + phantoplasm.color = Color.Lerp(Color.LightPink, Color.Red, Main.rand.NextFloat(0.67f)); + phantoplasm.scale = 1.2f; + phantoplasm.fadeIn = 0.55f; + phantoplasm.noGravity = true; + } + } + } +} diff --git a/Projectiles/Magic/SpiritCongregation.cs b/Projectiles/Magic/SpiritCongregation.cs new file mode 100644 index 0000000000..14dd4dd41e --- /dev/null +++ b/Projectiles/Magic/SpiritCongregation.cs @@ -0,0 +1,342 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class SpiritCongregation : ModProjectile + { + public Vector2 HoverOffset = Vector2.Zero; + public ref float Time => ref projectile.ai[0]; + public ref float BaseDamage => ref projectile.ai[1]; + public ref float DeathCounter => ref projectile.localAI[0]; + public bool WasStrongBefore + { + get => projectile.localAI[1] == 1f; + set => projectile.localAI[1] = value.ToInt(); + } + public Player Owner => Main.player[projectile.owner]; + public float CurrentPower => (float)Math.Pow(Utils.InverseLerp(15f, 840f, Time, true), 4D); + public float CongregationDiameter => MathHelper.SmoothStep(54f, 185f, CurrentPower); + public float MovementSpeed + { + get + { + float movementSpeed = 9f; + + // Make speed gradually build up over time, with growths at certain points. + movementSpeed += MathHelper.SmoothStep(0f, 2.2f, Utils.InverseLerp(0.18f, 0.3f, CurrentPower, true)); + movementSpeed += MathHelper.SmoothStep(0f, 4f, Utils.InverseLerp(0.4f, 0.52f, CurrentPower, true)); + movementSpeed += MathHelper.SmoothStep(0f, 5f, Utils.InverseLerp(0.6f, 0.72f, CurrentPower, true)); + movementSpeed += MathHelper.SmoothStep(0f, 6f, Utils.InverseLerp(0.8f, 0.92f, CurrentPower, true)); + + return movementSpeed; + } + } + public const float LargeMouthPowerLowerBound = 0.62f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spirit Monster"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 108; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.magic = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + projectile.timeLeft = 90000; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(DeathCounter); + writer.WriteVector2(HoverOffset); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + DeathCounter = reader.ReadSingle(); + HoverOffset = reader.ReadVector2(); + } + + public override void AI() + { + // If close to dying slow down and do nothing else. + if (DeathCounter > 0f) + { + DeathCounter++; + if (DeathCounter >= 35f) + projectile.Kill(); + projectile.scale = 1f - DeathCounter / 35f; + projectile.velocity *= 0.98f; + EmitGhostGas(); + return; + } + + if (Main.myPlayer == projectile.owner) + { + // Prepare for death prior to not being channeled. + if (!Owner.channel) + { + DeathCounter = 1f; + projectile.netUpdate = true; + return; + } + + Vector2 previousVelocity = projectile.velocity; + + // If not sufficiently close to the mouse, move towards it. + if (!projectile.WithinRange(Main.MouseWorld, 80f)) + MoveTowardsMouse(); + + // Otherwise slow down to a point. + else if (projectile.velocity.Length() > 4f) + projectile.velocity *= 0.95f; + + // Sync velocity if it changed from what it was before. + if (previousVelocity != projectile.velocity) + { + projectile.netSpam = 0; + projectile.netUpdate = true; + } + } + + // Handle dynamic damage. + if (BaseDamage == 0f) + BaseDamage = projectile.damage; + else + { + float damageBoostFactor = MathHelper.SmoothStep(1f, 3.3f, CurrentPower); + projectile.damage = (int)(BaseDamage * damageBoostFactor); + } + + // Increment the timer on the final extra update. + if (projectile.FinalExtraUpdate()) + Time++; + + // Set the hover offset to a zero vector after enough time has passed and the projectile is powerful/tame enough. + bool tame = CurrentPower > 0.97f; + projectile.hostile = !tame && Time > 75f; + if (tame) + { + if (HoverOffset != Vector2.Zero) + HoverOffset = Vector2.Zero; + } + + // Explode into a burst of spirit dust and gas clouds when a bigger face appears. + if (!WasStrongBefore && CurrentPower > LargeMouthPowerLowerBound) + { + float burstDirectionVariance = 3; + float burstSpeed = 14f; + for (int j = 0; j < 16; j++) + { + burstDirectionVariance += j * 2; + for (int k = 0; k < 40; k++) + { + Dust burstDust = Dust.NewDustPerfect(projectile.Center, 267); + burstDust.scale = Main.rand.NextFloat(1.74f, 2.5f); + burstDust.position += Main.rand.NextVector2Circular(10f, 10f); + burstDust.velocity = Main.rand.NextVector2Square(-burstDirectionVariance, burstDirectionVariance).SafeNormalize(Vector2.UnitY) * burstSpeed; + burstDust.color = Color.Lerp(Color.DarkViolet, Color.Black, Main.rand.NextFloat(0.6f)); + burstDust.noGravity = true; + } + burstSpeed += 1.8f; + } + if (Main.myPlayer == projectile.owner) + { + for (int i = 0; i < 25; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(4f, 4f); + Projectile.NewProjectile(projectile.Center, dustVelocity, ModContent.ProjectileType(), 0, 0f, projectile.owner); + } + } + + Main.PlaySound(SoundID.DD2_BetsyFlyingCircleAttack, projectile.Center); + WasStrongBefore = true; + } + + // Otherwise, if not tame, periodically define a new offset. + // This determines where to fly to and adds unpredictability at first. + else if (Main.myPlayer == projectile.owner && Time % 55f == 54f) + { + float maxHoverOffset = MathHelper.SmoothStep(460f, 0f, CurrentPower); + HoverOffset = Main.rand.NextVector2Unit() * Main.rand.NextFloat(0.6f, 1f) * maxHoverOffset; + projectile.netUpdate = true; + } + + // Release spirits that fly towards the target + if (!tame) + ReleaseSmallSpirits(); + + EmitGhostGas(); + UpdateFrames(); + } + + public void MoveTowardsMouse() + { + // Make inertia become more significant the more power the congregation has, due to growing size. + float inertia = MathHelper.Lerp(18f, 40f, CurrentPower); + + Vector2 directionToMouseOffset = projectile.SafeDirectionTo(Main.MouseWorld + HoverOffset); + Vector2 directionToOwner = projectile.SafeDirectionTo(Owner.Center); + Vector2 idealVelocity = Vector2.Lerp(directionToMouseOffset, directionToOwner, 0.25f) * MovementSpeed; + + // Approach the ideal velocity. + projectile.velocity = projectile.velocity.MoveTowards(idealVelocity, MovementSpeed * 0.04f); + projectile.velocity = (projectile.velocity * (inertia - 1f) + idealVelocity) / inertia; + projectile.rotation = projectile.velocity.ToRotation(); + } + + public void ReleaseSmallSpirits() + { + if (projectile.WithinRange(Owner.Center, 230f) || Time % 45f != 44f) + return; + + Main.PlaySound(SoundID.DD2_EtherianPortalSpawnEnemy, projectile.Center); + if (Main.myPlayer == projectile.owner) + { + Vector2 spiritVelocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(7f, 10f); + Projectile.NewProjectile(projectile.Center, spiritVelocity, ModContent.ProjectileType(), 70, 0f, projectile.owner, projectile.identity); + } + } + + public void EmitGhostGas() + { + float particleSize = CongregationDiameter; + if (projectile.oldPosition != projectile.position && Time > 2f) + particleSize += (projectile.oldPosition - projectile.position).Length() * 4.2f; + + // Place a hard limit on particle sizes. + if (particleSize > 500f) + particleSize = 500f; + + // Make particles shrink when dying. + particleSize *= MathHelper.Lerp(1f, 0.5f, Utils.InverseLerp(0f, 35f, DeathCounter, true)); + + int particleSpawnCount = Main.rand.NextBool(8) ? 3 : 1; + for (int i = 0; i < particleSpawnCount; i++) + { + // Summon a base particle. + Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Circular(1f, 1f) * particleSize / 26f; + FusableParticleManager.GetParticleSetByType().SpawnParticle(spawnPosition, particleSize); + + // And an "ahead" particle that spawns based on current movement. + // This causes the "head" of the overall thing to have bumps when moving. + spawnPosition += projectile.velocity.RotatedByRandom(1.38f) * particleSize / 105f; + FusableParticleManager.GetParticleSetByType().SpawnParticle(spawnPosition, particleSize * 0.4f); + } + + // Release gas projectiles randomly. This does not happen when dying. + if (Main.myPlayer == projectile.owner && Main.rand.NextBool(16) && DeathCounter <= 0f) + { + Vector2 dustVelocity = -projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(1.04f) * 1.5f; + Projectile.NewProjectile(projectile.Center, dustVelocity, ModContent.ProjectileType(), 0, 0f, projectile.owner); + } + } + + public void UpdateFrames() + { + int maxFrame = CurrentPower <= LargeMouthPowerLowerBound ? 6 : 9; + projectile.frameCounter++; + projectile.frame = projectile.frameCounter / 5 % maxFrame; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + int maxFrame = CurrentPower <= LargeMouthPowerLowerBound ? 6 : 9; + Vector2 backgroundOffset = Vector2.UnitX * Main.GlobalTime * maxFrame * 0.03f; + Texture2D texture = Main.projectileTexture[projectile.type]; + Texture2D backTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SpiritCongregationBack"); + Texture2D auraTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SpiritCongregationAura"); + Texture2D backgroundTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer1"); + if (CurrentPower > LargeMouthPowerLowerBound) + { + texture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SpiritCongregationBig"); + backTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SpiritCongregationBackBig"); + auraTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SpiritCongregationAuraBig"); + } + + Effect shader = GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader; + + float offsetFactor = projectile.scale * ((CongregationDiameter - 54f) / 90f + 1.5f); + offsetFactor *= texture.Width / 90f; + Vector2 drawPosition = projectile.Center - Main.screenPosition + projectile.rotation.ToRotationVector2() * offsetFactor * 15f; + Rectangle frame = texture.Frame(1, maxFrame, 0, projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + Color auraColor = Color.Lerp(Color.Fuchsia, Color.Black, 0.55f); + SpriteEffects direction = Math.Cos(projectile.rotation) > 0f ? SpriteEffects.None : SpriteEffects.FlipVertically; + + // Draw the outline aura below everything else. + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); ; + + for (int i = 0; i < 3; i++) + spriteBatch.Draw(auraTexture, drawPosition, frame, auraColor, projectile.rotation, origin, projectile.scale, direction, 0f); + + spriteBatch.ExitShaderRegion(); + + // Draw the back with the specified shader. + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + shader.Parameters["edgeBorderSize"].SetValue(0f); + shader.Parameters["borderShouldBeSolid"].SetValue(FusableParticleManager.GetParticleSetByType().BorderShouldBeSolid); + shader.Parameters["edgeBorderColor"].SetValue(FusableParticleManager.GetParticleSetByType().BorderColor.ToVector3()); + shader.Parameters["screenArea"].SetValue(backTexture.Size() / Main.GameViewMatrix.Zoom); + shader.Parameters["screenMoveOffset"].SetValue(Vector2.Zero); + shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition); + shader.Parameters["renderTargetArea"].SetValue(backTexture.Size()); + shader.Parameters["invertedScreen"].SetValue(Main.LocalPlayer.gravDir == -1f); + shader.Parameters["generalBackgroundOffset"].SetValue(backgroundOffset); + shader.Parameters["uWorldPosition"].SetValue(projectile.position); + shader.Parameters["uRotation"].SetValue(projectile.rotation); + shader.Parameters["uTime"].SetValue(Main.GlobalTime); + shader.Parameters["upscaleFactor"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight) / backTexture.Size() / maxFrame); + + // Prepare the background texture for loading. + Main.graphics.GraphicsDevice.Textures[1] = backgroundTexture; + shader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size()); + + shader.CurrentTechnique.Passes[0].Apply(); + + // Draw the normal texture. + spriteBatch.Draw(backTexture, drawPosition, frame, Color.White, projectile.rotation, origin, projectile.scale, direction, 0f); + spriteBatch.ExitShaderRegion(); + + spriteBatch.Draw(texture, drawPosition, frame, Color.White, projectile.rotation, origin, projectile.scale, direction, 0f); + return false; + } + + // Prevent obsence damage when hitting players. + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + damage = 92; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + for (int i = 0; i < projectile.oldPos.Length; i++) + { + float hitboxRadius = CongregationDiameter * MathHelper.Lerp(0.45f, 0.17f, i / (float)projectile.oldPos.Length); + Vector2 hitboxCircle = Vector2.One * hitboxRadius; + if (CalamityUtils.CircularHitboxCollision(projectile.oldPos[i] + hitboxCircle * 0.5f, hitboxRadius, targetHitbox)) + return true; + } + return false; + } + } +} diff --git a/Projectiles/Magic/SpiritCongregation.png b/Projectiles/Magic/SpiritCongregation.png new file mode 100644 index 0000000000..e8eadfee67 Binary files /dev/null and b/Projectiles/Magic/SpiritCongregation.png differ diff --git a/Projectiles/Magic/SpiritCongregationAura.png b/Projectiles/Magic/SpiritCongregationAura.png new file mode 100644 index 0000000000..71931556d4 Binary files /dev/null and b/Projectiles/Magic/SpiritCongregationAura.png differ diff --git a/Projectiles/Magic/SpiritCongregationAuraBig.png b/Projectiles/Magic/SpiritCongregationAuraBig.png new file mode 100644 index 0000000000..0f1b17a167 Binary files /dev/null and b/Projectiles/Magic/SpiritCongregationAuraBig.png differ diff --git a/Projectiles/Magic/SpiritCongregationBack.png b/Projectiles/Magic/SpiritCongregationBack.png new file mode 100644 index 0000000000..bc2ca885d1 Binary files /dev/null and b/Projectiles/Magic/SpiritCongregationBack.png differ diff --git a/Projectiles/Magic/SpiritCongregationBackBig.png b/Projectiles/Magic/SpiritCongregationBackBig.png new file mode 100644 index 0000000000..578c0408fb Binary files /dev/null and b/Projectiles/Magic/SpiritCongregationBackBig.png differ diff --git a/Projectiles/Magic/SpiritCongregationBig.png b/Projectiles/Magic/SpiritCongregationBig.png new file mode 100644 index 0000000000..6ff88c6805 Binary files /dev/null and b/Projectiles/Magic/SpiritCongregationBig.png differ diff --git a/Projectiles/Magic/SpiritDust.cs b/Projectiles/Magic/SpiritDust.cs new file mode 100644 index 0000000000..652cc57501 --- /dev/null +++ b/Projectiles/Magic/SpiritDust.cs @@ -0,0 +1,31 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class SpiritDust : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Spirit Dust"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 10; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 60; + } + + public override void AI() + { + float radius = MathHelper.SmoothStep(80f, 48f, 1f - projectile.timeLeft / 90f); + Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Circular(5f, 5f) * radius / 130f; + FusableParticleManager.GetParticleSetByType().SpawnParticle(spawnPosition, radius); + } + } +} diff --git a/Projectiles/Magic/T1000Proj.cs b/Projectiles/Magic/T1000Proj.cs index caebb2cf30..ba4cb99c21 100644 --- a/Projectiles/Magic/T1000Proj.cs +++ b/Projectiles/Magic/T1000Proj.cs @@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.Magic projectile.velocity = velocity; int projType = ModContent.ProjectileType(); - float velocityMult = 14f; + float velocityMult = 21f; float randNum = 4f; for (int j = 0; j < 4; j++) { diff --git a/Projectiles/Melee/AmidiasWhirlpool.cs b/Projectiles/Melee/AmidiasWhirlpool.cs index b197c6f61c..1f236e324e 100644 --- a/Projectiles/Melee/AmidiasWhirlpool.cs +++ b/Projectiles/Melee/AmidiasWhirlpool.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Melee int num3; projectile.rotation -= 0.104719758f; Vector2 vector145 = projectile.Center; - float num1015 = 100f; + float num1015 = 150f; bool flag59 = false; int num1016 = 0; if (projectile.ai[1] == 0f) diff --git a/Projectiles/Melee/BallOFuguProj.cs b/Projectiles/Melee/BallOFuguProj.cs index 888441710a..844d7e9498 100644 --- a/Projectiles/Melee/BallOFuguProj.cs +++ b/Projectiles/Melee/BallOFuguProj.cs @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Melee { projectile.alpha = 0; } - if (projectile.ai[1] % 4f == 0f && projectile.owner == Main.myPlayer) + if (projectile.ai[1] % 6f == 0f && projectile.owner == Main.myPlayer) { Vector2 vector63 = projVector * -1f; vector63.Normalize(); diff --git a/Projectiles/Melee/BonebreakerProjectile.cs b/Projectiles/Melee/BonebreakerProjectile.cs index 6020ec3daa..d23ae63938 100644 --- a/Projectiles/Melee/BonebreakerProjectile.cs +++ b/Projectiles/Melee/BonebreakerProjectile.cs @@ -110,7 +110,14 @@ namespace CalamityMod.Projectiles.Melee target.AddBuff(ModContent.BuffType(), 240); } - public override bool? CanHitNPC(NPC target) => projectile.ai[0] != 1f; + public override bool? CanHitNPC(NPC target) + { + if (projectile.ai[0] == 1f) + { + return false; + } + return null; + } public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; } diff --git a/Projectiles/Melee/GalileosPlanet.cs b/Projectiles/Melee/GalileosPlanet.cs index a1d4069b10..306f79c7c6 100644 --- a/Projectiles/Melee/GalileosPlanet.cs +++ b/Projectiles/Melee/GalileosPlanet.cs @@ -22,8 +22,7 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - projectile.width = 42; - projectile.height = 42; + projectile.width = projectile.height = 88; projectile.friendly = true; projectile.ignoreWater = true; projectile.extraUpdates = 1; diff --git a/Projectiles/Melee/Spears/UrchinSpearProjectile.cs b/Projectiles/Melee/Spears/UrchinSpearProjectile.cs index 9401b5637c..d8b664280a 100644 --- a/Projectiles/Melee/Spears/UrchinSpearProjectile.cs +++ b/Projectiles/Melee/Spears/UrchinSpearProjectile.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public override Action EffectBeforeReelback => (proj) => { Projectile.NewProjectile(projectile.Center.X + projectile.velocity.X, projectile.Center.Y + projectile.velocity.Y, - projectile.velocity.X * 1.6f, projectile.velocity.Y * 1.6f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); + projectile.velocity.X * 1.6f, projectile.velocity.Y * 1.6f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); }; public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/Yoyos/OracleYoyo.cs b/Projectiles/Melee/Yoyos/OracleYoyo.cs index 64e6a384b9..553ec8552f 100644 --- a/Projectiles/Melee/Yoyos/OracleYoyo.cs +++ b/Projectiles/Melee/Yoyos/OracleYoyo.cs @@ -142,7 +142,11 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - // Charge up the red lightning aura with every hit + // On hit effects do not apply if no damage was done. + if (damage <= 0) + return; + + // Charge up the red lightning aura with every hit. AuraCharge += ChargePerHit; // Fire Auric orbs every few hits while supercharged. diff --git a/Projectiles/Ranged/ChickenRocket.cs b/Projectiles/Ranged/ChickenRocket.cs index 27fbee1ae4..2416fdedda 100644 --- a/Projectiles/Ranged/ChickenRocket.cs +++ b/Projectiles/Ranged/ChickenRocket.cs @@ -127,7 +127,5 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[d].velocity *= 2f; } } - - } } diff --git a/Projectiles/Ranged/GodSlayerSlugProj.cs b/Projectiles/Ranged/GodSlayerSlugProj.cs index dbbafe9be0..d7cf18da91 100644 --- a/Projectiles/Ranged/GodSlayerSlugProj.cs +++ b/Projectiles/Ranged/GodSlayerSlugProj.cs @@ -55,8 +55,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - // On frame 1, store the original velocity. This is needed for the warp. - if (projectile.timeLeft == Lifetime) + // Store the original velocity if it has yet to be initialized. This is needed for the warp. + if (projectile.localAI[0] == 0f) projectile.localAI[0] = projectile.velocity.Length(); // Rapidly fade into visibility. @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.tileCollide = false; // Reduce damage, but remove piercing. Reset local iframes so the bullet, turned blue, may always strike again. - projectile.damage = (int)(0.3f * projectile.damage); + projectile.damage = (int)(0.28f * projectile.damage); projectile.penetrate = 1; for (int i = 0; i < Main.maxNPCs; i++) projectile.localNPCImmunity[i] = 0; diff --git a/Projectiles/Rogue/AlphaVirusProjectile.cs b/Projectiles/Rogue/AlphaVirusProjectile.cs index a0ce21a17e..9803143626 100644 --- a/Projectiles/Rogue/AlphaVirusProjectile.cs +++ b/Projectiles/Rogue/AlphaVirusProjectile.cs @@ -113,7 +113,7 @@ namespace CalamityMod.Projectiles.Rogue public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if (target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType()) + if (target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType()) { damage /= 5; } diff --git a/Projectiles/Rogue/EclipsesStealth.cs b/Projectiles/Rogue/EclipsesStealth.cs index 257317e083..7aa3f2efd9 100644 --- a/Projectiles/Rogue/EclipsesStealth.cs +++ b/Projectiles/Rogue/EclipsesStealth.cs @@ -106,7 +106,14 @@ namespace CalamityMod.Projectiles.Rogue return false; } - public override bool? CanHitNPC(NPC target) => projectile.ai[0] != 1f; + public override bool? CanHitNPC(NPC target) + { + if (projectile.ai[0] == 1f) + { + return false; + } + return null; + } public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; } diff --git a/Projectiles/Rogue/FantasyTalismanStealth.cs b/Projectiles/Rogue/FantasyTalismanStealth.cs index 375a2e1322..b85d9ff418 100644 --- a/Projectiles/Rogue/FantasyTalismanStealth.cs +++ b/Projectiles/Rogue/FantasyTalismanStealth.cs @@ -46,8 +46,11 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft % 10 == 0) { if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + { + // Use a tiny velocity to ensure that rotation works correctly. + // The speed should be so low that it will make no meaningful mechanical difference. + Vector2 soulVelocity = projectile.velocity.SafeNormalize(Vector2.Zero) * 0.0001f; + Projectile.NewProjectile(projectile.Center, soulVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Rogue/PhantasmalSoul.png b/Projectiles/Rogue/PhantasmalSoul.png index fe77251e7c..43ec7bc42b 100644 Binary files a/Projectiles/Rogue/PhantasmalSoul.png and b/Projectiles/Rogue/PhantasmalSoul.png differ diff --git a/Projectiles/Rogue/WrathwingSpear.cs b/Projectiles/Rogue/WrathwingSpear.cs index a1d54242ee..61a4e3a875 100644 --- a/Projectiles/Rogue/WrathwingSpear.cs +++ b/Projectiles/Rogue/WrathwingSpear.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) { int eruptionID = ModContent.ProjectileType(); - int damage = (int)(projectile.damage * 0.75f); + int damage = (int)(projectile.damage * 0.65f); float kb = 0f; // Spawns 13 erupting fireballs in total. diff --git a/Projectiles/Summon/EndoHydraHead.cs b/Projectiles/Summon/EndoHydraHead.cs index 6352c75f0e..84a73682f6 100644 --- a/Projectiles/Summon/EndoHydraHead.cs +++ b/Projectiles/Summon/EndoHydraHead.cs @@ -115,7 +115,7 @@ namespace CalamityMod.Projectiles.Summon if (body.ai[0] >= 0 && body.ai[0] < Main.npc.Length) { NPC target = Main.npc[(int)body.ai[0]]; - bool targetAliveAndInLineOfSight = target.active && projectile.Distance(target.Center) < EndoHydraBody.DistanceToCheck && Collision.CanHit(projectile.Center, 1, 1, target.Center, 1, 1); + bool targetAliveAndInLineOfSight = target.active && projectile.Distance(target.Center) < EndoHydraBody.DistanceToCheck; if (targetAliveAndInLineOfSight && target.CanBeChasedBy() && Main.myPlayer == projectile.owner) { if (Time % 40f == 24f) diff --git a/Projectiles/Summon/EndoRay.cs b/Projectiles/Summon/EndoRay.cs index 1ad285a510..b21267c6e3 100644 --- a/Projectiles/Summon/EndoRay.cs +++ b/Projectiles/Summon/EndoRay.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Summon projectile.extraUpdates = 100; projectile.timeLeft = 265; projectile.coldDamage = true; + projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 100; } diff --git a/Projectiles/Summon/Hiveling.cs b/Projectiles/Summon/Hiveling.cs index e869594621..5f4752e75f 100644 --- a/Projectiles/Summon/Hiveling.cs +++ b/Projectiles/Summon/Hiveling.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.tileCollide = false; projectile.penetrate = 1; - projectile.timeLeft = 300; + projectile.timeLeft = 240; } public override void AI() @@ -54,11 +54,6 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity = (projectile.velocity * 30f + projectile.SafeDirectionTo(potentialTarget.Center) * 10f) / 31f; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } - public override void Kill(int timeLeft) { for (int k = 0; k < 3; k++) diff --git a/Projectiles/Summon/LostSoulGiant.cs b/Projectiles/Summon/LostSoulGiant.cs index b7caaff612..ba043fe6dd 100644 --- a/Projectiles/Summon/LostSoulGiant.cs +++ b/Projectiles/Summon/LostSoulGiant.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Summon { if (time >= 15f) { - NPC potentialTarget = projectile.Center.ClosestNPCAt(1800f, false); + NPC potentialTarget = projectile.Center.MinionHoming(1800f, Main.player[projectile.owner], false); if (potentialTarget != null) HomeInOnTarget(projectile, potentialTarget); } diff --git a/Projectiles/Summon/MidnightSunBeaconProj.cs b/Projectiles/Summon/MidnightSunBeaconProj.cs index 8d2ab5d3a6..0c1ae920c8 100644 --- a/Projectiles/Summon/MidnightSunBeaconProj.cs +++ b/Projectiles/Summon/MidnightSunBeaconProj.cs @@ -30,17 +30,13 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - projectile.rotation = projectile.rotation.AngleLerp(-MathHelper.PiOver4, 0.03f); + projectile.rotation = projectile.rotation.AngleLerp(-MathHelper.PiOver4, 0.08f); if (Math.Abs(projectile.rotation + MathHelper.PiOver4) < 0.02f && projectile.ai[0] == 0f) { - for (int i = 1; i <= 4; i++) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 4, 0f, projectile.owner, - projectile.whoAmI, i - 2); - } - projectile.ai[1] = MidnightSunSkyBeam.TrueTimeLeft + 60f; + projectile.ai[1] = 85f; projectile.ai[0] = 1f; } + if (projectile.ai[1] == 1f) { Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 30f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, diff --git a/Projectiles/Summon/MidnightSunBeam.cs b/Projectiles/Summon/MidnightSunBeam.cs index 987dbf137b..e79b962e37 100644 --- a/Projectiles/Summon/MidnightSunBeam.cs +++ b/Projectiles/Summon/MidnightSunBeam.cs @@ -100,35 +100,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 samplingPoint = projectile.Center; float[] samples = new float[3]; - - float determinedLength = 0f; - Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, maximumLength, samples); - for (int i = 0; i < samples.Length; i++) - { - determinedLength += samples[i]; - } - determinedLength /= samples.Length; - - float lerpDelta = 0.5f; - projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, lerpDelta); - Vector2 beamEndPosiiton = projectile.Center + projectile.velocity * (projectile.localAI[1] - 6f); - for (int i = 0; i < 4; i++) - { - float theta = projectile.velocity.ToRotation() + Main.rand.NextBool(2).ToDirectionInt() * MathHelper.PiOver2; - float speed = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 velocity = theta.ToRotationVector2() * speed; - Dust dust = Dust.NewDustDirect(beamEndPosiiton, 0, 0, 185, velocity.X, velocity.Y, 0, default, 1f); - dust.noGravity = true; - dust.scale = 1.7f; - } - - for (int i = 0; i < 8; i++) - { - Dust dust = Dust.NewDustPerfect(beamEndPosiiton, 185); - dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.ToRadians(55f)).RotatedBy(projectile.rotation); - dust.noGravity = true; - dust.scale = 1.2f; - } + projectile.localAI[1] = body.ai[1]; // Draw light blue light across the laser DelegateMethods.v3_1 = new Vector3(0.52f, 0.93f, 0.97f); diff --git a/Projectiles/Summon/MidnightSunSkyBeam.cs b/Projectiles/Summon/MidnightSunSkyBeam.cs deleted file mode 100644 index c8f86e8e5a..0000000000 --- a/Projectiles/Summon/MidnightSunSkyBeam.cs +++ /dev/null @@ -1,206 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.Enums; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon -{ - public class MidnightSunSkyBeam : ModProjectile - { - // How long this laser can exist before it is deleted. - public const int TrueTimeLeft = 180; - - // Pretty self explanatory - private const float maximumLength = 2000f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Beam"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } - - public override void SetDefaults() - { - projectile.width = 18; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.minion = true; - projectile.minionSlots = 0f; - projectile.timeLeft = TrueTimeLeft; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 30; - } - - // Netcode for sending and receiving shit - // localAI[0] is the timer, localAI[1] is the laser length - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - projectile.localAI[1] = reader.ReadSingle(); - } - - public override void AI() - { - Projectile body = Main.projectile[(int)projectile.ai[0]]; - if (body.type != ModContent.ProjectileType() || !body.active) - projectile.Kill(); - - if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) - { - projectile.velocity = -Vector2.UnitY; - } - - if (body.active) - { - float angleVarianceRatio = projectile.localAI[0] / TrueTimeLeft; - float angleVariance = MathHelper.TwoPi * (projectile.ai[1] - 2f) / 2f * angleVarianceRatio * 1.25f; - float xDelta = 45f * (float)Math.Sin(angleVariance) * angleVarianceRatio; - projectile.Center = body.Center - new Vector2(xDelta, maximumLength / 2f); - } - - if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) - { - projectile.velocity = -Vector2.UnitY; - } - - // How fat the laser is - float laserSize = 1f; - - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= TrueTimeLeft) - { - projectile.Kill(); - return; - } - - // Causes the effect where the laser appears to expand/contract at the beginning and end of its life - projectile.scale = (float)Math.Sin(projectile.localAI[0] * MathHelper.Pi / TrueTimeLeft) * 10f * laserSize; - if (projectile.scale > laserSize) - { - projectile.scale = laserSize; - } - - projectile.rotation = 0f; - projectile.velocity = Vector2.UnitY; - - Vector2 samplingPoint = projectile.Center; - - float[] samples = new float[3]; - - float determinedLength = 0f; - Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, maximumLength, samples); - for (int i = 0; i < samples.Length; i++) - { - determinedLength += samples[i]; - } - determinedLength /= samples.Length; - - float lerpDelta = 0.5f; - projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, lerpDelta); - Vector2 beamEndPosiiton = projectile.Center + projectile.velocity * (projectile.localAI[1] - 6f); - for (int i = 0; i < 4; i++) - { - float theta = projectile.velocity.ToRotation() + Main.rand.NextBool(2).ToDirectionInt() * MathHelper.PiOver2; - float speed = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 velocity = theta.ToRotationVector2() * speed; - Dust dust = Dust.NewDustDirect(beamEndPosiiton, 0, 0, 185, velocity.X, velocity.Y, 0, default, 1f); - dust.noGravity = true; - dust.scale = 1.7f; - } - - for (int i = 0; i < 8; i++) - { - Dust dust = Dust.NewDustPerfect(beamEndPosiiton, 185); - dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.ToRadians(55f)).RotatedBy(projectile.rotation); - dust.noGravity = true; - dust.scale = 1.2f; - } - - // Draw light blue light across the laser - DelegateMethods.v3_1 = new Vector3(0.52f, 0.93f, 0.97f); - 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) - { - if (projectile.velocity == Vector2.Zero) - { - return false; - } - Texture2D laserTailTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamBegin"); - Texture2D laserBodyTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamMid"); - Texture2D laserHeadTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamEnd"); - float laserLength = projectile.localAI[1]; - Color drawColor = new Color(1f, 1f, 1f) * 0.9f; - - // Laser tail logic - - Main.spriteBatch.Draw(laserTailTexture, projectile.Center - Main.screenPosition, null, drawColor, projectile.rotation, laserTailTexture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - - // Laser body logic - - laserLength -= (laserTailTexture.Height / 2 + laserHeadTexture.Height) * projectile.scale; - Vector2 centerDelta = projectile.Center; - centerDelta += projectile.velocity * projectile.scale * (float)laserTailTexture.Height / 2f; - if (laserLength > 0f) - { - float laserLengthDelta = 0f; - Rectangle sourceRectangle = new Rectangle(0, 16 * (projectile.timeLeft / 3 % 5), laserBodyTexture.Width, 16); - while (laserLengthDelta + 1f < laserLength) - { - if (laserLength - laserLengthDelta < sourceRectangle.Height) - { - sourceRectangle.Height = (int)(laserLength - laserLengthDelta); - } - Main.spriteBatch.Draw(laserBodyTexture, centerDelta - Main.screenPosition, new Rectangle?(sourceRectangle), drawColor, projectile.rotation, new Vector2(sourceRectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); - laserLengthDelta += sourceRectangle.Height * projectile.scale; - centerDelta += projectile.velocity * sourceRectangle.Height * projectile.scale; - sourceRectangle.Y += 16; - if (sourceRectangle.Y + sourceRectangle.Height > laserBodyTexture.Height) - { - sourceRectangle.Y = 0; - } - } - } - - // Laser head logic - - Main.spriteBatch.Draw(laserHeadTexture, centerDelta - Main.screenPosition, null, drawColor, projectile.rotation, laserHeadTexture.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f); - return false; - } - - public override void CutTiles() - { - 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)); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (projHitbox.Intersects(targetHitbox)) - { - return true; - } - float value = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref value)) - { - return true; - } - return false; - } - } -} diff --git a/Projectiles/Summon/MidnightSunSkyBeam.png b/Projectiles/Summon/MidnightSunSkyBeam.png deleted file mode 100644 index d85e68b29d..0000000000 Binary files a/Projectiles/Summon/MidnightSunSkyBeam.png and /dev/null differ diff --git a/Projectiles/Summon/MidnightSunUFO.cs b/Projectiles/Summon/MidnightSunUFO.cs index 12c6f6f0ae..179d94ce3a 100644 --- a/Projectiles/Summon/MidnightSunUFO.cs +++ b/Projectiles/Summon/MidnightSunUFO.cs @@ -86,53 +86,39 @@ namespace CalamityMod.Projectiles.Summon if (potentialTarget != null) { - if (projectile.ai[0]++ % 360 < 180) + projectile.ai[0]++; + if (projectile.ai[0] % 360f < 180f) { projectile.rotation = projectile.rotation.AngleTowards(0f, 0.2f); - if (projectile.ai[1] != 0f) - { - projectile.ai[1] = 0f; - } float angle = MathHelper.ToRadians(2f * projectile.ai[0] % 180f); Vector2 destination = potentialTarget.Center - new Vector2((float)Math.Cos(angle) * potentialTarget.width * 0.65f, 250f); projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(destination) * 24f, 0.03f); - if (projectile.ai[0] % 4f == 3f && potentialTarget.Top.Y > projectile.Bottom.Y) + if (projectile.ai[0] % 8f == 7f && potentialTarget.Top.Y > projectile.Bottom.Y) { Vector2 laserVelocity = projectile.SafeDirectionTo(potentialTarget.Center, Vector2.UnitY).RotatedByRandom(0.15f) * 25f; Projectile.NewProjectile(projectile.Bottom, laserVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } projectile.MinionAntiClump(0.35f); + projectile.ai[1] = 0f; } else { - const float framesUsedSpinning = MidnightSunBeam.TrueTimeLeft; - float totalRadiansToSpin = MathHelper.ToRadians(120f); - float totalRadiansNegativeRange = totalRadiansToSpin - (totalRadiansToSpin / 2); - float radiansToSpinPerFrame = totalRadiansNegativeRange / framesUsedSpinning * 2f; - if (projectile.ai[0] % 180 < 180 - framesUsedSpinning) - { - projectile.rotation = projectile.rotation.AngleLerp(projectile.AngleTo(potentialTarget.Center) - MathHelper.PiOver2 - totalRadiansNegativeRange, 0.15f); + // Move very, very quickly above the target. + Vector2 hoverDestination = potentialTarget.Top - Vector2.UnitY * 40f + (projectile.minionPos + projectile.ai[0] / 7f).ToRotationVector2() * 40f; + projectile.Center = Vector2.Lerp(projectile.Center, hoverDestination, 0.1f).MoveTowards(hoverDestination, 20f); + projectile.velocity = projectile.velocity.MoveTowards(Vector2.Zero, 4f); + projectile.ai[1] = Math.Abs(hoverDestination.Y - potentialTarget.Bottom.Y) + MathHelper.Lerp(30f, 50f, projectile.identity % 7f / 7f); - Vector2 spawnPosition = projectile.Center + Utils.NextVector2Unit(Main.rand).RotatedBy(projectile.rotation) * new Vector2(13f, 6f) / 2f; - int idx = Dust.NewDust(spawnPosition - Vector2.One * 8f, 16, 16, 229, projectile.velocity.X / 2f, projectile.velocity.Y / 2f, 0, default, 1f); - Main.dust[idx].velocity = Vector2.Normalize(projectile.Center - spawnPosition) * 2.6f; - Main.dust[idx].noGravity = true; - Main.dust[idx].scale = 0.9f; - } - else + if (projectile.ai[0] % 360f == 240f) { - projectile.rotation += radiansToSpinPerFrame; - if (projectile.ai[1] == 0f) + if (Main.myPlayer == projectile.owner) { Main.PlaySound(SoundID.Item122, projectile.Center); - Projectile.NewProjectile(projectile.Center, (projectile.velocity.ToRotation() + MathHelper.PiOver2).ToRotationVector2(), - ModContent.ProjectileType(), projectile.damage * 2, projectile.knockBack, projectile.owner, - radiansToSpinPerFrame, projectile.whoAmI); - projectile.ai[1] = 1f; + Vector2 laserVelocity = projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.UnitY); + Projectile.NewProjectile(projectile.Center, laserVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, projectile.whoAmI); } } - projectile.velocity *= 0.935f; } } else diff --git a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs index 38e65e8656..e718783cfc 100644 --- a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs +++ b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs @@ -318,8 +318,7 @@ namespace CalamityMod.Projectiles.Summon public override bool? CanHitNPC(NPC target) { - bool instakill = target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() - || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); + bool instakill = target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); if (!instakill && this.target != null && target != this.target) { if (projectile.getRect().Intersects(target.getRect())) @@ -714,8 +713,7 @@ namespace CalamityMod.Projectiles.Summon public override bool? CanHitNPC(NPC target) { - bool instakill = target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() - || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); + bool instakill = target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); if (!instakill && this.target != null && target != this.target) return false; return null; diff --git a/Projectiles/Summon/RadiantResolutionAura.cs b/Projectiles/Summon/RadiantResolutionAura.cs index 6bcaedbc13..807f847c0d 100644 --- a/Projectiles/Summon/RadiantResolutionAura.cs +++ b/Projectiles/Summon/RadiantResolutionAura.cs @@ -6,119 +6,141 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Summon { public class RadiantResolutionAura : ModProjectile { - public const float DistanceToCheck = 1600f; + public Player Owner => Main.player[projectile.owner]; + public ref float AllocatedSlots => ref projectile.ai[0]; + public ref float GeneralTimer => ref projectile.ai[1]; + + public const float TargetCheckDistance = 1600f; + public const int RadiantOrbAppearRateLowerBound = 7; + public const int RadiantOrbDamageUpperBound = 10000; public override void SetStaticDefaults() { - DisplayName.SetDefault("Saros Possession"); + DisplayName.SetDefault("Radiant Aura"); ProjectileID.Sets.MinionSacrificable[projectile.type] = true; ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; } public override void SetDefaults() { - projectile.width = 66; - projectile.height = 66; + projectile.width = projectile.height = 66; projectile.netImportant = true; projectile.friendly = true; projectile.ignoreWater = true; projectile.minionSlots = 1f; - projectile.timeLeft = 18000; + projectile.timeLeft = 90000; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.timeLeft *= 5; projectile.minion = true; } public override void AI() { - Lighting.AddLight(projectile.Center, 2f, 2f, 2f); - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - player.AddBuff(ModContent.BuffType(), 3600); + // Emit some light. + Lighting.AddLight(projectile.Center, Vector3.One * 1.2f); + + // Ensure that the projectile using this AI is the correct projectile and that the owner has the appropriate buffs. + VerifyIdentityOfCaller(); + + // Handle dynamic minion damage. + HandleDynamicMinionDamage(); + + // Store the allocated slots in the minionSlots field so that the amount of slots the projectile is holding + // is always correct. + projectile.minionSlots = projectile.ai[0]; + + // Stay near the target and spin around. + projectile.Center = Owner.Center - Vector2.UnitY * 16f; + projectile.rotation += MathHelper.ToRadians(AllocatedSlots * 0.85f + 3f); + + float damageMultiplier = (float)Math.Log(AllocatedSlots, 3D) + 1f; + + // Softcap the multiplier after it has exceeded 3x the base value. + float softcappedDamageMultiplier = damageMultiplier; + if (softcappedDamageMultiplier > 3f) + softcappedDamageMultiplier = ((damageMultiplier - 3f) * 0.1f) + 3f; + + int radiantOrbDamage = (int)(projectile.damage * softcappedDamageMultiplier); + int radiantOrbAppearRate = (int)(130 * Math.Pow(0.9, AllocatedSlots)); + + // Hard-cap the orb appear rate and damage. + // The latter is basically impossible to reach now due to rebalancing, but it shall remain for the time being. + if (radiantOrbAppearRate < RadiantOrbAppearRateLowerBound) + radiantOrbAppearRate = RadiantOrbAppearRateLowerBound; + + if (radiantOrbDamage > RadiantOrbDamageUpperBound) + radiantOrbDamage = RadiantOrbDamageUpperBound; + + // Attack nearby targets. + GeneralTimer++; + NPC potentialTarget = projectile.Center.MinionHoming(TargetCheckDistance, Owner); + if (potentialTarget != null && Main.myPlayer == projectile.owner) + AttackTarget(potentialTarget, radiantOrbAppearRate, radiantOrbDamage); + } + + public void VerifyIdentityOfCaller() + { + Owner.AddBuff(ModContent.BuffType(), 3600); bool isCorrectProjectile = projectile.type == ModContent.ProjectileType(); if (isCorrectProjectile) { - if (player.dead) - { - modPlayer.radiantResolution = false; - } - if (modPlayer.radiantResolution) - { - projectile.timeLeft = 2; - } - } + if (Owner.dead) + Owner.Calamity().radiantResolution = false; + if (Owner.Calamity().radiantResolution) + projectile.timeLeft = 2; + } + } + + public void HandleDynamicMinionDamage() + { if (projectile.localAI[0] == 0f) { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] += 1f; } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); + Owner.MinionDamage()); projectile.damage = trueDamage; } - projectile.minionSlots = projectile.ai[0]; + } - projectile.Center = player.Center - Vector2.UnitY * 16f; - - float allocatedSlots = projectile.ai[0]; - projectile.rotation += MathHelper.ToRadians(3f) + MathHelper.ToRadians(allocatedSlots * 0.85f); - - float damageMult = (float)Math.Log(allocatedSlots, 3) + 1f; - - //Softcap the mult after 9 slots - float newMult = damageMult; - if (newMult > 3f) - { - newMult = ((damageMult - 3f) * 0.1f) + 3f; - } - - int radiantOrbDamage = (int)(projectile.damage * newMult); - int radiantOrbAppearRate = (int)(130 * Math.Pow(0.9, allocatedSlots)); - - if (radiantOrbAppearRate < 7) - radiantOrbAppearRate = 7; - - if (radiantOrbDamage > 10000) - radiantOrbDamage = 10000; - - projectile.ai[1]++; - NPC potentialTarget = projectile.Center.MinionHoming(DistanceToCheck, player); - if (potentialTarget != null && Main.myPlayer == projectile.owner) + public void AttackTarget(NPC target, int radiantOrbAppearRate, int radiantOrbDamage) + { + if (GeneralTimer % 35f == 34f) { - if (projectile.ai[1] % 35 == 34) + for (int i = 0; i < 2; i++) { - for (int i = 0; i < 2; i++) - { - float angle = MathHelper.Lerp(-MathHelper.ToRadians(20f), MathHelper.ToRadians(20f), i / 2f); - Vector2 fireVelocity = projectile.SafeDirectionTo(potentialTarget.Center).RotatedBy(angle) * 15f; - Projectile.NewProjectile(projectile.Center, fireVelocity, ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); - } + float angle = MathHelper.Lerp(-MathHelper.ToRadians(20f), MathHelper.ToRadians(20f), i / 2f); + Vector2 fireVelocity = projectile.SafeDirectionTo(target.Center).RotatedBy(angle) * 15f; + Projectile.NewProjectile(projectile.Center, fireVelocity, ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); } - if (projectile.ai[1] % radiantOrbAppearRate == radiantOrbAppearRate - 1) + } + + if (GeneralTimer % radiantOrbAppearRate == radiantOrbAppearRate - 1) + { + Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(100f, 360f); + Vector2 bootlegRadianceOrbVelocity = projectile.SafeDirectionTo(target.Center) * 2f; + Projectile.NewProjectile(spawnPosition, bootlegRadianceOrbVelocity, ModContent.ProjectileType(), radiantOrbDamage, projectile.knockBack * 4f, projectile.owner); + for (int i = 0; i < 3; i++) { - Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(100f, 360f); - Vector2 bootlegRadianceOrbVelocity = projectile.SafeDirectionTo(potentialTarget.Center) * 2f; - Projectile.NewProjectile(spawnPosition, bootlegRadianceOrbVelocity, ModContent.ProjectileType(), radiantOrbDamage, projectile.knockBack * 4f, projectile.owner); - for (int i = 0; i < 3; i++) - { - float angle = MathHelper.Lerp(-MathHelper.ToRadians(30f), MathHelper.ToRadians(30f), i / 3f); - Vector2 fireVelocity = projectile.SafeDirectionTo(potentialTarget.Center).RotatedBy(angle) * 19f; - Projectile.NewProjectile(projectile.Center, fireVelocity, ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); - } + float angle = MathHelper.Lerp(-MathHelper.ToRadians(30f), MathHelper.ToRadians(30f), i / 3f); + Vector2 fireVelocity = projectile.SafeDirectionTo(target.Center).RotatedBy(angle) * 19f; + Projectile.NewProjectile(projectile.Center, fireVelocity, ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); } } } public override bool CanDamage() => false; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D currentTexture = ModContent.GetTexture(Texture); diff --git a/Projectiles/Summon/SeekerSummonProj.cs b/Projectiles/Summon/SeekerSummonProj.cs index 7805fd543a..1b53b08cfa 100644 --- a/Projectiles/Summon/SeekerSummonProj.cs +++ b/Projectiles/Summon/SeekerSummonProj.cs @@ -6,32 +6,33 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SeekerSummonProj : ModProjectile - { - public Player Owner => Main.player[projectile.owner]; + public class SeekerSummonProj : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; public ref float CircleAngleRatio => ref projectile.ai[0]; public ref float Time => ref projectile.ai[1]; public override void SetStaticDefaults() - { - DisplayName.SetDefault("Soul Seeker"); - Main.projFrames[projectile.type] = 5; + { + DisplayName.SetDefault("Soul Seeker"); + Main.projFrames[projectile.type] = 5; ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - } + } - public override void SetDefaults() - { - projectile.width = projectile.height = 84; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 1f; - projectile.timeLeft = 90000; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.minion = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; + public override void SetDefaults() + { + projectile.width = projectile.height = 84; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = projectile.MaxUpdates * 8; projectile.alpha = 255; } @@ -127,7 +128,7 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity *= 0.9f; if (Time % 16f == 15f) { - float shootSpeed = 14f; + float shootSpeed = 23f; Vector2 eyePosition = projectile.Center + new Vector2(projectile.spriteDirection * 22f, -12f); Vector2 aheadAim = (target.Center - eyePosition) / target.velocity.Length() / shootSpeed; Vector2 shootVelocity = (target.Center + aheadAim - eyePosition).SafeNormalize(Vector2.UnitX * projectile.spriteDirection) * shootSpeed; diff --git a/Projectiles/Summon/SepulcherMinion.cs b/Projectiles/Summon/SepulcherMinion.cs index 7635085c33..dcecdacab2 100644 --- a/Projectiles/Summon/SepulcherMinion.cs +++ b/Projectiles/Summon/SepulcherMinion.cs @@ -97,6 +97,7 @@ namespace CalamityMod.Projectiles.Summon } public ref float JawRotation => ref projectile.localAI[0]; public ref float JawSnapTimer => ref projectile.localAI[1]; + public const int HeartCreationRate = 420; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -222,7 +223,7 @@ namespace CalamityMod.Projectiles.Summon // Check if ready to enrage every so often. IdleTimer++; - if (IdleTimer % 600 == 599) + if (IdleTimer % HeartCreationRate == HeartCreationRate - 1f) { int heartsAttachedToOwner = 0; int heartType = ModContent.NPCType(); @@ -282,7 +283,7 @@ namespace CalamityMod.Projectiles.Summon public void HandleBuffs() { - // Maintain or remove the Mechworm buff from the owner. + // Maintain or remove the Sepulcher buff from the owner. Owner.AddBuff(ModContent.BuffType(), 3600); if (Owner.dead) Owner.Calamity().sepulcher = false; @@ -627,9 +628,9 @@ namespace CalamityMod.Projectiles.Summon // Draw the head. if (afterimageOutwardness > 0f) - { + { for (int i = 0; i < 4; i++) - { + { Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * afterimageOutwardness; spriteBatch.Draw(headTexture, drawPosition + drawOffset, null, backAfterimageColor, projectile.rotation, headTexture.Size() * 0.5f, projectile.scale * 1.25f, SpriteEffects.None, 0f); } @@ -638,9 +639,9 @@ namespace CalamityMod.Projectiles.Summon // Draw demonic eyes if enraged. if (afterimageOutwardness > 0f) - { + { for (int i = 0; i < (int)(projectile.oldPos.Length * angerFactor); i++) - { + { drawPosition = projectile.Center - Main.screenPosition - projectile.velocity.SafeNormalize(Vector2.Zero) * 3f * i; Color fadeColor = Color.White * (1f - i / (float)projectile.oldPos.Length); spriteBatch.Draw(eyesTexture, drawPosition, null, projectile.GetAlpha(fadeColor), projectile.oldRot[i], eyesTexture.Size() * 0.5f, projectile.scale * 1.25f, SpriteEffects.None, 0f); @@ -671,20 +672,20 @@ namespace CalamityMod.Projectiles.Summon drawCacheProjsBehindProjectiles.Add(index); } - #endregion + #endregion - #region Damage Stuff - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { + #region Damage Stuff + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { damage = Main.rand.Next(80, 90); - } + } public override bool? CanHitNPC(NPC target) - { + { if (target.type == ModContent.NPCType()) return false; return null; - } + } #endregion } } diff --git a/Projectiles/Summon/SonOfYharon.cs b/Projectiles/Summon/SonOfYharon.cs index f24f76fb13..b253b25911 100644 --- a/Projectiles/Summon/SonOfYharon.cs +++ b/Projectiles/Summon/SonOfYharon.cs @@ -1,15 +1,21 @@ using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Summon { public class SonOfYharon : ModProjectile { + public Player Owner => Main.player[projectile.owner]; + public ref float AttackTimer => ref projectile.ai[0]; + public ref float RamCountdown => ref projectile.ai[1]; + public ref float RamReboundCountdown => ref projectile.localAI[1]; + public const int FireballShootRate = 20; public override void SetStaticDefaults() { DisplayName.SetDefault("Son of Yharon"); @@ -22,92 +28,196 @@ namespace CalamityMod.Projectiles.Summon { projectile.width = 100; projectile.height = 100; + projectile.extraUpdates = 1; projectile.netImportant = true; projectile.friendly = true; projectile.ignoreWater = true; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - projectile.extraUpdates = 1; + projectile.localNPCHitCooldown = projectile.MaxUpdates * 9; projectile.minionSlots = 4f; - projectile.timeLeft = 18000; + projectile.timeLeft = 90000; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.timeLeft *= 5; projectile.minion = true; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(RamReboundCountdown); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + RamReboundCountdown = reader.ReadSingle(); + } + public override void AI() { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); if (projectile.localAI[0] == 0f) { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); - projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int num501 = 100; - for (int num502 = 0; num502 < num501; num502++) - { - int num503 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 244, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; - } - projectile.localAI[0] += 1f; + PerformInitialization(); + projectile.localAI[0] = 1f; } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + + // Perform minion checks. + PerformMinionChecks(); + + // Dynamically adjust damage if it changes. + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { - int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); - projectile.damage = damage2; + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * Owner.MinionDamage()); + projectile.damage = trueDamage; } - if (Math.Abs(projectile.velocity.X) > 0.2f) - { - projectile.spriteDirection = -projectile.direction; - } - float lightScalar = (float)Main.rand.Next(90, 111) * 0.01f; - lightScalar *= Main.essScale; - Lighting.AddLight(projectile.Center, 1.2f * lightScalar, 0.8f * lightScalar, 0f * lightScalar); - bool correctMinion = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (correctMinion) - { - if (player.dead) - { - modPlayer.aChicken = false; - } - if (modPlayer.aChicken) - { - projectile.timeLeft = 2; - } - } - if (projectile.ai[0] == 2f) - { + + // Handle frame logic. + if (projectile.FinalExtraUpdate()) projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 2) - { - projectile.frame = 0; - } + projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type]; + + NPC potentialTarget = projectile.Center.MinionHoming(2000f, Owner); + + // Teleport to the player if extremely far away. + if (!projectile.WithinRange(Owner.Center, 4000f)) + { + projectile.Center = Owner.Center + Main.rand.NextVector2Circular(16f, 16f); + projectile.netUpdate = true; + return; + } + + // Rebound for a bit after a ram. + if (RamReboundCountdown > 0f) + { + projectile.velocity *= 0.97f; + RamReboundCountdown--; + return; + } + + if (potentialTarget is null) + { + DoPlayerHoverMovement(); + AttackTimer = 0f; } else { - projectile.frameCounter++; - if (projectile.frameCounter > 12) + AttackTarget(potentialTarget); + AttackTimer++; + } + } + + public void PerformInitialization() + { + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + + for (int i = 0; i < 45; i++) + { + Dust fire = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(55f, 55f), 244); + fire.velocity *= 2f; + fire.scale *= 1.15f; + } + } + + public void PerformMinionChecks() + { + bool correctMinion = projectile.type == ModContent.ProjectileType(); + Owner.AddBuff(ModContent.BuffType(), 3600); + if (!correctMinion) + return; + + if (Owner.dead) + Owner.Calamity().aChicken = false; + + if (Owner.Calamity().aChicken) + projectile.timeLeft = 2; + } + + public void DoPlayerHoverMovement() + { + // Move away from other minions of the same type. + projectile.MinionAntiClump(0.1f); + + Vector2 hoverDestination = Owner.Top - Vector2.UnitY * 50f; + if (!projectile.WithinRange(hoverDestination, 60f)) + projectile.velocity = (projectile.velocity * 19f + projectile.SafeDirectionTo(hoverDestination) * 11f) / 20f; + + // Adjust the sprite direction to point towards the hover destination. This does not happen if already really close + // horizontally to the destination, to prevent direction changing spam. + if (MathHelper.Distance(projectile.Center.X, hoverDestination.X) > 45f) + projectile.spriteDirection = (projectile.Center.X - hoverDestination.X > 0).ToDirectionInt(); + } + + public void AttackTarget(NPC target) + { + float distanceFromTarget = projectile.Distance(target.Center); + + // Approach the target quickly if far enough away. + // Movement becomes sharper the farther away from the target the minion is. + // Also release fireballs. + if (distanceFromTarget > 220f) + { + float interpolantToIdealVelocity = MathHelper.Lerp(0.05f, 0.3f, Utils.InverseLerp(300f, 560f, distanceFromTarget, true)); + Vector2 idealVelocity = projectile.SafeDirectionTo(target.Center) * MathHelper.Min(distanceFromTarget, 14f); + projectile.velocity = Vector2.Lerp(projectile.velocity, idealVelocity, interpolantToIdealVelocity); + + // Adjust the sprite direction to point towards the hover destination. + projectile.spriteDirection = (projectile.Center.X - target.Center.X > 0).ToDirectionInt(); + + // Periodically release fireballs at the target. + // They move faster the farther away from the target the minion is. + if (AttackTimer % FireballShootRate == FireballShootRate - 1f) { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; + float shootSpeed = (distanceFromTarget - 220f) * 0.015f + 45f; + Main.PlaySound(SoundID.Item73, projectile.Center); + if (Main.myPlayer == projectile.owner) + { + Vector2 shootPosition = projectile.Center + Vector2.UnitX * projectile.spriteDirection * 10f; + Vector2 shootVelocity = (target.Center - shootPosition).SafeNormalize(Vector2.UnitX * projectile.spriteDirection) * shootSpeed; + Projectile.NewProjectile(shootPosition, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack * 0.5f, projectile.owner); + } } } - projectile.ChargingMinionAI(1000f, 2000f, 3000f, 500f, 1, 30f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, true, true); + // Otherwise ram at the target. + else if (RamCountdown <= 0f) + { + RamCountdown = 60f; + + projectile.velocity = projectile.SafeDirectionTo(target.Center, -Vector2.UnitY) * 23f; + projectile.netUpdate = true; + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + // Create an explosion and rebound on hitting an NPC if a ram is happening. + if (RamCountdown > 0f) + { + RamCountdown = 0f; + RamReboundCountdown = 30f; + projectile.velocity *= -0.6f; + + // Create an explosion of dust. + for (int i = 0; i < 150; i++) + { + Dust fire = Dust.NewDustPerfect(projectile.Center, 244); + fire.velocity = Main.rand.NextVector2Circular(20f, 20f); + fire.scale *= 3f; + fire.noGravity = true; + + fire = Dust.NewDustPerfect(projectile.Center, 244); + fire.velocity *= Main.rand.NextVector2Circular(8f, 8f); + fire.scale *= 2f; + } + + projectile.netUpdate = true; + } + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + // Do much more damage during a ram than otherwise. + if (RamCountdown > 0f) + damage = (int)(damage * AngryChickenStaff.ReboundRamDamageFactor); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -116,7 +226,7 @@ namespace CalamityMod.Projectiles.Summon Texture2D texture2D13 = Main.projectileTexture[projectile.type]; 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, 0f); + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Rectangle(0, y6, texture2D13.Width, num214), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, spriteEffects, 0f); return false; } } diff --git a/Projectiles/Summon/YharonMinionFireball.cs b/Projectiles/Summon/YharonMinionFireball.cs new file mode 100644 index 0000000000..bfe190d799 --- /dev/null +++ b/Projectiles/Summon/YharonMinionFireball.cs @@ -0,0 +1,99 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class YharonMinionFireball : ModProjectile + { + public ref float InitialSpeed => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Projectiles/Boss/YharonFireball"; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dragon Fireball"); + Main.projFrames[projectile.type] = 5; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + } + + public override void SetDefaults() + { + projectile.width = 34; + projectile.height = 34; + projectile.friendly = true; + projectile.minion = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.minionSlots = 0f; + projectile.alpha = 255; + projectile.penetrate = 1; + projectile.timeLeft = 300; + } + + public override void AI() + { + projectile.frameCounter++; + projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type]; + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.075f, 0f, 1f); + + if (InitialSpeed == 0f) + { + InitialSpeed = projectile.velocity.Length(); + projectile.netUpdate = true; + return; + } + + NPC potentialTarget = projectile.Center.MinionHoming(600f, Main.player[projectile.owner]); + if (potentialTarget != null) + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(potentialTarget.Center) * InitialSpeed, 0.15f); + } + + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + SpriteEffects direction = SpriteEffects.None; + if (projectile.spriteDirection == -1) + direction = SpriteEffects.FlipHorizontally; + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 0; i < projectile.oldPos.Length; i++) + { + Vector2 afterimageDrawPosition = projectile.oldPos[i] + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color afterimageColor = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - i) / (float)projectile.oldPos.Length); + spriteBatch.Draw(texture, afterimageDrawPosition, frame, afterimageColor, projectile.rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + } + + Vector2 drawPosition = projectile.Center - Main.screenPosition - Vector2.UnitY * projectile.gfxOffY; + spriteBatch.Draw(texture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + + return false; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item74, projectile.Center); + + for (int d = 0; d < 2; d++) + Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 50, default, 1.5f); + + for (int d = 0; d < 20; d++) + { + Dust fire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 0, default, 2.2f); + fire.noGravity = true; + fire.velocity *= 4f; + + fire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 50, default, 1.5f); + fire.velocity *= 5f; + fire.noGravity = true; + } + } + } +} diff --git a/Projectiles/Typeless/CursorProjSplit.cs b/Projectiles/Typeless/CursorProjSplit.cs index a992d5d345..28d1320458 100644 --- a/Projectiles/Typeless/CursorProjSplit.cs +++ b/Projectiles/Typeless/CursorProjSplit.cs @@ -201,7 +201,14 @@ namespace CalamityMod.Projectiles.Typeless target.AddBuff(ModContent.BuffType(), 60); } - public override bool? CanHitNPC(NPC target) => projectile.alpha < 128; + public override bool? CanHitNPC(NPC target) + { + if (projectile.alpha >= 128) + { + return false; + } + return null; + } public override bool CanHitPvp(Player target) => projectile.alpha < 128; diff --git a/Projectiles/Typeless/SuicideBomberDemon.cs b/Projectiles/Typeless/SuicideBomberDemon.cs index 85061dca7d..74da20096f 100644 --- a/Projectiles/Typeless/SuicideBomberDemon.cs +++ b/Projectiles/Typeless/SuicideBomberDemon.cs @@ -1,6 +1,9 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using System.IO; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -13,23 +16,27 @@ namespace CalamityMod.Projectiles.Typeless get => projectile.ai[0] == 1f; set => projectile.ai[0] = value.ToInt(); } + public ref float Time => ref projectile.ai[1]; public Player Owner => Main.player[projectile.owner]; + public PrimitiveTrail FlameTrailDrawer = null; public override void SetStaticDefaults() { DisplayName.SetDefault("Demon"); - Main.projFrames[projectile.type] = 5; + Main.projFrames[projectile.type] = 12; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 11; } public override void SetDefaults() { - projectile.width = projectile.height = 32; + projectile.width = projectile.height = 48; projectile.tileCollide = false; projectile.ignoreWater = true; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; projectile.Opacity = 0f; - projectile.timeLeft = 300; + projectile.timeLeft = 600; } public override void SendExtraAI(BinaryWriter writer) @@ -46,18 +53,22 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { + Time++; + + // Decide an owner if necessary. if (projectile.owner == 255) projectile.owner = Player.FindClosest(projectile.Center, 1, 1); - projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.025f, 0f, 1f); - projectile.frame = projectile.frameCounter++ / 5 % Main.projFrames[projectile.type]; + // Rapidly fade in. + projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.025f, 0f, 1f); // Anti-clumping behavior. float pushForce = 0.08f; for (int k = 0; k < Main.maxProjectiles; k++) { Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible + + // Short circuits to make the loop as fast as possible. if (!otherProj.active || otherProj.type != projectile.type || k == projectile.whoAmI) continue; @@ -78,33 +89,100 @@ namespace CalamityMod.Projectiles.Typeless } } - if (projectile.hostile) + Entity target = Owner; + float attackFlySpeed = 18.5f; + float flyInertia = 25f; + if (projectile.friendly) { - projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(Owner.Center) * 16f, 1.4f); - projectile.spriteDirection = (Owner.Center.X > projectile.Center.X).ToDirectionInt(); - - if (HasDamagedSomething && projectile.WithinRange(Owner.Center, Owner.Size.Length() * 0.25f)) - projectile.Kill(); + target = projectile.Center.ClosestNPCAt(1360f); + attackFlySpeed = 26.75f; + flyInertia = 8f; } - else if (projectile.friendly) + + // Nullify the target value if they're a dead player. + else if (!Owner.active || Owner.dead) + target = null; + + int oldSpriteDirection = projectile.spriteDirection; + + // Rise upward somewhat slowly and flap wings. + if (Time < 45f) { - NPC potentialTarget = projectile.Center.ClosestNPCAt(1360f); - if (potentialTarget is null) - projectile.velocity = Vector2.Lerp(projectile.velocity, -Vector2.UnitY * 10f, 0.06f); - else + projectile.velocity = Vector2.Lerp(projectile.velocity, -Vector2.UnitY * 5f, 0.06f); + if (projectile.frameCounter >= 6) { - projectile.spriteDirection = (potentialTarget.Center.X > projectile.Center.X).ToDirectionInt(); - projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(potentialTarget.Center) * 18.5f, 3f); - projectile.friendly = true; + projectile.frame = (projectile.frame + 1) % 5; + projectile.frameCounter = 0; + } + } + else if (Time < 90f) + { + // Slow down. + projectile.velocity = projectile.velocity.MoveTowards(Vector2.Zero, 0.4f) * 0.95f; + + // Handle frames. + projectile.frame = (int)Math.Round(MathHelper.Lerp(5f, 10f, Utils.InverseLerp(45f, 90f, Time, true))); + + // And look at the target. + float idealAngle = target is null ? 0f : projectile.AngleTo(target.Center); + projectile.spriteDirection = target is null ? 1 : (target.Center.X > projectile.Center.X).ToDirectionInt(); + if (projectile.spriteDirection != oldSpriteDirection) + projectile.rotation += MathHelper.Pi; + + if (projectile.spriteDirection == -1) + idealAngle += MathHelper.Pi; + projectile.rotation = projectile.rotation.AngleTowards(idealAngle, 0.3f).AngleLerp(idealAngle, 0.08f); + + if (Time == 75f) + Main.PlaySound(SoundID.DD2_WyvernScream, projectile.Center); + + // Reset the oldPos array in anticipation of a trail being drawn during the fly phase. + projectile.oldPos = new Vector2[projectile.oldPos.Length]; + } + else + { + + if (Time == 90f) + Main.PlaySound(SoundID.DD2_WyvernDiveDown, projectile.Center); + + projectile.frame = Main.projFrames[projectile.type] - 1; + + // Fly away if no valid target was found. + if (target is null) + projectile.velocity = -Vector2.UnitY * 18f; + + // Otherwise fly towards the target. + else + projectile.velocity = (projectile.velocity * (flyInertia - 1f) + projectile.SafeDirectionTo(target.Center) * attackFlySpeed) / flyInertia; + + projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt(); + projectile.rotation = CalamityUtils.WrapAngle90Degrees(projectile.velocity.ToRotation()); + if (target is null) + { + projectile.spriteDirection = 1; + projectile.rotation = projectile.velocity.ToRotation(); } - if (HasDamagedSomething && projectile.WithinRange(potentialTarget.Center, potentialTarget.Size.Length() * 0.25f)) + // Die if something has been hit and the target is either gone or really close. + if (HasDamagedSomething && (target is null || target == Owner || projectile.WithinRange(target.Center, target.Size.Length() * 0.4f))) projectile.Kill(); } + + if (target != null && !HasDamagedSomething && projectile.Center.ManhattanDistance(target.Center) < target.height) + { + HasDamagedSomething = true; + projectile.netUpdate = true; + } + + if (Time >= 300f) + projectile.Kill(); + + projectile.frameCounter++; } public override void Kill(int timeLeft) { + Main.PlaySound(SoundID.DD2_KoboldExplosion, projectile.Center); for (int i = 0; i < 40; i++) { Dust explosion = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 267); @@ -113,6 +191,15 @@ namespace CalamityMod.Projectiles.Typeless explosion.scale = 1.35f; explosion.fadeIn = 0.45f; explosion.noGravity = true; + + if (Main.rand.NextBool(3)) + explosion.scale *= 1.45f; + + if (Main.rand.NextBool(6)) + { + explosion.scale *= 1.75f; + explosion.fadeIn += 0.4f; + } } } @@ -121,6 +208,68 @@ namespace CalamityMod.Projectiles.Typeless // Ensure damage is not absolutely obscene when hitting players. public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => damage = 95; + public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio); + + public Color FlameTrailColorFunction(float completionRatio) + { + float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true); + Color startingColor = Color.Lerp(Color.Cyan, Color.White, 0.4f); + Color middleColor = Color.Lerp(Color.Orange, Color.Yellow, 0.3f); + Color endColor = Color.Lerp(Color.Orange, Color.Red, 0.67f); + return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * trailOpacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + spriteBatch.EnterShaderRegion(); + + // Initialize the flame trail drawer. + if (FlameTrailDrawer is null) + FlameTrailDrawer = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); + + // Prepare the flame trail shader with its map texture. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); + + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/SuicideBomberDemon"); + Texture2D glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/SuicideBomberDemonGlowmask"); + Texture2D orbTexture = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/SuicideBomberDemonOrb"); + if (projectile.friendly) + { + texture = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/SuicideBomberDemonFriendly"); + glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/SuicideBomberDemonGlowmaskFriendly"); + orbTexture = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/SuicideBomberDemonOrbFriendly"); + } + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Vector2 drawPosition = projectile.Center - Main.screenPosition; + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + // Draw the base sprite and glowmask. + spriteBatch.Draw(texture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, frame, projectile.GetAlpha(Color.White), projectile.rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + + // Draw the flame trail and flame orb once ready. + if (Time >= 90f) + { + float flameOrbGlowIntensity = Utils.InverseLerp(90f, 98f, Time, true); + for (int i = 0; i < 12; i++) + { + Color flameOrbColor = Color.LightCyan * flameOrbGlowIntensity * 0.125f; + flameOrbColor.A = 0; + Vector2 flameOrbDrawOffset = (MathHelper.TwoPi * i / 12f + Main.GlobalTime * 2f).ToRotationVector2(); + flameOrbDrawOffset *= flameOrbGlowIntensity * 3f; + spriteBatch.Draw(orbTexture, drawPosition + flameOrbDrawOffset, frame, projectile.GetAlpha(flameOrbColor), projectile.rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + + Vector2 trailOffset = projectile.Size * 0.5f; + trailOffset += (projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 20f; + FlameTrailDrawer.Draw(projectile.oldPos, trailOffset - Main.screenPosition, 61); + } + + spriteBatch.ExitShaderRegion(); + + return false; + } + public override void OnHitPlayer(Player target, int damage, bool crit) { HasDamagedSomething = true; diff --git a/Projectiles/Typeless/SuicideBomberDemon.png b/Projectiles/Typeless/SuicideBomberDemon.png index bd3a5924ca..88d6c83614 100644 Binary files a/Projectiles/Typeless/SuicideBomberDemon.png and b/Projectiles/Typeless/SuicideBomberDemon.png differ diff --git a/Projectiles/Typeless/SuicideBomberDemonFriendly.png b/Projectiles/Typeless/SuicideBomberDemonFriendly.png new file mode 100644 index 0000000000..4607178568 Binary files /dev/null and b/Projectiles/Typeless/SuicideBomberDemonFriendly.png differ diff --git a/Projectiles/Typeless/SuicideBomberDemonGlowmask.png b/Projectiles/Typeless/SuicideBomberDemonGlowmask.png new file mode 100644 index 0000000000..9659f522f3 Binary files /dev/null and b/Projectiles/Typeless/SuicideBomberDemonGlowmask.png differ diff --git a/Projectiles/Typeless/SuicideBomberDemonGlowmaskFriendly.png b/Projectiles/Typeless/SuicideBomberDemonGlowmaskFriendly.png new file mode 100644 index 0000000000..c8d5391794 Binary files /dev/null and b/Projectiles/Typeless/SuicideBomberDemonGlowmaskFriendly.png differ diff --git a/Projectiles/Typeless/SuicideBomberDemonOrb.png b/Projectiles/Typeless/SuicideBomberDemonOrb.png new file mode 100644 index 0000000000..8a3fdf2f0d Binary files /dev/null and b/Projectiles/Typeless/SuicideBomberDemonOrb.png differ diff --git a/Projectiles/Typeless/SuicideBomberDemonOrbFriendly.png b/Projectiles/Typeless/SuicideBomberDemonOrbFriendly.png new file mode 100644 index 0000000000..5a00fa580a Binary files /dev/null and b/Projectiles/Typeless/SuicideBomberDemonOrbFriendly.png differ diff --git a/Projectiles/Typeless/YanmeisKnifeSlash.cs b/Projectiles/Typeless/YanmeisKnifeSlash.cs index 0ea7c02233..8aca33f7b1 100644 --- a/Projectiles/Typeless/YanmeisKnifeSlash.cs +++ b/Projectiles/Typeless/YanmeisKnifeSlash.cs @@ -20,7 +20,6 @@ namespace CalamityMod.Projectiles.Typeless { bool validBoss = npc.boss && npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() - && npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() diff --git a/Skies/ExoMechsSky.cs b/Skies/ExoMechsSky.cs index dec32d2f8f..7ded899e2c 100644 --- a/Skies/ExoMechsSky.cs +++ b/Skies/ExoMechsSky.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using Terraria; using Terraria.Graphics; using Terraria.Graphics.Effects; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Skies @@ -25,8 +26,8 @@ namespace CalamityMod.Skies public List LightningBolts = new List(); public static bool CanSkyBeActive { - get - { + get + { int draedon = CalamityGlobalNPC.draedon; if (draedon == -1 || !Main.npc[draedon].active) return Draedon.ExoMechIsPresent; @@ -36,12 +37,12 @@ namespace CalamityMod.Skies return true; } - } + } public float CurrentIntensity - { - get - { + { + get + { float combinedLifeRatio = 0f; if (CalamityGlobalNPC.draedonExoMechPrime != -1 && Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) combinedLifeRatio += Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; @@ -54,12 +55,15 @@ namespace CalamityMod.Skies return (float)Math.Pow(1f - combinedLifeRatio / 3f, 2D); } - } + } public static readonly Color DrawColor = new Color(0.16f, 0.16f, 0.16f); public static void CreateLightningBolt(int count = 1, bool playSound = false) - { + { + if (Main.netMode == NetmodeID.Server) + return; + for (int i = 0; i < count; i++) { Lightning lightning = new Lightning() @@ -73,7 +77,7 @@ namespace CalamityMod.Skies // Make the sky flash if enough lightning bolts are created. if (count >= 10) - { + { (SkyManager.Instance["CalamityMod:ExoMechs"] as ExoMechsSky).LightningIntensity = 1f; playSound = true; } @@ -84,12 +88,12 @@ namespace CalamityMod.Skies if (lightningSound != null) lightningSound.Volume *= 0.5f; } - } + } public override void Update(GameTime gameTime) - { + { if (!CanSkyBeActive) - { + { LightningIntensity = 0f; BackgroundIntensity = MathHelper.Clamp(BackgroundIntensity - 0.08f, 0f, 1f); LightningBolts.Clear(); @@ -100,9 +104,9 @@ namespace CalamityMod.Skies BackgroundIntensity = MathHelper.Clamp(BackgroundIntensity + 0.01f, 0f, 1f); for (int i = 0; i < LightningBolts.Count; i++) - { + { LightningBolts[i].Lifetime--; - } + } if (Main.rand.NextBool((int)MathHelper.Lerp(50f, 195f, CurrentIntensity))) CreateLightningBolt(); @@ -114,7 +118,7 @@ namespace CalamityMod.Skies CreateLightningBolt(4); if (!Main.gamePaused) - { + { var lightningSound = Main.PlaySound(CalamityMod.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), Main.LocalPlayer.Center); if (lightningSound != null) lightningSound.Volume *= 0.5f; @@ -176,7 +180,7 @@ namespace CalamityMod.Skies public override float GetCloudAlpha() => 0f; - public override void Reset() { } + public override void Reset() { } public override void Activate(Vector2 position, params object[] args) { } diff --git a/Skies/StormWeaverFlashSky.cs b/Skies/StormWeaverFlashSky.cs index 6481e2987d..78dba77b3b 100644 --- a/Skies/StormWeaverFlashSky.cs +++ b/Skies/StormWeaverFlashSky.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Skies public override void Update(GameTime gameTime) { - int weaverType = ModContent.NPCType(); + int weaverType = ModContent.NPCType(); if (StormWeaverHeadIndex >= 0 && Main.npc[StormWeaverHeadIndex].active && Main.npc[StormWeaverHeadIndex].type == weaverType) return; @@ -36,7 +36,7 @@ namespace CalamityMod.Skies // Draw lightning in the background based on Main.magicPixel. // It is a long, white vertical strip that exists for some reason. // This lightning effect is achieved by expanding this to fit the entire background and then drawing it as a distinct element. - float lightningFlashPower = (Main.npc[StormWeaverHeadIndex].modNPC as StormWeaverHeadNaked).lightning; + float lightningFlashPower = (Main.npc[StormWeaverHeadIndex].modNPC as StormWeaverHead).lightning; Vector2 scale = new Vector2(Main.screenWidth * 1.1f / Main.magicPixel.Width, Main.screenHeight * 1.1f / Main.magicPixel.Height); Vector2 screenCenter = new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; Color drawColor = Color.White * MathHelper.Lerp(0f, 0.88f, lightningFlashPower); diff --git a/TileEntities/TECodebreaker.cs b/TileEntities/TECodebreaker.cs index 0442166a17..b09ab0329a 100644 --- a/TileEntities/TECodebreaker.cs +++ b/TileEntities/TECodebreaker.cs @@ -96,13 +96,17 @@ namespace CalamityMod.TileEntities int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; if (schematicType == ModContent.ItemType()) - return "test1"; + return "Within an army, as weapons do, the soldiers serve different purposes. That distinction is crucial, as the wrong tool in the wrong hands—no matter how potent—may as well be a wooden club.\n" + + "Addendum: Seek out my base of operations closest to the Lihzard’s home. I wish you the best of luck with all sincerity, for it has been a long time since I have had a worthy test subject. "; if (schematicType == ModContent.ItemType()) - return "test2"; + return "As rank progresses, so often does the lethality of equipment. In the hands of competent soldiers, the weapons have the ability to make change. However, competent soldiers take no action but orders from above.\n" + + "Addendum: If you read this, you have come far. Do not disappoint. Go now to Hell, for the next component stored in what were once my forges."; if (schematicType == ModContent.ItemType()) - return "test3"; + return "Only the highest ranking in the battalions of Yharim’s army held these weapons. However these are still not my most potent tools. Those...characters could not be trusted with them.\n" + + "Addendum: The final piece remains. Travel now from the hottest fire this land has to offer, to the most frigid cold. I cannot deny having some sense of poetic symmetry."; if (schematicType == ModContent.ItemType()) - return "test4"; + return "I have since made progress to even greater weapons than these, but they remain creations to be proud of. No progress can be made without a desire that comes from dissatisfaction.\n" + + "Addendum: The time has come. You are ready."; return string.Empty; } diff --git a/Tiles/Furniture/ChaosCandle.cs b/Tiles/Furniture/ChaosCandle.cs index 2a6c8aaae9..e8d55436b1 100644 --- a/Tiles/Furniture/ChaosCandle.cs +++ b/Tiles/Furniture/ChaosCandle.cs @@ -59,7 +59,8 @@ namespace CalamityMod.Tiles.Furniture public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - CalamityUtils.DrawFlameSparks(235, 5, i, j); + if (Main.tile[i, j].frameX < 18) + CalamityUtils.DrawFlameSparks(235, 5, i, j); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) diff --git a/Tiles/Furniture/TranquilityCandle.cs b/Tiles/Furniture/TranquilityCandle.cs index f1c55286d4..af6f18d820 100644 --- a/Tiles/Furniture/TranquilityCandle.cs +++ b/Tiles/Furniture/TranquilityCandle.cs @@ -59,7 +59,8 @@ namespace CalamityMod.Tiles.Furniture public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - CalamityUtils.DrawFlameSparks(62, 5, i, j); + if (Main.tile[i, j].frameX < 18) + CalamityUtils.DrawFlameSparks(62, 5, i, j); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) diff --git a/Tiles/FurnitureAbyss/AbyssTorch.cs b/Tiles/FurnitureAbyss/AbyssTorch.cs index ec76fb1868..c28ff30a23 100644 --- a/Tiles/FurnitureAbyss/AbyssTorch.cs +++ b/Tiles/FurnitureAbyss/AbyssTorch.cs @@ -70,7 +70,8 @@ namespace CalamityMod.Tiles.FurnitureAbyss } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - CalamityUtils.DrawFlameSparks(187, 5, i, j); + if (Main.tile[i, j].frameX < 66) + CalamityUtils.DrawFlameSparks(187, 5, i, j); } public override bool NewRightClick(int i, int j) diff --git a/Tiles/FurnitureAncient/AncientBasin.cs b/Tiles/FurnitureAncient/AncientBasin.cs index 748c8c4a80..4e4f9ac1ab 100644 --- a/Tiles/FurnitureAncient/AncientBasin.cs +++ b/Tiles/FurnitureAncient/AncientBasin.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Tiles.FurnitureAncient public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameY == 18) + if (tile.frameY == 18 && tile.frameX < 54) { CalamityUtils.DrawFlameSparks(60, 5, i, j); } diff --git a/Tiles/FurnitureAncient/AncientChandelier.cs b/Tiles/FurnitureAncient/AncientChandelier.cs index 8234044626..69ff43f743 100644 --- a/Tiles/FurnitureAncient/AncientChandelier.cs +++ b/Tiles/FurnitureAncient/AncientChandelier.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Tiles.FurnitureAncient public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameX == 18 && tile.frameY == 36) + if (tile.frameX < 54 && tile.frameY == 36) { CalamityUtils.DrawFlameSparks(60, 5, i, j); } diff --git a/Tiles/FurnitureAncient/AncientLamp.cs b/Tiles/FurnitureAncient/AncientLamp.cs index 15c3513f02..c63de59066 100644 --- a/Tiles/FurnitureAncient/AncientLamp.cs +++ b/Tiles/FurnitureAncient/AncientLamp.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Tiles.FurnitureAncient public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameY == 18) + if (tile.frameY == 18 && tile.frameX < 18) { CalamityUtils.DrawFlameSparks(60, 5, i, j); } diff --git a/Tiles/FurnitureAncient/AncientLantern.cs b/Tiles/FurnitureAncient/AncientLantern.cs index 40295c533a..22f7093077 100644 --- a/Tiles/FurnitureAncient/AncientLantern.cs +++ b/Tiles/FurnitureAncient/AncientLantern.cs @@ -36,21 +36,36 @@ namespace CalamityMod.Tiles.FurnitureAncient Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].frameX < 18) + { + r = 1f; + g = 0.5f; + b = 0.5f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { CalamityUtils.DrawFlameEffect(ModContent.GetTexture("CalamityMod/Tiles/FurnitureAncient/AncientLanternFlame"), i, j); } - public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + CalamityUtils.LightHitWire(Type, i, j, 1, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameY == 18) + if (tile.frameY == 18 && tile.frameX < 18) { CalamityUtils.DrawFlameSparks(60, 5, i, j); } diff --git a/Tiles/FurnitureAshen/AshenBasin.cs b/Tiles/FurnitureAshen/AshenBasin.cs index 54b0988925..885db098c8 100644 --- a/Tiles/FurnitureAshen/AshenBasin.cs +++ b/Tiles/FurnitureAshen/AshenBasin.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameY == 18) + if (tile.frameY == 18 && tile.frameX < 54) { CalamityUtils.DrawFlameSparks(60, 5, i, j); } diff --git a/Tiles/FurnitureAshen/AshenCandelabra.cs b/Tiles/FurnitureAshen/AshenCandelabra.cs index 9225e4dc4b..b0fd790b25 100644 --- a/Tiles/FurnitureAshen/AshenCandelabra.cs +++ b/Tiles/FurnitureAshen/AshenCandelabra.cs @@ -77,7 +77,8 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - CalamityUtils.DrawFlameSparks(60, 5, i, j); + if (Main.tile[i, j].frameX < 35) + CalamityUtils.DrawFlameSparks(60, 5, i, j); } } } diff --git a/Tiles/FurnitureAshen/AshenCandle.cs b/Tiles/FurnitureAshen/AshenCandle.cs index 47b8bd56cb..b2a051ca0b 100644 --- a/Tiles/FurnitureAshen/AshenCandle.cs +++ b/Tiles/FurnitureAshen/AshenCandle.cs @@ -73,7 +73,8 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - CalamityUtils.DrawFlameSparks(60, 5, i, j); + if (Main.tile[i, j].frameX < 18) + CalamityUtils.DrawFlameSparks(60, 5, i, j); } } } diff --git a/Tiles/FurnitureAshen/AshenChandelier.cs b/Tiles/FurnitureAshen/AshenChandelier.cs index 56fb3c82ae..60036b2535 100644 --- a/Tiles/FurnitureAshen/AshenChandelier.cs +++ b/Tiles/FurnitureAshen/AshenChandelier.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameY == 18) + if (tile.frameY == 18 && tile.frameX < 54) { CalamityUtils.DrawFlameSparks(60, 5, i, j); } diff --git a/Tiles/FurnitureAshen/AshenLamp.cs b/Tiles/FurnitureAshen/AshenLamp.cs index e6179be5bb..402c59dffe 100644 --- a/Tiles/FurnitureAshen/AshenLamp.cs +++ b/Tiles/FurnitureAshen/AshenLamp.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameY == 0) + if (tile.frameY == 0 && tile.frameX < 18) { CalamityUtils.DrawFlameSparks(60, 5, i, j); } diff --git a/Tiles/FurnitureAshen/AshenLantern.cs b/Tiles/FurnitureAshen/AshenLantern.cs index 7ef4799944..97d243117f 100644 --- a/Tiles/FurnitureAshen/AshenLantern.cs +++ b/Tiles/FurnitureAshen/AshenLantern.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameY == 18) + if (tile.frameY == 18 && tile.frameX < 18) { CalamityUtils.DrawFlameSparks(60, 5, i, j); } diff --git a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs index 2912fab2db..2912b63572 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs @@ -83,7 +83,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Tile tile = Main.tile[i, j]; - if (tile.frameY == 18) + if (tile.frameY == 18 && tile.frameX < 54) { CalamityUtils.DrawFlameSparks((int)CalamityDusts.PurpleCosmilite, 5, i, j); } diff --git a/Tiles/FurnitureProfaned/ProfanedBench.png b/Tiles/FurnitureProfaned/ProfanedBench.png index 2d16239eba..b6fc1a0d35 100644 Binary files a/Tiles/FurnitureProfaned/ProfanedBench.png and b/Tiles/FurnitureProfaned/ProfanedBench.png differ diff --git a/Tiles/FurnitureProfaned/ProfanedCandelabra.cs b/Tiles/FurnitureProfaned/ProfanedCandelabra.cs index 00de7fe7b3..8ba459625d 100644 --- a/Tiles/FurnitureProfaned/ProfanedCandelabra.cs +++ b/Tiles/FurnitureProfaned/ProfanedCandelabra.cs @@ -64,7 +64,8 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - CalamityUtils.DrawFlameSparks(246, 5, i, j); + if (Main.tile[i, j].frameX < 35) + CalamityUtils.DrawFlameSparks(246, 5, i, j); } } } diff --git a/Tiles/FurnitureProfaned/ProfanedCandle.cs b/Tiles/FurnitureProfaned/ProfanedCandle.cs index 4946095dbd..3087e8d025 100644 --- a/Tiles/FurnitureProfaned/ProfanedCandle.cs +++ b/Tiles/FurnitureProfaned/ProfanedCandle.cs @@ -74,7 +74,8 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - CalamityUtils.DrawFlameSparks(246, 5, i, j); + if (Main.tile[i, j].frameX < 18) + CalamityUtils.DrawFlameSparks(246, 5, i, j); } } } diff --git a/Tiles/FurnitureProfaned/ProfanedLamp.cs b/Tiles/FurnitureProfaned/ProfanedLamp.cs index bce7c22619..347fdb75d9 100644 --- a/Tiles/FurnitureProfaned/ProfanedLamp.cs +++ b/Tiles/FurnitureProfaned/ProfanedLamp.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - if (Main.tile[i, j].frameY == 0) + if (Main.tile[i, j].frameY == 0 && Main.tile[i, j].frameX < 18) { CalamityUtils.DrawFlameSparks(246, 5, i, j); } diff --git a/Tiles/FurnitureProfaned/ProfanedLantern.cs b/Tiles/FurnitureProfaned/ProfanedLantern.cs index a4f836b7cf..5f9f70084d 100644 --- a/Tiles/FurnitureProfaned/ProfanedLantern.cs +++ b/Tiles/FurnitureProfaned/ProfanedLantern.cs @@ -65,7 +65,8 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { - CalamityUtils.DrawFlameSparks(246, 5, i, j); + if (Main.tile[i, j].frameX < 18) + CalamityUtils.DrawFlameSparks(246, 5, i, j); } } } diff --git a/Tiles/FurnitureProfaned/ProfanedPiano.png b/Tiles/FurnitureProfaned/ProfanedPiano.png index e0a24c7064..efe7762c5a 100644 Binary files a/Tiles/FurnitureProfaned/ProfanedPiano.png and b/Tiles/FurnitureProfaned/ProfanedPiano.png differ diff --git a/Tiles/FurnitureVoid/VoidChair.png b/Tiles/FurnitureVoid/VoidChair.png index 3db9215362..01ed2d7466 100644 Binary files a/Tiles/FurnitureVoid/VoidChair.png and b/Tiles/FurnitureVoid/VoidChair.png differ diff --git a/Tiles/Ores/CharredOre.cs b/Tiles/Ores/CharredOre.cs index a413f1f556..bdf11823e8 100644 --- a/Tiles/Ores/CharredOre.cs +++ b/Tiles/Ores/CharredOre.cs @@ -33,11 +33,6 @@ namespace CalamityMod.Tiles.Ores Main.tileSpelunker[Type] = true; } - public override bool CanKillTile(int i, int j, ref bool blockDamaged) - { - return CalamityWorld.downedBrimstoneElemental; - } - public override bool CanExplode(int i, int j) { return false; diff --git a/TrailGeneration/PrimitiveTrail.cs b/TrailGeneration/PrimitiveTrail.cs index 7ad02a7ca4..75ea803c74 100644 --- a/TrailGeneration/PrimitiveTrail.cs +++ b/TrailGeneration/PrimitiveTrail.cs @@ -73,29 +73,8 @@ namespace CalamityMod public void UpdateBaseEffect(out Matrix effectProjection, out Matrix effectView) { - // Screen bounds. - int height = Main.instance.GraphicsDevice.Viewport.Height; + CalamityUtils.CalculatePerspectiveMatricies(out effectView, out effectProjection); - Vector2 zoom = Main.GameViewMatrix.Zoom; - Matrix zoomScaleMatrix = Matrix.CreateScale(zoom.X, zoom.Y, 1f); - - // Get a matrix that aims towards the Z axis (these calculations are relative to a 2D world). - effectView = Matrix.CreateLookAt(Vector3.Zero, Vector3.UnitZ, Vector3.Up); - - // Offset the matrix to the appropriate position. - effectView *= Matrix.CreateTranslation(0f, -height, 0f); - - // Flip the matrix around 180 degrees. - effectView *= Matrix.CreateRotationZ(MathHelper.Pi); - - // Account for the inverted gravity effect. - if (Main.LocalPlayer.gravDir == -1f) - effectView *= Matrix.CreateScale(1f, -1f, 1f) * Matrix.CreateTranslation(0f, height, 0f); - - // And account for the current zoom. - effectView *= zoomScaleMatrix; - - effectProjection = Matrix.CreateOrthographicOffCenter(0f, Main.screenWidth * zoom.X, 0f, Main.screenHeight * zoom.Y, 0f, 1f) * zoomScaleMatrix; BaseEffect.View = effectView; BaseEffect.Projection = effectProjection; } diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 516551a6cd..e010352316 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -191,15 +191,10 @@ namespace CalamityMod.UI NPCType(), NPCType(), NPCType(), - NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), NPCType(), NPCType(), NPCType(), diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index 4e7c63f4c1..7c3007e6af 100644 --- a/UI/CalamitasEnchantments/EnchantmentManager.cs +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Accessories; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.Other; using CalamityMod.Projectiles.Melee; @@ -272,7 +273,7 @@ namespace CalamityMod.UI.CalamitasEnchants player.Calamity().lecherousOrbEnchant = true; bool orbIsPresent = false; - int orbType = ModContent.NPCType(); + int orbType = ModContent.NPCType(); for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].type != orbType || Main.npc[i].target != player.whoAmI || !Main.npc[i].active) @@ -306,7 +307,10 @@ namespace CalamityMod.UI.CalamitasEnchants ItemUpgradeRelationship = new Dictionary() { [ModContent.ItemType()] = ModContent.ItemType(), - [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType() }; } diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 22a268ab9e..bd581c0318 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -644,8 +644,8 @@ namespace CalamityMod // Frog Leg r = GetNewRecipe(); - r.AddIngredient(ItemID.Frog, 10); - r.AddTile(TileID.Anvils); + r.AddIngredient(ItemID.Frog, 6); + r.AddTile(TileID.Anvils); r.SetResult(ItemID.FrogLeg); r.AddRecipe(); diff --git a/Utilities/CollisionUtils.cs b/Utilities/CollisionUtils.cs index 7170919ac6..193270aded 100644 --- a/Utilities/CollisionUtils.cs +++ b/Utilities/CollisionUtils.cs @@ -72,7 +72,7 @@ namespace CalamityMod // Since Terraria's tile coordinate system is discrete and does not care for more advanced concepts, // the amount of tiles searched such far is a sufficient answer. Tile tile = ParanoidTileRetrieval(checkPosition.X, checkPosition.Y); - if (WorldGen.SolidTile(tile) || (checkDirection.Y > 0f && tile.active() && Main.tileSolidTop[tile.type])) + if (WorldGen.SolidTile(tile) || (checkDirection.Y >= 0f && tile.active() && Main.tileSolidTop[tile.type])) return i; } return null; diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index e9cc64ecde..25e9bd1d51 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -180,6 +180,38 @@ namespace CalamityMod } #endregion + /// + /// Calculates perspective matrices for usage by vertex shaders. + /// + /// The view matrix. + /// The projection matrix. + public static void CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix) + { + Vector2 zoom = Main.GameViewMatrix.Zoom; + Matrix zoomScaleMatrix = Matrix.CreateScale(zoom.X, zoom.Y, 1f); + + // Screen bounds. + int height = Main.instance.GraphicsDevice.Viewport.Height; + + // Get a matrix that aims towards the Z axis (these calculations are relative to a 2D world). + viewMatrix = Matrix.CreateLookAt(Vector3.Zero, Vector3.UnitZ, Vector3.Up); + + // Offset the matrix to the appropriate position. + viewMatrix *= Matrix.CreateTranslation(0f, -height, 0f); + + // Flip the matrix around 180 degrees. + viewMatrix *= Matrix.CreateRotationZ(MathHelper.Pi); + + // Account for the inverted gravity effect. + if (Main.LocalPlayer.gravDir == -1f) + viewMatrix *= Matrix.CreateScale(1f, -1f, 1f) * Matrix.CreateTranslation(0f, height, 0f); + + // And account for the current zoom. + viewMatrix *= zoomScaleMatrix; + + projectionMatrix = Matrix.CreateOrthographicOffCenter(0f, Main.screenWidth * zoom.X, 0f, Main.screenHeight * zoom.Y, 0f, 1f) * zoomScaleMatrix; + } + /// /// Sets a 's arbitrarily. /// @@ -191,6 +223,18 @@ namespace CalamityMod spriteBatch.Begin(SpriteSortMode.Immediate, blendState, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix); } + // Cached for efficiency purposes. + internal static readonly FieldInfo BeginEndPairField = typeof(SpriteBatch).GetField("inBeginEndPair", BindingFlags.NonPublic | BindingFlags.Instance); + + /// + /// Determines if a is in a lock due to a call. + /// + /// The sprite batch to check. + public static bool HasBeginBeenCalled(this SpriteBatch spriteBatch) + { + return (bool)BeginEndPairField.GetValue(spriteBatch); + } + /// /// Draws text with an eight-way one-pixel offset border. /// @@ -436,8 +480,18 @@ namespace CalamityMod public static string ColorMessage(string msg, Color color) { - StringBuilder sb = new StringBuilder(msg.Length + 12); - sb.Append("[c/").Append(color.Hex3()).Append(':').Append(msg).Append(']'); + StringBuilder sb; + if (!msg.Contains("\n")) + { + sb = new StringBuilder(msg.Length + 12); + sb.Append("[c/").Append(color.Hex3()).Append(':').Append(msg).Append(']'); + } + else + { + sb = new StringBuilder(); + foreach (string newlineSlice in msg.Split('\n')) + sb.Append("[c/").Append(color.Hex3()).Append(':').Append(newlineSlice).Append(']').Append('\n'); + } return sb.ToString(); } diff --git a/Utilities/MathematicalUtils.cs b/Utilities/MathematicalUtils.cs index bee488ebe1..15b2b7b3b3 100644 --- a/Utilities/MathematicalUtils.cs +++ b/Utilities/MathematicalUtils.cs @@ -72,6 +72,25 @@ namespace CalamityMod /// The first point. /// The second point. public static float ManhattanDistance(this Vector2 a, Vector2 b) => Math.Abs(a.X - b.X) + Math.Abs(a.Y - b.Y); + + /// + /// Wraps an angle between -90 and 90 degrees. If an angle goes past this range it'll go back to the other end. + /// + /// + /// + public static float WrapAngle90Degrees(float theta) + { + // Ensure that the angle starts off in the -180 to 180 degree range instead of the 0 to 360 degree range. + if (theta > MathHelper.Pi) + theta -= MathHelper.Pi; + + if (theta > MathHelper.PiOver2) + theta -= MathHelper.Pi; + if (theta < -MathHelper.PiOver2) + theta += MathHelper.Pi; + + return theta; + } /// /// Determines the angular distance between two vectors based on dot product comparisons. This method ensures underlying normalization is performed safely. diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index 0bd6769842..5bd2706ed9 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -151,12 +151,9 @@ namespace CalamityMod { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType() }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, @@ -174,9 +171,6 @@ namespace CalamityMod { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, diff --git a/Utilities/NPCStats.cs b/Utilities/NPCStats.cs index 01981d44e5..c08ca8429a 100644 --- a/Utilities/NPCStats.cs +++ b/Utilities/NPCStats.cs @@ -185,7 +185,6 @@ namespace CalamityMod { NPCID.BrainofCthulhu, 0.9 }, { ModContent.NPCType(), 0.9 }, - { ModContent.NPCType(), 0.9 }, { ModContent.NPCType(), 0.9 }, @@ -265,8 +264,6 @@ namespace CalamityMod { ModContent.NPCType(), 0.8 }, { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, { ModContent.NPCType(), 0.9 }, @@ -279,8 +276,6 @@ namespace CalamityMod { ModContent.NPCType(), 0.85 }, { ModContent.NPCType(), 0.85 }, - { ModContent.NPCType(), 0.85 }, - { ModContent.NPCType(), 0.85 }, { ModContent.NPCType(), 0.8 }, @@ -330,8 +325,7 @@ namespace CalamityMod { NPCID.BrainofCthulhu, new int[] { 30, 54, 81, 99, 135 } }, { NPCID.Creeper, new int[] { 20, 36, 54, 72, 90 } }, - { ModContent.NPCType(), new int[] { 20, 36, 45, 54, 81 } }, - { ModContent.NPCType(), new int[] { 35, 63, 81, 90, 135 } }, + { ModContent.NPCType(), new int[] { 35, 63, 81, 90, 135 } }, { ModContent.NPCType(), new int[] { 25, 50, 62, 68, 90 } }, { ModContent.NPCType(), new int[] { 30, 54, 63, 72, 108 } }, @@ -504,12 +498,9 @@ namespace CalamityMod { ModContent.NPCType(), new int[] { 150, 300, 330, 348, 450 } }, { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 360 } }, - { ModContent.NPCType(), new int[] { 140, 280, 308, 324, 420 } }, - { ModContent.NPCType(), new int[] { 100, 160, 192, 208, 300 } }, - { ModContent.NPCType(), new int[] { 80, 128, 160, 176, 240 } }, - { ModContent.NPCType(), new int[] { 180, 360, 396, 418, 540 } }, - { ModContent.NPCType(), new int[] { 120, 192, 224, 250, 330 } }, - { ModContent.NPCType(), new int[] { 100, 160, 192, 210, 270 } }, + { ModContent.NPCType(), new int[] { 180, 360, 396, 418, 540 } }, + { ModContent.NPCType(), new int[] { 120, 192, 224, 250, 330 } }, + { ModContent.NPCType(), new int[] { 100, 160, 192, 210, 270 } }, { ModContent.NPCType(), new int[] { 175, 315, 351, 369, 459 } }, { ModContent.NPCType(), new int[] { 110, 220, 242, 256, 336 } }, @@ -532,12 +523,9 @@ namespace CalamityMod { ModContent.NPCType(), new int[] { 180, 270, 300, 315, 405 } }, { ModContent.NPCType(), new int[] { 180, 270, 300, 315, 405 } }, - { ModContent.NPCType(), new int[] { 300, 600, 650, 680, 760 } }, - { ModContent.NPCType(), new int[] { 180, 306, 340, 357, 510 } }, - { ModContent.NPCType(), new int[] { 150, 255, 289, 306, 408 } }, - { ModContent.NPCType(), new int[] { 350, 700, 750, 780, 880 } }, - { ModContent.NPCType(), new int[] { 220, 374, 425, 442, 561 } }, - { ModContent.NPCType(), new int[] { 180, 306, 340, 357, 459 } }, + { ModContent.NPCType(), new int[] { 350, 700, 750, 780, 880 } }, + { ModContent.NPCType(), new int[] { 220, 374, 425, 442, 561 } }, + { ModContent.NPCType(), new int[] { 180, 306, 340, 357, 459 } }, { ModContent.NPCType(), new int[] { 180, 360, 396, 420, 510 } }, { ModContent.NPCType(), new int[] { 130, 260, 290, 320, 420 } }, { ModContent.NPCType(), new int[] { 100, 200, 230, 260, 330 } }, @@ -571,7 +559,7 @@ namespace CalamityMod { new Tuple(NPCID.EaterofWorldsHead, ProjectileID.CursedFlameHostile), new int[] { 32, 48, 60, 68, 90 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 68, 90 } }, @@ -758,8 +746,6 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrb), new int[] { 150, 264, 288, 300, 432 } }, { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 150, 264, 288, 300, 432 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrb), new int[] { 150, 264, 288, 300, 432 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 150, 264, 288, 300, 432 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 212, 224, 318 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, @@ -779,8 +765,7 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 160, 276, 304, 320, 456 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 300, 332, 348, 498 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 160, 276, 304, 320, 456 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 300, 332, 348, 498 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 520, 548, 564, 822 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 300, 332, 348, 498 } }, diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 7defb32ca0..c2c30d3114 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -75,10 +75,10 @@ namespace CalamityMod.World public static bool death = false; // Death Mode public static bool armageddon = false; // Armageddon Mode public static bool ironHeart = false; // Iron Heart Mode - public static bool malice = false; // Malice Mode, enrages all bosses and makes them drop good shit + public static bool malice = false; // Malice Mode - // New Temple Altar - public static int newAltarX = 0; + // New Temple Altar + public static int newAltarX = 0; public static int newAltarY = 0; // Evil Islands @@ -158,6 +158,7 @@ namespace CalamityMod.World public static bool stylistName = false; public static bool tavernkeepName = false; public static bool taxCollectorName = false; + public static bool travelingMerchantName = false; public static bool truffleName = false; public static bool witchDoctorName = false; public static bool wizardName = false; @@ -166,6 +167,7 @@ namespace CalamityMod.World public static int DraedonSummonCountdown = 0; public static ExoMech DraedonMechToSummon; public static Vector2 DraedonSummonPosition = Vector2.Zero; + public static bool TalkedToDraedon = false; public static bool AbleToSummonDraedon { get @@ -307,6 +309,7 @@ namespace CalamityMod.World stylistName = false; tavernkeepName = false; taxCollectorName = false; + travelingMerchantName = false; truffleName = false; witchDoctorName = false; wizardName = false; @@ -333,6 +336,7 @@ namespace CalamityMod.World downedAres = false; downedThanatos = false; downedArtemisAndApollo = false; + TalkedToDraedon = false; downedSCal = false; downedAdultEidolonWyrm = false; downedCLAM = false; @@ -408,6 +412,8 @@ namespace CalamityMod.World downed.Add("thanatos"); if (downedArtemisAndApollo) downed.Add("artemisAndApollo"); + if (TalkedToDraedon) + downed.Add("TalkedToDraedon"); if (downedSCal) downed.Add("supremeCalamitas"); if (downedAdultEidolonWyrm) @@ -502,6 +508,8 @@ namespace CalamityMod.World downed.Add("tavernkeepName"); if (taxCollectorName) downed.Add("taxCollectorName"); + if (travelingMerchantName) + downed.Add("travelingMerchantName"); if (truffleName) downed.Add("truffleName"); if (witchDoctorName) @@ -538,12 +546,12 @@ namespace CalamityMod.World ["Reforges"] = Reforges, ["MoneyStolenByBandit"] = MoneyStolenByBandit, - ["SunkenSeaLabCenter"] = SunkenSeaLabCenter, + ["SunkenSeaLabCenter"] = SunkenSeaLabCenter, ["PlanetoidLabCenter"] = PlanetoidLabCenter, ["JungleLabCenter"] = JungleLabCenter, ["HellLabCenter"] = HellLabCenter, - ["IceLabCenter"] = IceLabCenter, - }; + ["IceLabCenter"] = IceLabCenter + }; } #endregion @@ -573,6 +581,7 @@ namespace CalamityMod.World downedAres = downed.Contains("ares"); downedThanatos = downed.Contains("thanatos"); downedArtemisAndApollo = downed.Contains("artemisAndApollo"); + TalkedToDraedon = downed.Contains("TalkedToDraedon"); downedSCal = downed.Contains("supremeCalamitas"); downedAdultEidolonWyrm = downed.Contains("adultEidolonWyrm"); downedBumble = downed.Contains("bumblebirb"); @@ -622,6 +631,7 @@ namespace CalamityMod.World stylistName = downed.Contains("stylistName"); tavernkeepName = downed.Contains("tavernkeepName"); taxCollectorName = downed.Contains("taxCollectorName"); + travelingMerchantName = downed.Contains("travelingMerchantName"); truffleName = downed.Contains("truffleName"); witchDoctorName = downed.Contains("witchDoctorName"); wizardName = downed.Contains("wizardName"); @@ -644,7 +654,7 @@ namespace CalamityMod.World Reforges = tag.GetInt("Reforges"); MoneyStolenByBandit = tag.GetInt("MoneyStolenByBandit"); - SunkenSeaLabCenter = tag.Get("SunkenSeaLabCenter"); + SunkenSeaLabCenter = tag.Get("SunkenSeaLabCenter"); PlanetoidLabCenter = tag.Get("PlanetoidLabCenter"); JungleLabCenter = tag.Get("JungleLabCenter"); HellLabCenter = tag.Get("HellLabCenter"); @@ -661,7 +671,7 @@ namespace CalamityMod.World Reforges = reader.ReadInt32(); MoneyStolenByBandit = reader.ReadInt32(); - if (loadVersion == 0) + if (loadVersion == 0) { BitsByte flags = reader.ReadByte(); downedDesertScourge = flags[0]; @@ -878,7 +888,7 @@ namespace CalamityMod.World flags10[0] = anglerName; flags10[1] = clothierName; flags10[2] = encounteredOldDuke; - flags10[3] = false; + flags10[3] = travelingMerchantName; flags10[4] = false; flags10[5] = false; flags10[6] = false; @@ -892,8 +902,9 @@ namespace CalamityMod.World flags11[4] = downedAres; flags11[5] = downedThanatos; flags11[6] = downedArtemisAndApollo; + flags11[7] = TalkedToDraedon; - writer.Write(flags); + writer.Write(flags); writer.Write(flags2); writer.Write(flags3); writer.Write(flags4); @@ -1020,7 +1031,7 @@ namespace CalamityMod.World anglerName = flags10[0]; clothierName = flags10[1]; encounteredOldDuke = flags10[2]; - _ = flags10[3]; + travelingMerchantName = flags10[3]; _ = flags10[4]; _ = flags10[5]; _ = flags10[6]; @@ -1036,12 +1047,13 @@ namespace CalamityMod.World downedAres = flags11[4]; downedThanatos = flags11[5]; downedArtemisAndApollo = flags11[6]; + TalkedToDraedon = flags11[7]; - abyssChasmBottom = reader.ReadInt32(); + abyssChasmBottom = reader.ReadInt32(); acidRainPoints = reader.ReadInt32(); Reforges = reader.ReadInt32(); MoneyStolenByBandit = reader.ReadInt32(); - DraedonSummonCountdown = reader.ReadInt32(); + DraedonSummonCountdown = reader.ReadInt32(); DraedonMechToSummon = (ExoMech)reader.ReadInt32(); DraedonSummonPosition = reader.ReadVector2(); SunkenSeaLabCenter = reader.ReadVector2(); diff --git a/World/CustomConditions.cs b/World/CustomConditions.cs index 27c7f73e60..28e5a09f31 100644 --- a/World/CustomConditions.cs +++ b/World/CustomConditions.cs @@ -1,5 +1,6 @@ using Terraria; +using Terraria.ID; using Terraria.World.Generation; namespace CalamityMod.World @@ -30,6 +31,11 @@ namespace CalamityMod.World } } + public class SolidOrPlatform : GenCondition + { + protected override bool CheckValidity(int x, int y) => TileID.Sets.Platforms[CalamityUtils.ParanoidTileRetrieval(x, y).type] || WorldGen.SolidTile(x, y); + } + public class IsNotTouchingAir : GenCondition { private bool _useDiagonals; diff --git a/World/WorldUpdateMiscEffects.cs b/World/WorldUpdateMiscEffects.cs index d599a963fd..dba9b25a23 100644 --- a/World/WorldUpdateMiscEffects.cs +++ b/World/WorldUpdateMiscEffects.cs @@ -80,7 +80,7 @@ namespace CalamityMod.World // Update Boss Rush. BossRushEvent.Update(); - // Handle Phase 2 DoG's summon-code, for both DoG directly and his sentinels. + // Handle Phase 2 DoG's summon-code, for his sentinels. HandleDoGP2Countdown(player); // Handle conditional summons. @@ -127,9 +127,6 @@ namespace CalamityMod.World public static void HandleDraedonSummoning() { - Main.LocalPlayer.Calamity().MusicMuffleFactor = Utils.InverseLerp(DraedonSummonCountdownMax, 32f, DraedonSummonCountdown, true); - Main.LocalPlayer.Calamity().MusicMuffleFactor = (float)Math.Pow(Main.LocalPlayer.Calamity().MusicMuffleFactor, 0.1); - // Fire a giant laser into the sky. if (DraedonSummonCountdown == DraedonSummonCountdownMax - 45) Projectile.NewProjectile(DraedonSummonPosition + Vector2.UnitY * 80f, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); @@ -361,26 +358,6 @@ namespace CalamityMod.World CalamityUtils.SpawnBossBetter(player.Center, ModContent.NPCType(), new OffscreenBossSpawnContext()); if (DoGSecondStageCountdown == 7140) CalamityUtils.SpawnBossBetter(player.Center, ModContent.NPCType(), new OffscreenBossSpawnContext()); - - if (DoGSecondStageCountdown <= 60) - { - int freeNPCSlots = Main.maxNPCs - Main.npc.Take(Main.maxNPCs).Where(npc => npc.active).Count(); - - // If there are too many slots occupied, make a note in the logs, - // and don't attempt to spawn the Devourer of Gods. - if (freeNPCSlots < 102) - { - CalamityMod.Instance.Logger.Warn("You have too many occupied NPC slots for DoG to spawn. Remove dummies or kill excessive town NPCs."); - DoGSecondStageCountdown = 0; - } - else if (!NPC.AnyNPCs(ModContent.NPCType())) - { - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - string key = "Mods.CalamityMod.EdgyBossText10"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - } } if (Main.netMode == NetmodeID.Server) {