added Whispering Pearls

This commit is contained in:
GinYuH committed 2025-05-18 01:02:03 -07:00
1 parent 87dc8b83b6
commit fb2ef221a8
28 files changed
+637

No files matched your search

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearl : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 0;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlBlack : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 9;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlDarkBlue : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 6;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlDarkGreen : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 8;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlLightBlue : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 5;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlLightGreen : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 4;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlOrange : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 2;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlPurple : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 7;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlRed : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 1;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,17 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls
{
public class WhisperingPearlYellow : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Placeables";
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.SunkenSea.WhisperingPearl>());
Item.rare = ItemRarityID.Blue;
Item.placeStyle = 3;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -3207,6 +3207,56 @@ VoidWorkBench: {
Tooltip: ""
}
WhisperingPearl: {
DisplayName: Whispering Pearl
Tooltip: Contains knowledge
}
WhisperingPearlBlack: {
DisplayName: Black Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WhisperingPearlDarkBlue: {
DisplayName: Dark Blue Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WhisperingPearlDarkGreen: {
DisplayName: Dark Green Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WhisperingPearlLightBlue: {
DisplayName: Light Blue Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WhisperingPearlLightGreen: {
DisplayName: Light Green Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WhisperingPearlOrange: {
DisplayName: Orange Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WhisperingPearlPurple: {
DisplayName: Purple Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WhisperingPearlRed: {
DisplayName: Red Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WhisperingPearlYellow: {
DisplayName: Yellow Whispering Pearl
Tooltip: "{$Items.Placeables.WhisperingPearl.Tooltip}"
}
WulfrumBathtub: {
DisplayName: Wulfrum Bathtub
Tooltip: ""
@@ -32,6 +32,8 @@ SpineTree.MapEntry: Giant Spine
InactivePowerCellFactory.MapEntry: Inactive Power Cell Factory
OnyxExcavatorTile.MapEntry: Onyx Excavator
CodebreakerTile.MapEntry: The Codebreaker
// Sunken Sea
WhisperingPearl: "{$Items.Placeables.SunkenSea.WhisperingPearl.DisplayName}"
// Ores
AerialiteOre.MapEntry: Aerialite
AerialiteOreDisenchanted.MapEntry: Disenchanted Aerialite
@@ -588,6 +588,127 @@ Lecherous: {
Description: Spawns a resilient brimstone monster that stays between you and your mouse that interferes with your homing weapons. It releases a bunch of hearts on death.
}
// Moving text to a new line inserts a paragraph break. Two blank newlines separate pages.
WhisperingPearl: {
Basic:
'''
Something about clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
Red:
'''
Something about red clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
Orange:
'''
Something about orange clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
Yellow:
'''
Something about yellow clams Something about yellow clams Something about yellow clams Something about yellow clams Something about yellow clams Something about yellow clams Something about yellow clams
Like yknow those shellfish? Something about yellow clams Something about yellow clams Something about yellow clams Something about yellow clams Something about yellow clams
By the way I ate curry today
MMM....
'''
LightGreen:
'''
Something about light green clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
LightBlue:
'''
Something about light blue clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
DarkBlue:
'''
Something about dark blue clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
Purple:
'''
Something about purple clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
DarkGreen:
'''
Something about dark green clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
Black:
'''
Something about black clams
Like yknow those shellfish?
By the way I ate curry today
MMM....
'''
}
Disenchant: Disenchant
// Worldgen Tasks
BetterUnderworld: Creating a smoother Underworld
+6
View File
@@ -34,6 +34,12 @@ namespace CalamityMod.Systems
int mouseIndex = layers.FindIndex(layer => layer.Name == "Vanilla: Mouse Text");
if (mouseIndex != -1)
{
layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Whispering Pearl", () =>
{
WhisperingPearlUI.Draw(Main.spriteBatch);
return true;
}, InterfaceScaleType.Game));
layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Draedon Hologram", () =>
{
LabHologramProjectorUI.Draw(Main.spriteBatch);
+99
View File
@@ -0,0 +1,99 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.SunkenSea.WhisperingPearls;
using CalamityMod.TileEntities;
using CalamityMod.UI;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Terraria;
using Terraria.Audio;
using Terraria.Enums;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace CalamityMod.Tiles.SunkenSea
{
public class WhisperingPearl : ModTile
{
public override void SetStaticDefaults()
{
Main.tileFrameImportant[Type] = true;
Main.tileLighted[Type] = true;
Main.tileNoFail[Type] = true;
Main.tileWaterDeath[Type] = false;
TileID.Sets.HasOutlines[Type] = true;
TileID.Sets.DisableSmartCursor[Type] = true;
TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1);
TileObjectData.newTile.StyleHorizontal = true;
TileObjectData.newTile.WaterDeath = false;
TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed;
TileObjectData.newTile.LavaDeath = false;
TileObjectData.newTile.LavaPlacement = LiquidPlacement.NotAllowed;
TileObjectData.addTile(Type);
AddMapEntry(Color.LightCyan, CalamityUtils.GetText("Tiles.WhisperingPearl"));
DustType = DustID.BlueCrystalShard;
HitSound = SoundID.Item27;
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
r = 0f;
g = 0.3f;
b = 0.3f;
}
public override bool RightClick(int i, int j)
{
int frameNum = Main.tile[i, j].TileFrameX / 18;
string key = frameNum switch
{
1 => "Red",
2 => "Orange",
3 => "Yellow",
4 => "LightGreen",
5 => "LightBlue",
6 => "DarkBlue",
7 => "Purple",
8 => "DarkGreen",
9 => "Black",
_ => "Basic"
};
if (!WhisperingPearlUI.IsActive)
{
WhisperingPearlUI.StartDialogue(new Vector2(i, j) * 16, key);
}
else
{
WhisperingPearlUI.ProgressDialogue(new Vector2(i, j) * 16, key);
}
return true;
}
public override bool HasSmartInteract(int i, int j, Terraria.GameContent.ObjectInteractions.SmartInteractScanSettings settings) => true;
public override void MouseOver(int i, int j)
{
int frameNum = Main.tile[i, j].TileFrameX / 18;
int pearl = frameNum switch
{
1 => ModContent.ItemType<WhisperingPearlRed>(),
2 => ModContent.ItemType<WhisperingPearlOrange>(),
3 => ModContent.ItemType<WhisperingPearlYellow>(),
4 => ModContent.ItemType<WhisperingPearlLightGreen>(),
5 => ModContent.ItemType<WhisperingPearlLightBlue>(),
6 => ModContent.ItemType<WhisperingPearlDarkBlue>(),
7 => ModContent.ItemType<WhisperingPearlPurple>(),
8 => ModContent.ItemType<WhisperingPearlDarkGreen>(),
9 => ModContent.ItemType<WhisperingPearlBlack>(),
_ => ModContent.ItemType<Items.Placeables.SunkenSea.WhisperingPearls.WhisperingPearl>(),
};
Main.LocalPlayer.cursorItemIconID = pearl;
Main.LocalPlayer.noThrow = 2;
Main.LocalPlayer.cursorItemIconEnabled = true;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

+189
View File
@@ -0,0 +1,189 @@
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Weapons.Typeless;
using CalamityMod.TileEntities;
using CalamityMod.Tiles.SunkenSea;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.UI
{
public class WhisperingPearlUI
{
/// <summary>
/// Controls how many characters can currently be displayed
/// </summary>
public static float textTimer = -1;
/// <summary>
/// The maximum amount of characters to display for this page
/// </summary>
public static int maxTextTime = -1;
/// <summary>
/// Which page are we reading?
/// </summary>
public static int currentPage = -1;
/// <summary>
/// The localization key for the dialogue
/// </summary>
public static string key = "";
/// <summary>
/// The bottom position of the text
/// </summary>
public static Vector2 position = Vector2.Zero;
/// <summary>
/// How many page there are
/// </summary>
public static int pageCount = 0;
public static void Draw(SpriteBatch sb)
{
if (IsActive)
{
bool noPearl = false;
Point pearlTilePos = new Point((int)position.X / 16, (int)position.Y / 16);
Tile target = CalamityUtils.ParanoidTileRetrieval(pearlTilePos.X, pearlTilePos.Y);
// If there is no pearl, stop the dialogue
if (!target.HasTile || target.TileType != ModContent.TileType<WhisperingPearl>())
{
noPearl = true;
}
// If the player is too far from the pearl, cancel the dialogue
else if (!Main.LocalPlayer.IsInTileInteractionRange(pearlTilePos.X, pearlTilePos.Y, TileReachCheckSettings.Simple))
{
noPearl = true;
}
if (noPearl)
{
FinishDialogue();
return;
}
string text = CalamityUtils.GetTextValue("UI.WhisperingPearl." + key);
// Separate the text into pages
string[] separated = text.Split("\n\n");
pageCount = separated.Length;
// If the current page is more than the total amount of pages, stop the dialogue
if (currentPage > separated.Length - 1)
{
FinishDialogue();
return;
}
// Cut the page even further down into individual lines
string[] wrapped = Utils.WordwrapString(separated[currentPage], FontAssets.MouseText.Value, 600, 100000, out int lineAmt);
string combined = "";
// Combine them back together with newlines separating them
for (int i = 0; i < wrapped.Length; i++)
{
if (wrapped[i] != null)
{
combined += '\n' + wrapped[i];
}
}
// Remove the newlines from every line except the last which doesn't have one
maxTextTime = combined.Length;
Vector2 size = FontAssets.MouseText.Value.MeasureString(combined);
// Shave off text based on the timer
combined = combined.Remove((int)textTimer, (combined.Length - (int)textTimer));
// How much further the BOTTOM of the text should be drawn above the pearl
float yOffset = 40;
Utils.DrawBorderString(sb, combined, position - Main.screenPosition - Vector2.UnitY * (size.Y + yOffset), Color.White, anchorx: 0.5f, anchory: 0, maxCharactersDisplayed: 100000);
// Increment the text timer
// 0.33 means that it takes 3ish frames for 1 letter to appear
if (textTimer < maxTextTime)
{
textTimer += 0.33f;
}
}
// If dialogue can't be active, finish it
else
{
FinishDialogue();
}
}
/// <summary>
/// Checks if the dialogue is active
/// </summary>
public static bool IsActive => textTimer >= 0 && currentPage >= 0 && key != "" && position != Vector2.Zero;
/// <summary>
/// Manually progresses dialogue
/// </summary>
public static void ProgressDialogue(Vector2 drawPos, string pearlKey)
{
bool samePearl = pearlKey == key && drawPos == position;
if (IsActive && samePearl)
{
// If the timer hasn't finished, set it to max
if (textTimer < maxTextTime)
{
textTimer = maxTextTime;
}
// If the tmier has finished, progress to the next page or finish if we're out of pages
else
{
if (currentPage + 1 > pageCount)
{
FinishDialogue();
}
else
{
currentPage++;
}
textTimer = 0;
}
}
else if (!samePearl)
{
StartDialogue(drawPos, pearlKey);
}
else
{
FinishDialogue();
}
}
/// <summary>
/// Starts up pearl dialogue
/// </summary>
/// <param name="drawPos">The position of the bottom of the text</param>
/// <param name="pearlkey">The name of the pearl's localization key</param>
public static void StartDialogue(Vector2 drawPos, string pearlkey)
{
position = drawPos;
currentPage = 0;
textTimer = 0;
key = pearlkey;
pageCount = 0;
}
/// <summary>
/// Resets all of the dialogue's variables
/// </summary>
public static void FinishDialogue()
{
position = Vector2.Zero;
currentPage = -1;
textTimer = -1;
key = "";
pageCount = 0;
}
}
}