From aa6a8a7956befbae348a70ba5e3c8217ca121822 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Fri, 20 Mar 2026 18:11:06 -0400 Subject: [PATCH] The Monument Uses placeholder sprites --- Items/Placeables/Furniture/TheMonument.cs | 42 +++++++++++++++++++ Items/Tools/TheGift.cs | 15 ++++++- .../Mods.CalamityMod.Items.Placeables.hjson | 9 ++++ NPCs/CalamityGlobalTownNPC.cs | 38 +++++++++++++++++ Tiles/Furniture/TheMonumentTile.cs | 29 +++++++++++++ 5 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 Items/Placeables/Furniture/TheMonument.cs create mode 100644 Tiles/Furniture/TheMonumentTile.cs diff --git a/Items/Placeables/Furniture/TheMonument.cs b/Items/Placeables/Furniture/TheMonument.cs new file mode 100644 index 0000000000..226cd424a9 --- /dev/null +++ b/Items/Placeables/Furniture/TheMonument.cs @@ -0,0 +1,42 @@ +using CalamityMod.NPCs; +using CalamityMod.Tiles.Furniture; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Furniture +{ + public class TheMonument : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override string Texture => "Terraria/Images/Item_1177"; //Placeholder + + public const float MonumentTaxIncrease = 0.25f; + public const float MonumentHappinessReduction = 0.2f; + + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.rare = ItemRarityID.Pink; + Item.value = Item.buyPrice(gold: 5); + } + + public override void Load() + { + On_Player.CollectTaxes += AddMonumentTaxes; + } + + private static void AddMonumentTaxes(On_Player.orig_CollectTaxes orig, Player self) + { + orig(self); + + foreach (NPC n in Main.ActiveNPCs) + { + if (!n.homeless && !NPCID.Sets.IsTownPet[n.type] && NPC.TypeToDefaultHeadIndex(n.type) > 0 && n.GetGlobalNPC().AffectedByTheMonument) + self.taxMoney += (int)(CalamityGlobalTownNPC.TotalTaxesPerNPC * MonumentTaxIncrease); + } + if (self.taxMoney > CalamityGlobalTownNPC.TaxesToCollectLimit) + self.taxMoney = CalamityGlobalTownNPC.TaxesToCollectLimit; + } + } +} diff --git a/Items/Tools/TheGift.cs b/Items/Tools/TheGift.cs index 293727b9bd..f65ac856a7 100644 --- a/Items/Tools/TheGift.cs +++ b/Items/Tools/TheGift.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs; +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -67,11 +68,21 @@ namespace CalamityMod.Items.Tools } } + // Also contains logic for The Monument, so I can make sure these apply in the correct order private static void TheGiftHappiness(On_ShopHelper.orig_ProcessMood orig, ShopHelper self, Player player, NPC npc) { orig(self, player, npc); - bool? gift = npc.GetGlobalNPC().TheGiftStatus; + var gtnpc = npc.GetGlobalNPC(); + // The Monument lowers happiness by a fixed amount. This is not applied to the Tax Collector. + if (npc.type != NPCID.TaxCollector && gtnpc.SearchForTheMonument(npc)) + { + self._currentPriceAdjustment += TheMonument.MonumentHappinessReduction; + self.LimitAndRoundMultiplier(self._currentPriceAdjustment); + } + + // The Gift sets happiness to a fixed either extremely high or extremely low value, depending on its random state. + bool? gift = gtnpc.TheGiftStatus; if (gift.HasValue) { if (gift.Value) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson index 4a8f1cc711..9ae145a490 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson @@ -990,6 +990,15 @@ ThaumaticChair: { Tooltip: One of Chloe's finest creations } +TheMonument: { + DisplayName: The Monument + Tooltip: + ''' + A monument celebrating the accomplishments of capitalism + Funded by the taxes of nearby Town NPCs, though they may not be too happy about that + ''' +} + ThermalTorch: { DisplayName: Thermal Torch Tooltip: diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 4784f8b305..86ec12c772 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -22,6 +22,7 @@ using CalamityMod.Items.Weapons.Rogue; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Rogue; using CalamityMod.Systems.Collections; +using CalamityMod.Tiles.Furniture; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -31,6 +32,7 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using Terraria.WorldBuilding; using static Terraria.ModLoader.ModContent; namespace CalamityMod.NPCs @@ -81,6 +83,8 @@ namespace CalamityMod.NPCs /// public double TheGiftReset = -1.0; + public bool AffectedByTheMonument = false; + public override bool InstancePerEntity => true; public override bool AppliesToEntity(NPC entity, bool lateInstantiation) @@ -96,6 +100,8 @@ namespace CalamityMod.NPCs myClone.shopAlertAnimTimer = shopAlertAnimTimer; myClone.shopAlertAnimFrame = shopAlertAnimFrame; myClone.TheGiftStatus = TheGiftStatus; + myClone.TheGiftReset = TheGiftReset; + myClone.AffectedByTheMonument = AffectedByTheMonument; return myClone; } @@ -828,8 +834,40 @@ namespace CalamityMod.NPCs } } + // Search for The Monument, for the purposes of assigning higher taxes + AffectedByTheMonument = false; + SearchForTheMonument(npc); + return true; } + + public bool SearchForTheMonument(NPC npc) + { + Point tileCenter = npc.Center.ToTileCoordinates(); + Rectangle searchArea = new((int)(tileCenter.X - Main.buffScanAreaWidth / 2), (int)(tileCenter.Y - Main.buffScanAreaHeight / 2), Main.buffScanAreaWidth, Main.buffScanAreaHeight); + searchArea = WorldUtils.ClampToWorld(searchArea); + for (int i = searchArea.Left; i < searchArea.Right; i++) + { + for (int j = searchArea.Top; j < searchArea.Bottom; j++) + { + if (!searchArea.Contains(i, j)) + continue; + + Tile tile = Main.tile[i, j]; + if (tile == null) + continue; + if (!tile.HasTile) + continue; + + if (tile.TileType == TileType()) + { + AffectedByTheMonument = true; + return true; + } + } + } + return false; + } #endregion #region PreDraw diff --git a/Tiles/Furniture/TheMonumentTile.cs b/Tiles/Furniture/TheMonumentTile.cs new file mode 100644 index 0000000000..a5510f44ff --- /dev/null +++ b/Tiles/Furniture/TheMonumentTile.cs @@ -0,0 +1,29 @@ +using CalamityMod.Items.Placeables.Furniture; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Furniture +{ + public class TheMonumentTile : ModTile + { + public override string Texture => "CalamityMod/Tiles/Furniture/Monoliths/BlueDistortedMonolithTile"; //Placeholder + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.Width = 5; + TileObjectData.newTile.Height = 5; + TileObjectData.newTile.Origin = new Point16(2, 4); + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16, 16, 18 }; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 5, 0); + + AnimationFrameHeight = TileObjectData.newTile.CoordinateFullHeight; + TileObjectData.addTile(Type); + } + } +}