From 7e39efc84cea037c9a6704fecb9d05daa52de5f2 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+ben-tk@users.noreply.github.com> Date: Thu, 18 Nov 2021 00:38:29 -0500 Subject: [PATCH] allowed discount card effect to apply to most items that Calamity adds --- NPCs/CalamityGlobalTownNPC.cs | 4 +++- NPCs/TownNPCs/DILF.cs | 4 ++++ NPCs/TownNPCs/FAP.cs | 2 ++ NPCs/TownNPCs/SEAHOE.cs | 12 ++++++++++++ NPCs/TownNPCs/THIEF.cs | 11 +++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 7e78460347..5909fae429 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -1384,7 +1384,7 @@ namespace CalamityMod.NPCs } } - public static void SetShopItem(ref Chest shop, ref int nextSlot, int itemID, bool condition = true, int? price = null) + public static void SetShopItem(ref Chest shop, ref int nextSlot, int itemID, bool condition = true, int? price = null, bool ignoreDiscount = false) { if (condition) { @@ -1392,6 +1392,8 @@ namespace CalamityMod.NPCs if (price != null) { shop.item[nextSlot].shopCustomPrice = price; + if (Main.LocalPlayer.discount && !ignoreDiscount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); } nextSlot++; diff --git a/NPCs/TownNPCs/DILF.cs b/NPCs/TownNPCs/DILF.cs index 547dec2ccd..41f13fe171 100644 --- a/NPCs/TownNPCs/DILF.cs +++ b/NPCs/TownNPCs/DILF.cs @@ -128,6 +128,8 @@ namespace CalamityMod.NPCs.TownNPCs { shop.item[nextSlot].SetDefaults(ItemID.WarmthPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; @@ -167,6 +169,8 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(5, 0, 0, 0); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; if (Main.LocalPlayer.HasItem(ModContent.ItemType())) { diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index b800edb7d9..6d0e62bbb9 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -275,6 +275,8 @@ namespace CalamityMod.NPCs.TownNPCs public override void SetupShop(Chest shop, ref int nextSlot) //charges 50% extra than the original alcohol value { + // All prices are manually set. This means the Discount Card does not work. + // Cirrus doesn't accept your card. shop.item[nextSlot].SetDefaults(ItemID.HeartreachPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); nextSlot++; diff --git a/NPCs/TownNPCs/SEAHOE.cs b/NPCs/TownNPCs/SEAHOE.cs index 281b4a2311..730931c04f 100644 --- a/NPCs/TownNPCs/SEAHOE.cs +++ b/NPCs/TownNPCs/SEAHOE.cs @@ -365,29 +365,41 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.GillsPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.WaterWalkingPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.FlipperPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; if (CalamityWorld.downedEoCAcidRain) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(gold: 3); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; } if (NPC.downedFishron) { shop.item[nextSlot].SetDefaults(ItemID.TruffleWorm); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 10, 0, 0); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; } if (CalamityWorld.downedBoomerDuke) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(2, 0, 0, 0); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; } } diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index a64d92ad51..e49828765d 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -245,6 +245,8 @@ namespace CalamityMod.NPCs.TownNPCs public override void SetupShop(Chest shop, ref int nextSlot) { + // All prices are manually set. This means the Discount Card does not work. + // The Bandit doesn't believe in discounts. shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 9, 0, 0); nextSlot++; @@ -258,6 +260,7 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 40, 0, 0); nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.TigerClimbingGear); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.InvisibilityPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); @@ -271,6 +274,7 @@ namespace CalamityMod.NPCs.TownNPCs if (CalamityWorld.downedSlimeGod) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; } if (Main.hardMode) @@ -294,22 +298,28 @@ namespace CalamityMod.NPCs.TownNPCs if (NPC.downedMechBossAny) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; } if (CalamityWorld.downedCalamitas) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; } if (NPC.downedPlantBoss) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; } if (NPC.downedGolemBoss) @@ -344,6 +354,7 @@ namespace CalamityMod.NPCs.TownNPCs } //:BearWatchingYou: shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; }