Cheat Engine Speed Hack Patches

Posts 1–7 of 7 · Page 1 of 1
Cheat Engine Speed Hack Patches
Credits to Transferred for original tutorial. This tutorial is made for Fabiano Swagger of Doom source and might not work with other sources, I have modified the code a little bit to work with it and gave it some more checks to work that tiny bit better.

First Part Dexterity Hack

Let's start off by navigating to Player.cs, search for "mpRegenCounter" under it or above it, wherever you prefer, add this code;
Code:
        public int checkForDex = 0;
        public int lastShootTime = -1;
        public int shootCounter = 0;
Now, let's go to PlayerShootHandler.cs which is in wServer->networking->handlers in case you cannot find it.
There, replace the whole file with this;
 
Patch
Code:
#region
using System;
using wServer.networking.cliPackets;
using wServer.networking.svrPackets;
using wServer.realm;
using wServer.realm.entities;
using wServer.realm.entities.player;


#endregion

namespace wServer.networking.handlers
{
    internal class PlayerShootPacketHandler : PacketHandlerBase<PlayerShootPacket>
    {
        public override PacketID ID
        {
            get { return PacketID.PLAYERSHOOT; }
        }

        protected override void HandlePacket(Client client, PlayerShootPacket packet)
        {
            client.Manager.Logic.AddPendingAction(t =>
            {
                StatsManager statsMgr = new StatsManager(client.Player, 0);
                if (client.Player.Owner == null) return;
                client.Player.UpdateCount++;
                Random rnd = new Random();
                Item item = client.Player.Manager.GameData.Items[(ushort)packet.ContainerType];
                Player playeEr = client.Player;
                int stype = 0;
                for (int i = 0; i < 4; i++)
                {
                    if (client.Player.Inventory[i]?.ObjectType == packet.ContainerType)
                    {
                        stype = i;
                        break;
                        client.Player.UpdateCount++;
                    }
                }

            
                
              
                if (client.Player.SlotTypes[stype] != item.SlotType && client.Account.Rank< 2)
                {
                    log.FatalFormat("{0} is trying to cheat (Weapon doesnt match the slot type)", client.Player.Name);
                    client.Player.SendError("This cheating attempt has beed logged and a message was send to all online admins.");
                    client.Player.SaveToAccount();
                    client.Player.SaveToCharacter();
                    client.Disconnect();
                    foreach (Player player in client.Player.Owner.Players.Values)
                        if (player.Client.Account.Rank >= 2)
                            player.SendInfo(String.Format("Player {0} is shooting with a weapon that doesnt match the class slot type.", client.Player.Name));
                    return;
                }
    ProjectileDesc prjDesc = item.Projectiles[0]; //Assume only one
    Projectile prj = client.Player.PlayerShootProjectile(
        packet.BulletId, prjDesc, item.ObjectType,
        packet.Time, packet.Position, packet.Angle);
    client.Player.Owner.EnterWorld(prj);
                CheckShootSpeed(playeEr, item);
    client.Player.BroadcastSync(new AllyShootPacket
                {
                    OwnerId = client.Player.Id,
                    Angle = packet.Angle,
                    ContainerType = packet.ContainerType,
                    BulletId = packet.BulletId,
                }, p => p != client.Player && client.Player.Dist(p) < 25);
                client.Player.FameCounter.Shoot(prj);
            }, PendingPriority.Networking);
        }

        public void CheckShootSpeed(Player player, Item item)
{
    StatsManager statsMgr = new StatsManager(player, 0);
    player.shootCounter++;
    if (player.lastShootTime == -1)
    {
        player.lastShootTime = Environment.TickCount;
    }
    int tolerance = 60;
    float diff = (Environment.TickCount - player.lastShootTime) + tolerance;

    float APS = statsMgr.GetDex();

    if (diff < 670f / APS)
    {
        if (player.shootCounter > (item.NumProjectiles * item.RateOfFire))
        {
            player.shootCounter = 0;
            player.checkForDex++;
            player.Owner.Timers.Add(new WorldTimer(23500, (world, t) =>
            {
                player.checkForDex--;
                return;

            }));

        }
        if (player.checkForDex >= 9)
        {
            Client.Player.SaveToCharacter();
            Client.Disconnect();
            Console.WriteLine("{0} seems to be speedhacking, kicking the user. Dexterity Hack", player.Name);
        }

        if (player.checkForDex < 0)
        {
            player.checkForDex = 0;
        }
    }
    else
    {
        player.shootCounter = 0;
        player.lastShootTime = Environment.TickCount;
    }

}
    }
}

