diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 69da5dee7e..1d068940fc 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -886,7 +886,7 @@ namespace CalamityMod.ILEditing return; } cursor.Emit(OpCodes.Pop); - cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalNPC.TotalTaxesPerNPC)}"); + cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalTownNPC.TotalTaxesPerNPC)}"); if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall(nameof(Item.buyPrice)))) { @@ -894,7 +894,7 @@ namespace CalamityMod.ILEditing return; } cursor.Emit(OpCodes.Pop); - cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalNPC.TaxesToCollectLimit)}"); + cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalTownNPC.TaxesToCollectLimit)}"); } #endregion diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index b7820a0559..9056efabe0 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -962,9 +962,9 @@ namespace CalamityMod #region Town NPC Alert support public static void RegisterTownNPCShop(int id, Predicate getShop, Action setShop) { - if (!CalamityGlobalNPC.npcAlertList.Contains((id, getShop, setShop))) + if (!CalamityGlobalTownNPC.npcAlertList.Contains((id, getShop, setShop))) { - CalamityGlobalNPC.npcAlertList.Add((id, getShop, setShop)); + CalamityGlobalTownNPC.npcAlertList.Add((id, getShop, setShop)); } } #endregion @@ -2180,7 +2180,7 @@ namespace CalamityMod return new ArgumentException("ERROR: The first argument to \"SetNewShopVariable\" must be an integer array of npc ids that should be alerted."); if (args.Length != 3 || args[2] is not bool alreadySet) return new ArgumentException("ERROR: The second argument to \"SetNewShopVariable\" Must be a bool that determines if the shop alert should show."); - CalamityGlobalNPC.SetNewShopVariable(npcs, alreadySet); + CalamityGlobalTownNPC.SetNewShopVariable(npcs, alreadySet); return null; } diff --git a/NPCs/CalClone/CalamitasClone.cs b/NPCs/CalClone/CalamitasClone.cs index 8a7ec86dcd..9e8f0d709b 100644 --- a/NPCs/CalClone/CalamitasClone.cs +++ b/NPCs/CalClone/CalamitasClone.cs @@ -96,7 +96,7 @@ namespace CalamityMod.NPCs.CalClone if (lifeRatio < 0.1f && !inBulletHell && CalamityWorld.death) baseSize *= MathHelper.Lerp(Main.getGoodWorld ? 0.22f : 0.4f, 1f, lifeRatio * 10f); // Scale down the lower health calclone has. Much lower bound on FTW. - return baseSize + new Vector4(-22, 0 ,22,0); + return baseSize + new Vector4(-22, 0, 22, 0); } public override void SetStaticDefaults() { @@ -1071,7 +1071,7 @@ namespace CalamityMod.NPCs.CalClone CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedCalamitasClone); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedCalamitasClone); // Mark the Calamitas Clone as dead DownedBossSystem.downedCalamitasClone = true; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index a053e8554d..56e32e5f9e 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -232,11 +232,6 @@ namespace CalamityMod.NPCs public const int maxPlayerImmunities = Main.maxPlayers + 1; public int[] dashImmunityTime = new int[maxPlayerImmunities]; - /// Used to control the animation of the Town NPC Shop Alert icon, if the respective config is enabled. - public int shopAlertAnimTimer = 0; - /// - public int shopAlertAnimFrame = 0; - /// /// If set to false, prevents this NPC from allowing Rage to be generated by nearby players, regardless of other factors.
/// Defaults to true. @@ -249,9 +244,6 @@ namespace CalamityMod.NPCs public float[] newAI = new float[maxAIMod]; public int killTimeTimer = 0; - /// Used for allowing Patreon names for Town NPCs. - public bool setNewName = true; - /// If set to true, the Boss Health Bar for this NPC will count the total health of all individual segments using worm segment logic. public bool SplittingWorm = false; /// If set to true, allows this NPC to draw a Boss Health Bar, regardless of other factors. @@ -541,9 +533,6 @@ namespace CalamityMod.NPCs for (int i = 0; i < maxPlayerImmunities; ++i) myClone.dashImmunityTime[i] = dashImmunityTime[i]; - myClone.shopAlertAnimTimer = shopAlertAnimTimer; - myClone.shopAlertAnimFrame = shopAlertAnimFrame; - myClone.ProvidesProximityRage = ProvidesProximityRage; myClone.newAI = new float[maxAIMod]; @@ -551,8 +540,6 @@ namespace CalamityMod.NPCs myClone.newAI[i] = newAI[i]; myClone.killTimeTimer = killTimeTimer; - myClone.setNewName = setNewName; - myClone.SplittingWorm = SplittingWorm; myClone.CanHaveBossHealthBar = CanHaveBossHealthBar; myClone.ShouldCloseHPBar = ShouldCloseHPBar; @@ -1248,7 +1235,6 @@ namespace CalamityMod.NPCs npc.SetDebuffImmunities(); VulnerabilitiesAndResistances(npc); - BoundNPCSafety(Mod, npc); } public override bool? CanFallThroughPlatforms(NPC npc) @@ -2882,8 +2868,6 @@ namespace CalamityMod.NPCs ManaBurnFireDrawer.Update(); } - SetPatreonTownNPCName(npc, Mod); - // Decrement each immune timer if it's greater than 0. for (int i = 0; i < maxPlayerImmunities; i++) { @@ -5357,8 +5341,6 @@ namespace CalamityMod.NPCs } } - TownNPCAlertSystem(npc, Mod, spriteBatch); - // VHex, Mana Burn and Miracle Blight visuals do not appear if Odd Mushroom is in use for sanity reasons if (!Main.LocalPlayer.Calamity().trippy) { diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 22b601d5e7..2fab5b9abd 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -31,6 +31,7 @@ using Terraria.Audio; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.NPCs.CalamityGlobalTownNPC; namespace CalamityMod.NPCs { @@ -699,7 +700,7 @@ namespace CalamityMod.NPCs case NPCID.Drippler: postEoC.Add(ModContent.ItemType(), 4); break; - + //Hardmode enemies drop orbs even if EoC is not dead //99% of players will not encounter this and challenge runners will appreciate it case NPCID.Clown: @@ -1701,12 +1702,12 @@ namespace CalamityMod.NPCs } } catch (ArgumentNullException) { } - DukeEditFailed: +DukeEditFailed: - // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic - // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.ShrimpyTruffle)); +// 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic +// npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.ShrimpyTruffle)); - // Would be in the bag otherwise +// Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), 10); npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 006bbc258e..451ecf73dc 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -35,7 +35,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.NPCs { - public partial class CalamityGlobalNPC : GlobalNPC + public class CalamityGlobalTownNPC : GlobalNPC { public static float TaxYieldFactor { @@ -63,16 +63,42 @@ namespace CalamityMod.NPCs // Vanilla: 25 gold public static int TaxesToCollectLimit => (int)(Item.buyPrice(gold: 50) * TaxYieldFactor); + + /// Used for allowing Patreon names for Town NPCs. + public bool setNewName = true; + /// Used to control the animation of the Town NPC Shop Alert icon, if the respective config is enabled. + public int shopAlertAnimTimer = 0; + /// + public int shopAlertAnimFrame = 0; + + public override bool InstancePerEntity => true; + + public override bool AppliesToEntity(NPC entity, bool lateInstantiation) + { + return entity.isLikeATownNPC; + } + + public override GlobalNPC Clone(NPC npc, NPC npcClone) + { + CalamityGlobalTownNPC myClone = (CalamityGlobalTownNPC)base.Clone(npc, npcClone); + + myClone.setNewName = setNewName; + myClone.shopAlertAnimTimer = shopAlertAnimTimer; + myClone.shopAlertAnimFrame = shopAlertAnimFrame; + + return myClone; + } + #region Town NPC Patreon Name Sets private static readonly string[] AnglerNames = - { + [ "Dazren", "Johnny Test", // <@!589966747977777197> (konorango) "Bling Bling Boy", // <@!522970788203069442> (phallguy) "RICE", // <@!400107830889152524> (rice_xd.) - }; + ]; private static readonly string[] ArmsDealerNames = - { + [ "Finchi", "Heniek", // <@!363404700445442050> (kazurgundu) "Fire", // <@!354362326947856384> (ultimatefirewaster) @@ -82,37 +108,37 @@ namespace CalamityMod.NPCs "The Cooler Arthur", // <@!568263512523014154> (gokuartillery) "Shark", // <@!874464051697172492> (congratsistrash) "Sagi", // <@!508233115781693441> (sagittariod) - }; + ]; private static readonly string[] ClothierNames = - { + [ "Joeseph Jostar", "Storm Havik", // <@!1013452363178197072> (fishnotduck) "Magorfis Splunt the Greater Finklejim", // <@!147490809334333440> (eidolbyssus) "Perrin", // <@!253764551139393537> (easyperrin) - }; + ]; private static readonly string[] CyborgNames = - { + [ "Sylux", // <@!331812782183809025> (gonkachino) "Nemesis", // <@!1104036024063107082> (yashimayamanata) - }; + ]; private static readonly string[] DemolitionistNames = - { + [ "Tavish DeGroot", // <@!442447226992721930> (magicoal) "Fimmy", // <@!407348617079160832> (darkmega5) "John Helldiver", // <@!614126424751603714> (exellent.) - }; + ]; private static readonly string[] DryadNames = - { + [ "Rythmi", "Izuna", "Jasmine", // <@!430532867479699456> (phantasmagoria.) "Cybil", // <@!486507232666845185> (Captain Doofus#????) "Ruth", // <@!1001307586068492388> (briny_coffee) "Kanna", // <@!730203712898859018> (cosmoredeathwish) - }; + ]; private static readonly string[] DyeTraderNames = null; private static readonly string[] GoblinTinkererNames = - { + [ "Verth", "Gormer", // <@!287651204924833795> (picassosbean2819 -- RIP) "TingFlarg", // <@!185605031716847616> (smugggo) @@ -126,10 +152,10 @@ namespace CalamityMod.NPCs "Bars Boldia", // <@!332989575708540939> (careless_imp) "Basel Raiden John Clive Fantasy 16", // <@!529392083136413696> (raiden_ii) "Gobby, Destroyer of Wallets", // <@!429024941296582658> (bwlstorm) - }; + ]; private static readonly string[] GolferNames = null; private static readonly string[] GuideNames = - { + [ "Lapp", "Ben Shapiro", "Streakist", // used to be "StreakistYT". couldn't find the youtube channel, and decided to remove the ad. @@ -148,39 +174,39 @@ namespace CalamityMod.NPCs "Dinkleberg", // <@!581993958037520404> (hyperionzx) "Wamy", // Fab added this name with no Discord ID. May be a donor who has no Discord account. "Baggute", // <@!535140564174110720> (thebaggutegamer) - }; + ]; private static readonly string[] MechanicNames = - { + [ "Lilly", "Daawn", // <@!206162323541458944> (daawnily) "Robin", // <@!654737510030639112> (altzeus) "Curly", // <@!673092101780668416> (curly4830) "Cobalt", // <@!132962828922388481> (cobalt_44) - }; + ]; private static readonly string[] MerchantNames = - { + [ "Morshu", // <@!194931581826236416> (uberransy) "Spamton G. Spamton", // <@!497146350438318101> (j.u.n.e.s) - }; + ]; private static readonly string[] NurseNames = - { + [ "Farsni", "Fanny", // <@!799749125720637460> (zombiewolf511) "Mausi", // <@!194156349347594241> (sadouken) "Fiona", // <@!475216964168450048> (thatgayguy69) - }; + ]; private static readonly string[] PainterNames = - { + [ "Picasso", // <@!353316526306361347> (sconicboom -- for the late picassosbean2819) "Bew", // <@!232291351167893505> (dmshi) - }; + ]; private static readonly string[] PartyGirlNames = - { + [ "Arin", // <@!268169458302976012> (kiyotu) "Typhäne", // <@!222064016107896832> (typhane.) - }; + ]; private static readonly string[] PirateNames = - { + [ "Tyler Van Hook", "Cap'n Deek", // "Alex N" on Patreon (No discord account) "Captain Billy Bones", // <@!699589229507772416> (djackv) @@ -189,9 +215,9 @@ namespace CalamityMod.NPCs "Yarrim", // <@!290061123137306624> (borb9834) "Hector Barbossa", // <@!615704209303797790> (thatrockisfullamagic) "Blunderbeard", // <@!1039460813490102293> (parmiigianoreggiano) - }; + ]; private static readonly string[] PrincessNames = - { + [ "Nyapano", // <@!120976656826368003> (nyapano) "Jade", // <@!187395834625785869> (verymasterninja) "Nyavi Aceso", // <@!270260920888852480> (navigator.) @@ -200,21 +226,21 @@ namespace CalamityMod.NPCs "Hael", // <@!641747280944431156> (kalebtull) "Yumesaki Mirrin", // <@!100235144744415232> (milinen) "Vela", // <@!208719047146209281> (nyxxynightstar) - }; + ]; private static readonly string[] SantaClausNames = - { + [ "Jank", // <@!339950757472239616> (jankle_) "Aoi Kurashiki", // <@!358411687885537291> (nothinpurrsonal) - }; + ]; private static readonly string[] SkeletonMerchantNames = - { + [ "Sans Undertale", // <@!534770496038895616> (done_22_) "Papyrus Undertale", // <@!262663471189983242> (nycro) "Mr. Bones", // <@!359215912856977408> (jaybones.) "Freakbob", // <@!377863128140087296> (jevilamv) - }; + ]; private static readonly string[] SteampunkerNames = - { + [ "Vorbis", "Angel", "Mòrag Ladair", // <@!161893929485074432> (jalapeno9) @@ -223,51 +249,51 @@ namespace CalamityMod.NPCs "Kreutz", // <@!553445849149997056> (red_r_kreutz) "Cathlyn", // <@!156672312425316352> (xaqult) "Eunice", // <@!358376627400605699> (srmg267) - }; + ]; private static readonly string[] StylistNames = - { + [ "Amber", // <@!114677116473180169> (mishirousui) "Faith", // <@!509050283871961123> (toasty1007) "Xsiana", // <@!625780237489143839> (lokistic) "Lain", // <@!655201622863118337> (literallyadeerfr) "Hamis", // <@!608455754093035521> (haefer) "Brio Scarlet", // <@!358576903701004289> (brio_scarlet) - }; + ]; private static readonly string[] TavernkeepNames = - { + [ "Tim Lockwood", // <@!605839945483026434> (pomvoid) "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (ryaegos) "Brutus", // <@!591889650692521984> (.brutus._) "Sloth", // <@!486265327387279391> (bossypunch) - }; + ]; private static readonly string[] TaxCollectorNames = - { + [ "Emmett", "Casino King Gray", // <@!555512087711973390> (eternalgrayson) - }; + ]; private static readonly string[] TravelingMerchantNames = - { + [ "Stan Pines", "Intergaze", // <@!923504188615450654> (intergaze) "Borgus", // <@!539127427482255376> (therealmeepman) "Postman Hiss", // <@!454638106122125312> (karinthefairy) - }; + ]; private static readonly string[] TruffleNames = - { + [ "Aldrimil", // <@!413719640238194689> (Thorioum#2475) "Wonton", // <@!1198092982923043040> (imonthatgudkush) "Mad Lad", // <@!215269032360804352> (crimsoncb) "Nokko", // <@!706732954079985745> (violet.prime) - }; + ]; private static readonly string[] WitchDoctorNames = - { + [ "Sok'ar", "Aeroni", // <@!348174404984766465> (aeroni) (previously: toxin) "Mixcoatl", // <@!284775927294984203> (.sharzz) "Amnesia Wapers", // <@!326821498323075073> (retardedadvicefromaretard) - }; + ]; private static readonly string[] WizardNames = - { + [ "Inorim, son of Ivukey", "Jensen", "Merasmus", // <@!288066987819663360> (spiderprovidence) @@ -278,16 +304,16 @@ namespace CalamityMod.NPCs "Nextdoor Psycho", // <@!173261518572486656> (nextdoorpsycho) "Mike Cyclops", // <@!702327497475227741> (seichoseicho) "Derin", // <@!466703979695308820> (god_15) - }; + ]; private static readonly string[] ZoologistNames = - { + [ "Kiriku", // <@!395312478160027668> (rulosss) "Lacuna", // <@!790746689211203604> (_lacuna_) "Mae Borowski", //<@!219158690433990656> (justakkolite) "Fera", // <@!195850711567826945> (juneark_) "Gwenhwyvar", // <@!291342874497515531> (diamondnife) "Daxie", // <@!465438861103988737> (daxie626) - }; + ]; // Town Slimes private static readonly string[] ClumsySlimeNames = null; private static readonly string[] CoolSlimeNames = null; @@ -295,10 +321,10 @@ namespace CalamityMod.NPCs private static readonly string[] ElderSlimeNames = null; private static readonly string[] MysticSlimeNames = null; private static readonly string[] NerdySlimeNames = - { + [ "Big Blungus", // <@!272759434282008577> (schmoov) "Rimuru Tempest", // <@!806463201398358036> (c0d3_404) - }; + ]; private static readonly string[] SquireSlimeNames = null; private static readonly string[] SurlySlimeNames = null; @@ -313,29 +339,29 @@ namespace CalamityMod.NPCs private const int TownDogDalmatianVanillaNames = 13; private const int TownDogHuskyVanillaNames = 16; private static readonly string[] TownDogNames = - { + [ "Ozymandias", // <@!146333264871686145> (ozzatron) "Miss Throws a Lot", // <@!799345607847182400> (oakhamsam) "Brikwilla", // <@!543803736909414438> (lavendercobra) - }; + ]; private static readonly string[] TownDogLabradorNames = - { + [ "Riley", // <@!260875558592708619> (potionpal) - }; + ]; private static readonly string[] TownDogPitBullNames = - { + [ "Splinter", // <@!320320801213775873> (kaimonick) - }; + ]; private static readonly string[] TownDogBeagleNames = - { + [ "Kendra", // <@!237247188005158912> (lordmetarex) - }; + ]; private static readonly string[] TownDogCorgiNames = null; private static readonly string[] TownDogDalmatianNames = null; private static readonly string[] TownDogHuskyNames = - { + [ "Yoshi", // <@!541127291426832384> (gregthespinarak) - }; + ]; private const int TownCatSiameseVanillaNames = 12; private const int TownCatBlackVanillaNames = 23; @@ -344,34 +370,34 @@ namespace CalamityMod.NPCs private const int TownCatSilverVanillaNames = 17; private const int TownCatWhiteVanillaNames = 15; private static readonly string[] TownCatNames = - { + [ "Smoogle", // <@!709968379334623274> (smooglin) "The Meowurer of Gods", // <@!385949114271268864> (thatgp) "Katsafaros", // <@!190595401328492544> (gr_mm) "Lucerne", // <@!271954788676141066> (lord_lucerne) "Milo", // <@!401849201597874179> (maskedmilo) "Octo", // <@!796112889353994281> (octolinggrimm) - }; + ]; private static readonly string[] TownCatSiameseNames = null; private static readonly string[] TownCatBlackNames = - { + [ "Bear", // <@!183424826407518208> (lilac_vrt_olligoci) "Storm", // <@!620383533516718085> (airwaveslr) "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) - }; + ]; private static readonly string[] TownCatOrangeTabbyNames = - { + [ "Felix", // <@!183424826407518208> (lilac_vrt_olligoci) "Tardo", // <@!739343546867384391> (midnight295) "Dali", // <@!460238880436781061> (darthlego) "Kiba", // <@!852348657072340992> (jollydragonslayer) - }; + ]; private static readonly string[] TownCatRussianBlueNames = null; private static readonly string[] TownCatSilverNames = - { + [ "Archie", // <@!303022375191183360> (jackshiz) "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) - }; + ]; private static readonly string[] TownCatWhiteNames = null; private const int TownBunnyWhiteVanillaNames = 14; @@ -381,10 +407,10 @@ namespace CalamityMod.NPCs private const int TownBunnyLopVanillaNames = 13; private const int TownBunnySilverVanillaNames = 13; private static readonly string[] TownBunnyNames = - { + [ "Poco", // <@!1192261996146593872> (tostitomuncher33) "Puffer", // <@!181103507711983616> (piky) - }; + ]; private static readonly string[] TownBunnyWhiteNames = null; private static readonly string[] TownBunnyAngoraNames = null; private static readonly string[] TownBunnyDutchNames = null; @@ -734,6 +760,29 @@ namespace CalamityMod.NPCs } #endregion + #region SetDefaults + public override void SetDefaults(NPC npc) + { + BoundNPCSafety(Mod, npc); + } + #endregion + + #region PreAI + public override bool PreAI(NPC npc) + { + SetPatreonTownNPCName(npc, Mod); + return true; + } + #endregion + + #region PreDraw + public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + TownNPCAlertSystem(npc, Mod, spriteBatch); + return true; + } + #endregion + #region NPC New Shop Alert public static List<(int, Predicate, Action)> npcAlertList = new List<(int, Predicate, Action)>() @@ -896,7 +945,7 @@ namespace CalamityMod.NPCs chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.DarksunEclipse"); else if (Main.rand.NextBool(5) && Main.LocalPlayer.ZoneGlowshroom) { - chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.Mushroom"); + chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.Mushroom"); } else if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.SulphurSea"); diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 7cfd029d27..1d67b1fa91 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.DevourerofGods [LongDistanceNetSync] public class DevourerofGodsHead : ModNPC { - public static Color SpecialMoveColor => Color.Lerp(Color.Fuchsia, Color.Cyan, MathHelper.SmoothStep(0,1,(MathF.Sin(Main.GlobalTimeWrappedHourly*2)+1) * 0.5f)); + public static Color SpecialMoveColor => Color.Lerp(Color.Fuchsia, Color.Cyan, MathHelper.SmoothStep(0, 1, (MathF.Sin(Main.GlobalTimeWrappedHourly * 2) + 1) * 0.5f)); public static int phase1IconIndex; public static int phase2IconIndex; @@ -67,7 +67,7 @@ namespace CalamityMod.NPCs.DevourerofGods { string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss"; - + phase1IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); } @@ -152,7 +152,7 @@ namespace CalamityMod.NPCs.DevourerofGods public bool isInPassiveState { - get + get { if (Phase2Started && NPC.ai[3] == 1) return true; @@ -625,7 +625,7 @@ namespace CalamityMod.NPCs.DevourerofGods { string key = "Mods.CalamityMod.Status.Boss.DoGPhase2"; Color messageColor = Color.Cyan; - var ctid = CombatText.NewText(NPC.Hitbox,messageColor, Language.GetTextValue(key),true); + var ctid = CombatText.NewText(NPC.Hitbox, messageColor, Language.GetTextValue(key), true); if (ctid < Main.maxCombatText) player.Calamity().subtitletext = Main.combatText[ctid]; player.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; @@ -685,7 +685,7 @@ namespace CalamityMod.NPCs.DevourerofGods AttemptingToEnterPortal = true; } #endregion - + // Phase 2 else { @@ -929,7 +929,8 @@ namespace CalamityMod.NPCs.DevourerofGods VelocityRotation -= maxSpeed; else VelocityRotation += dif; - } else + } + else { if (dif > maxSpeed) VelocityRotation += maxSpeed; @@ -975,11 +976,11 @@ namespace CalamityMod.NPCs.DevourerofGods float targetY = destination.Y; int destinationTileX = (int)(destination.X / 16f); int destinationTileY = (int)(destination.Y / 16f); - - + + speedCopy = homingSpeed; turnSpeedCopy = homingTurnSpeed; - + speedCopy += Vector2.Distance(destination, NPC.Center) * 0.005f; turnSpeedCopy += Vector2.Distance(destination, NPC.Center) * 0.00025f; @@ -1013,7 +1014,7 @@ namespace CalamityMod.NPCs.DevourerofGods targetX *= timeToReachTarget; targetY *= timeToReachTarget; - turnSpeedCopy *= NPC.Distance(destination) / ( death ? 800 : 1000f); + turnSpeedCopy *= NPC.Distance(destination) / (death ? 800 : 1000f); if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { if (NPC.velocity.X < targetX) @@ -1374,14 +1375,14 @@ namespace CalamityMod.NPCs.DevourerofGods if (calamityGlobalNPC.newAI[2] > phaseLimit) { - + calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); NPC.ai[3] = 0f; calamityGlobalNPC.newAI[2] = 0f; if ((phase4)) { - calamityGlobalNPC.newAI[3] = AlphaGateValue-120; + calamityGlobalNPC.newAI[3] = AlphaGateValue - 120; NPC.ai[3] = 2f; } @@ -1405,11 +1406,12 @@ namespace CalamityMod.NPCs.DevourerofGods var currentVelLength = NPC.velocity.Length(); var goalVel = NPC.DirectionTo(goalpos) * currentVelLength; - TurnTowards(goalpos,maxSpeed: 6f * calamityGlobalNPC.newAI[2] / 120f); + TurnTowards(goalpos, maxSpeed: 6f * calamityGlobalNPC.newAI[2] / 120f); NPC.velocity = VelocityRotation.ToRotationVector2() * (currentVelLength < 40 ? currentVelLength + 0.2f : currentVelLength > 42 ? currentVelLength - 0.2f : currentVelLength); NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; - } else + } + else { NPC.dontTakeDamage = true; } @@ -1441,7 +1443,7 @@ namespace CalamityMod.NPCs.DevourerofGods if (isInPassiveState) { ShootFireballs(player, distanceFromTarget, revenge); - } + } else { calamityGlobalNPC.newAI[0] = 0f; @@ -1523,11 +1525,11 @@ namespace CalamityMod.NPCs.DevourerofGods calamityGlobalNPC.newAI[1] += 1f; if (calamityGlobalNPC.newAI[1] >= laserBarragePhaseGateValue) { - if (!Main.dedServ) - { - if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.Calamity().infiniteFlight = true; - } + if (!Main.dedServ) + { + if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.LocalPlayer.Calamity().infiniteFlight = true; + } if (calamityGlobalNPC.newAI[1] >= laserBarrageGateValue) { calamityGlobalNPC.newAI[1] = 0f; @@ -1621,7 +1623,7 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 npcCenter = NPC.Center; float targetX = player.position.X + (player.width / 2); float targetY = player.position.Y + (player.height / 2); - + speedCopy = homingSpeed; turnSpeedCopy = homingTurnSpeed; @@ -1746,7 +1748,7 @@ namespace CalamityMod.NPCs.DevourerofGods { calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; if (phase2) { NPC.ai[3] = 2; @@ -2185,8 +2187,8 @@ namespace CalamityMod.NPCs.DevourerofGods if (!phase2Transition) teleportTimer = baseTeleportTime; - - SoundEngine.PlaySound(RiftOpenSound with {Volume = 1.5f}, player.Center); + + SoundEngine.PlaySound(RiftOpenSound with { Volume = 1.5f }, player.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -2227,31 +2229,31 @@ namespace CalamityMod.NPCs.DevourerofGods return; bool phase6 = NPC.life / (float)NPC.lifeMax < 0.25f; - if (Main.netMode != NetmodeID.MultiplayerClient && !(death && phase6 && NPC.ai[3] < 7)) // 4 dashes on Death phase 3 without fireballs + if (Main.netMode != NetmodeID.MultiplayerClient && !(death && phase6 && NPC.ai[3] < 7)) // 4 dashes on Death phase 3 without fireballs + { + float finalVelocity = death ? 12f : 10f; + int totalSpreads = revenge ? 6 : 3; + float mult = revenge ? 1.5f : 3f; + for (int i = 0; i < totalSpreads; i++) { - float finalVelocity = death ? 12f : 10f; - int totalSpreads = revenge ? 6 : 3; - float mult = revenge ? 1.5f : 3f; - for (int i = 0; i < totalSpreads; i++) + if (!death && i % 3 == 2) + continue; + int totalProjectiles = 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++) { - if (!death && i % 3 == 2) - continue; - int totalProjectiles = 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(NPC.GetSource_FromAI(), newPosition, vector255, ModContent.ProjectileType(), FireballDamage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); - } + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), newPosition, vector255, ModContent.ProjectileType(), FireballDamage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); } } + } NPC.TargetClosest(); NPC.position = newPosition; @@ -2259,17 +2261,17 @@ namespace CalamityMod.NPCs.DevourerofGods chargeVelocity *= (death) ? (!(phase6 && NPC.ai[3] < 7)) ? 2.5f : 3 : 2.25f; float maxChargeDistance = 1800f; postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); - int phase6dashcount = death ? 5 : 3; - if (phase6 && NPC.ai[3] < 2 + phase6dashcount) - { - if (NPC.ai[3] < 3) - NPC.ai[3] = 3; - NPC.ai[3]++; + int phase6dashcount = death ? 5 : 3; + if (phase6 && NPC.ai[3] < 2 + phase6dashcount) + { + if (NPC.ai[3] < 3) + NPC.ai[3] = 3; + NPC.ai[3]++; // On FTW the final 10% is infinite portal dashing if (Main.getGoodWorld && NPC.life / (float)NPC.lifeMax < 0.1f) { NPC.ai[3] = 4; - NPC.SimpleStrikeNPC(10000,1); + NPC.SimpleStrikeNPC(10000, 1); } } else @@ -2503,7 +2505,7 @@ namespace CalamityMod.NPCs.DevourerofGods CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedDoG); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedDoG); // If DoG has not been killed yet, notify players that the holiday moons are buffed if (!DownedBossSystem.downedDoG) @@ -2737,7 +2739,7 @@ namespace CalamityMod.NPCs.DevourerofGods { if (hurtInfo.Damage <= 0) return; - + if (target.Calamity().dogTextCooldown <= 0 && !BossRushEvent.BossRushActive) { string[] headHitKeys = new string[] @@ -2755,13 +2757,13 @@ namespace CalamityMod.NPCs.DevourerofGods "Mods.CalamityMod.Status.Boss.DoGHead11", "Mods.CalamityMod.Status.Boss.DoGHead12", "Mods.CalamityMod.Status.Boss.DoGHead13", - + }; Color messageColor = Color.Cyan; Rectangle location = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); var counter = target.Calamity().DoGHeadHitCounter; - string text = headHitKeys[Main.rand.Next(10, 13)]; + string text = headHitKeys[Main.rand.Next(10, 13)]; if (target.statLife - hurtInfo.Damage <= 0) { if (counter == 0) @@ -2777,7 +2779,8 @@ namespace CalamityMod.NPCs.DevourerofGods text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath1"; //Tasteless slop. else text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath2"; //A feast worthy of a god! - } else + } + else { if (counter == 0 && Phase2Started) { @@ -2785,7 +2788,8 @@ namespace CalamityMod.NPCs.DevourerofGods text = "Mods.CalamityMod.Status.Boss.DoGHeadRunning2"; //WHAT'S THE PROBLEM?! CAN'T RUN ANYMORE?! else text = "Mods.CalamityMod.Status.Boss.DoGHeadRunning"; //You can't run forever! - } else + } + else { if (counter > 9) text = headHitKeys[Main.rand.Next(10, 13)]; //DogHead11-13 @@ -2793,7 +2797,7 @@ namespace CalamityMod.NPCs.DevourerofGods text = headHitKeys[9]; //DogHead10 else if (counter > 4) text = headHitKeys[Main.rand.Next(4, 9)]; //DogHead5-9 - else + else text = headHitKeys[Main.rand.Next(0, 4)]; //DogHead1-4 } } @@ -2804,7 +2808,7 @@ namespace CalamityMod.NPCs.DevourerofGods target.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; target.Calamity().dogTextCooldown = 60; } - target.Calamity().DoGHeadHitCounter++; + target.Calamity().DoGHeadHitCounter++; } } } diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index e54290bb3b..ea70d84fb2 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -1981,7 +1981,7 @@ namespace CalamityMod.NPCs.OldDuke drawLocation += new Vector2(Main.rand.NextFloat(-shake, shake), Main.rand.NextFloat(-shake, shake)); spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(finalDrawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(overlayDrawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); float auraOutset = 6f + (float)(Math.Sin(VisualTimerSystem.GlobalVisualTimer / 10f) * 10f); @@ -2066,7 +2066,7 @@ namespace CalamityMod.NPCs.OldDuke CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedBoomerDuke); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedBoomerDuke); // Mark Old Duke as dead DownedBossSystem.downedBoomerDuke = true; diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index 142151602d..684cccea79 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.Polterghast { public static int phase1IconIndex; public static int phase3IconIndex; - + public override void Load() { string phase1IconPath = "CalamityMod/NPCs/Polterghast/Polterghast_Head_Boss"; @@ -943,7 +943,7 @@ namespace CalamityMod.NPCs.Polterghast CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Cyborg }, DownedBossSystem.downedPolterghast); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Cyborg }, DownedBossSystem.downedPolterghast); // If Polterghast has not been killed, notify players about the Abyss minibosses now dropping items if (!DownedBossSystem.downedPolterghast) diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 6535fc98c8..c554318e43 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -3018,7 +3018,7 @@ namespace CalamityMod.NPCs.Yharon if (BossRushEvent.BossRushActive) return; - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedYharon); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedYharon); CalamityGlobalNPC.SetNewBossJustDowned(NPC); // If Yharon has not been killed yet, notify players of Auric Ore diff --git a/Systems/EntityUpdateInterceptionSystem.cs b/Systems/EntityUpdateInterceptionSystem.cs index 98a14899e8..5390343164 100644 --- a/Systems/EntityUpdateInterceptionSystem.cs +++ b/Systems/EntityUpdateInterceptionSystem.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Systems #region Post NPC Updating // TODO -- Apply caching to this process. For now most of the looping issues should be eradicated but it can be reduced further. - public override void PostUpdateNPCs() => CalamityGlobalNPC.ResetTownNPCNameBools(); + public override void PostUpdateNPCs() => CalamityGlobalTownNPC.ResetTownNPCNameBools(); #endregion #region Tile Entity Time Handler