Better wing tooltips

This commit is contained in:
Altixal committed 2026-03-11 11:09:48 +07:00
1 parent 4f8cf0ca6e
commit 2b7d8525b1
6 files changed
+204 -27

No files matched your search

+164 -6
View File
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using CalamityMod.Balancing;
@@ -6,6 +8,7 @@ using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Items.Accessories.Wings
{
@@ -86,26 +89,181 @@ namespace CalamityMod.Items.Accessories.Wings
float baseJumpSpeed = (CalamityServerConfig.Instance.FasterJumpSpeed ? BalancingConstants.ConfigBoostedBaseJumpSpeed : 5.01f) + 1f;
StringBuilder sb = new StringBuilder(512);
sb.Append('\n');
sb.Append(CalamityUtils.GetText($"Common.WingStats").Format(time.FramesToSeconds(), run.ToMph(), (MaxAscentSpeed * baseJumpSpeed).ToMph()));
sb.Append('\n');
if (Main.keyState.PressingShift())
{
sb.Append(CalamityUtils.GetText($"Common.WingStatsAcceleration").Format(rAcc.ToMphps(), BaseAscent.ToMphps(),
sb.Append(GetText($"Common.WingStatsFull").Format(time.FramesToSeconds(),
HorizontalSpeedText(run), run.ToMph(),
VerticalSpeedText(MaxAscentSpeed), (MaxAscentSpeed * baseJumpSpeed).ToMph(),
HorizontalAccelerationText(stats.AccRunAccelerationMult), rAcc.ToMphps(),
VerticalAccelerationText(BaseAscent), BaseAscent.ToMphps(),
(BaseAscent + BonusAscentWhileRising).ToMphps(), (RisingSpeedThreshold * baseJumpSpeed).ToMph(),
(BaseAscent + BonusAscentWhileFalling).ToMphps()));
if (hover)
{
sb.Append('\n');
sb.Append(CalamityUtils.GetText($"Common.WingStatsHover").Format(hSpeed.ToMph(), hAcc.ToMphps()));
sb.Append(GetText($"Common.WingStatsHover").Format(hSpeed.ToMph(), hAcc.ToMphps()));
}
}
else
sb.Append($"[c/B8B8B8:{CalamityUtils.GetTextValue("UI.HoldShiftTooltipExtensionIndicator")}]");
{
sb.Append(GetText($"Common.WingStats").Format(time.FramesToSeconds(), HorizontalSpeedText(run), VerticalSpeedText(MaxAscentSpeed),
HorizontalAccelerationText(stats.AccRunAccelerationMult), VerticalAccelerationText(BaseAscent)));
sb.Append('\n');
sb.Append($"[c/B8B8B8:{GetTextValue("UI.HoldShiftTooltipExtensionIndicator")}]");
}
// Add stats below the common "Allows flight" line
var wingTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.Mod == "Terraria");
if (wingTooltip != null)
wingTooltip.Text += sb.ToString();
}
public static string HorizontalSpeedText(float speed)
{
string key = "Average";
Vector3 hsl = new Vector3(0.334f, 0.35f, 1f);
if (speed > 9f)
{
key = "Excellent";
hsl.Y = 1f;
hsl.Z = 0.61f;
}
else if (speed >= 8f)
{
key = "Great";
hsl.Y = 0.65f;
hsl.Z = 0.61f;
}
else if (speed >= 7f)
{
key = "Good";
hsl.Z = 0.61f;
}
else if (speed <= 3f)
{
key = "Awful";
hsl.X = 0f;
hsl.Y = 0.65f;
hsl.Z = 0.61f;
}
else if (speed <= 6f)
{
key = "Poor";
hsl.X = 0f;
hsl.Z = 0.61f;
}
return $"[c/{Main.hslToRgb(hsl).Hex3()}:{GetTextValue($"Common.Stats{key}")}]";
}
public static string VerticalSpeedText(float speed)
{
string key = "Average";
Vector3 hsl = new Vector3(0.334f, 0.35f, 1f);
if (speed > 2.5f)
{
key = "Excellent";
hsl.Y = 1f;
hsl.Z = 0.61f;
}
else if (speed >= 2f)
{
key = "Great";
hsl.Y = 0.65f;
hsl.Z = 0.61f;
}
else if (speed >= 1.65f)
{
key = "Good";
hsl.Z = 0.61f;
}
else if (speed <= 1f)
{
key = "Awful";
hsl.X = 0f;
hsl.Y = 0.65f;
hsl.Z = 0.61f;
}
else if (speed <= 1.35f)
{
key = "Poor";
hsl.X = 0f;
hsl.Z = 0.61f;
}
return $"[c/{Main.hslToRgb(hsl).Hex3()}:{GetTextValue($"Common.Stats{key}")}]";
}
public static string HorizontalAccelerationText(float acc)
{
string key = "Average";
Vector3 hsl = new Vector3(0.334f, 0.35f, 1f);
if (acc > 2.5f)
{
key = "Excellent";
hsl.Y = 1f;
hsl.Z = 0.61f;
}
else if (acc >= 2f)
{
key = "Great";
hsl.Y = 0.65f;
hsl.Z = 0.61f;
}
else if (acc >= 1.25f)
{
key = "Good";
hsl.Z = 0.61f;
}
else if (acc <= 0.5f)
{
key = "Awful";
hsl.X = 0f;
hsl.Y = 0.65f;
hsl.Z = 0.61f;
}
else if (acc <= 0.75f)
{
key = "Poor";
hsl.X = 0f;
hsl.Z = 0.61f;
}
return $"[c/{Main.hslToRgb(hsl).Hex3()}:{GetTextValue($"Common.Stats{key}")}]";
}
public static string VerticalAccelerationText(float acc)
{
string key = "Average";
Vector3 hsl = new Vector3(0.334f, 0.35f, 1f);
if (acc > 0.2f)
{
key = "Excellent";
hsl.Y = 1f;
hsl.Z = 0.61f;
}
else if (acc >= 0.135f)
{
key = "Great";
hsl.Y = 0.65f;
hsl.Z = 0.61f;
}
else if (acc >= 0.11f)
{
key = "Good";
hsl.Z = 0.61f;
}
else if (acc <= 0.05f)
{
key = "Awful";
hsl.X = 0f;
hsl.Y = 0.65f;
hsl.Z = 0.61f;
}
else if (acc <= 0.09f)
{
key = "Poor";
hsl.X = 0f;
hsl.Z = 0.61f;
}
return $"[c/{Main.hslToRgb(hsl).Hex3()}:{GetTextValue($"Common.Stats{key}")}]";
}
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories.Wings
Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 3));
ItemID.Sets.AnimatesAsSoul[Type] = true;
ItemID.Sets.ItemNoGravity[Type] = true;
ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(120, 6.25f, 1f);
ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(160, 7.5f, 1f);
}
public override void SetDefaults()
+2 -4
View File
@@ -200,10 +200,10 @@ namespace CalamityMod.Items
// 170 -> 240 flight time
stats[(int)VanillaWingID.BoneWings].FlyTime = 240;
// 160 -> 170 flight time, 7.5 -> 9 horizontal speed, 1 -> 1.5 acceleration multiplier
// 160 -> 170 flight time, 7.5 -> 9 horizontal speed, 1 -> 2 acceleration multiplier
stats[(int)VanillaWingID.LeafWings].FlyTime = 170;
stats[(int)VanillaWingID.LeafWings].AccRunSpeedOverride = 9f;
stats[(int)VanillaWingID.LeafWings].AccRunAccelerationMult = 1.5f;
stats[(int)VanillaWingID.LeafWings].AccRunAccelerationMult = 2f;
// (Spectre Wings) 1 -> 1.5 acceleration multiplier
stats[(int)VanillaWingID.GhostWings].AccRunAccelerationMult = 1.5f;
@@ -1319,8 +1319,6 @@ namespace CalamityMod.Items
break;
case ItemID.DemonWings:
ascentWhenFalling *= 2f;
ascentWhenRising *= 2f;
maxCanAscendMultiplier *= 2f;
break;
case ItemID.FlameWings:
maxAscentMultiplier *= 1.1067f;
+17 -7
View File
@@ -8,6 +8,7 @@ using CalamityMod.CustomRecipes;
using CalamityMod.DataStructures;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Accessories.Vanity;
using CalamityMod.Items.Accessories.Wings;
using CalamityMod.Items.Armor.Demonshade;
using CalamityMod.Items.Tools;
using CalamityMod.Items.VanillaArmorChanges;
@@ -1093,24 +1094,33 @@ namespace CalamityMod.Items
float baseJumpSpeed = (CalamityServerConfig.Instance.FasterJumpSpeed ? BalancingConstants.ConfigBoostedBaseJumpSpeed : 5.01f) + 1f;
StringBuilder sb = new StringBuilder(512);
sb.Append('\n');
sb.Append(CalamityUtils.GetText($"Common.WingStats").Format(time.FramesToSeconds(), run.ToMph(), (tMax * baseJumpSpeed).ToMph()));
sb.Append('\n');
if (Main.keyState.PressingShift())
{
sb.Append(CalamityUtils.GetText($"Common.WingStatsAcceleration").Format(rAcc.ToMphps(), asc.ToMphps(), (asc + rise).ToMphps(), (rMax * baseJumpSpeed).ToMph(), (asc + fall).ToMphps()));
sb.Append(GetText($"Common.WingStatsFull").Format(time.FramesToSeconds(),
BaseWings.HorizontalSpeedText(run), run.ToMph(),
BaseWings.VerticalSpeedText(tMax), (tMax * baseJumpSpeed).ToMph(),
BaseWings.HorizontalAccelerationText(stats.AccRunAccelerationMult), rAcc.ToMphps(),
BaseWings.VerticalAccelerationText(asc), asc.ToMphps(),
(asc + rise).ToMphps(), (rMax * baseJumpSpeed).ToMph(),
(asc + fall).ToMphps()));
if (hover)
{
sb.Append('\n');
sb.Append(CalamityUtils.GetText($"Common.WingStatsHover").Format(hSpeed.ToMph(), hAcc.ToMphps()));
sb.Append(GetText($"Common.WingStatsHover").Format(hSpeed.ToMph(), hAcc.ToMphps()));
}
}
else
sb.Append($"[c/B8B8B8:{CalamityUtils.GetTextValue("UI.HoldShiftTooltipExtensionIndicator")}]");
{
sb.Append(GetText($"Common.WingStats").Format(time.FramesToSeconds(), BaseWings.HorizontalSpeedText(run), BaseWings.VerticalSpeedText(tMax),
BaseWings.HorizontalAccelerationText(stats.AccRunAccelerationMult), BaseWings.VerticalAccelerationText(asc)));
sb.Append('\n');
sb.Append($"[c/B8B8B8:{GetTextValue("UI.HoldShiftTooltipExtensionIndicator")}]");
}
if (extraKey != null)
{
sb.Append('\n');
sb.Append(CalamityUtils.GetTextValue($"Vanilla.Wings.{extraKey}"));
sb.Append(GetTextValue($"Vanilla.Wings.{extraKey}"));
}
return sb.ToString();
}
@@ -1125,7 +1135,7 @@ namespace CalamityMod.Items
AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.8f, 0.135f);
if (item.type == ItemID.DemonWings)
AddWingStats(item.wingSlot, 1f, 0.2f, 1f, 1.5f, 0.1f, "DemonWings");
AddWingStats(item.wingSlot, 1f, 0.1f, 0.5f, 1.5f, 0.1f, "DemonWings");
if (item.type == ItemID.Jetpack)
AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f);
@@ -47,19 +47,30 @@ GrappleStats:
Reelback Velocity: {2}
Pull Velocity: {3}
'''
StatsAwful: Awful
StatsPoor: Poor
StatsAverage: Average
StatsGood: Good
StatsGreat: Great
StatsExcellent: Excellent
WingStats:
'''
Flight time: {0} seconds
Max horizontal speed: {1} mph
Max vertical speed: {2} mph
Max horizontal speed: {1}
Max vertical speed: {2}
Horizontal acceleration: {3}
Vertical acceleration: {4}
'''
WingStatsAcceleration:
WingStatsFull:
'''
Horizontal acceleration: {0} mph/s
Vertical acceleration:
{1} mph/s
{2} mph/s if ascending slower than {3} mph
{4} mph/s if ascending while falling
Flight time: {0} seconds
Max horizontal speed: {1} ({2} mph)
Max vertical speed: {3} ({4} mph)
Horizontal acceleration: {5} ({6} mph/s)
Vertical acceleration: {7}
- {8} mph/s
- {9} mph/s if ascending slower than {10} mph
- {11} mph/s if ascending while falling
'''
WingStatsHover:
'''
@@ -1,6 +1,6 @@
BeeWings: Decreases fall speed while not pressing {$Key.DOWN}
BoneWings: Halves flight time when taking a hit
DemonWings: Increases fall speed
DemonWings: Increases fall speed and accelerates up faster while falling
FestiveWings: Spawns ornaments which restore flight time
FinWings: Allows quick travel in water
TatteredFairyWings: Leaves a trail of flight draining fairy dust