Note: Where you see diff < 670f, the 670 is what worked for me, server ticking 9 times a second (9 TPS) you might want to make it lower (lower = lower chance to detect(higher being the opposite)). Test it with cheat engine and see how it works, adjust the number so it doesn't kick the player whilst his not cheating, and it does whilst he is, it might take some time but it is worth it.

Second Part Speed Hack

Navigate to Player.cs again, and search for the same "mpRegenCounter", now add this code above/below it;
Code:
        public int lastMoveTime = -1;
        public int outOfBoundsCount = 0;
        public int goodCount = 0;
Now move onto MoveHandler.cs which is found in the same folder as the previous file and replace the all of it with;
 
Patch
Code:
#region

using System;
using wServer.networking.cliPackets;
using wServer.realm;
using wServer.realm.entities.player;
using wServer.networking.svrPackets;
using wServer.realm.entities;

#endregion

namespace wServer.networking.handlers
{
    internal class MoveHandler : PacketHandlerBase<MovePacket>
    {
        public override PacketID ID
        {
            get { return PacketID.MOVE; }
        }
        protected override void HandlePacket(Client client, MovePacket packet)
        {
            client.Manager.Logic.AddPendingAction(t =>
            {
                StatsManager statsMgr = new StatsManager(client.Player, 0);
                if (client.Player?.Owner == null) return;
                CheckPosition(client.Player, packet.Position.X, packet.Position.Y);
                client.Player.Flush();

                if (client.Player.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
                if (packet.Position.X == -1 || packet.Position.Y == -1) return;

                double newX = client.Player.X;
                double newY = client.Player.Y;
                
                if (newX != packet.Position.X)
                {
                    newX = packet.Position.X;
                    client.Player.UpdateCount++;
                }
                if (newY != packet.Position.Y)
                {
                    newY = packet.Position.Y;
                    client.Player.UpdateCount++;
                }

                CheckLabConditions(client.Player, packet);

                client.Player.Move((float)newX, (float)newY);

                client.Player.ClientTick(t, packet);
            }, PendingPriority.Networking);
        }
        public void CheckPosition(Player player, double newX, double newY)
        {
            StatsManager statsMgr = new StatsManager(player, 0);
            float curDex = statsMgr.GetStats(7); //test
            float TPS = statsMgr.GetSpeed();
            TileDesc tile = player.Owner.getCurrentTile(player);
            float amplifier = tile.Speed;
           
            if (amplifier != 0)
                TPS *= amplifier;

            if (player.lastMoveTime == -1)
            {
                player.lastMoveTime = Environment.TickCount;
            }
            //float tolerance = 0.5f;
            float diff = (Environment.TickCount - player.lastMoveTime);

            float actualTPS = (float)Math.Sqrt(Math.Abs(Math.Pow(newX - player.X, 2) + Math.Pow(newY - player.Y, 2)));

            actualTPS *= 670f / diff;

            float threshold = TPS * 1.35f;
            if (actualTPS > threshold)
            {
                player.Owner.Timers.Add(new WorldTimer(20000, (world, t) =>
                {
                    player.outOfBoundsCount--;
                    return;

                }));
                player.outOfBoundsCount++;
                player.goodCount = 0;
                if (player.outOfBoundsCount >= 9)
                {
                    Client.Player.SaveToCharacter();
                        Client.Disconnect();
                        Console.WriteLine("{0} seems to be speedhacking, kicking user. Speed Hack", player.Name);
                }
            }
            else
            {
                if (player.outOfBoundsCount > 0)
                {
                    player.goodCount++;
                    if (player.goodCount >= 3)
                    {
                        player.outOfBoundsCount = 0;
                        player.goodCount = 0;
                    }
                }
                else
                {
                    player.goodCount = 0;
                }
            }

            player.lastMoveTime = Environment.TickCount;
        }
        private static void CheckLabConditions(Entity player, MovePacket packet)
        {
            var tile = player.Owner.Map[(int) packet.Position.X, (int) packet.Position.Y];
            switch (tile.TileId)
            {
                //Green water
                case 0xa9:
                case 0x82:
                    if(tile.ObjId != 0) return;
                    if (!player.HasConditionEffect(ConditionEffectIndex.Hexed) ||
                        !player.HasConditionEffect(ConditionEffectIndex.Stunned) ||
                        !player.HasConditionEffect(ConditionEffectIndex.Speedy))
                    {
                        player.ApplyConditionEffect(ConditionEffectIndex.Hexed);
                        player.ApplyConditionEffect(ConditionEffectIndex.Stunned);
                        player.ApplyConditionEffect(ConditionEffectIndex.Speedy);
                    }
                    break;
                //Blue water
                case 0xa7:
                case 0x83:
                    if (tile.ObjId != 0) return;
                    if (player.HasConditionEffect(ConditionEffectIndex.Hexed) ||
                        player.HasConditionEffect(ConditionEffectIndex.Stunned) ||
                        player.HasConditionEffect(ConditionEffectIndex.Speedy))
                    {
                        player.ApplyConditionEffect(ConditionEffectIndex.Hexed, 0);
                        player.ApplyConditionEffect(ConditionEffectIndex.Stunned, 0);
                        player.ApplyConditionEffect(ConditionEffectIndex.Speedy, 0);
                    }
                    break;
            }
        }
    }
}

Again, same 670f, adjust it to fit your TPS and server but from what I've tested, if you test one of the patches, the same number should work well with both of them.

Have fun.
Error CS1061 'Player' does not contain a definition for 'SaveToAccount' and no extension method 'SaveToAccount' accepting a first argument of type 'Player' could be found (are you missing a using directive or an assembly reference?) \wServer\networking\handlers\PlayerShootHandler.cs line 49
Quote Originally Posted by Zxoro View Post
Error CS1061 'Player' does not contain a definition for 'SaveToAccount' and no extension method 'SaveToAccount' accepting a first argument of type 'Player' could be found (are you missing a using directive or an assembly reference?) \wServer\networking\handlers\PlayerShootHandler.cs line 49
You should actually need that part so here I took some unnecessary things out
Code:
#region

using System;
using wServer.networking.cliPackets;
using wServer.networking.svrPackets;
using wServer.realm;
using wServer.realm.entities;
using wServer.realm.entities.player;

#endregion

namespace wServer.networking.handlers
{
    internal class PlayerShootPacketHandler : PacketHandlerBase<PlayerShootPacket>
    {
        public override PacketID ID
        {
            get { return PacketID.PLAYERSHOOT; }
        }

