Tutorial Unity Hacks - How to make a Unity Bot Tutorial

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

timb3r

Semi-Retired
Dank Tier VIP
Jul 15, 2018
768
22,668
47


Game: Timberman
Engine: Unity Engine
Studio: Digital Melody
Version: Steam
Buy: Steam (51% off)

Introduction:

I think you can see where this is going, there I was minding my own business when suddenly I see this monstrosity appear in my recommended games list on steam. Using my name on such an inferior product that's nothing more than a party game designed to induce rage quitting and then having the audacity to charge money for it! This shall not stand time to rip and tear.

The Basics:

The game is unity obviously like most indie titles are nowadays you can immediately tell by browsing the game's directory:


unity-directory.PNG

Yep that's unity alright.

Our next step is to use a tool like Dnspy to check out the guts of the game and get all up in there.

Here's the basic game structure:

Class GameEngine -> Class Environment -> Class TreeManager[]

In single player TreeManager is an array but in multiplayer only the first element is used. I decided to use Harmony to hook the input handling function and overwrite it. So lets look at that function:
handleinput.PNG

Pretty simple CheckSticks just queries for input (Environment class).

What IS interesting though is if we look at the next HandleInput function:

botinput.PNG


Yes, you read that correctly the devs wrote a bot for their own game and actually left the code in for us to reuse.

botmeme.jpg


Who am I to judge? They probably spent months tweaking this code and getting it juuuuust right it'd be a shame to let it sit there doing nothing.

Here's our new HandleInput code:

C#:
        [HarmonyPatch(typeof(TreeManager), "HandleInput")]
        class TreeMgrPatch
        {
            static public float _lastBotColliderCheck = 0.0f;
            static public float _botSpeed = 0.1f;

            static bool Prefix(TreeManager __instance)
            {
                if (Input.GetKeyDown(KeyCode.Delete))
                {
                    // Since input is blocked during gameplay we need a way to kill our bot
                    __instance.lumberJack.handleDie(TimbermanDeadType.ByBranch);
                    return false;
                }

                if (Time.time > _lastBotColliderCheck + _botSpeed && !__instance.tree.CurrentPart.isAligning())
                {
                    GameEngine.Instance.HideTapsIfNecessary();
                    // Get current time
                    _lastBotColliderCheck = Time.time;

                    // We're using a raycast to detect a collision
                    RaycastHit raycastHit;
                    // Cast our ray upwards looking for a sprite on the layer branch
                    // If we hit something switch sides so we dont die
                    if (Physics.Raycast(__instance.lumberJack.transform.position + new Vector3(0f, 0f, 0.5f), Vector3.up, out raycastHit, 3f, 1 << LayerMask.NameToLayer("branch")))
                    {
                        __instance.handleTreeHited(!__instance.lumberJack.IsOnLeft, 1);
                    }
                    else
                    {
                        __instance.handleTreeHited(__instance.lumberJack.IsOnLeft, 1);
                    }
                }
                return false;
            }
        }
That is pretty much it bot wise this game is not very complex. However there is one other patch we need to apply so we can let our bot run for hours uninterrupted:

C#:
        [HarmonyPatch(typeof(Environment), "killLumberjackByPoints")]
        class EnvPatch
        {
            static bool Prefix()
            {
                return false;
            }
        }
The stamina bar at the top of the screen will scale according to the current level and points accrued. So eventually no matter how fast our bot chops it will die because the game says so. During testing I noted this value to be around 3400 points or so however I wanted to get on the leaderboards but unfortunately filthy cheaters had beaten me to it:

max-signed-int.PNG

Max signed int......fuck.

I won't bother uploading the entire project because it's only like 64 lines of code big here's the source:

C#:
using System;
using System.Reflection;
using HarmonyLib;
using UnityEngine;

