Thanks for using Frenzy's Coding Tutorial online book, which was created for everyone to truley understand how things work with Toontown 'under the hood' you could say. The entire tutorial was created by Frenzy, so he'd like a little credit for this! All I say now, is enjoy the book, and I hope you understand everything I'm talking about. I'm trying to be as fluent with you, and explain things as well as I can. This is the first dedicated tutorial, by a real, good, coder for Toontown. This is not registered, and you can distribute this if you'd like. All I want is credit for what I do.
Hello, there. If you don't know me, my name is Frenzy. I am apart of Team FD, which as of the moment, is the best team out there in the Toontown land; My YouTube channel is http://youtube.com/user/frenzythehorse2011/ , check some of my videos out if you'd like. Anyway, now its time to get down to business. Toontown. Toontown was made in a language known as Panda3D, which was created in C++ (another programming language, created by the Microsoft Company); Panda3D is basically a 3D gaming engine that executes its scripts through another language known as Python. For now, think of Python as a more advanced Command Prompt system. Python was also created in C++; Panda3D injects scripts into the game process through Python classes, functions, and other modules. There isn't much to say about it, that's all there is to know about it. The main reason that Disney created the language was to create Toontown Online, which came out to be one of the most successful games in America (and other countries around the world as well), so, if it wasn't for Panda3D, or Python, Toontown might not be here today. Imagine that.
It's time for a little history lesson, Toons. Have you learned your hacking history? Just in case, this is to let you get alot of those questions out of your minds. First, I will say, all of the Toontown Injectors and exploits for Toontown and whatnot, are all basically just Python Clients; Meaning, they're in-game Python extensions, which hook to the Toontown process (or any other game that is Python-based), and allows us to tamper with the Toontown code. Lucky for us, we wouldn't have even thought that this would be possible until someone known as Maverick came up with the idea. Maverick (also known as mmavipc, which is his YouTube channel) created the first ever Python exploit for Toontown. The Toontown Injector. The exploit was created on February 13th, 2010; However, I am not sure when it got leaked to everyone, but I do know that it was leaked on to a Toontown forum known as the Toontown News forum, but was taken down shortley afterwards by the owner of the website. All you need to know is, basically, all of these Python exploits for games such as Toontown that use Python to execute scripts are just custom 'Python extensions' you could say. Not really a hack, but more of just an extension, but I suppose you could see it both ways, since the application's weren't produced by the publisher of the game(s).
Now, we're going to discuss how using Python functions will benefit you in finding codes. In this article, we'll discuss 'print dir', a function used by the common people, but do people really know how to use it? No. Most people just say they do, but they don't know why to use it. Basically, Toontown has a bunch of folders for each task they need to preform during the game to keep it working. These tasks are stored in folders, basically like 'toontown\toon\DistributedToon.py', etc., but they are frozen for only modules that are hooked to the main application can access them. That's where the exploits come in, and help us with tampering. Anyhow, to view the directories you use this like so: 'print dir(toontown)', and you also need to remember to use 'import toontown' before printing it, otherwise you'll get an error. Then, to view the folders inside of 'toontown\', you open your current *.log file, and scroll all the way to the bottom. Eventually, you'll see a list that looks somewhat like this: ['toon', 'distributed', 'char'], and other words such as that. That's where you put the next part of the directory on to the previous function, which should still be 'print dir(toontown)', now, you use a '.' as a split, like how '/' is a split normally for folders; '.' is a split, but for Python only. Now, what you do is add a '.' to the function I previously said, and then one of the words in the directory that you had just printed. Here's an example: 'print dir(toontown.toon)', which would print all the files in that directory, 'toontown\toon'. Then, a list will appear similar to the last one, with more words. Here's an example: 'print dir(toontown.toon.DistributedToon)', once you get to an object that has 'Distributed', or is in all capital letters, it is a *.py object, and is readable (meaning you can use the function 'print help' on it now); That's all for 'print dir', though.
Now that you understand the 'print dir' function, and how it helps you... lets get on to 'print help'. What happens when you hit a certain object, and all you get when printing it is a bunch of objects that have things such as '__init__' inside of them? Is there nothing left to print? What are the arguments to the code? That's where print help comes in. If you get something like that where there are functions such as '__init__' inside of it, change 'dir' to 'help'. This will then show it's argument names, which are easy to guess; but there are no ways on how to get them, you have to guess, or use 'base.cr.wantUpdateCalls = True' and see if you can get the arguments through every-day Toontown life, using that. The first argument in all objects is 'self', which is something known as a 'NoneType', or null, meaning zero. It's not needed. Meaning, you leave it as nothing, don't even add it into your code. It's just a default class argument, used inside that class. Other arguments, such as 'avId', 'toonId', or 'doId' would be your localAvatar's ID, which is 'localAvatar.doId'; 'doId' stands for 'Distributed Object ID', which is what your Toon is; A distributed object. Other arguments such as 'zoneId', 'shardId', and anything in between are easy to fill in. However, some arguments, such as 'ts', you might not understand. These arguments are abbrieviations; 'ts' stands for 'time stamp', which could be a random number. More advanced arguments are things such as 'di', which stands for 'datagram iterator', which is something that iterates, or times, a Python Datagram. These are more advanced, so if you'd like to know how to use them, I'd suggest contacting me on my AIM account, if you know it.
This is just a brief passage on a little secret on how to find server codes alot quicker than most people would think. Most people spend hours wasting time looking through directories that turn out to have client functions inside them. How do you tell that they're's any server functions inside of them? Look for any Python Object that has 'Distributed' inside of it's title. This means, as I said before, it is broadcasted to the entire server (meaning that every single Toon can see this object.); so, next time you start looking for something to do, don't waste time looking through shitloads of modules when you can search for ones that only have 'Distributed' located in its title. :-)
There are many ways you can tell Client modules (which are things that only appear to the client, you, and aren't broadcasted to the server, other Toons.). The easiest ways are to see if they have 'send' in their name, which means that the client sends something to the server; This is where datagrams get in here, but we'll wait a while to talk about them. For now, all you need to know is that datagram's are sent from the client, and recieved by the server. No questions about it. Otherwise, they'd have 'd_' in the function's name, which stands for D.C., or Distributed Classes. Distributed Classes are modules that are 'distributed' to the entire server, or given out and broadcasted to every single Toon in a district; Other ways you can tell, if you want to make sure, you can use the function 'print dis', which we'll talk about later, to disassemble the object's modules. If there is a 'sendUpdate' function inside of its modules, then it will be broadcasted to everyone in the local area (your zone, in your district.). Basically, the way things go with Toontown are there is a server. Then, it breaks down in sections, known as Districts (Toon Valley, Nutty River, etc.), then it breaks down to default Playground areas (Toontown Central, Sellbot HQ, etc.), and then it goes down to your custom, generated zone for special events, such as going into a Factory, or fighting the V.P., which is how they break down the game into sections. Think of each place as a seprate server, inside of the game. Anyways, I went a little off subject there, but you get my point. If the function doesn't have any of those qualities, then it isn't sent to the server; only to the client.
Hooking is a wonderful method to making Toontown automatically execute scripts that us Hacker's would use, but would seem like it's normal. Basically, what hooking does is takes our own, custom module and replaces the old module with our custom one. Things such as maybe 'localAvatar.setName = localAvatar.setScale', which we could then do something such as 'localAvatar.setName(2)', and that would change our Toon's scale. Pretty interesting, right? If you'd like automatic ones, then use the skills that I taught you in the 'print dir' section of this book. See if theres anything you'd see that'd be valuable to hook, if you want. Here is my example of an automatic hook: 'base.cr.doFindAll('HQ Officer').handleCollisionSphereEnter = localAvatar.setX', which would set your Toon's X axis to '0', because the collision entry, the argument used with 'handleCollisionSphereEnter' is 'collEntry', which would be an integer. This would be automatic as soon as you'd enter the selected HQ Officer's collision sphere.
This function I am about to teach you, most people don't know what it does or how to use it. But, it is very benefitial when it comes to coding. This function, which is 'lambda *x:None', basically kills any function that you 'hook' it to, which was discussed with you earlier. Basically, if the server ever triggers the event that you hooked it to... it won't do anything. So lets say, you killed the task that is supposed to ban you when you do something like say 'shit' or something like that. You could just do 'localAvatar.sendLogSuspiciousEvent = lambda *x:None', and that would kill the function for getting banned in-game. That would be a small ban blocker, but it would only work with certain things. If you would want to make a more advanced one, you'd better look through some Client Repository modules, (base.cr). Anyhow, if you we're to use an invalid animation with that function killed... you wouldn't get banned. Although, nothing would happen when on that animation; you'd be standing there normally, so sorry if you believed that we had found a new disconnection code, but things don't work out always as planned.
The first thing I'll need to tell you is how to extract the Toontown phase files. First, you must have the 'Panda3D SDK 1.7.1' version of it installed on to your computer. Then, open up Command Prompt and go to your Toontown directory using the 'CD' function. Here is an example: 'CD C:\Program Files (x86)\Disney\Disney Online\ToontownOnline\', then, with Panda3D SDK 1.7.1 installed, type in 'multify -x -f phase_' and the phase file number, plus the extension type. Here is an example of this, as well: 'multify -x -f phase_3.5.mf', and then, to view the *.bam files, or the 3D models that are used in the game, you right click them and open up 'C:\Panda3D-1.7.1\Bin\PView.exe', as the default application to open this file extension, *.bam. Then, you can just pick and choose what modules you want from the phase files that you've extracted. To view the *.bam files now, just double click them and Panda3D will load the model. If they have a texture, it worked well, otherwise, if it's completely white, then you're out of luck. Make sure you use things correctly as well. The non-loadable *.bam files that show nothing but a plain, gray screen are animations for the object that it is parented to. Use the 'Actor' module, which I will not explain, because it has nothing to deal with regular Toontown hacking, and more with learning about Panda3D.
By now, you should have a basic understanding on how Toontown, and all other Python-based games work. I hope you enjoyed this tutorial, and I hope you understood everything. As I said before, I tried explaining this as thoroughly as I could. I hope this creates a few new coders out there in the Toontown world. :-)