From 234bc893376992051205df83f3d36ac8aaee7aa1 Mon Sep 17 00:00:00 2001 From: GinYuH <72181395+GinYuH@users.noreply.github.com> Date: Wed, 3 Jun 2026 22:23:13 -0700 Subject: [PATCH] additional Beldum functionality --- .../en-US/Mods.CalamityMod.Items.Pets.hjson | 7 +- Localization/en-US/Mods.CalamityMod.UI.hjson | 1 + Projectiles/Pets/Beldum.cs | 91 ++++++++++++++++-- Projectiles/Pets/Beldum.png | Bin 739 -> 731 bytes Systems/World/WorldgenManagementSystem.cs | 6 ++ Tiles/IronBallPlaced.cs | 53 ++++++++++ Tiles/IronBallPlaced.png | Bin 0 -> 256 bytes Tiles/IronBallPlaced_Glow.png | Bin 0 -> 162 bytes World/DraedonStructures.cs | 9 +- World/MiscWorldgenRoutines.cs | 25 +++++ 10 files changed, 176 insertions(+), 16 deletions(-) create mode 100644 Tiles/IronBallPlaced.cs create mode 100644 Tiles/IronBallPlaced.png create mode 100644 Tiles/IronBallPlaced_Glow.png diff --git a/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson b/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson index 17ab111ba8..2020bbdbea 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson @@ -108,7 +108,12 @@ HermitsBoxofOneHundredMedicines: { IronBall: { DisplayName: Iron Ball - Tooltip: Summons a living iron ball + Tooltip: + ''' + Summons a living iron ball + the pet to pet it + the pet to have it sit on your shoulder + ''' } JoyfulHeart: { diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index 92531f5615..bd0c8302a5 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -664,6 +664,7 @@ Abyss: Disposing of Silva's remains SulphurSea2: Irradiating one of the oceans Roxcalibur: I wanna rock AuricLandMines: Setting god killing traps +IronBall: Adding a bit more iron // Hold Shift tooltip default HoldShiftTooltipExtensionIndicator: Hold Shift for more HoldShiftTooltipReplacementIndicator: Hold Shift for details diff --git a/Projectiles/Pets/Beldum.cs b/Projectiles/Pets/Beldum.cs index 028e875f55..c1b73e06ff 100644 --- a/Projectiles/Pets/Beldum.cs +++ b/Projectiles/Pets/Beldum.cs @@ -4,6 +4,7 @@ using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -35,9 +36,9 @@ namespace CalamityMod.Projectiles.Pets public override void AI() { Player player = Main.player[Projectile.owner]; - Vector2 perfcenter = Projectile.Center; - Vector2 vectorperf = player.Center - perfcenter; - float playerdistance = vectorperf.Length(); + Vector2 beldumcenter = Projectile.Center; + Vector2 vectorbeldum = player.Center - beldumcenter; + float playerdistance = vectorbeldum.Length(); if (!player.active) { Projectile.active = false; @@ -60,17 +61,91 @@ namespace CalamityMod.Projectiles.Pets Projectile.timeLeft = 2; } - Projectile.FloatingPetAI(false, 0); + if (player.InInteractionRange((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, TileReachCheckSettings.Simple)) + { + if (Projectile.Hitbox.Contains(player.ClampedMouseWorld().ToPoint())) + { + if (player.controlUseItem && player.velocity == Vector2.Zero) + { + Projectile.ai[1] = Projectile.ai[1] == 1 ? 0 : 1; + } + else if (player.controlUseTile) + { + Projectile.ai[1] = Projectile.ai[1] == 2 ? 0 : 2; + } + } + } - Projectile.ai[0]++; - Projectile.rotation = MathF.Sin(Projectile.ai[0] * 0.05f) * MathHelper.ToRadians(20); - Projectile.spriteDirection = -Projectile.velocity.X.DirectionalSign(); + // Normal behaviour + if (Projectile.ai[1] == 0) + { + Projectile.FloatingPetAI(false, 0); + } + // Being pet + else if (Projectile.ai[1] == 1) + { + if (player.velocity != Vector2.Zero || player.HasIFrames()) + { + Projectile.ai[1] = 0; + } + else + { + Projectile.Center = player.Center + new Vector2(40 * player.direction, 0); + Projectile.velocity = Vector2.Zero; + PlayerPetting(); + } + } + // Shoulder + else + { + Projectile.Center = player.Center + new Vector2(0, -20 * player.gravDir) + Vector2.UnitY * player.gfxOffY; + } + + if (Projectile.ai[1] != 2) + { + Projectile.ai[0]++; + if (Projectile.ai[1] == 0) + { + Projectile.spriteDirection = -Projectile.velocity.X.DirectionalSign(); + Projectile.rotation = MathF.Sin(Projectile.ai[0] * 0.05f) * MathHelper.ToRadians(20); + } + else + { + Projectile.spriteDirection = -Projectile.DirectionTo(player.Center).X.DirectionalSign(); + Projectile.rotation = MathF.Sin(Projectile.ai[0] * 0.05f) * MathHelper.ToRadians(5); + } + } + else + { + Projectile.ai[0] = 0; + Projectile.rotation = 0; + Projectile.spriteDirection = -player.direction; + } + } + + public void PlayerPetting() + { + Player player = Main.player[Projectile.owner]; + int targetDirection = (Projectile.Center.X > player.Center.X) ? 1 : (-1); + player.StopVanityActions(); + player.ChangeDir(targetDirection); + player.gravDir = 1f; + int completion = player.miscCounter % 14 / 7; + Player.CompositeArmStretchAmount stretch = Player.CompositeArmStretchAmount.ThreeQuarters; + if (completion == 1) + { + stretch = Player.CompositeArmStretchAmount.Full; + } + player.SetCompositeArmBack(enabled: true, stretch, player.DirectionTo(Projectile.Center).ToRotation() - MathHelper.PiOver2); } public override bool PreDraw(ref Color lightColor) { Texture2D tex = TextureAssets.Projectile[Type].Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + Vector2.UnitY * MathF.Cos(Projectile.ai[0] * 0.05f) * 10, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2, Projectile.scale, Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + SpriteEffects fx = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + if (Main.player[Projectile.owner].gravDir == -1) + fx |= SpriteEffects.FlipVertically; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + Vector2.UnitY * MathF.Cos(Projectile.ai[0] * 0.05f) * (Projectile.ai[1] == 0 ? 10 : 2), null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2, Projectile.scale, fx); return false; } } diff --git a/Projectiles/Pets/Beldum.png b/Projectiles/Pets/Beldum.png index 77715bc121fe70986630293194087913ba8cfd0f..1894a7ef526cbf2644e4968d19194f855c8e18df 100644 GIT binary patch delta 713 zcmV;)0yh2Q1=|H7iBL{Q4GJ0x0000DNk~Le0000w0000W2nGNE07Ld`)sZ0}e}zdz zK~z{r?U+x9O;H@jKVz?k-pHTG!a~v;ER4{bh15umSZG8Er7WbBX2ph@q^4x?N)4qE zDaw>gX*MrY-e#tGVId0b4*n7Y zC(nOR$MP-@N8y$?AdbwW~Qby;|pba(Wv7&SSpnOICJVq zdYHz`*O}OiMU*VK*z>us`?o!Ce6M9X^^FS2h3iHd!anY|q)vdo?`DM?j?bu&SLxuWlr!3C$8%M=C$p3FsnpZ?XueP_2pRRNE8@#h z8CBH_Rl{99-AQaatvHmc)sazJ;T=#OI%#?jp{hIn=r#cJ^K(DlBt&JjvvXNuwA=&0 z!!KO`lqN0#(0efHcw|=ieI`S0RQGDTG@DHTy0>l3jE6cS5nqmme~gMNUta+*-L(Q* zm{L{tp4IPD;YNxga|ibCffl{)@tt!3tSl`B;N0*Vh|;J&xLM)9Qq<|>nRGO-=JR(?8lyh|Hs@9Y5QG;100000NkvXXu0mjfR47_8 delta 721 zcmV;?0xtdA1>*%FiBL{Q4GJ0x0000DNk~Le0000u0000W2nGNE07nD6=#e2He~n2* zK~z{r?Uzr8jZqkfpOLbnp}R0d78d?>hgld!*FtI}qmX7Ig;EyNlxR|{*i33t7E@~2 zjQlGxB~!Aw&6K+t%?%4#h_G;Dwu;8a&z$r2z1{m6b?f^)n|sf>r*m%KbAInRUkmf3 z=fs)WuzlyoP)pcuHVbS=*7)nEe=Tzt2l}G^OM};uVeX=*~ruy=A z)E18(KLg;?+xYi#dA#o0|APD&Y}Ay+ntS*8Yt&xTwk&FUMlCX2Ds@HwE3NtL8}zDS zT4d51^pII^{F8gP0N8W*NYp<)^#W2<=j!bO!uASdAXsf8m zPX=XB=U%-VjXmd-6`RH3kj9}@Pw zhgVH?F3uO7x9uHUqJFLCk)I68;DtpS0l57A6#zf?9fAatGG=cYf3}M1JQUVIqv+1L zfA20x$o%2bX*ahRvOm7HiH@EOtUrrM)|@kTKznw+4I9 zJ_KN9=3CC+ChWQBp&NwE*(YadZCx6@ciN14*z79%qt~xQ{oeZdGbp?_eVaA!$<@Oe zRaXDBP3G + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.IronBall").Value; + MiscWorldgenRoutines.GenerateIronBall(); + })); + // No Traps/GFB Auric Land Mines if (Main.noTrapsWorld) { diff --git a/Tiles/IronBallPlaced.cs b/Tiles/IronBallPlaced.cs new file mode 100644 index 0000000000..be04d56908 --- /dev/null +++ b/Tiles/IronBallPlaced.cs @@ -0,0 +1,53 @@ +using System; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles +{ + public class IronBallPlaced : ModTile + { + public static Asset GlowTexture = null; + + public override void Load() + { + GlowTexture = ModContent.Request("CalamityMod/Tiles/IronBallPlaced_Glow"); + } + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLighted[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.addTile(Type); + + DustType = DustID.Silver; + + AddMapEntry(new Color(108, 118, 134)); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType(), Type, 0); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + // Dim flickering red light + r = MathF.Sin(Main.GlobalTimeWrappedHourly * 20) * 0.05f + 0.3f; + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + spriteBatch.Draw(GlowTexture.Value, new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + CalamityUtils.TileDrawOffset, new Rectangle(Main.tile[i, j].TileFrameX, Main.tile[i, j].TileFrameY, 16, 16), Color.White); + } + } +} diff --git a/Tiles/IronBallPlaced.png b/Tiles/IronBallPlaced.png new file mode 100644 index 0000000000000000000000000000000000000000..232ca8d88f027cc53e6a92e9b4689976035cc68e GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|+7J3Ei|DT|k{-Fo%r{hYEk0Rh3+2C@I&-i}Br0xCJ!>hlChag_x5 z1^~bj+Fg!LV)cAM1VFO2zzO90B mlI|p(JJaO?N}m7y#x2fV$70BG#^x;00tQc4KbLh*2~7Z=*;)Mn literal 0 HcmV?d00001 diff --git a/Tiles/IronBallPlaced_Glow.png b/Tiles/IronBallPlaced_Glow.png new file mode 100644 index 0000000000000000000000000000000000000000..ae2214656dfd2d999d3bd06b5b79e0b83f837aba GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL32+R#}EtuFVdQ&MBb@05Om% A*#H0l literal 0 HcmV?d00001 diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index 6598ef87cf..f796e476cf 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -636,7 +636,7 @@ namespace CalamityMod.World #endregion #region Cavern Lab - public static void FillCavernLaboratoryChest(Chest chest, int useless, bool placedIronBall) + public static void FillCavernLaboratoryChest(Chest chest, int useless) { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.EndurancePotion, ItemID.GravitationPotion, ItemID.HeartreachPotion, ItemID.LifeforcePotion); List contents = new List() @@ -651,11 +651,6 @@ namespace CalamityMod.World new ChestItem(ModContent.ItemType(), 1), }; - if (!placedIronBall) - { - contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - } - for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); @@ -707,7 +702,7 @@ namespace CalamityMod.World else { bool placedBeldum = false; - PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref placedBeldum, new Action(FillCavernLaboratoryChest)); + PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref placedBeldum, new Action(FillCavernLaboratoryChest)); CalamityUtils.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 20); CalamityWorld.CavernLabCenter = placementPoint.ToWorldCoordinates() + new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)) * 8f; break; diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index 1f37a9c1d9..0850262d29 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Food; +using CalamityMod.Tiles; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.FurnitureAuric; @@ -564,5 +565,29 @@ namespace CalamityMod.World } } #endregion + + #region Iron Ball + public static void GenerateIronBall() + { + int ballID = ModContent.TileType(); + int attempts = 0; + int ballsPlaced = 0; + int maxBalls = 8; + while (attempts < 10000) + { + Point location = new Point(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)Main.rockLayer, Main.UnderworldLayer)); + Tile t = CalamityUtils.ParanoidTileRetrieval(location.X, location.Y); + Tile above = CalamityUtils.ParanoidTileRetrieval(location.X, location.Y - 1); + if (t.TileType == TileID.Stone && t.HasTile && !above.HasTile) + { + WorldGen.SlopeTile(location.X, location.Y); + WorldGen.PlaceTile(location.X, location.Y - 1, ballID); + ballsPlaced++; + } + if (ballsPlaced >= maxBalls) + break; + } + } + #endregion } }