additional Beldum functionality

This commit is contained in:
GinYuH committed 2026-06-03 22:23:13 -07:00
1 parent aaa18d19d3
commit 234bc89337
10 files changed
+176 -16

No files matched your search

@@ -108,7 +108,12 @@ HermitsBoxofOneHundredMedicines: {
IronBall: {
DisplayName: Iron Ball
Tooltip: Summons a living iron ball
Tooltip:
'''
Summons a living iron ball
<left> the pet to pet it
<right> the pet to have it sit on your shoulder
'''
}
JoyfulHeart: {
@@ -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
+83 -8
View File
@@ -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;
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 739 B

After

Width:  |  Height:  |  Size: 731 B

@@ -418,6 +418,12 @@ namespace CalamityMod.Systems
SulphurousSea.SulphurSeaGenerationAfterAbyss();
}));
tasks.Insert(++currentFinalIndex, new PassLegacy("Iron Ball", (progress, config) =>
{
progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.IronBall").Value;
MiscWorldgenRoutines.GenerateIronBall();
}));
// No Traps/GFB Auric Land Mines
if (Main.noTrapsWorld)
{
+53
View File
@@ -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<Texture2D> GlowTexture = null;
public override void Load()
{
GlowTexture = ModContent.Request<Texture2D>("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<IronBall>());
FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType<IronBall>(), 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);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

+2 -7
View File
@@ -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<ChestItem> contents = new List<ChestItem>()
@@ -651,11 +651,6 @@ namespace CalamityMod.World
new ChestItem(ModContent.ItemType<LabSeekingMechanism>(), 1),
};
if (!placedIronBall)
{
contents.Insert(0, new ChestItem(ModContent.ItemType<IronBall>(), 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<Chest, int, bool>(FillCavernLaboratoryChest));
PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref placedBeldum, new Action<Chest, int>(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;
+25
View File
@@ -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<IronBallPlaced>();
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
}
}