From 91e3ebf4f07008929dacfadd25fd49494eb4cbe5 Mon Sep 17 00:00:00 2001 From: Patrikkk Date: Mon, 18 May 2020 02:37:39 +0200 Subject: [PATCH] Fix false cheat catch on stab items. Stab items (swords) now send projectiles to imitate directional stabbing. Bouncer catched since there was no handling of these new projectiles. --- TShockAPI/Bouncer.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 17c1a92e..18b0cbd3 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -796,6 +796,17 @@ namespace TShockAPI return; } + + if (stabProjectile.ContainsKey(type)) + { + if (stabProjectile.Values.Any(t => t == args.Player.TPlayer.HeldItem.type)) + { + args.Handled = false; + return; + } + } + + // Main.projHostile contains projectiles that can harm players // without PvP enabled and belong to enemy mobs, so they shouldn't be // possible for players to create. (Source: Ijwu, QuiCM) @@ -1922,5 +1933,18 @@ namespace TShockAPI TileID.Campfire }; + private static Dictionary stabProjectile = new Dictionary() + { + { ProjectileID.GladiusStab, ItemID.Gladius }, + { ProjectileID.RulerStab, ItemID.Ruler }, + { ProjectileID.CopperShortswordStab, ItemID.CopperShortsword }, + { ProjectileID.TinShortswordStab, ItemID.TinShortsword }, + { ProjectileID.IronShortswordStab, ItemID.IronShortsword }, + { ProjectileID.LeadShortswordStab, ItemID.LeadShortsword }, + { ProjectileID.SilverShortswordStab, ItemID.SilverShortsword }, + { ProjectileID.TungstenShortswordStab, ItemID.TungstenShortsword }, + { ProjectileID.GoldShortswordStab, ItemID.GoldShortsword }, + { ProjectileID.PlatinumShortswordStab, ItemID.PlatinumShortsword } + }; } }