Results 1 to 10 of 10
  1. #1
    ApparentlySo's Avatar
    Join Date
    Mar 2013
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    34
    My Mood
    Sleepy

    Making a Hacked Client

    Hey guys! Since I won't be doing anything productive with my time, I decided to make a tutorial on how to make your own Terraria hacked client :) So, let's get started.

     

    **HIGHLY RECOMMENDED**: Some basic knowledge of C#. If you end up copy and pasting the code, you won't learn anything new.

    Visual Studio: This is the IDE that I will be using in this tutorial. While others exist, this is what I recommend for .NET code.

    A copy of the decompiled Terraria: You can try to decompile Terraria by yourself using various tools such as ILSpy or dotPeek. But for the sake of simplicity, we will be using a pre-existing source by MPGH user Xenoxiluna found here (Thank you!!!)

     

    1. So after downloading the decompiled source, make a new folder and extract the files from the source into the folder.

    2. Then, open up Visual Studio (or the IDE of your choice) and press File>Open Project/Solution> and select the Terraria.csproj.

    2a. I highly recommend that you poke around the source code and see how things function.

    3. After a while, Visual Studio (refered to as VS from now on) should display a list of folders to the right. Let's create our own "hack" class for better organization. Right click the Terraria project, and press Add>New Class. I'll call our new class Hacks.cs but you can call it whatever you want.

    4. Navigate to Terraria>SocialAPI and comment out everything in the LoadSteam() method. This lets us run our client directly without connecting to steam.

    5. Now try to build and run your project. If you get an error with something along the lines of "cannot locate /.xnb", download the Content folder attached and move it to your "FolderName"/bin/Debug.

    6. And now we can start the fun part of the tutorial, making hacks!

     

    Before we actually begin, we have to have a way for our client to communicate with the hacks. For this, we'll have our client listen to all messages we send, and if it begins with a "~", we'll stop it from going to the server and interpret it. To do this, we'll add a "hook" to our chat.
     

    Using the solution explorer to the right, find the "main" class of Terraria. It should be in Terraria>Main.cs. Now that we have the main class open, let's find out how the client handles chat messages. I encourage you to find it for yourself, but if you're lazy, the line number is about 11844 in the main class. It should look something like this:
    Code:
    if (Main.inputTextEnter && Main.chatRelease)
    {
    	if (Main.chatText != "")
    	{
    		NetMessage.SendData(25, -1, -1, Main.chatText, Main.myPlayer, 0f, 0f, 0f, 0, 0, 0);
    	}
    ...
    The "NetMessage.SendData" sends our message to the server, so we want to make sure to not do that when our client detects that it is a hack message. To actually hook our class into the chat, let's go back to our chat class and make a new method called onChat. The signature should be "public static bool onChat(string message)", returning true if we should send the message to our server, and false if we shouldn't. Now, we edit the code in the main class to make it:
    Code:
    if (Main.inputTextEnter && Main.chatRelease)
    {
    	if (Main.chatText != "" && Hacks.onChat(Main.chatText))
    	{
    		NetMessage.SendData(25, -1, -1, Main.chatText, Main.myPlayer, 0f, 0f, 0f, 0, 0, 0);
    	}
    ...
    Back in our hack class, our onChat method should look something like this:
    Code:
    public static bool onChat(string message)
    {
        if (message.StartsWith("~"))
    	{
            if (message.StartsWith("~god"))
            {
                //In the next section!
            }
            else if (message.StartsWith("~infmana"))
            {
                //Are you excited?
            }
            //You can keep chaining these else if's for future code
    
            return false; //Message should NOT go to the server, so we return false.
        }
    
        return true; //Message does NOT start with ~, so it is okay to send it to the server.
    }
    Now we have a method with communicating with our hacks, let's get started with the fun.


     

    Let's make a dictionary for our hacks that stores the state of the hack. Add this to the top of your Hacks class.
    Code:
    public static Dictionary<String, bool> HackStates = new Dictionary<String, bool>()
    {
        {"Godmode", false},
        {"InfiniteMana", false }
    };
    To handle the toggling of these hacks, let's make another method within our Hacks class called "Toggle" that recieves a string of the Hack name, toggles it to the other state, and echos a message to our client.
    Code:
    public static void Toggle(String hack)
    {
        //Toggles the hack
        HackStates[hack] = !HackStates[hack];
        //Writes a new message to the text box of our client, string represents the message, and the number represents the RGB value of the color. Only you can see this message.
        Main.NewText("[MPGH Tutorial Client] Set the hack state of " + hack + " to "HackStates[hack], 255, 0, 0);
    }
    Now that we have that, we can go back to our onChat method and implement the toggle method like so:
    Code:
    if (message.StartsWith("~"))
    {
        if (message.StartsWith("~god"))
        {
            Toggle("Godmode");
        }
        else if (message.StartsWith("~infmana"))
        {
            Toggle("InfiniteMana");
        }
    ...
    }
    Now that we can control the state of our hacks, let's have them impact our game.


     

    So again, I highly recommend that you look through the code and try to find these methods by yourself, but if you're lazy, read on! Let's first implement our godmode hack.
     

    Find the method that controls when your player takes damage. In Terraria>Player, you should find a method that looks like this:
    Code:
    public double Hurt(int Damage, int hitDirection, bool pvp = false, bool quiet = false, string deathText = " was slain...", bool Crit = false, int cooldownCounter = -1)
    {
        bool flag = !this.immune;
        if (cooldownCounter == 0)
        {
    	flag = (this.hurtCooldowns[cooldownCounter] <= 0);
        }
    ...
    }
    Bingo! This controls how much damage our player takes. To not take any damage, we can just make it return 0.0. Modify the code a little, and we have ourselves a working godmode hack! Final code:
    Code:
    public double Hurt(int Damage, int hitDirection, bool pvp = false, bool quiet = false, string deathText = " was slain...", bool Crit = false, int cooldownCounter = -1)
    {
        //HACK: Godmode hack
        if (Hacks.HackStates["Godmode"]) //If our godmode is on, return 0 damage
        {
            return 0.0;
        }
        bool flag = !this.immune;
        if (cooldownCounter == 0)
        {
    	flag = (this.hurtCooldowns[cooldownCounter] <= 0);
        }
    ...
    }


     

    Okay, I am going to complicate things a bit in order to make it easier to add more hacks in the future. Let's find our player's Update() method, which is frequently called and add our own hook onto it. At around lines 15652 in the Terraria>Player.cs class, you should find something that looks like this:
    Code:
    public void Update(int i)
    {
    	if (this.launcherWait > 0)
    	{
    		this.launcherWait--;
    	}
    ...
    Let's create a method in our Hacks class called onUpdate() and call it whenever the player Update() is called.
    Code:
    //In player.cs
    public void Update(int i)
    {
    	Hacks.onUpdate()
    	if (this.launcherWait > 0)
    	{
    		this.launcherWait--;
    	}
    ...
    }
    //In Hacks.cs
    public static void onUpdate()
    {
        if (HackStates["InfiniteMana"])
        {
            Main.player[Main.myPlayer].statMana = Main.player[Main.myPlayer].statManaMax; //Set our current mana to our max mana
        }
    }







    This will be a bit short in order to guage interest in these tutorials. If you want to see more, leave a comment with suggestions or feedback, thanks!

  2. The Following 7 Users Say Thank You to ApparentlySo For This Useful Post:

    David2002V (03-27-2017),GamecrackingDE (04-12-2017),GameGuyTR (12-19-2017),lukkyz (05-16-2016),Moull (05-07-2017),Qiu233 (12-16-2017),Zeromaru9 (03-28-2017)

  3. #2
    asdasddsa213's Avatar
    Join Date
    Jun 2015
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Amazed
    nice waiting

  4. #3
    NOP3's Avatar
    Join Date
    Feb 2015
    Gender
    male
    Posts
    39
    Reputation
    10
    Thanks
    0
    My Mood
    Amused
    nice tutorial!

  5. #4
    SmellyMelly's Avatar
    Join Date
    Jun 2016
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    someone got 1.3.5.3 source code for terraria without the errors?
    im only getting errors.
    someone can help me?
    i'm pretty new wth C#
    Last edited by SmellyMelly; 12-15-2017 at 10:36 AM.

  6. #5
    Qiu233's Avatar
    Join Date
    Oct 2017
    Gender
    male
    Location
    china
    Posts
    27
    Reputation
    10
    Thanks
    617
    emmm....
    But now there's no perfect 1.3.5.3 source code we can find.
    Decompiling is unrealistic for common players.
    Especially on 1.3.5.3 the decompiled source code(by ilspy or dnspy) is in many complex error.
    The only one which was compilable I found on ****** can only be compiled but run.
    In fact,I once tried to decompile and made it runnable,but I failed.An exception about initialization occured when I start running the code.
    I debugged it for a long time then found that the exception may be due to the ItemID.cs.
    There is all the infomation I can provide with.Hope you can solve this problem,thanks.

  7. #6
    HiImKyle's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Location
    England
    Posts
    233
    Reputation
    10
    Thanks
    206
    I advise against wasting your time with making a "perfect 1.3.5.3 source code" as Qiu mentions.
    Avoid decompiling the entire game, and you will find yourself if a good place for making a client.

  8. #7
    Qiu233's Avatar
    Join Date
    Oct 2017
    Gender
    male
    Location
    china
    Posts
    27
    Reputation
    10
    Thanks
    617
    Perhaps you're right.But recompiling code in dnspy or other decompilers always bothers me.What's worse,sometimes even it doesn't work,only can I do is to change my idea.If source code was obtained,problems can be solved once and for all.

    Sorry that it was until just now that I found this is such an old thread...
    Last edited by Qiu233; 12-16-2017 at 07:51 AM.

  9. #8
    SmellyMelly's Avatar
    Join Date
    Jun 2016
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    ah thank you guys.
    i got a question,
    how people make those 1.3.5.3 hacked clients without source code?
    i heard about putting your own codes in terraria patcher and patch it,
    is there any other way?
    sorry for my amateuristic questions :P

  10. #9
    HiImKyle's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Location
    England
    Posts
    233
    Reputation
    10
    Thanks
    206
    Quote Originally Posted by Qiu233 View Post
    Perhaps you're right.But recompiling code in dnspy or other decompilers always bothers me.What's worse,sometimes even it doesn't work,only can I do is to change my idea.If source code was obtained,problems can be solved once and for all.

    Sorry that it was until just now that I found this is such an old thread...
    Old but still informational, helpful for those who are new.

    Quote Originally Posted by SmellyMelly View Post
    ah thank you guys.
    i got a question,
    how people make those 1.3.5.3 hacked clients without source code?
    i heard about putting your own codes in terraria patcher and patch it,
    is there any other way?
    sorry for my amateuristic questions :P
    I made the Crimson Client with dnSpy.
    I'm not 100% open to helping randoms out in creating a client but I can offer some help if needed. Just pick your choice of communication other than here.

  11. #10
    Huntermuir1213's Avatar
    Join Date
    Jul 2017
    Gender
    male
    Posts
    16
    Reputation
    10
    Thanks
    13
    My Mood
    Tired
    Hi, if anybody is looking for an updated tutorial (1.3.5.3), follow this link. https://www.mpgh.net/forum/showthread.php?t=1383814

Similar Threads

  1. [Help Request] Could anyone make a hacked client that without interface
    By mrxer in forum Minecraft Help
    Replies: 2
    Last Post: 12-24-2013, 01:11 PM
  2. how to make a hacked client
    By bring me 115 in forum Realm of the Mad God Help & Requests
    Replies: 1
    Last Post: 11-07-2013, 06:53 AM
  3. [Tutorial] How to make a Hacked client simple **With Pictures**
    By tsj9834 in forum Minecraft Tutorials
    Replies: 7
    Last Post: 09-28-2013, 11:34 AM
  4. Replies: 2
    Last Post: 05-05-2013, 11:41 AM
  5. [Help Request] can somebody make a hacked client?
    By domgor in forum Realm of the Mad God Help & Requests
    Replies: 5
    Last Post: 10-29-2012, 08:02 PM