        protected override void HandlePacket(Client client, PlayerShootPacket packet)
        {
            client.Manager.Logic.AddPendingAction(t =>
            {
                StatsManager statsMgr = new StatsManager(client.Player, 0);
                if (client.Player.Owner == null) return;
                client.Player.UpdateCount++;
                Random rnd = new Random();
                Player plr = client.Player;
                Item item = client.Player.Manager.GameData.Items[(ushort)packet.ContainerType];
                int stype = 0;

                for (int i = 0; i < 4; i++)
                {
                    if (client.Player.Inventory[i]?.ObjectType == packet.ContainerType)
                    {
                        stype = i;
                        break;
                    }
                }

                if (client.Player.SlotTypes[stype] != item.SlotType && client.Account.Rank < 2)
                {
                    log.FatalFormat("{0} is trying to cheat (Weapon doesnt match the slot type)", client.Player.Name);
                    client.Player.SendError("This cheating attempt has beed logged and a message was send to all online admins.");
                    client.Disconnect();
                    foreach (Player player in client.Player.Owner.Players.Values)
                        if (player.Client.Account.Rank >= 0)
                            player.SendInfo(String.Format("Player {0} is shooting with a weapon that doesnt match the class slot type.", client.Player.Name));
                    return;
                }
                ProjectileDesc prjDesc = item.Projectiles[0]; //Assume only one
                Projectile prj = client.Player.PlayerShootProjectile(
                    packet.BulletId, prjDesc, item.ObjectType,
                    packet.Time, packet.Position, packet.Angle);
                client.Player.Owner.EnterWorld(prj);
                    CheckShootSpeed(plr, item);
                client.Player.BroadcastSync(new AllyShootPacket
                {
                    OwnerId = client.Player.Id,
                    Angle = packet.Angle,
                    ContainerType = packet.ContainerType,
                    BulletId = packet.BulletId,
                }, p => p != client.Player && client.Player.Dist(p) < 25);
                client.Player.FameCounter.Shoot(prj);
            }, PendingPriority.Networking);
        }
        public void CheckShootSpeed(Player player, Item item)
        {
            StatsManager statsMgr = new StatsManager(player, 0);
            player.shootCounter++;
            if (player.lastShootTime == -1)
            {
                player.lastShootTime = Environment.TickCount;
            }
            int tolerance = 60;
            float diff = (Environment.TickCount - player.lastShootTime) + tolerance;

            float APS = statsMgr.GetDex();

            if (diff < 670f / APS)
            {
                if (player.shootCounter > (item.NumProjectiles * item.RateOfFire))
                {
                    player.shootCounter = 0;
                    player.checkForDex++;
                    player.Owner.Timers.Add(new WorldTimer(23500, (world, t) =>
                    {
                        player.checkForDex--;
                        return;

                    }));

                }
                if (player.checkForDex >= 9)
                {
                    Client.Player.SaveToCharacter();
                    Client.Disconnect();
                    Console.WriteLine("{0} seems to be speedhacking, kicking the user. Dexterity Hack", player.Name);
                }

                if (player.checkForDex < 0)
                {
                    player.checkForDex = 0;
                }
            }
            else
            {
                player.shootCounter = 0;
                player.lastShootTime = Environment.TickCount;
            }

        }
    }
}
Does this work on FSOD
Quote Originally Posted by gravityPug View Post
This tutorial is made for Fabiano Swagger of Doom source and might not work with other sources
Quote Originally Posted by Aerostorm View Post
Does this work on FSOD
Read the post before asking stupid questions
Quote Originally Posted by gravityPug View Post
Credits to Transferred for original tutorial. This tutorial is made for Fabiano Swagger of Doom source and might not work with other sources, I have modified the code a little bit to work with it and gave it some more checks to work that tiny bit better.

First Part Dexterity Hack

Let's start off by navigating to Player.cs, search for "mpRegenCounter" under it or above it, wherever you prefer, add this code;
Code:
        public int checkForDex = 0;
        public int lastShootTime = -1;
        public int shootCounter = 0;
Now, let's go to PlayerShootHandler.cs which is in wServer->networking->handlers in case you cannot find it.
There, replace the whole file with this;
 
Patch
Code:
#region
using System;
using wServer.networking.cliPackets;
using wServer.networking.svrPackets;
using wServer.realm;
using wServer.realm.entities;
using wServer.realm.entities.player;


#endregion

namespace wServer.networking.handlers
{
    internal class PlayerShootPacketHandler : PacketHandlerBase<PlayerShootPacket>
    {
        public override PacketID ID
        {
            get { return PacketID.PLAYERSHOOT; }
        }

