diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index cf7aa23563..cf85506a16 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -2748,6 +2748,11 @@ namespace CalamityMod.CalPlayer pinkCandle = false; yellowCandle = false; + + //Disable Lockon when not on gamepad to prevent it being left on forever by The Pointer + if (!Main.gamePad) + LockOnHelper.ForceUsability = false; + SelectedFishingMinigame = FishingMinigames.None; #region Minion Reset Effects diff --git a/CalamityKeybinds.cs b/CalamityKeybinds.cs index f50b60e5b4..235da907f4 100644 --- a/CalamityKeybinds.cs +++ b/CalamityKeybinds.cs @@ -21,6 +21,7 @@ namespace CalamityMod public static ModKeybind TransformerHotKey { 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 override void Load() { @@ -42,6 +43,7 @@ namespace CalamityMod TransformerHotKey = KeybindLoader.RegisterKeybind(Mod, "TransformerHotKey", "K"); SwitchGravityHotkey = KeybindLoader.RegisterKeybind(Mod, "GravitySwapOverride", "T"); ExpandDebuffInfo = KeybindLoader.RegisterKeybind(Mod, "ExpandDebuffInfo", "LeftControl"); + ThePointerLock = KeybindLoader.RegisterKeybind(Mod, "ThePointerLock", "N"); } public override void Unload() diff --git a/Items/Accessories/ThePointer.cs b/Items/Accessories/ThePointer.cs new file mode 100644 index 0000000000..cbf05e1b17 --- /dev/null +++ b/Items/Accessories/ThePointer.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameInput; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class ThePointer : ModItem, ILocalizedModType + { + public static Asset ActiveTexture; + public new string LocalizationCategory => "Items.Accessories"; + public override void SetDefaults() + { + Item.width = 26; + Item.height = 26; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + Item.accessory = true; + } + + public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.ThePointerLock); + + public override void UpdateAccessory(Player player, bool hideVisual) + { + LockOnHelper.ForceUsability = true; + if (CalamityKeybinds.ThePointerLock.JustPressed) + { + LockOnHelper.Toggle(); + if (LockOnHelper.AimedTarget != null) + { + Vector2 dir = player.DirectionTo(LockOnHelper.AimedTarget.Center); + int loops = (int)((player.Center.Distance(LockOnHelper.AimedTarget.Center)) / 30f) + 1; + for (var i = 1; i < loops; i++) + { + var pos = player.Center + dir * i * 30f; + if (i >= loops - 1) + pos = LockOnHelper.AimedTarget.Center - dir * 30f; + var x = new LineParticle(pos, dir, false, 10, 1, new Color(238, 2, 52)); + GeneralParticleHandler.SpawnParticle(x); + } + } + } + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + if (LockOnHelper.AimedTarget == null) + return true; + var tex = ActiveTexture ??= ModContent.Request("CalamityMod/Items/Accessories/ThePointer_Active"); + CalamityUtils.DrawInventoryCustomScale( + spriteBatch, + tex.Value, + position, + tex.Frame(), + drawColor, + itemColor, + tex.Size() * 0.5f, + 0.1f, + wantedScale: 0.75f); + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.Glass). + AddRecipeGroup("AnyCopperBar", 2). + AddRecipeGroup("IronBar", 3). + AddIngredient(ItemID.ManaCrystal). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Accessories/ThePointer.png b/Items/Accessories/ThePointer.png new file mode 100644 index 0000000000..b6325d80d8 Binary files /dev/null and b/Items/Accessories/ThePointer.png differ diff --git a/Items/Accessories/ThePointer_Active.png b/Items/Accessories/ThePointer_Active.png new file mode 100644 index 0000000000..74259616a5 Binary files /dev/null and b/Items/Accessories/ThePointer_Active.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 6f51b70f95..94661b965d 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1950,6 +1950,17 @@ TheFirstShadowflame: { ''' } +ThePointer: { + DisplayName: The Pointer + Tooltip: + ''' + Allows automatic targeting of enemies + Press [KEY] to cycle through targets near your mouse + After cycling through all close enemies, the next press will disable it + 'Great for cats!' + ''' +} + TheSponge: { DisplayName: The Sponge Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson index 9235ed6df0..8c950f3fd4 100644 --- a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson +++ b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson @@ -15,3 +15,4 @@ 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