diff --git a/CalamityMod.cs b/CalamityMod.cs index 221c974b64..08400366ab 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -56,8 +56,119 @@ namespace CalamityMod public static Texture2D AstralSky; public static Effect CustomShader; - // Lists - public static IList donatorList; + // DR data structure + public static SortedDictionary DRValues = new SortedDictionary + { + { NPCID.AngryBonesBig, 0.2f }, + { NPCID.AngryBonesBigHelmet, 0.2f }, + { NPCID.AngryBonesBigMuscle, 0.2f }, + { NPCID.AnomuraFungus, 0.1f }, + { NPCID.Antlion, 0.1f }, + { NPCID.Arapaima, 0.1f }, + { NPCID.ArmoredSkeleton, 0.15f }, + { NPCID.ArmoredViking, 0.1f }, + { NPCID.BigMimicCorruption, 0.3f }, + { NPCID.BigMimicCrimson, 0.3f }, + { NPCID.BigMimicHallow, 0.3f }, + { NPCID.BigMimicJungle, 0.3f }, // unused vanilla enemy + { NPCID.BlueArmoredBones, 0.2f }, + { NPCID.BlueArmoredBonesMace, 0.2f }, + { NPCID.BlueArmoredBonesNoPants, 0.2f }, + { NPCID.BlueArmoredBonesSword, 0.2f }, + { NPCID.BoneLee, 0.2f }, + { NPCID.Crab, 0.05f }, + { NPCID.Crawdad, 0.2f }, + { NPCID.Crawdad2, 0.2f }, + { NPCID.CultistBoss, 0.05f }, + { NPCID.DD2Betsy, 0.1f }, + { NPCID.DD2OgreT2, 0.1f }, + { NPCID.DD2OgreT3, 0.15f }, + { NPCID.DeadlySphere, 0.4f }, + { NPCID.DiabolistRed, 0.2f }, + { NPCID.DiabolistWhite, 0.2f }, + { NPCID.DungeonGuardian, 0.999999f }, + { NPCID.DungeonSpirit, 0.2f }, + { NPCID.ElfCopter, 0.15f }, + { NPCID.Everscream, 0.1f }, + { NPCID.FlyingAntlion, 0.05f }, + { NPCID.GiantCursedSkull, 0.2f }, + { NPCID.GiantShelly, 0.2f }, + { NPCID.GiantShelly2, 0.2f }, + { NPCID.GiantTortoise, 0.35f }, + { NPCID.Golem, 0.25f }, + { NPCID.GolemFistLeft, 0.25f }, + { NPCID.GolemFistRight, 0.25f }, + { NPCID.GolemHead, 0.25f }, + { NPCID.GolemHeadFree, 0.25f }, + { NPCID.GraniteFlyer, 0.1f }, + { NPCID.GraniteGolem, 0.15f }, + { NPCID.GreekSkeleton, 0.1f }, + { NPCID.HellArmoredBones, 0.2f }, + { NPCID.HellArmoredBonesMace, 0.2f }, + { NPCID.HellArmoredBonesSpikeShield, 0.2f }, + { NPCID.HellArmoredBonesSword, 0.2f }, + { NPCID.IceGolem, 0.1f }, + { NPCID.IceQueen, 0.1f }, + { NPCID.IceTortoise, 0.35f }, + { NPCID.HeadlessHorseman, 0.05f }, + { NPCID.MartianDrone, 0.2f }, + { NPCID.MartianSaucer, 0.2f }, + { NPCID.MartianSaucerCannon, 0.2f }, + { NPCID.MartianSaucerCore, 0.2f }, + { NPCID.MartianSaucerTurret, 0.2f }, + { NPCID.MartianTurret, 0.2f }, + { NPCID.MartianWalker, 0.35f }, + { NPCID.Mimic, 0.3f }, + { NPCID.MoonLordCore, 0.05f }, + { NPCID.MoonLordFreeEye, 0.05f }, + { NPCID.MoonLordHand, 0.05f }, + { NPCID.MoonLordHead, 0.05f }, + { NPCID.Mothron, 0.2f }, + { NPCID.MothronEgg, 0.5f }, + { NPCID.MourningWood, 0.1f }, + { NPCID.Necromancer, 0.2f }, + { NPCID.NecromancerArmored, 0.2f }, + { NPCID.Paladin, 0.45f }, + { NPCID.PirateCaptain, 0.05f }, + { NPCID.PirateShipCannon, 0.15f }, + { NPCID.PossessedArmor, 0.25f }, + { NPCID.PresentMimic, 0.3f }, + { NPCID.PrimeCannon, 0.2f }, + { NPCID.PrimeLaser, 0.2f }, + { NPCID.PrimeSaw, 0.25f }, + { NPCID.PrimeVice, 0.25f }, + { NPCID.Probe, 0.25f }, + { NPCID.Pumpking, 0.1f }, + { NPCID.QueenBee, 0.05f }, + { NPCID.RaggedCaster, 0.2f }, + { NPCID.RaggedCasterOpenCoat, 0.2f }, + { NPCID.Retinazer, 0.2f }, + { NPCID.RustyArmoredBonesAxe, 0.2f }, + { NPCID.RustyArmoredBonesFlail, 0.2f }, + { NPCID.RustyArmoredBonesSword, 0.2f }, + { NPCID.RustyArmoredBonesSwordNoArmor, 0.2f }, + { NPCID.SandElemental, 0.1f }, + { NPCID.SantaNK1, 0.35f }, + { NPCID.SeaSnail, 0.05f }, + { NPCID.SkeletonArcher, 0.1f }, + { NPCID.SkeletonCommando, 0.2f }, + { NPCID.SkeletonSniper, 0.2f }, + { NPCID.SkeletronHand, 0.05f }, + { NPCID.SkeletronHead, 0.05f }, + { NPCID.SkeletronPrime, 0.25f }, + { NPCID.Spazmatism, 0.2f }, + { NPCID.TacticalSkeleton, 0.2f }, + { NPCID.TheDestroyer, 0.1f }, + { NPCID.TheDestroyerBody, 0.2f }, + { NPCID.TheDestroyerTail, 0.35f }, + { NPCID.TheHungry, 0.1f }, + { NPCID.UndeadViking, 0.1f }, + { NPCID.WalkingAntlion, 0.1f }, + { NPCID.WallofFlesh, 0.5f }, + }; + + // Lists + public static IList donatorList; public static List rangedProjectileExceptionList; public static List projectileMinionList; public static List enemyImmunityList; @@ -138,6 +249,7 @@ namespace CalamityMod Config.Load(); SetupLists(); + RegisterThoriumBossDR(ModLoader.GetMod("ThoriumMod")); CalamityLocalization.AddLocalizations(); } @@ -2041,10 +2153,41 @@ namespace CalamityMod } } } - #endregion + #endregion - #region Music - public override void UpdateMusic(ref int music, ref MusicPriority priority) + #region Thorium Boss DR + private void RegisterThoriumBossDR(Mod thorium) + { + if (thorium is null || !Config.RevengeanceAndDeathThoriumBossBuff) + return; + + void ThoriumDR(string npcName, float dr) { DRValues.Add(thorium.NPCType(npcName), dr); } + ThoriumDR("Viscount", 0.05f); + ThoriumDR("BoreanStrider", 0.05f); + ThoriumDR("FallenDeathBeholder", 0.05f); + ThoriumDR("Lich", 0.05f); + ThoriumDR("AbyssionReleased", 0.05f); + ThoriumDR("CryoCore", 0.1f); + ThoriumDR("BioCore", 0.1f); + ThoriumDR("PyroCore", 0.1f); + ThoriumDR("Aquaius", 0.1f); + ThoriumDR("ThePrimeScouter", 0.2f); + ThoriumDR("FallenDeathBeholder2", 0.2f); + ThoriumDR("SlagFury", 0.2f); + ThoriumDR("Aquaius2", 0.2f); + ThoriumDR("GraniteEnergyStorm", 0.2f); + ThoriumDR("TheBuriedWarrior", 0.25f); + ThoriumDR("TheBuriedWarrior1", 0.25f); + ThoriumDR("TheBuriedWarrior2", 0.25f); + ThoriumDR("LichHeadless", 0.25f); + ThoriumDR("AbyssionCracked", 0.25f); + ThoriumDR("Omnicide", 0.3f); + ThoriumDR("Abyssion", 0.35f); + } + #endregion + + #region Music + public override void UpdateMusic(ref int music, ref MusicPriority priority) { Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); if (Main.musicVolume != 0) @@ -2152,7 +2295,7 @@ namespace CalamityMod public override object Call(params object[] args) { - return ModSupport.Call(args); + return ModCalls.Call(args); } #endregion diff --git a/MiscModSupport/ModSupport.cs b/MiscModSupport/ModCalls.cs similarity index 97% rename from MiscModSupport/ModSupport.cs rename to MiscModSupport/ModCalls.cs index c88141940c..80d6f2ddfe 100644 --- a/MiscModSupport/ModSupport.cs +++ b/MiscModSupport/ModCalls.cs @@ -8,7 +8,7 @@ using CalamityMod.CalPlayer; namespace CalamityMod.MiscModSupport { - public class ModSupport + public class ModCalls { #region Boss / Event Downed /// @@ -479,10 +479,12 @@ namespace CalamityMod.MiscModSupport #region Set Damage Reduction - // TODO -- There isn't a DR map yet, so this can't be implemented until that is done - public static bool SetDamageReduction(string npcName, float DR) + public static float SetDamageReduction(int npcID, float dr) { - return false; + CalamityMod.DRValues.TryGetValue(npcID, out float oldDR); + CalamityMod.DRValues.Remove(npcID); + CalamityMod.DRValues.Add(npcID, dr); + return oldDR; } #endregion @@ -549,13 +551,14 @@ namespace CalamityMod.MiscModSupport case "DamageReduction": case "SetDR": case "SetDamageReduction": - if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify both NPC name as a string and damage reduction as a float or double."); + if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify both NPC ID as an int and damage reduction as a float or double."); if (args.Length < 3) return new ArgumentNullException("ERROR: Must specify damage reduction as a float or double."); if (!(args[2] is float) && !(args[2] is double)) return new ArgumentException("ERROR: The second argument to \"SetDamageReduction\" must be a float or a double."); - if (!(args[1] is string)) return new ArgumentException("ERROR: The first argument to \"SetDamageReduction\" must be a string."); + if (!(args[1] is string)) return new ArgumentException("ERROR: The first argument to \"SetDamageReduction\" must be an int."); + int npcID = (int)args[1]; float DR = (float)args[2]; - return SetDamageReduction(args[1].ToString(), DR); + return SetDamageReduction(npcID, DR); default: return new ArgumentException("ERROR: Invalid method name."); diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 5fae293f76..2b90761f0e 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -112,7 +112,7 @@ namespace CalamityMod.NPCs public static int SCalWorm = -1; // Collections - public SortedDictionary BossRushHPChanges = new SortedDictionary + public static SortedDictionary BossRushHPChanges = new SortedDictionary { // Tier 1 { NPCID.QueenBee, 420000 }, @@ -177,7 +177,7 @@ namespace CalamityMod.NPCs { NPCID.MoonLordFreeEye, 1000 } }; - public SortedDictionary BossValues = new SortedDictionary + public static SortedDictionary BossValues = new SortedDictionary { { NPCID.QueenBee, Item.buyPrice(0, 5)}, { NPCID.SkeletronHead, Item.buyPrice(0, 7) }, @@ -834,42 +834,6 @@ namespace CalamityMod.NPCs #region Revengeance Damage Reduction private void RevengeanceDamageReduction(NPC npc, Mod mod) { - if (Config.RevengeanceAndDeathThoriumBossBuff) - { - Mod thorium = ModLoader.GetMod("ThoriumMod"); - if (thorium != null) - { - if (npc.type == thorium.NPCType("Viscount") || npc.type == thorium.NPCType("BoreanStrider") || npc.type == thorium.NPCType("FallenDeathBeholder") || - npc.type == thorium.NPCType("Lich") || npc.type == thorium.NPCType("AbyssionReleased")) - { - DR = 0.05f; - } - else if (npc.type == thorium.NPCType("CryoCore") || npc.type == thorium.NPCType("BioCore") || npc.type == thorium.NPCType("PyroCore") || - npc.type == thorium.NPCType("Aquaius")) - { - DR = 0.1f; - } - else if (npc.type == thorium.NPCType("ThePrimeScouter") || npc.type == thorium.NPCType("FallenDeathBeholder2") || npc.type == thorium.NPCType("SlagFury") || - npc.type == thorium.NPCType("Aquaius2") || npc.type == thorium.NPCType("GraniteEnergyStorm")) - { - DR = 0.2f; - } - else if (npc.type == thorium.NPCType("TheBuriedWarrior") || npc.type == thorium.NPCType("TheBuriedWarrior1") || npc.type == thorium.NPCType("TheBuriedWarrior2") || - npc.type == thorium.NPCType("LichHeadless") || npc.type == thorium.NPCType("AbyssionCracked")) - { - DR = 0.25f; - } - else if (npc.type == thorium.NPCType("Omnicide")) - { - DR = 0.3f; - } - else if (npc.type == thorium.NPCType("Abyssion")) - { - DR = 0.35f; - } - } - } - if (npc.type == mod.NPCType("Cnidrion") || npc.type == mod.NPCType("DesertScourgeBody") || npc.type == mod.NPCType("ColossalSquid") || npc.type == mod.NPCType("Siren") || npc.type == mod.NPCType("ThiccWaifu") || npc.type == mod.NPCType("ProfanedGuardianBoss3") || npc.type == mod.NPCType("ScornEater") || npc.type == mod.NPCType("AquaticScourgeBody") || npc.type == mod.NPCType("AquaticScourgeBodyAlt") || @@ -930,153 +894,6 @@ namespace CalamityMod.NPCs { DR = 0.5f; } - else - { - switch (npc.type) - { - case NPCID.SkeletronHand: - case NPCID.SkeletronHead: - case NPCID.QueenBee: - case NPCID.HeadlessHorseman: - case NPCID.FlyingAntlion: - case NPCID.PirateCaptain: - case NPCID.MoonLordHead: - case NPCID.MoonLordHand: - case NPCID.MoonLordCore: - case NPCID.MoonLordFreeEye: - case NPCID.CultistBoss: - case NPCID.Crab: - case NPCID.SeaSnail: - DR = 0.05f; - break; - - case NPCID.Antlion: - case NPCID.TheHungry: - case NPCID.TheDestroyer: - case NPCID.UndeadViking: - case NPCID.MourningWood: - case NPCID.Everscream: - case NPCID.GreekSkeleton: - case NPCID.GraniteFlyer: - case NPCID.WalkingAntlion: - case NPCID.Pumpking: - case NPCID.IceQueen: - case NPCID.IceGolem: - case NPCID.AnomuraFungus: - case NPCID.SkeletonArcher: - case NPCID.SandElemental: - case NPCID.Arapaima: - case NPCID.ArmoredViking: - case NPCID.DD2Betsy: - case NPCID.DD2OgreT2: - DR = 0.1f; - break; - - case NPCID.ElfCopter: - case NPCID.GraniteGolem: - case NPCID.ArmoredSkeleton: - case NPCID.PirateShipCannon: - case NPCID.DD2OgreT3: - DR = 0.15f; - break; - - case NPCID.Retinazer: - case NPCID.Spazmatism: - case NPCID.PrimeCannon: - case NPCID.PrimeLaser: - case NPCID.TheDestroyerBody: - case NPCID.RustyArmoredBonesAxe: - case NPCID.RustyArmoredBonesFlail: - case NPCID.RustyArmoredBonesSword: - case NPCID.RustyArmoredBonesSwordNoArmor: - case NPCID.BlueArmoredBones: - case NPCID.BlueArmoredBonesMace: - case NPCID.BlueArmoredBonesNoPants: - case NPCID.BlueArmoredBonesSword: - case NPCID.HellArmoredBones: - case NPCID.HellArmoredBonesSpikeShield: - case NPCID.HellArmoredBonesMace: - case NPCID.HellArmoredBonesSword: - case NPCID.RaggedCaster: - case NPCID.RaggedCasterOpenCoat: - case NPCID.Necromancer: - case NPCID.NecromancerArmored: - case NPCID.DiabolistRed: - case NPCID.DiabolistWhite: - case NPCID.BoneLee: - case NPCID.DungeonSpirit: - case NPCID.GiantCursedSkull: - case NPCID.SkeletonSniper: - case NPCID.TacticalSkeleton: - case NPCID.SkeletonCommando: - case NPCID.AngryBonesBig: - case NPCID.AngryBonesBigMuscle: - case NPCID.AngryBonesBigHelmet: - case NPCID.MartianSaucerTurret: - case NPCID.MartianSaucerCannon: - case NPCID.MartianTurret: - case NPCID.MartianDrone: - case NPCID.MartianSaucer: - case NPCID.MartianSaucerCore: - case NPCID.Crawdad: - case NPCID.Crawdad2: - case NPCID.GiantShelly: - case NPCID.GiantShelly2: - case NPCID.Mothron: - DR = 0.2f; - break; - - case NPCID.PrimeSaw: - case NPCID.PrimeVice: - case NPCID.SkeletronPrime: - case NPCID.Probe: - case NPCID.PossessedArmor: - case NPCID.Golem: - case NPCID.GolemFistLeft: - case NPCID.GolemFistRight: - case NPCID.GolemHead: - case NPCID.GolemHeadFree: - DR = 0.25f; - break; - - case NPCID.Mimic: - case NPCID.PresentMimic: - case NPCID.BigMimicCorruption: - case NPCID.BigMimicCrimson: - case NPCID.BigMimicHallow: - case NPCID.BigMimicJungle: - DR = 0.3f; - break; - - case NPCID.GiantTortoise: - case NPCID.IceTortoise: - case NPCID.SantaNK1: - case NPCID.MartianWalker: - case NPCID.TheDestroyerTail: - DR = 0.35f; - break; - - case NPCID.DeadlySphere: - DR = 0.4f; - break; - - case NPCID.Paladin: - DR = 0.45f; - break; - - case NPCID.WallofFlesh: - case NPCID.MothronEgg: - DR = 0.5f; - break; - - case NPCID.DungeonGuardian: - DR = 0.999999f; - break; - - default: - break; - } - } } #endregion