        protected override void HandlePacket(Client client, PlayerShootPacket packet)
        {
            client.Manager.Logic.AddPendingAction(t =>
            {
                StatsManager statsMgr = new StatsManager(client.Player, 0);
                if (client.Player.Owner == null) return;
                client.Player.UpdateCount++;
                Random rnd = new Random();
                Item item = client.Player.Manager.GameData.Items[(ushort)packet.ContainerType];
                Player playeEr = client.Player;
                int stype = 0;
                for (int i = 0; i < 4; i++)
                {
                    if (client.Player.Inventory[i]?.ObjectType == packet.ContainerType)
                    {
                        stype = i;
                        break;
                        client.Player.UpdateCount++;
                    }
                }

            
                
              
                if (client.Player.SlotTypes[stype] != item.SlotType && client.Account.Rank< 2)
                {
                    log.FatalFormat("{0} is trying to cheat (Weapon doesnt match the slot type)", client.Player.Name);
                    client.Player.SendError("This cheating attempt has beed logged and a message was send to all online admins.");
                    client.Player.SaveToAccount();
                    client.Player.SaveToCharacter();
                    client.Disconnect();
                    foreach (Player player in client.Player.Owner.Players.Values)
                        if (player.Client.Account.Rank >= 2)
                            player.SendInfo(String.Format("Player {0} is shooting with a weapon that doesnt match the class slot type.", client.Player.Name));
                    return;
                }
    ProjectileDesc prjDesc = item.Projectiles[0]; //Assume only one
    Projectile prj = client.Player.PlayerShootProjectile(
        packet.BulletId, prjDesc, item.ObjectType,
        packet.Time, packet.Position, packet.Angle);
    client.Player.Owner.EnterWorld(prj);
                CheckShootSpeed(playeEr, item);
    client.Player.BroadcastSync(new AllyShootPacket
                {
                    OwnerId = client.Player.Id,
                    Angle = packet.Angle,
                    ContainerType = packet.ContainerType,
                    BulletId = packet.BulletId,
                }, p => p != client.Player && client.Player.Dist(p) < 25);
                client.Player.FameCounter.Shoot(prj);
            }, PendingPriority.Networking);
        }

