mirror of
https://github.com/YouHaveTrouble/YHTMod.git
synced 2026-05-11 21:56:54 +00:00
update to newest tmodloader version
This commit is contained in:
+30
-31
@@ -6,52 +6,51 @@ using Terraria.ModLoader;
|
||||
|
||||
namespace YHTMod.Items;
|
||||
|
||||
public class KatanaRedo : GlobalItem {
|
||||
|
||||
public class KatanaRedo : GlobalItem
|
||||
{
|
||||
public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
|
||||
{
|
||||
if (item.type != ItemID.Katana) return;
|
||||
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."));
|
||||
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 base.AltFunctionUse(item, player);
|
||||
}
|
||||
return true;
|
||||
public override bool AltFunctionUse(Item item, Player player)
|
||||
{
|
||||
return item.type == ItemID.Katana || base.AltFunctionUse(item, player);
|
||||
}
|
||||
|
||||
public override bool? UseItem(Item item, Player player) {
|
||||
public override bool? UseItem(Item item, Player player)
|
||||
{
|
||||
if (item.type != ItemID.Katana || player.altFunctionUse != 2) return null;
|
||||
YhtPlayer yhtPlayer = player.GetModPlayer<YhtPlayer>();
|
||||
var yhtPlayer = player.GetModPlayer<YhtPlayer>();
|
||||
|
||||
if (yhtPlayer.katanaTeleportCooldown > 0) return null;
|
||||
yhtPlayer.katanaTeleportCooldown = 300;
|
||||
|
||||
for (int i = 0; i < Main.maxNPCs; i++) {
|
||||
NPC npc = Main.npc[i];
|
||||
for (var i = 0; i < Main.maxNPCs; i++)
|
||||
{
|
||||
var 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,
|
||||
var between = Vector2.Distance(npc.Center, player.Center);
|
||||
var inRange = between < 650;
|
||||
|
||||
var 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));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (!inRange || !lineOfSight) continue;
|
||||
var tpPos = npc.position;
|
||||
tpPos.X += -(npc.direction * npc.width + (player.width * 2));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user