diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs
index 76ca7d151f..c6bb3f1b97 100644
--- a/CalPlayer/CalamityPlayer.cs
+++ b/CalPlayer/CalamityPlayer.cs
@@ -956,7 +956,7 @@ namespace CalamityMod.CalPlayer
public bool procDodgeEffects = false;
public bool nanotech = false;
public int nanotechHitCooldown = 0;
- public bool deadshotBrooch = false;
+ public Item ammoCycleItem = null;
public bool shadowMinions = false;
public bool statisMinions = false;
public bool alchFlask = false;
@@ -1067,6 +1067,7 @@ namespace CalamityMod.CalPlayer
public bool thiefsDime = false;
public bool dynamoStemCells = false;
public bool etherealExtorter = false;
+ public Item AccessoryParryItem = null;
public bool blazingCore = false;
public int blazingCoreParry = 0;
public int blazingCoreSuccessfulParry = 0;
@@ -1110,7 +1111,7 @@ namespace CalamityMod.CalPlayer
public bool spectralVeil = false;
public int spectralVeilImmunity = 0;
/// Check for if the player has Plagued Fuel Pack OR Blunder Booster equipped.
- public bool hasJetpack = false;
+ public Item rogueDashItem = null;
public bool hasEngineDash = false;
public bool plaguedFuelPack = false;
public bool blunderBooster = false;
@@ -2395,7 +2396,7 @@ namespace CalamityMod.CalPlayer
v8000Engine = false;
nanotech = false;
nanotechHitCooldown = 0;
- deadshotBrooch = false;
+ ammoCycleItem = null;
tesla = false;
teslaVisuals = true;
ascendantInsignia = false;
@@ -2473,6 +2474,7 @@ namespace CalamityMod.CalPlayer
thiefsDime = false;
dynamoStemCells = false;
etherealExtorter = false;
+ AccessoryParryItem = null;
blazingCore = false;
voltaicJelly = false;
jellyChargedBattery = false;
@@ -2612,7 +2614,7 @@ namespace CalamityMod.CalPlayer
filthyGlove = false;
sandCloak = false;
spectralVeil = false;
- hasJetpack = false;
+ rogueDashItem = null;
hasEngineDash = false;
plaguedFuelPack = false;
blunderBooster = false;
@@ -3467,7 +3469,7 @@ namespace CalamityMod.CalPlayer
if (Player.dead)
return;
- if (ascendantInsignia && Main.myPlayer == Player.whoAmI && CalamityKeybinds.AscendantInsigniaHotKey.JustPressed && ascendantInsigniaCooldown <= 0)
+ if (ascendantInsignia && Main.myPlayer == Player.whoAmI && FindAccessory().JustPressedKeybind() && ascendantInsigniaCooldown <= 0)
{
var source = Player.GetSource_Accessory(FindAccessory());
Projectile.NewProjectile(source, Player.Center - Vector2.UnitY * 45f, Vector2.Zero, ProjectileType(), 0, 0f);
@@ -3477,7 +3479,7 @@ namespace CalamityMod.CalPlayer
}
int numOfBlobs = Player.ownedProjectileCounts[ProjectileType()];
- if (transformer && numOfBlobs > 0 && Main.myPlayer == Player.whoAmI && CalamityKeybinds.TransformerHotKey.JustPressed && transformerCooldown <= 0 && true) // Add check if projectiles are active
+ if (transformer && numOfBlobs > 0 && Main.myPlayer == Player.whoAmI && FindAccessory().JustPressedKeybind() && transformerCooldown <= 0 && true) // Add check if projectiles are active
{
// Go fire all the blobs
int cooldownTime = 300;
@@ -3504,7 +3506,8 @@ namespace CalamityMod.CalPlayer
}
//Only increment the slam if not on ground, not mounted, not on rope, not hooked, not tongued, otherwise reset slam time to zero
- if (CalamityKeybinds.GravistarSabatonHotkey.JustPressed && gSabatonHotkeyFallWindup < 0)
+
+ if (gSabaton && FindAccessory().JustPressedKeybind() && gSabatonHotkeyFallWindup < 0)
gSabatonHotkeyFallWindup = 0;
if (gSabaton && gSabatonHotkeyFallWindup >= 0 && Main.myPlayer == Player.whoAmI && (Player.velocity.Y != 0) && !Player.pulley && !Player.mount.Active && Player.grappling[0] == -1 && !Player.tongued)
{
@@ -3550,7 +3553,7 @@ namespace CalamityMod.CalPlayer
}
}
}
- if (CalamityKeybinds.AngelicAllianceHotKey.JustPressed && angelicAlliance && Main.myPlayer == Player.whoAmI && !divineBless && !Player.HasCooldown(Cooldowns.DivineBless.ID))
+ if (angelicAlliance && Main.myPlayer == Player.whoAmI && FindAccessory().JustPressedKeybind() && !divineBless && !Player.HasCooldown(Cooldowns.DivineBless.ID))
{
Player.AddBuff(BuffType(), AngelicAlliance.DivineBlessDuration, false);
SoundEngine.PlaySound(AngelicAlliance.ActivationSound, Player.Center);
@@ -3577,7 +3580,7 @@ namespace CalamityMod.CalPlayer
Player.HealPlayer(AngelicAlliance.HealPerAngelSpawned);
}
}
- if (CalamityKeybinds.SpectralVeilHotKey.JustPressed && spectralVeil && Main.myPlayer == Player.whoAmI && rogueStealth >= rogueStealthMax * 0.25f &&
+ if (spectralVeil && Main.myPlayer == Player.whoAmI && FindAccessory().JustPressedKeybind() && rogueStealth >= rogueStealthMax * 0.25f &&
wearingRogueArmor && rogueStealthMax > 0)
{
if (!Player.chaosState)
@@ -3623,7 +3626,7 @@ namespace CalamityMod.CalPlayer
}
}
}
- if (CalamityKeybinds.BoosterDashHotKey.JustPressed && hasJetpack && Main.myPlayer == Player.whoAmI && rogueStealth >= rogueStealthMax * 0.25f &&
+ if (rogueDashItem != null && Main.myPlayer == Player.whoAmI && rogueDashItem.JustPressedKeybind() && rogueStealth >= rogueStealthMax * 0.25f &&
wearingRogueArmor && rogueStealthMax > 0 && !Player.HasCooldown(RogueBooster.ID) && !Player.mount.Active)
{
jetPackDash = blunderBooster ? 15 : 10;
@@ -3634,7 +3637,7 @@ namespace CalamityMod.CalPlayer
SoundEngine.PlaySound(SoundID.Item34, Player.Center);
}
- if (CalamityKeybinds.AmmoCycleHotkey.JustPressed && deadshotBrooch)
+ if (ammoCycleItem != null && ammoCycleItem.JustPressedKeybind())
{
SoundEngine.PlaySound(SoundID.Item149, Player.Center);
@@ -3733,7 +3736,7 @@ namespace CalamityMod.CalPlayer
else
ArmorSetBonusKeyHeldTimer = 0;
- if (CalamityKeybinds.AccessoryParryHotKey.JustPressed)
+ if (AccessoryParryItem != null && AccessoryParryItem.JustPressedKeybind())
{
if (blazingCore && blazingCoreParry == 0 && blazingCoreSuccessfulParry == 0)
{
diff --git a/CalamityKeybinds.cs b/CalamityKeybinds.cs
index 62b5f44039..56fd1f6497 100644
--- a/CalamityKeybinds.cs
+++ b/CalamityKeybinds.cs
@@ -1,72 +1,207 @@
-using Terraria.ModLoader;
+using System;
+using System.Linq;
+using CalamityMod.Systems.Collections;
+using Terraria;
+using Terraria.ModLoader;
namespace CalamityMod
{
public class CalamityKeybinds : ModSystem
{
- public static ModKeybind AccessoryParryHotKey { get; private set; }
public static ModKeybind AdrenalineHotKey { get; private set; }
- public static ModKeybind AmmoCycleHotkey { get; private set; }
- public static ModKeybind AngelicAllianceHotKey { get; private set; }
public static ModKeybind ArmorSetBonusHotKey { get; private set; }
- public static ModKeybind AscendantInsigniaHotKey { get; private set; }
- public static ModKeybind BoosterDashHotKey { get; private set; }
public static ModKeybind DashHotkey { get; private set; }
public static ModKeybind ExoChairSlowdownHotkey { get; private set; }
public static ModKeybind GodSlayerDashHotKey { get; private set; }
- public static ModKeybind GravistarSabatonHotkey { get; private set; }
public static ModKeybind NormalityRelocatorHotKey { get; private set; }
public static ModKeybind RageHotKey { get; private set; }
- public static ModKeybind SpectralVeilHotKey { get; private set; }
- public static ModKeybind SpringStoolJumpHotKey { get; private set; }
- public static ModKeybind TransformerHotKey { get; private set; }
- public static ModKeybind SwitchGravityHotkey {get; private set;}
+ public static ModKeybind SwitchGravityHotkey { get; private set; }
public static ModKeybind ExpandDebuffInfo { get; private set; }
- public static ModKeybind ThePointerLock {get; private set;}
+
+
+ public static ModKeybind HeldItem { get; private set; }
+ public static ModKeybind Accessory1 { get; private set; }
+ public static ModKeybind Accessory2 { get; private set; }
+ public static ModKeybind Accessory3 { get; private set; }
+ public static ModKeybind Accessory4 { get; private set; }
+ public static ModKeybind Accessory5 { get; private set; }
+ public static ModKeybind Accessory6 { get; private set; }
+ public static ModKeybind Accessory7 { get; private set; }
+
+ public static ModKeybind[] AccessoryKeybinds = [];
public override void Load()
{
// Register keybinds
- AccessoryParryHotKey = KeybindLoader.RegisterKeybind(Mod, "ActivateAccessoryParry", "N");
AdrenalineHotKey = KeybindLoader.RegisterKeybind(Mod, "AdrenalineMode", "B");
- AmmoCycleHotkey = KeybindLoader.RegisterKeybind(Mod, "AmmoCycle", "Mouse3");
- AngelicAllianceHotKey = KeybindLoader.RegisterKeybind(Mod, "AngelicAllianceBlessing", "G");
ArmorSetBonusHotKey = KeybindLoader.RegisterKeybind(Mod, "ArmorSetBonus", "Y");
- AscendantInsigniaHotKey = KeybindLoader.RegisterKeybind(Mod, "AscendantInsigniaHotKey", "K");
- BoosterDashHotKey = KeybindLoader.RegisterKeybind(Mod, "BoosterDash", "Q");
DashHotkey = KeybindLoader.RegisterKeybind(Mod, "DashDoubleTapOverride", "F");
ExoChairSlowdownHotkey = KeybindLoader.RegisterKeybind(Mod, "ExoChairSlowDown", "RightShift");
GodSlayerDashHotKey = KeybindLoader.RegisterKeybind(Mod, "GodSlayerDash", "H");
- GravistarSabatonHotkey = KeybindLoader.RegisterKeybind(Mod, "GravistarSabatonHotkey", "X");
NormalityRelocatorHotKey = KeybindLoader.RegisterKeybind(Mod, "NormalityRelocator", "Z");
RageHotKey = KeybindLoader.RegisterKeybind(Mod, "RageMode", "V");
- SpectralVeilHotKey = KeybindLoader.RegisterKeybind(Mod, "SpectralVeilTeleport", "Z");
- SpringStoolJumpHotKey = KeybindLoader.RegisterKeybind(Mod, "SpringStoolJumpHotKey", "U");
- TransformerHotKey = KeybindLoader.RegisterKeybind(Mod, "TransformerHotKey", "K");
SwitchGravityHotkey = KeybindLoader.RegisterKeybind(Mod, "GravitySwapOverride", "T");
ExpandDebuffInfo = KeybindLoader.RegisterKeybind(Mod, "ExpandDebuffInfo", "LeftControl");
- ThePointerLock = KeybindLoader.RegisterKeybind(Mod, "ThePointerLock", "N");
+
+ HeldItem = KeybindLoader.RegisterKeybind(Mod, "HeldItem", "NumPad0");
+ Accessory1 = KeybindLoader.RegisterKeybind(Mod, "Accessory1", "NumPad1");
+ Accessory2 = KeybindLoader.RegisterKeybind(Mod, "Accessory2", "NumPad2");
+ Accessory3 = KeybindLoader.RegisterKeybind(Mod, "Accessory3", "NumPad3");
+ Accessory4 = KeybindLoader.RegisterKeybind(Mod, "Accessory4", "NumPad4");
+ Accessory5 = KeybindLoader.RegisterKeybind(Mod, "Accessory5", "NumPad5");
+ Accessory6 = KeybindLoader.RegisterKeybind(Mod, "Accessory6", "NumPad6");
+ Accessory7 = KeybindLoader.RegisterKeybind(Mod, "Accessory7", "NumPad7");
+
+ AccessoryKeybinds = [
+ Accessory1,
+ Accessory2,
+ Accessory3,
+ Accessory4,
+ Accessory5,
+ Accessory6,
+ Accessory7
+ ];
}
public override void Unload()
{
- AccessoryParryHotKey = null;
AdrenalineHotKey = null;
- AmmoCycleHotkey = null;
- AngelicAllianceHotKey = null;
ArmorSetBonusHotKey = null;
- AscendantInsigniaHotKey = null;
- BoosterDashHotKey = null;
DashHotkey = null;
ExoChairSlowdownHotkey = null;
GodSlayerDashHotKey = null;
- GravistarSabatonHotkey = null;
NormalityRelocatorHotKey = null;
RageHotKey = null;
- SpectralVeilHotKey = null;
- SpringStoolJumpHotKey = null;
- TransformerHotKey = null;
ExpandDebuffInfo = null;
+
+ Accessory1 = null;
+ Accessory2 = null;
+ Accessory3 = null;
+ Accessory4 = null;
+ Accessory5 = null;
+ Accessory6 = null;
+ Accessory1 = null;
+ Accessory7 = null;
+
+ AccessoryKeybinds = null;
+ }
+ }
+
+ public static class CalamityKeybindsExtensions
+ {
+ ///
+ /// Gets if the Calamity keybind for the given item was just pressed.
+ /// Automatically adjusts between Held Item and Accessory Ability keybinds based on if the item is held and equip order of accessories
+ ///
+ ///
+ ///
+ ///
+ public static bool JustPressedKeybind(this Item item)
+ {
+ if (item == Main.LocalPlayer.HeldItem)
+ return CalamityKeybinds.HeldItem.JustPressed;
+
+ if (!CalamityItemSets.HasAccessoryKeybind[item.type])
+ throw new InvalidOperationException("Item is not marked as having a Calamity keybind in the HasAccessoryKeybind item set");
+
+ int keybindToUse = 0;
+
+ for (var i = 0; i < Main.LocalPlayer.armor.Length; i++)
+ {
+ if (Main.LocalPlayer.armor[i].type == item.type)
+ break;
+ if (CalamityItemSets.HasAccessoryKeybind[Main.LocalPlayer.armor[i].type])
+ keybindToUse++;
+ }
+ return CalamityKeybinds.AccessoryKeybinds[keybindToUse].JustPressed;
+ }
+
+ ///
+ /// Gets if the Calamity keybind for the given item was just released.
+ /// Automatically adjusts between Held Item and Accessory Ability keybinds based on if the item is held and equip order of accessories
+ ///
+ ///
+ ///
+ ///
+ public static bool JustReleasedKeybind(this Item item)
+ {
+
+ if (item == Main.LocalPlayer.HeldItem)
+ return CalamityKeybinds.HeldItem.JustReleased;
+
+ if (!CalamityItemSets.HasAccessoryKeybind[item.type])
+ throw new InvalidOperationException("Item is not marked as having a Calamity keybind in the HasAccessoryKeybind item set");
+
+ int keybindToUse = 0;
+
+ for (var i = 0; i < Main.LocalPlayer.armor.Length; i++)
+ {
+ if (Main.LocalPlayer.armor[i].type == item.type)
+ break;
+ if (CalamityItemSets.HasAccessoryKeybind[Main.LocalPlayer.armor[i].type])
+ keybindToUse++;
+ }
+
+ return CalamityKeybinds.AccessoryKeybinds[keybindToUse].JustReleased;
+ }
+
+
+ ///
+ /// Gets if the Calamity keybind for the given item is currently held down.
+ /// Automatically adjusts between Held Item and Accessory Ability keybinds based on if the item is held and equip order of accessories
+ ///
+ ///
+ ///
+ ///
+ public static bool CurrentlyPressingKeybind(this Item item)
+ {
+ if (item == Main.LocalPlayer.HeldItem)
+ return CalamityKeybinds.HeldItem.Current;
+
+ if (!CalamityItemSets.HasAccessoryKeybind[item.type])
+ throw new InvalidOperationException("Item is not marked as having a Calamity keybind in the HasAccessoryKeybind item set");
+
+ int keybindToUse = 0;
+
+ for (var i = 0; i < Main.LocalPlayer.armor.Length; i++)
+ {
+ if (Main.LocalPlayer.armor[i].type == item.type)
+ break;
+ if (CalamityItemSets.HasAccessoryKeybind[Main.LocalPlayer.armor[i].type])
+ keybindToUse++;
+ }
+
+ return CalamityKeybinds.AccessoryKeybinds[keybindToUse].Current;
+ }
+
+
+ ///
+ /// Gets the Calamity keybind for the given item.
+ /// Automatically adjusts between Held Item and Accessory Ability keybinds based on if the item is held and equip order of accessories
+ ///
+ ///
+ ///
+ ///
+ public static ModKeybind? GetDynamicModHotkey(this Item item)
+ {
+
+ if (!CalamityItemSets.HasAccessoryKeybind[item.type])
+ return CalamityKeybinds.HeldItem;
+
+ if (!Main.LocalPlayer.armor.Any(x => x.type == item.type))
+ return null;
+
+ int keybindToUse = 0;
+
+ for (var i = 0; i < Main.LocalPlayer.armor.Length; i++)
+ {
+ if (Main.LocalPlayer.armor[i].type == item.type)
+ break;
+ if (CalamityItemSets.HasAccessoryKeybind[Main.LocalPlayer.armor[i].type])
+ keybindToUse++;
+ }
+
+ return CalamityKeybinds.AccessoryKeybinds[keybindToUse];
}
}
}
diff --git a/Items/Accessories/AngelicAlliance.cs b/Items/Accessories/AngelicAlliance.cs
index aca8d30b28..4d26811f71 100644
--- a/Items/Accessories/AngelicAlliance.cs
+++ b/Items/Accessories/AngelicAlliance.cs
@@ -2,6 +2,7 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Rarities;
+using CalamityMod.Systems.Collections;
using CalamityMod.Tiles.Furniture.CraftingStations;
using Terraria;
using Terraria.Audio;
@@ -39,7 +40,7 @@ namespace CalamityMod.Items.Accessories
Item.Calamity().devItem = true;
}
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.AngelicAllianceHotKey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Item);
public override void UpdateAccessory(Player player, bool hideVisual)
{
diff --git a/Items/Accessories/AscendantInsignia.cs b/Items/Accessories/AscendantInsignia.cs
index cd3b024632..9a38c4ae96 100644
--- a/Items/Accessories/AscendantInsignia.cs
+++ b/Items/Accessories/AscendantInsignia.cs
@@ -23,7 +23,7 @@ namespace CalamityMod.Items.Accessories
public static int AbilityCooldown = CalamityUtils.SecondsToFrames(40);
public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(FlightTimeBoost.ToPercent(), MoveSpeedBoost.ToPercent(), (1f + AccelerationBoost).Round(), AbilityDuration.FramesToSeconds(), AbilityCooldown.FramesToSeconds());
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.AscendantInsigniaHotKey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Item);
public override void SetDefaults()
{
Item.width = 46;
diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs
index 87edf334c1..6082a7d1ae 100644
--- a/Items/Accessories/BlazingCore.cs
+++ b/Items/Accessories/BlazingCore.cs
@@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories
ItemID.Sets.AnimatesAsSoul[Type] = true;
}
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.AccessoryParryHotKey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Main.LocalPlayer.Calamity().AccessoryParryItem != null ? Main.LocalPlayer.Calamity().AccessoryParryItem : Item);
public override void SetDefaults()
{
Item.width = 42;
@@ -43,6 +43,7 @@ namespace CalamityMod.Items.Accessories
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.Calamity().blazingCore = true;
+ player.Calamity().AccessoryParryItem = Item;
player.noKnockback = true;
}
diff --git a/Items/Accessories/BlunderBooster.cs b/Items/Accessories/BlunderBooster.cs
index 1a1b2bac13..19e94e34f6 100644
--- a/Items/Accessories/BlunderBooster.cs
+++ b/Items/Accessories/BlunderBooster.cs
@@ -18,12 +18,9 @@ namespace CalamityMod.Items.Accessories
Item.accessory = true;
}
- // TODO -- Check if its trying to replace the other rogue jetpack. If its the case, return true.
- public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().hasJetpack;
-
public override void UpdateAccessory(Player player, bool hideVisual)
{
- player.Calamity().hasJetpack = true;
+ player.Calamity().rogueDashItem = Item;
player.GetDamage() += 0.12f;
player.Calamity().rogueVelocity += 0.15f;
player.Calamity().blunderBooster = true;
@@ -32,7 +29,7 @@ namespace CalamityMod.Items.Accessories
player.Calamity().stealthGenMoving += 0.1f;
}
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.BoosterDashHotKey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Item);
public override void AddRecipes()
{
diff --git a/Items/Accessories/DeadshotBrooch.cs b/Items/Accessories/DeadshotBrooch.cs
index 16e3459913..5c3497351d 100644
--- a/Items/Accessories/DeadshotBrooch.cs
+++ b/Items/Accessories/DeadshotBrooch.cs
@@ -21,13 +21,13 @@ namespace CalamityMod.Items.Accessories
public override void UpdateAccessory(Player player, bool hideVisual)
{
- player.Calamity().deadshotBrooch = true;
+ player.Calamity().ammoCycleItem = Item;
player.Calamity().ammoCost *= 0.8f;
player.GetDamage() += 0.12f;
player.GetCritChance() += 7;
}
- public override void ModifyTooltips(List tooltips) => tooltips.IntegrateHotkey(CalamityKeybinds.AmmoCycleHotkey);
+ public override void ModifyTooltips(List tooltips) => tooltips.IntegrateDynamicHotkey(Item);
public override void AddRecipes()
{
diff --git a/Items/Accessories/FlameLickedShell.cs b/Items/Accessories/FlameLickedShell.cs
index 53f57e9697..244eddd3d0 100644
--- a/Items/Accessories/FlameLickedShell.cs
+++ b/Items/Accessories/FlameLickedShell.cs
@@ -17,7 +17,7 @@ namespace CalamityMod.Items.Accessories
{
public new string LocalizationCategory => "Items.Accessories";
internal const int flameLickedParry = 30;
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.AccessoryParryHotKey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Main.LocalPlayer.Calamity().AccessoryParryItem != null ? Main.LocalPlayer.Calamity().AccessoryParryItem : Item);
public override void SetStaticDefaults()
{
CalamityItemSets.ExtraDebuffTooltip_Enemy[Type] = [ModContent.BuffType()];
@@ -36,6 +36,7 @@ namespace CalamityMod.Items.Accessories
{
CalamityPlayer modPlayer = player.Calamity();
modPlayer.flameLickedShell = true;
+ modPlayer.AccessoryParryItem = Item;
player.noKnockback = true;
}
diff --git a/Items/Accessories/InterstellarStompers.cs b/Items/Accessories/InterstellarStompers.cs
index 2f82b292fb..0991544716 100644
--- a/Items/Accessories/InterstellarStompers.cs
+++ b/Items/Accessories/InterstellarStompers.cs
@@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories
Item.expert = true;
}
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.GravistarSabatonHotkey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Item);
public override void UpdateAccessory(Player player, bool hideVisual)
{
diff --git a/Items/Accessories/PlaguedFuelPack.cs b/Items/Accessories/PlaguedFuelPack.cs
index 7ba1dcb02f..6af7b7c0ad 100644
--- a/Items/Accessories/PlaguedFuelPack.cs
+++ b/Items/Accessories/PlaguedFuelPack.cs
@@ -17,12 +17,9 @@ namespace CalamityMod.Items.Accessories
Item.accessory = true;
}
- // TODO -- Check if the slot contains the other rogue jetpack, in which case, let the player swap accs
- public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().hasJetpack;
-
public override void UpdateAccessory(Player player, bool hideVisual)
{
- player.Calamity().hasJetpack = true;
+ player.Calamity().rogueDashItem = Item;
player.GetDamage() += 0.08f;
player.Calamity().rogueVelocity += 0.15f;
player.Calamity().plaguedFuelPack = true;
@@ -30,6 +27,6 @@ namespace CalamityMod.Items.Accessories
player.Calamity().stealthGenMoving += 0.1f;
}
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.BoosterDashHotKey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Item);
}
}
diff --git a/Items/Accessories/PlanebreakersPouch.cs b/Items/Accessories/PlanebreakersPouch.cs
index 30445b7dcc..3d14c9d991 100644
--- a/Items/Accessories/PlanebreakersPouch.cs
+++ b/Items/Accessories/PlanebreakersPouch.cs
@@ -27,11 +27,11 @@ namespace CalamityMod.Items.Accessories
player.GetCritChance() += 7;
player.magicQuiver = true;
CalamityPlayer modPlayer = player.Calamity();
- modPlayer.deadshotBrooch = true;
+ modPlayer.ammoCycleItem = Item;
modPlayer.ammoCost *= 0.8f;
}
- public override void ModifyTooltips(List tooltips) => tooltips.IntegrateHotkey(CalamityKeybinds.AmmoCycleHotkey);
+ public override void ModifyTooltips(List tooltips) => tooltips.IntegrateDynamicHotkey(Item);
public override void AddRecipes()
{
diff --git a/Items/Accessories/SpectralVeil.cs b/Items/Accessories/SpectralVeil.cs
index 3cc01929cb..d0d9b60bef 100644
--- a/Items/Accessories/SpectralVeil.cs
+++ b/Items/Accessories/SpectralVeil.cs
@@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories
Item.expert = true;
}
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.SpectralVeilHotKey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Item);
public override void UpdateAccessory(Player player, bool hideVisual)
{
diff --git a/Items/Accessories/SpringStool.cs b/Items/Accessories/SpringStool.cs
index b3c39d4ca4..9d9ac064f9 100644
--- a/Items/Accessories/SpringStool.cs
+++ b/Items/Accessories/SpringStool.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using CalamityMod.CalPlayer;
using CalamityMod.Cooldowns;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
@@ -15,7 +16,7 @@ namespace CalamityMod.Items.Accessories
public class SpringStool : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Accessories";
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.SpringStoolJumpHotKey);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Item);
public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((JumpCooldown).FramesToSeconds(), (CritRateBoostAboveTargets));
public static int JumpCooldown = CalamityUtils.SecondsToFrames(20);
@@ -32,7 +33,7 @@ namespace CalamityMod.Items.Accessories
public override void UpdateAccessory(Player player, bool hideVisual)
{
- player.GetModPlayer().springStool = true;
+ player.GetModPlayer().springStoolItem = Item;
}
public override void AddRecipes()
@@ -48,7 +49,8 @@ namespace CalamityMod.Items.Accessories
public class SpringStoolPlayer : ModPlayer
{
- public bool springStool = false;
+ public bool springStool { get => springStoolItem != null; }
+ public Item springStoolItem = null;
public int springStoolTimer = 0;
public bool hasGroundedSinceJump = true;
@@ -73,7 +75,7 @@ namespace CalamityMod.Items.Accessories
public override void PostUpdateEquips()
{
// Ensures the special jump initiates only works when unmounted, not grappled to a surface, and the ability is off cooldown
- if (CalamityKeybinds.SpringStoolJumpHotKey.JustPressed && springStool && Main.myPlayer == Player.whoAmI && !Player.HasCooldown(Stooldown.ID) && !Player.mount.Active && hasGroundedSinceJump && !(Player.grappling[0] >= 0))
+ if (springStool && Main.myPlayer == Player.whoAmI && !Player.HasCooldown(Stooldown.ID) && springStoolItem.JustPressedKeybind() && !Player.mount.Active && hasGroundedSinceJump && !(Player.grappling[0] >= 0))
{
springStoolTimer = 12;
@@ -214,13 +216,13 @@ namespace CalamityMod.Items.Accessories
public override void ResetEffects()
{
- springStool = false;
+ springStoolItem = null;
springStoolTimer = 0;
}
public override void UpdateDead()
{
- springStool = false;
+ springStoolItem = null;
springStoolTimer = 0;
hasGroundedSinceJump = true;
}
diff --git a/Items/Accessories/ThePointer.cs b/Items/Accessories/ThePointer.cs
index cbf05e1b17..7d09678505 100644
--- a/Items/Accessories/ThePointer.cs
+++ b/Items/Accessories/ThePointer.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using CalamityMod.Particles;
+using CalamityMod.Systems.Collections;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
@@ -23,12 +24,12 @@ namespace CalamityMod.Items.Accessories
Item.accessory = true;
}
- public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.ThePointerLock);
+ public override void ModifyTooltips(List list) => list.IntegrateDynamicHotkey(Item);
public override void UpdateAccessory(Player player, bool hideVisual)
{
LockOnHelper.ForceUsability = true;
- if (CalamityKeybinds.ThePointerLock.JustPressed)
+ if (Item.JustPressedKeybind())
{
LockOnHelper.Toggle();
if (LockOnHelper.AimedTarget != null)
diff --git a/Items/Accessories/TheTransformer.cs b/Items/Accessories/TheTransformer.cs
index fb3ba3f541..9491464ebb 100644
--- a/Items/Accessories/TheTransformer.cs
+++ b/Items/Accessories/TheTransformer.cs
@@ -20,7 +20,7 @@ namespace CalamityMod.Items.Accessories
public override void ModifyTooltips(List list)
{
list.FindAndReplace("[GFB]", Lang.SupportGlyphs(this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")));
- list.IntegrateHotkey(CalamityKeybinds.TransformerHotKey);
+ list.IntegrateDynamicHotkey(Item);
}
public override void SetStaticDefaults()
{
diff --git a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson
index b139893fdb..1d7f6b5baf 100644
--- a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson
+++ b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson
@@ -1,19 +1,17 @@
-ActivateAccessoryParry.DisplayName: Activate Accessory Parry
AdrenalineMode.DisplayName: Adrenaline Mode
-AmmoCycle.DisplayName: Ammo Cycle Hotkey
-AngelicAllianceBlessing.DisplayName: Angelic Alliance Blessing
ArmorSetBonus.DisplayName: Armor Set Bonus
-AscendantInsigniaHotKey.DisplayName: Ascendant Insignia Flight
-BoosterDash.DisplayName: Booster Dash
DashDoubleTapOverride.DisplayName: Dash Double Tap Override
ExoChairSlowDown.DisplayName: Exo Chair Slow Down
GodSlayerDash.DisplayName: Dimensional Drive
-GravistarSabatonHotkey.DisplayName: Interstellar Stompers Slam
NormalityRelocator.DisplayName: Normality Relocator
RageMode.DisplayName: Rage Mode
-SpectralVeilTeleport.DisplayName: Spectral Veil Teleport
-TransformerHotKey.DisplayName: Transformer Hot Key
GravitySwapOverride.DisplayName: Gravity Swap Override
ExpandDebuffInfo.DisplayName: See Debuff Information
-ThePointerLock.DisplayName: The Pointer Lock On
-SpringStoolJumpHotKey.DisplayName: Spring Stool Jump Hotkey
+HeldItem.DisplayName: Held Item Ability
+Accessory1.DisplayName: Accessory Ability 1
+Accessory2.DisplayName: Accessory Ability 2
+Accessory3.DisplayName: Accessory Ability 3
+Accessory4.DisplayName: Accessory Ability 4
+Accessory5.DisplayName: Accessory Ability 5
+Accessory6.DisplayName: Accessory Ability 6
+Accessory7.DisplayName: Accessory Ability 7
diff --git a/Localization/en-US/Mods.CalamityMod.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Misc.hjson
index 873189767c..a7c5075c8c 100644
--- a/Localization/en-US/Mods.CalamityMod.Misc.hjson
+++ b/Localization/en-US/Mods.CalamityMod.Misc.hjson
@@ -128,3 +128,4 @@ GFBRougeUppercase: Rouge
GFBRogueLowercase: rogue
GFBRougeLowercase: rouge
HotkeyNotBound: "[None]"
+HotkeyNotEquipped: an Accessory Ability hotkey
diff --git a/Systems/Collections/CalamityItemSets.cs b/Systems/Collections/CalamityItemSets.cs
index 5abf9646f5..43d08c5de4 100644
--- a/Systems/Collections/CalamityItemSets.cs
+++ b/Systems/Collections/CalamityItemSets.cs
@@ -168,5 +168,10 @@ namespace CalamityMod.Systems.Collections
.RegisterBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType());
+
+ public static bool[] HasAccessoryKeybind = Factory.CreateNamedSet("HasAccessoryKeybind")
+ .Description("Counts this item as having an accessory keybind. Used to detect which keybind goes to which accessory")
+ .RegisterBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(),ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType());
}
}
diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs
index 848c00118a..d04a35ceae 100644
--- a/Utilities/ItemUtils.cs
+++ b/Utilities/ItemUtils.cs
@@ -109,6 +109,25 @@ namespace CalamityMod
tooltips.FindAndReplace("[KEY]", finalKey);
}
+ ///
+ /// Shortcut for automatically placing one keybind within a tooltip. Requires the "[KEY]" string to be replaced.
+ ///
+ /// The tooltip list provided to a ModifyTooltips TML hook.
+ /// The ModKeybind to integrate into the tooltip.
+ public static void IntegrateDynamicHotkey(this List tooltips, Item item)
+ {
+ if (Main.dedServ)
+ return;
+
+ var mhk = item.GetDynamicModHotkey();
+
+ string finalKey = GetText("Misc.HotkeyNotEquipped").Value;
+ if (mhk is not null)
+ finalKey = mhk.TooltipHotkeyString();
+
+ tooltips.FindAndReplace("[KEY]", finalKey);
+ }
+
///
/// Shortcut method for adding "You have already consumed this item" tooltip
///