namespace Timberman_BOT
{
    public class Main : MonoBehaviour
    {
        public static void Entry()
        {
            var harmony = new Harmony("com.timb3r.patch");
            var assembly = Assembly.GetExecutingAssembly();
            harmony.PatchAll(assembly);
        }

        [HarmonyPatch(typeof(TreeManager), "HandleInput")]
        class TreeMgrPatch
        {
            static public float _lastBotColliderCheck = 0.0f;
            static public float _botSpeed = 0.1f;

            static bool Prefix(TreeManager __instance)
            {
                if (Input.GetKeyDown(KeyCode.Delete))
                {
                    // Since input is blocked during gameplay we need a way to kill our bot
                    __instance.lumberJack.handleDie(TimbermanDeadType.ByBranch);
                    return false;
                }

                if (Time.time > _lastBotColliderCheck + _botSpeed && !__instance.tree.CurrentPart.isAligning())
                {
                    GameEngine.Instance.HideTapsIfNecessary();
                    // Get current time
                    _lastBotColliderCheck = Time.time;

                    // We're using a raycast to detect a collision
                    RaycastHit raycastHit;
                    // Cast our ray upwards looking for a sprite on the layer branch
                    // If we hit something switch sides so we dont die
                    if (Physics.Raycast(__instance.lumberJack.transform.position + new Vector3(0f, 0f, 0.5f), Vector3.up, out raycastHit, 3f, 1 << LayerMask.NameToLayer("branch")))
                    {
                        __instance.handleTreeHited(!__instance.lumberJack.IsOnLeft, 1);
                    }
                    else
                    {
                        __instance.handleTreeHited(__instance.lumberJack.IsOnLeft, 1);
                    }
                }
                return false;
            }
        }

        [HarmonyPatch(typeof(Environment), "killLumberjackByPoints")]
        class EnvPatch
        {
            static bool Prefix()
            {
                return false;
            }
        }
    }
}
And some teaser vids:

Now the only people rage quitting are the weirdos playing this game legitimately.

Almost forgot you need to do two things to get this to work:
  1. Make sure you have a copy of 0Harmony.dll in the managed folder in the game's directory.
  2. Use a mono injector like MInject to inject the DLL.
 
Last edited:

Petko123

Biggest paster
Dank Tier VIP
Trump Tier Donator
Feb 19, 2018
80
6,593
3
You are on fire with these guides. I need to start pumping out tutorials as well now. Good job once again. :)👏
 

timb3r

Semi-Retired
Dank Tier VIP
Jul 15, 2018
768
22,668
47
You are on fire with these guides. I need to start pumping out tutorials as well now. Good job once again. :)👏
Not so much a tutorial but more so a walkthrough of how I reversed the game and got it working. There's a bunch of stuff I've been meaning to cover like hooking unity with harmony but due to il2cpp seems kinda redundant now.
 
  • Like
Reactions: Petko123

XdarionX

Dying Light Hacker
Dank Tier VIP
Dank Tier Donator
Mar 30, 2018
813
21,408
111
really damn good and clear tut! thanks

Using my name on such an inferior product that's nothing more than a party game designed to induce rage quitting
such a rude people developed this game! this should @Rake pin to the wall of shame ! :ROFLMAO:

max-signed-int.PNG

Max signed int......fuck.
they didnt got banned ? i have a friend who is dev a game on android and before he got ac he was manually banning cheaters - but at least was doing something.... this looks dead
 
Last edited:

Rake

Cesspool Admin
Administrator
Jan 21, 2014
11,537
78,998
2,310
really damn good and clear tut! thanks


such a rude people developed this game! this should @Rake pin to the wall of shame ! :ROFLMAO:


they didnt got banned ? i have a friend who is dev a game on android and before he got ac he was manually banning cheaters - but at least was doing something.... this looks dead
we need to start hacking all these free games with leaderboards and put our name as guidedhacking.com!
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
11,537
78,998
2,310
just released this from the premium section, donate to get early access
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods League of Legends Accounts