New Keybind system for accessories/held items

This commit is contained in:
Doze-Zoze authored and Cameron Ewell committed 2026-07-07 21:05:24 -04:00
1 parent 2287d96e38
commit dcfa8ad9e1
19 files changed
+243 -82

No files matched your search

+15 -12
View File
@@ -957,7 +957,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;
@@ -1068,6 +1068,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;
@@ -1111,7 +1112,7 @@ namespace CalamityMod.CalPlayer
public bool spectralVeil = false;
public int spectralVeilImmunity = 0;
/// <summary> Check for if the player has Plagued Fuel Pack OR Blunder Booster equipped. </summary>
public bool hasJetpack = false;
public Item rogueDashItem = null;
public bool hasEngineDash = false;
public bool plaguedFuelPack = false;
public bool blunderBooster = false;
@@ -2396,7 +2397,7 @@ namespace CalamityMod.CalPlayer
v8000Engine = false;
nanotech = false;
nanotechHitCooldown = 0;
deadshotBrooch = false;
ammoCycleItem = null;
tesla = false;
teslaVisuals = true;
ascendantInsignia = false;
@@ -2474,6 +2475,7 @@ namespace CalamityMod.CalPlayer
thiefsDime = false;
dynamoStemCells = false;
etherealExtorter = false;
AccessoryParryItem = null;
blazingCore = false;
voltaicJelly = false;
jellyChargedBattery = false;
@@ -2613,7 +2615,7 @@ namespace CalamityMod.CalPlayer
filthyGlove = false;
sandCloak = false;
spectralVeil = false;
hasJetpack = false;
rogueDashItem = null;
hasEngineDash = false;
plaguedFuelPack = false;
blunderBooster = false;
@@ -3468,7 +3470,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<AscendantInsignia>().JustPressedKeybind() && ascendantInsigniaCooldown <= 0)
{
var source = Player.GetSource_Accessory(FindAccessory<AscendantInsignia>());
Projectile.NewProjectile(source, Player.Center - Vector2.UnitY * 45f, Vector2.Zero, ProjectileType<AscendantAura>(), 0, 0f);
@@ -3478,7 +3480,7 @@ namespace CalamityMod.CalPlayer
}
int numOfBlobs = Player.ownedProjectileCounts[ProjectileType<TransformerBlob>()];
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<TheTransformer>().JustPressedKeybind() && transformerCooldown <= 0 && true) // Add check if projectiles are active
{
// Go fire all the blobs
int cooldownTime = 300;
@@ -3505,7 +3507,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<InterstellarStompers>().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)
{
@@ -3551,7 +3554,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<AngelicAlliance>().JustPressedKeybind() && !divineBless && !Player.HasCooldown(Cooldowns.DivineBless.ID))
{
Player.AddBuff(BuffType<Buffs.StatBuffs.DivineBless>(), AngelicAlliance.DivineBlessDuration, false);
SoundEngine.PlaySound(AngelicAlliance.ActivationSound, Player.Center);
@@ -3578,7 +3581,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<SpectralVeil>().JustPressedKeybind() && rogueStealth >= rogueStealthMax * 0.25f &&
wearingRogueArmor && rogueStealthMax > 0)
{
if (!Player.chaosState)
@@ -3624,7 +3627,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;
@@ -3635,7 +3638,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);
@@ -3734,7 +3737,7 @@ namespace CalamityMod.CalPlayer
else
ArmorSetBonusKeyHeldTimer = 0;
if (CalamityKeybinds.AccessoryParryHotKey.JustPressed)
if (AccessoryParryItem != null && AccessoryParryItem.JustPressedKeybind())
{
if (blazingCore && blazingCoreParry == 0 && blazingCoreSuccessfulParry == 0)
{
+166 -31
View File
@@ -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
{
/// <summary>
/// Gets if the Calamity keybind for the given item was just pressed. <br/>
/// Automatically adjusts between Held Item and Accessory Ability keybinds based on if the item is held and equip order of accessories
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
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;
}
/// <summary>
/// Gets if the Calamity keybind for the given item was just released. <br/>
/// Automatically adjusts between Held Item and Accessory Ability keybinds based on if the item is held and equip order of accessories
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
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;
}
/// <summary>
/// Gets if the Calamity keybind for the given item is currently held down. <br/>
/// Automatically adjusts between Held Item and Accessory Ability keybinds based on if the item is held and equip order of accessories
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
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;
}
/// <summary>
/// Gets the Calamity keybind for the given item. <br/>
/// Automatically adjusts between Held Item and Accessory Ability keybinds based on if the item is held and equip order of accessories
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
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];
}
}
}
+2 -1
View File
@@ -2,6 +2,7 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Rarities;
using CalamityMod.Systems.Collections;
using CalamityMod.Tiles.Furniture.CraftingStations;
using Microsoft.Xna.Framework;
using Terraria;
@@ -40,7 +41,7 @@ namespace CalamityMod.Items.Accessories
Item.Calamity().devItem = true;
}
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.AngelicAllianceHotKey);
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateDynamicHotkey(Item);
public override void UpdateAccessory(Player player, bool hideVisual)
{
+1 -1
View File
@@ -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<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.AscendantInsigniaHotKey);
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateDynamicHotkey(Item);
public override void SetDefaults()
{
Item.width = 46;
+2 -1
View File
@@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories
ItemID.Sets.AnimatesAsSoul[Type] = true;
}
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.AccessoryParryHotKey);
public override void ModifyTooltips(List<TooltipLine> 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;
}
+2 -5
View File
@@ -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<ThrowingDamageClass>() += 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<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.BoosterDashHotKey);
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateDynamicHotkey(Item);
public override void AddRecipes()
{
+2 -2
View File
@@ -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<RangedDamageClass>() += 0.12f;
player.GetCritChance<RangedDamageClass>() += 7;
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => tooltips.IntegrateHotkey(CalamityKeybinds.AmmoCycleHotkey);
public override void ModifyTooltips(List<TooltipLine> tooltips) => tooltips.IntegrateDynamicHotkey(Item);
public override void AddRecipes()
{
+2 -1
View File
@@ -17,7 +17,7 @@ namespace CalamityMod.Items.Accessories
{
public new string LocalizationCategory => "Items.Accessories";
internal const int flameLickedParry = 30;
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.AccessoryParryHotKey);
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateDynamicHotkey(Main.LocalPlayer.Calamity().AccessoryParryItem != null ? Main.LocalPlayer.Calamity().AccessoryParryItem : Item);
public override void SetStaticDefaults()
{
CalamityItemSets.ExtraDebuffTooltip_Enemy[Type] = [ModContent.BuffType<BrimstoneFlames>()];
@@ -36,6 +36,7 @@ namespace CalamityMod.Items.Accessories
{
CalamityPlayer modPlayer = player.Calamity();
modPlayer.flameLickedShell = true;
modPlayer.AccessoryParryItem = Item;
player.noKnockback = true;
}
+1 -1
View File
@@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories
Item.expert = true;
}
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.GravistarSabatonHotkey);
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateDynamicHotkey(Item);
public override void UpdateAccessory(Player player, bool hideVisual)
{
+2 -5
View File
@@ -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<ThrowingDamageClass>() += 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<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.BoosterDashHotKey);
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateDynamicHotkey(Item);
}
}
+2 -2
View File
@@ -27,11 +27,11 @@ namespace CalamityMod.Items.Accessories
player.GetCritChance<RangedDamageClass>() += 7;
player.magicQuiver = true;
CalamityPlayer modPlayer = player.Calamity();
modPlayer.deadshotBrooch = true;
modPlayer.ammoCycleItem = Item;
modPlayer.ammoCost *= 0.8f;
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => tooltips.IntegrateHotkey(CalamityKeybinds.AmmoCycleHotkey);
public override void ModifyTooltips(List<TooltipLine> tooltips) => tooltips.IntegrateDynamicHotkey(Item);
public override void AddRecipes()
{
+1 -1
View File
@@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories
Item.expert = true;
}
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.SpectralVeilHotKey);
public override void ModifyTooltips(List<TooltipLine> list) => list.IntegrateDynamicHotkey(Item);
public override void UpdateAccessory(Player player, bool hideVisual)
{
+8 -6
View File
@@ -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<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.SpringStoolJumpHotKey);
public override void ModifyTooltips(List<TooltipLine> 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<SpringStoolPlayer>().springStool = true;
player.GetModPlayer<SpringStoolPlayer>().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;
}
+3 -2
View File
@@ -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<TooltipLine> list) => list.IntegrateHotkey(CalamityKeybinds.ThePointerLock);
public override void ModifyTooltips(List<TooltipLine> 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)
+1 -1
View File
@@ -20,7 +20,7 @@ namespace CalamityMod.Items.Accessories
public override void ModifyTooltips(List<TooltipLine> list)
{
list.FindAndReplace("[GFB]", Lang.SupportGlyphs(this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")));
list.IntegrateHotkey(CalamityKeybinds.TransformerHotKey);
list.IntegrateDynamicHotkey(Item);
}
public override void SetStaticDefaults()
{
@@ -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
@@ -128,3 +128,4 @@ GFBRougeUppercase: Rouge
GFBRogueLowercase: rogue
GFBRougeLowercase: rouge
HotkeyNotBound: "[None]"
HotkeyNotEquipped: an Accessory Ability hotkey
+5
View File
@@ -168,5 +168,10 @@ namespace CalamityMod.Systems.Collections
.RegisterBoolSet(ItemType<FishStocks>(), ItemType<TrustyOldRod>(), ItemType<RageBait>(), ItemType<GluttonyBlender>(), ItemType<TheMonument>(), ItemType<GreedPot>(), ItemType<BaconOil>(), ItemType<TheSandwich>(), ItemType<TheConcoction>(), ItemType<TheElixir>(), ItemType<TheGift>(), ItemType<OmniGun>(),
ItemType<CombatVoucher>(), ItemType<AggressiveVoucher>(), ItemType<OddVoucher>(), ItemType<UnbreakableVoucher>(), ItemType<HurriedVoucher>(), ItemType<TheHousingContract>(), ItemType<CorruptionEffigy>(), ItemType<CrimsonEffigy>(), ItemType<TrinketofChi>(), ItemType<FrozenCube>(), ItemType<LuxorsGift>(),
ItemType<FungalSymbiote>(), ItemType<GladiatorsLocket>(), ItemType<UnstableGraniteCore>(), ItemType<HeartofDarkness>(), ItemType<StressPills>(), ItemType<TheWand>());
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<AngelicAlliance>(), ItemType<AscendantInsignia>(), ItemType<BlazingCore>(), ItemType<BlunderBooster>(), ItemType<DeadshotBrooch>(), ItemType<FlameLickedShell>(),
ItemType<InterstellarStompers>(),ItemType<PlaguedFuelPack>(), ItemType<PlanebreakersPouch>(), ItemType<SpectralVeil>(), ItemType<SpringStool>(), ItemType<ThePointer>(), ItemType<TheTransformer>());
}
}
+19
View File
@@ -109,6 +109,25 @@ namespace CalamityMod
tooltips.FindAndReplace("[KEY]", finalKey);
}
/// <summary>
/// Shortcut for automatically placing one keybind within a tooltip. Requires the "[KEY]" string to be replaced.
/// </summary>
/// <param name="tooltips">The tooltip list provided to a <b>ModifyTooltips</b> TML hook.</param>
/// <param name="mhk">The ModKeybind to integrate into the tooltip.</param>
public static void IntegrateDynamicHotkey(this List<TooltipLine> 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);
}
/// <summary>
/// Shortcut method for adding "You have already consumed this item" tooltip
/// </summary>