        public void CheckShootSpeed(Player player, Item item)
{
    StatsManager statsMgr = new StatsManager(player, 0);
    player.shootCounter++;
    if (player.lastShootTime == -1)
    {
        player.lastShootTime = Environment.TickCount;
    }
    int tolerance = 60;
    float diff = (Environment.TickCount - player.lastShootTime) + tolerance;

    float APS = statsMgr.GetDex();

    if (diff < 670f / APS)
    {
        if (player.shootCounter > (item.NumProjectiles * item.RateOfFire))
        {
            player.shootCounter = 0;
            player.checkForDex++;
            player.Owner.Timers.Add(new WorldTimer(23500, (world, t) =>
            {
                player.checkForDex--;
                return;

            }));

        }
        if (player.checkForDex >= 9)
        {
            Client.Player.SaveToCharacter();
            Client.Disconnect();
            Console.WriteLine("{0} seems to be speedhacking, kicking the user. Dexterity Hack", player.Name);
        }

        if (player.checkForDex < 0)
        {
            player.checkForDex = 0;
        }
    }
    else
    {
        player.shootCounter = 0;
        player.lastShootTime = Environment.TickCount;
    }

}
    }
}

Note: Where you see diff < 670f, the 670 is what worked for me, server ticking 9 times a second (9 TPS) you might want to make it lower (lower = lower chance to detect(higher being the opposite)). Test it with cheat engine and see how it works, adjust the number so it doesn't kick the player whilst his not cheating, and it does whilst he is, it might take some time but it is worth it.

Second Part Speed Hack

Navigate to Player.cs again, and search for the same "mpRegenCounter", now add this code above/below it;
Code:
        public int lastMoveTime = -1;
        public int outOfBoundsCount = 0;
        public int goodCount = 0;
Now move onto MoveHandler.cs which is found in the same folder as the previous file and replace the all of it with;
 
Patch
Code:
#region

using System;
using wServer.networking.cliPackets;
using wServer.realm;
using wServer.realm.entities.player;
using wServer.networking.svrPackets;
using wServer.realm.entities;

#endregion

namespace wServer.networking.handlers
{
    internal class MoveHandler : PacketHandlerBase<MovePacket>
    {
        public override PacketID ID
        {
            get { return PacketID.MOVE; }
        }
        protected override void HandlePacket(Client client, MovePacket packet)
        {
            client.Manager.Logic.AddPendingAction(t =>
            {
                StatsManager statsMgr = new StatsManager(client.Player, 0);
                if (client.Player?.Owner == null) return;
                CheckPosition(client.Player, packet.Position.X, packet.Position.Y);
                client.Player.Flush();

                if (client.Player.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
                if (packet.Position.X == -1 || packet.Position.Y == -1) return;

                double newX = client.Player.X;
                double newY = client.Player.Y;
                
                if (newX != packet.Position.X)
                {
                    newX = packet.Position.X;
                    client.Player.UpdateCount++;
                }
                if (newY != packet.Position.Y)
                {
                    newY = packet.Position.Y;
                    client.Player.UpdateCount++;
                }

                CheckLabConditions(client.Player, packet);

                client.Player.Move((float)newX, (float)newY);

                client.Player.ClientTick(t, packet);
            }, PendingPriority.Networking);
        }
        public void CheckPosition(Player player, double newX, double newY)
        {
            StatsManager statsMgr = new StatsManager(player, 0);
            float curDex = statsMgr.GetStats(7); //test
            float TPS = statsMgr.GetSpeed();
            TileDesc tile = player.Owner.getCurrentTile(player);
            float amplifier = tile.Speed;
           
            if (amplifier != 0)
                TPS *= amplifier;

            if (player.lastMoveTime == -1)
            {
                player.lastMoveTime = Environment.TickCount;
            }
            //float tolerance = 0.5f;
            float diff = (Environment.TickCount - player.lastMoveTime);

            float actualTPS = (float)Math.Sqrt(Math.Abs(Math.Pow(newX - player.X, 2) + Math.Pow(newY - player.Y, 2)));

            actualTPS *= 670f / diff;

            float threshold = TPS * 1.35f;
            if (actualTPS > threshold)
            {
                player.Owner.Timers.Add(new WorldTimer(20000, (world, t) =>
                {
                    player.outOfBoundsCount--;
                    return;

                }));
                player.outOfBoundsCount++;
                player.goodCount = 0;
                if (player.outOfBoundsCount >= 9)
                {
                    Client.Player.SaveToCharacter();
                        Client.Disconnect();
                        Console.WriteLine("{0} seems to be speedhacking, kicking user. Speed Hack", player.Name);
                }
            }
            else
            {
                if (player.outOfBoundsCount > 0)
                {
                    player.goodCount++;
                    if (player.goodCount >= 3)
                    {
                        player.outOfBoundsCount = 0;
                        player.goodCount = 0;
                    }
                }
                else
                {
                    player.goodCount = 0;
                }
            }

            player.lastMoveTime = Environment.TickCount;
        }
        private static void CheckLabConditions(Entity player, MovePacket packet)
        {
            var tile = player.Owner.Map[(int) packet.Position.X, (int) packet.Position.Y];
            switch (tile.TileId)
            {
                //Green water
                case 0xa9:
                case 0x82:
                    if(tile.ObjId != 0) return;
                    if (!player.HasConditionEffect(ConditionEffectIndex.Hexed) ||
                        !player.HasConditionEffect(ConditionEffectIndex.Stunned) ||
                        !player.HasConditionEffect(ConditionEffectIndex.Speedy))
                    {
                        player.ApplyConditionEffect(ConditionEffectIndex.Hexed);
                        player.ApplyConditionEffect(ConditionEffectIndex.Stunned);
                        player.ApplyConditionEffect(ConditionEffectIndex.Speedy);
                    }
                    break;
                //Blue water
                case 0xa7:
                case 0x83:
                    if (tile.ObjId != 0) return;
                    if (player.HasConditionEffect(ConditionEffectIndex.Hexed) ||
                        player.HasConditionEffect(ConditionEffectIndex.Stunned) ||
                        player.HasConditionEffect(ConditionEffectIndex.Speedy))
                    {
                        player.ApplyConditionEffect(ConditionEffectIndex.Hexed, 0);
                        player.ApplyConditionEffect(ConditionEffectIndex.Stunned, 0);
                        player.ApplyConditionEffect(ConditionEffectIndex.Speedy, 0);
                    }
                    break;
            }
        }
    }
}

Again, same 670f, adjust it to fit your TPS and server but from what I've tested, if you test one of the patches, the same number should work well with both of them.

Have fun.
thats alot of work for one small issue
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?