diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 4825292c84..adc2a8e900 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -1528,6 +1528,8 @@ namespace CalamityMod.NPCs { int goldCost = NPC.downedMoonlord ? 8 : Main.hardMode ? 4 : 2; + bool happy = Main.LocalPlayer.currentShoppingSettings.PriceAdjustment <= 0.8999999761581421; + if (type == NPCID.Merchant) { SetShopItem(ref shop, ref nextSlot, ItemID.Bottle, CalamityConfig.Instance.PotionSelling, Item.buyPrice(0, 0, 0, 20)); @@ -1582,6 +1584,7 @@ namespace CalamityMod.NPCs SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.revenge); SetShopItem(ref shop, ref nextSlot, ItemID.StylistKilLaKillScissorsIWish, true, Item.buyPrice(0, 15)); SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.Calamity().alcoholPoisoning && NPC.FindFirstNPC(NPCType()) != -1); + SetShopItem(ref shop, ref nextSlot, ItemID.ChocolateChipCookie, happy && NPC.FindFirstNPC(NPCType()) != -1, Item.buyPrice(0, 3)); } if (type == NPCID.Cyborg) @@ -1684,6 +1687,13 @@ namespace CalamityMod.NPCs { SetShopItem(ref shop, ref nextSlot, ItemID.PrincessWeapon, true, Item.buyPrice(0, 50, 0, 0)); SetShopItem(ref shop, ref nextSlot, ItemType()); + SetShopItem(ref shop, ref nextSlot, ItemID.AppleJuice, NPC.FindFirstNPC(NPCType()) != -1); + SetShopItem(ref shop, ref nextSlot, ItemID.FruitJuice, NPC.FindFirstNPC(NPCType()) != -1); + SetShopItem(ref shop, ref nextSlot, ItemID.GrapeJuice, NPC.FindFirstNPC(NPCType()) != -1); + SetShopItem(ref shop, ref nextSlot, ItemID.Lemonade, NPC.FindFirstNPC(NPCType()) != -1); + SetShopItem(ref shop, ref nextSlot, ItemID.PrismaticPunch, NPC.FindFirstNPC(NPCType()) != -1); + SetShopItem(ref shop, ref nextSlot, ItemID.SmoothieofDarkness, NPC.FindFirstNPC(NPCType()) != -1); + SetShopItem(ref shop, ref nextSlot, ItemID.TropicalSmoothie, NPC.FindFirstNPC(NPCType()) != -1); } if (type == NPCID.SkeletonMerchant) diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index 8d9789b647..85febaf0c7 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -308,6 +308,10 @@ namespace CalamityMod.NPCs.TownNPCs public override void SetupShop(Chest shop, ref int nextSlot) //charges 50% extra than the original alcohol value { + int wife = NPC.FindFirstNPC(NPCID.Stylist); + bool wifeIsAround = wife != -1; + bool beLessDrunk = wifeIsAround && NPC.downedMoonlord; + if (CalamityConfig.Instance.PotionSelling) { shop.item[nextSlot].SetDefaults(ItemID.HeartreachPotion); @@ -426,6 +430,25 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; } + if (beLessDrunk) + { + shop.item[nextSlot].SetDefaults(ItemID.BloodyMoscato); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; + + shop.item[nextSlot].SetDefaults(ItemID.BananaDaiquiri); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 75, 0); + nextSlot++; + + shop.item[nextSlot].SetDefaults(ItemID.PeachSangria); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 50, 0); + nextSlot++; + + shop.item[nextSlot].SetDefaults(ItemID.PinaColada); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; + } + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 50, 0, 0); nextSlot++; @@ -449,9 +472,12 @@ namespace CalamityMod.NPCs.TownNPCs bool happyAsFuck = Main.LocalPlayer.currentShoppingSettings.PriceAdjustment <= 0.8999999761581421; if (happyAsFuck) { - shop.item[nextSlot].SetDefaults(ItemID.MilkCarton); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); - nextSlot++; + if (wifeIsAround) + { + shop.item[nextSlot].SetDefaults(ItemID.MilkCarton); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; + } if (Main.LocalPlayer.ZoneHallow) { @@ -459,9 +485,12 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 50, 0); nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.Milkshake); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 5, 0, 0); - nextSlot++; + if (wifeIsAround) + { + shop.item[nextSlot].SetDefaults(ItemID.Milkshake); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 5, 0, 0); + nextSlot++; + } } } } diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 301ffd3361..d3847ad10c 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -17,8 +17,10 @@ using System.Linq; using System.Reflection; using Terraria; using Terraria.DataStructures; +using Terraria.Enums; using Terraria.ID; using Terraria.ModLoader; +using System; namespace CalamityMod.Tiles { @@ -141,6 +143,118 @@ namespace CalamityMod.Tiles { Tile tile = Main.tile[i, j]; + // Fruit from trees upon tree destruction + GetTreeBottom(i, j, out int treeX, out int treeY); + TreeTypes treeType = WorldGen.GetTreeType(Main.tile[treeX, treeY].TileType); + if (treeType != TreeTypes.None) + { + treeY--; + while (treeY > 10 && Main.tile[treeX, treeY].HasTile && TileID.Sets.IsShakeable[Main.tile[treeX, treeY].TileType]) + treeY--; + + treeY++; + + if (WorldGen.IsTileALeafyTreeTop(treeX, treeY) && !Collision.SolidTiles(treeX - 2, treeX + 2, treeY - 2, treeY + 2)) + { + int randomAmt = WorldGen.genRand.Next(1, 4); + for (int z = 0; z < randomAmt; z++) + { + int treeDropItemType = 0; + switch (treeType) + { + case TreeTypes.Forest: + + switch (WorldGen.genRand.Next(5)) + { + case 0: + treeDropItemType = ItemID.Apple; + break; + case 1: + treeDropItemType = ItemID.Apricot; + break; + case 2: + treeDropItemType = ItemID.Peach; + break; + case 3: + treeDropItemType = ItemID.Grapefruit; + break; + default: + treeDropItemType = ItemID.Lemon; + break; + } + + break; + + case TreeTypes.Snow: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Cherry : ItemID.Plum; + break; + + case TreeTypes.Jungle: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Mango : ItemID.Pineapple; + break; + + case TreeTypes.Palm: + + if (WorldGen.IsPalmOasisTree(treeX)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + + break; + + case TreeTypes.PalmCorrupt: + + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + else if (WorldGen.IsPalmOasisTree(treeX)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + + break; + + case TreeTypes.Corrupt: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + break; + + case TreeTypes.PalmHallowed: + + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; + else if (WorldGen.IsPalmOasisTree(treeX)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; + + break; + + case TreeTypes.Hallowed: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; + break; + + case TreeTypes.PalmCrimson: + + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; + else if (WorldGen.IsPalmOasisTree(treeX)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; + + break; + + case TreeTypes.Crimson: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; + break; + + default: + break; + } + + if (treeDropItemType != 0) + Item.NewItem(new EntitySource_TileBreak(treeX, treeY), treeX * 16, treeY * 16, 16, 16, treeDropItemType); + } + } + } + // Helper function to shatter crystals attached to neighboring solid tiles. void CheckShatterCrystal(int xPos, int yPos, bool dontShatter) { @@ -313,5 +427,45 @@ namespace CalamityMod.Tiles return base.CanKillTile(i, j, type, ref blockDamaged); } + + // "Private" my ass, fuck off + public static void GetTreeBottom(int i, int j, out int x, out int y) + { + x = i; + y = j; + Tile tileSafely = Framing.GetTileSafely(x, y); + if (tileSafely.TileType == TileID.PalmTree) + { + while (y < Main.maxTilesY - 50 && (!tileSafely.HasTile || tileSafely.TileType == TileID.PalmTree)) + { + y++; + tileSafely = Framing.GetTileSafely(x, y); + } + + return; + } + + int num = tileSafely.TileFrameX / 22; + int num2 = tileSafely.TileFrameY / 22; + if (num == 3 && num2 <= 2) + x++; + else if (num == 4 && num2 >= 3 && num2 <= 5) + x--; + else if (num == 1 && num2 >= 6 && num2 <= 8) + x--; + else if (num == 2 && num2 >= 6 && num2 <= 8) + x++; + else if (num == 2 && num2 >= 9) + x++; + else if (num == 3 && num2 >= 9) + x--; + + tileSafely = Framing.GetTileSafely(x, y); + while (y < Main.maxTilesY - 50 && (!tileSafely.HasTile || TileID.Sets.IsATreeTrunk[tileSafely.TileType] || tileSafely.TileType == TileID.MushroomTrees)) + { + y++; + tileSafely = Framing.GetTileSafely(x, y); + } + } } } diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index e09370f061..13219f6d0d 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -1140,6 +1140,36 @@ namespace CalamityMod r.AddIngredient(ModContent.ItemType()); r.AddTile(TileID.CookingPots); r.Register(); + + r = Recipe.Create(ItemID.ApplePie); + r.AddIngredient(ItemID.Apple, 3); + r.AddTile(TileID.Furnaces); + r.Register(); + + r = Recipe.Create(ItemID.BananaSplit); + r.AddIngredient(ItemID.Banana); + r.AddIngredient(ItemID.IceBlock); + r.AddIngredient(ItemID.MilkCarton); + r.AddTile(TileID.CookingPots); + r.Register(); + + r = Recipe.Create(ItemID.BBQRibs); + r.AddIngredient(ItemID.FleshBlock, 6); + r.AddIngredient(ItemID.Bone, 6); + r.AddTile(TileID.Furnaces); + r.Register(); + + r = Recipe.Create(ItemID.MilkCarton); + r.AddIngredient(ItemID.BottledWater); + r.AddIngredient(ItemID.Bone, 2); + r.AddTile(TileID.CookingPots); + r.Register(); + + r = Recipe.Create(ItemID.Nachos); + r.AddIngredient(ItemID.PotatoChips); + r.AddIngredient(ItemID.MilkCarton); + r.AddTile(TileID.CookingPots); + r.Register(); } #endregion