From c6fc5fbb1322edfa91014243a035ae526048386c Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Sat, 5 Nov 2022 02:46:08 +0100 Subject: [PATCH] nothing personel kid --- Items/KatanaRedo.cs | 58 +++++++++++++++++++++++++++++++++++++++++++++ YHTMod.cs | 7 +++++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Items/KatanaRedo.cs diff --git a/Items/KatanaRedo.cs b/Items/KatanaRedo.cs new file mode 100644 index 0000000..b3d9946 --- /dev/null +++ b/Items/KatanaRedo.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Chat; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace YHTMod.Items; + +public class KatanaRedo : GlobalItem { + + public override void ModifyTooltips(Item item, List tooltips) + { + if (item.type == ItemID.Katana) { + tooltips.Insert(5, new TooltipLine(YHTMod.GetInstance(), "flavor" , "Nothing personel kid.")); + tooltips.Insert(6, new TooltipLine(YHTMod.GetInstance(), "usage" , "Right click to teleport behind them.")); + } + + } + + public override bool AltFunctionUse(Item item, Player player) { + if (item.type == ItemID.Katana) { + return true; + } + + return base.AltFunctionUse(item, player); + } + + public override bool? UseItem(Item item, Player player) { + if (item.type != ItemID.Katana || player.altFunctionUse != 2) return null; + for (int i = 0; i < Main.maxNPCs; i++) { + NPC npc = Main.npc[i]; + if (!npc.CanBeChasedBy()) continue; + + float between = Vector2.Distance(npc.Center, player.Center); + bool inRange = between < 650; + + bool lineOfSight = Collision.CanHitLine(player.position, player.width, player.height, npc.position, + npc.width, npc.height); + + if (inRange && lineOfSight) { + Vector2 tpPos = npc.position; + tpPos.X += -(npc.direction * npc.width + (player.width*2)); + + ChatHelper.DisplayMessage(NetworkText.FromLiteral(npc.TypeName+" "+tpPos), Color.Aqua, 0 ); + if (Collision.TileCollision(tpPos, Vector2.Zero, player.width, player.height) != Vector2.Zero) return true; + + player.Teleport(tpPos, TeleportationStyleID.RodOfDiscord); + player.velocity = Vector2.Zero; + player.NinjaDodge(); + return true; + } + } + + return null; + } +} \ No newline at end of file diff --git a/YHTMod.cs b/YHTMod.cs index de157c4..418186c 100644 --- a/YHTMod.cs +++ b/YHTMod.cs @@ -2,8 +2,13 @@ using Terraria.ModLoader; namespace YHTMod { public class YHTMod : Mod { + private static YHTMod mod; public YHTMod() { - + mod = this; + } + + public static YHTMod GetInstance() { + return mod; } } } \ No newline at end of file