Learn to Hack Games - Warcraft III - Custom Map Deprotection - Part 3


 Description

This is part 3 of my series on game modding. In this video I mod a protected custom map for Warcraft III. Topics covered: JASS, LUA, Debugging, Deprotection, Map Editor, Modding, Hacking, Reverse Engineering

Transcript

hey guys today we're going to be doing a game hacking tutorial on the Warcraft 3 reforged game so you might be wondering why are we messing with Warcraft 3 originally this game was super popular back about 15 years ago and it kind of died down because I stopped getting updates from blizzard and now that they've done reforged um I'm excited about playing it again but there has been some negative publicity about it so I don't know that it's really gonna pick up popularity so the main thing that made Warcraft popular is this custom games section if you look on here you'll see a whole bunch of different maps and these are created by random programmers using the map editor for the Warcraft 3 game and that map editor allows you to make any kind of game you want that's really different than the original base game so from Warcraft 3 a whole bunch of different game genres were created things like tower defenses mobas and this is what kept the game alive for so long the base game is kind of a mix between city building and fighting and Warcraft 3 also spawned into Starcraft which is the same game only with space units instead of fantasy units but the most popular games in the world right now for example League of Legends which is a MOBA spawned out of Warcraft 3 and there's also DOTA which spawned out of Warcraft 3. and the reason that blizzard got bad publicity when they did the reforged version of Warcraft is they broke a few features of the original game that made the hardcore Gamers that were still playing it 20 years after it launched made them upset but also they announced that the custom maps would now be owned by blizzard instead of by the original programmer that made the map and so that made all the map creators upset and then also they promised a bunch of new features like new cut scenes in the campaign mode and they under delivered from what they promised so they kind of upset people in multiple Realms but for me uh I actually like it is because the thing that they did do was upgrade the graphics and I wanted to be able to play the game still but I didn't want to look at Graphics from 20 years ago and they did make a few improvements um to the map editor which could allow better custom maps to get created in the future so if you wanted to just play a random type of game you could click on any of these random maps and hit join and on the right side it says preview unavailable as soon as I hit join it will download the map and then I can play with somebody online but the games since it's not that popular you're going to be waiting 15-20 minutes for other people to join this particular game so instead I can back out and I should either pick a game that's really popular or I could filter based on the number of players and start with games that are almost full and start with those um but the problem is so say like I picked this DOTA this is not the Dota 2 that valve released this is the original DOTA that a programmer made inside the custom map of Warcraft 3 before Dota 2 got created but uh anyone I play with online here they're going to really understand this game of Dota or aspect of Doom or leech and TD and so if you're a new player they're going to get upset at you for not playing very well so what I would suggest download a map and then going to hit back and go into single player mode custom games and here it'll show everything that you've downloaded so if I scroll down I could find whatever game I just barely downloaded and I could try it out in single player mode and decide if I really like it enough to play it online with other people and practice a little bit so that I don't get yelled at for playing poorly but that that's a custom games but there's two other features of Warcraft that are really good so first of all the campaign so um there's multiple races in Warcraft so this first one is Orcs And the second one is humans and I have to unlock the other ones but if I were to play as Orcs And I guess I'll go in story mode which is kind of like easy mode it'll probably give me a cut scene and I'll quit out of this the graphics are pretty good and then updated cutscenes but so it'll kind of give me a story of what the characters are doing and I'll skip out of those and then I can kind of control my units and and follow the quests that it gives me so I've got this hero and it wants me to navigate around the map you know find a certain waypoints which maybe I'll encounter enemies or Allies and maybe build a base and Etc but this is kind of like tutorial mode right now so it'll get more complicated uh in future levels of the campaign so let me put out of the campaign mode and show you just regular mode and then I'll show you a custom game that we're going to hack so if I went into custom games and instead of going into the download folder I just pick one of these existing ones these are maps created by blizzard and they don't have any modifications to the base game they they're just different Maps whereas the downloaded maps they're like mods that are completely different from the base game so I'm going to go into advanced options and just change a few settings I want visibility to be always visible so that way we can see the map and then go back to map inter information I can create so looking at the minimap you can see the the yellow circles are gold mines the little houses are like neutral shops and then the Red X and the blue X are me or the computer so I'm going to play against the computer I'll put them on easy mode and I'll just so I can kind of explain the game without him killing me quick I'll just put it on 50 and and then I can choose which race I want to be so I'll be human I guess and I don't really care who he is so I'll hit start and I think this game is really fun and if you look at the updated Graphics they're really not too bad so I've got a town hall here in the center and that's where I do all my upgrades from and then these are my peasants and I'll first send them to the gold mine so that they can start Gathering gold at the top you can see my resources I have 500 gold and 150 wood and 5 out of 12 food so the gold you can see it's increasing because the peasants are gathering gold and the food is five because I have five peasants on the screen but it's slash 12 because I can have a maximum of 12. so if I want to train another peasant I go to the town hall train a peasant and then I can right click for example on the trees and that'll make a waypoint so my town hall anytime it creates a peasant it'll automatically send him to the trees to start chopping wood and at the bottom you can see when I start so now I'm at six out of 12 because of food but when I get a whole bunch of peasants then you can see they get queued up so after each one is trained it'll just start the next one in queue and they cost if you Mouse over the peasant it says it costs 75 gold and one food so because I'm at seven now eight I can really only do four so once it gets to this further cue Point it'll stop building because I won't be able to so I'll cancel those and then also gold wise since there's 75 each I technically have enough and actually I think you prepay so like right here it says 870 if I click it drops down to 800. so if I unqueue it it gives me it jumps that go back up so anyways if I click on a peasant on the bottom left corner I can click build and then there are shortcut keys as well so I can also hit the letter b and then I could build some kind of building um so like maybe a tower to protect myself if the enemy comes now in the middle here I can see the mini map and I can see what he's building so they're the race of night elf which is and so their buildings are trees that are living creatures instead of wood buildings like the humans create and because I've been explaining he's obviously a lot faster than me he's already built multiple archers and he's got a hero so he's gonna win unless I start speaking up but um anyways that's kind of the basics of the game so you build a base which his base is a lot more developed and then you build army guys and once army guys are ready you go attack the enemy but there are also neutral places that you can make your units stronger so only the hero gains experience but right now it's level one if you take your whole Army and your hero together so say down here there are some neutral monsters to fight if you attack them then your hero will gain experience and the hero will gain spells which makes your entire Army stronger and you can also capture more gold mines in order to build secondary bases and at some point you're going to want to go attack the enemy and destroy their base but you can also team up with other people so right now I'm in one versus one and the person I'm against is the AI the computer but I could actually you know do up to I think 24 players at a time and this is a very small map with only a few gold mines but if you're doing 24 players you'd want to pick one of the larger maps and you can be Allied and help each other out so it's pretty fun game and it uh there's like a tournament mode that people play online and they rank up to see um how good they are compared to other people and uh but that's the base game now if I quit out let me show you a custom map so you can see how different they can be so I'm gonna pick a game that I want to hack so if I scroll down here the game I just started playing yesterday that seemed kind of fun we'll try hacking it it was called heroic Origins I've downloaded too many Maps here so like you can see all of these are completely different if you were to jump in and play one but the one I've been playing it's a tower defense here it is ho which stands for Heroic Origins and I think the G is Galaxy and the TD is Tower Defense and it's version 13. so somebody whoever made this has been upgrading it over and over again over time that's why it's first and 13. so you can imagine it's going to be kind of advanced if it was version one it probably wouldn't have that many features and this one takes a minute to load so while it's loading I'll explain it a little bit so if I my main peasant is here in the middle he's a builder but if I scroll up this purple spot is a waypoint where the monster spawn from and down at the bottom so they'll walk down this path when they get to okay I'll do easy mode when they get to the far left here uh this second Waypoint when they get there they'll teleport and this is intended to be a team game so they would teleport to my teammates and my job is to kill them but if I if I don't kill the monsters in time the teammates will kill my monster and then if my teammates leak then the teleport will take him to the secondary weight point and then they'll walk keep walking again so in my case since I'm playing one player if I leak it'll just go to my own Waypoint so if I take this Builder I can build a building real quick and these buildings will be towers and it gives you four random choices so I'll just pick one it doesn't matter I I and if I was actually going to strategize then it would matter and I'll show you how interesting the game gets so for example this witch doctor if I click on him so he's just automatically attacking all the time that's why he's considered a tower even though he looks like a a unit and uh if I Mouse over it says this ability gets unlocked if I have a witch doctor and a tauren well he is the witch doctor so I need a tauren to unlock this extra ability which will make him stronger and that tauren will also get stronger because they synergize but over here um a Headhunter would give us a secondary ability and then over here it says if I get this guy to level three he gains a third ability so right now he's got one star so if I I didn't get any tyrants here but I I did get a Headhunter so if I chooses Headhunter now you can see on my first guy that ability unlocked and also the Headhunter has his ability unlocked because it's not grayed out anymore so the towers have synergies in order order to get the star level up higher you click this merge button you have to build an identical unit so I'd have to build another witch doctor and merge them together and that would get it to two stars which makes them stronger and then once they get to three they gain an ability once they get to Five Stars which is the maximum there that ability gets even stronger and then also under right here under inventory you can put down different items and the items make them stronger as well and then over here there's just these neutral buildings each building is a little shop where I can purchase upgrades so this upgrade gives me more food so right now I have two towers out of four if I purchase this I could get more Towers if I purchase this then I get Lumber quicker and lumber is how you build towers and also how you um re-roll because if you remember I got random choices when I picked build build it gave me four random choices at the bottom here these keys let me re-roll to get different choices of towers and there's like 20 different choices the towers are all very different and these towers are considered tier one you'll notice that the green text on them if I roll these more expensive Keys like this purple and red then I can give the ability for a tier 2 which is purple or a tier 3 which is orange so obviously those are going to be stronger so over here you know upgrading to have more Towers is useful but then also paying gold to regenerate Lumber faster is important because the lumber is what lets me roll into the more expensive tiers of towers every time I kill a unit I'm gaining gold and sometimes they drop little pieces of lumber and then once I get certain quests so in this case the quest is to build five Towers then I can do an upgrade which gives me a bonus of gold and there's multiple upgrades you can do each Quest is is different so after I click on this Quest once I've built the five Towers then a new Quest will unlock but appear if I click on quests there are also these hidden quests so this one says like if I beat the horses six times I get gold coins but that that's not gold like up here it's actually an item and if I equip that item on a tower then anytime he kills something he gets bonus gold and so there are a bunch of different quests here and what's interesting about this game as well is whenever the game is over it actually saves your game so I I played this a few times so that's why I have I started with these 50 Medal of Honor tokens and I started at rank 102 when you when you normally should start at rank 100 and then I also got these 25 Soul Gems and you get those from like beating the game or like completing certain quests well I can these things stay with my character each game after I play and I can use those for upgrades that stay with me forever whereas these towers I've built they don't stay with me forever they're just for the current game I'm playing so it would take me an hour to explain all the strategies behind this game and all the different neutral buildings but you know each neutral building does something completely different and the way the tower synergize is very complex and the reason I wanted to explain all this is because this is very different than the campaign mode um where you're following a storyline and it's also very different than just the one versus one build the base and kill each other mode because in this case you're not even playing against anyone else you're all in a big team and so this is a tower defense game but there are other games like Dota or League of Legends that Spawn from here which are different from any of the modes we've talked about before so that's what's really cool to me about Warcraft 3 is that it's kind of a tool for quickly iterating over different game ideas and people can collaborate with each other so I I was sad that it the community died down especially when blizzard failed with the reforged launch but they have promised that they're going to fix things recently and I hope they fall asleep with that promise we'll see but anyways let me show you uh for a second the map editor because that's got a lot of coding things that will be interesting and then also I'm going to show you how to hack this particular map but every map will be hacked slightly differently so I'll just show you this map for now but just as a starting point in Warcraft in the base game if you're in single player mode there are built-in cheat codes so if I hit the enter key it'll let me start typing and there are codes like greed is good if I were to hit enter it would give me gold and wood and there are other codes that do other things you can look them up online but the programmer that made this custom map he didn't want anyone to be able to cheat and that's what we're going to hack so if I hit enter on Greed is good it's going to tell me that it detected that I cheated and so even though my golden wood I think did go up it instantly said I lose and it and that it detected that I was cheating so that's what we're going to fix so that we can cheat if we want so I'm just going to quit out and I'll show you how I would hack this so first of all if I open up Battle.net this is where you purchase the Warcraft 3 game and where you can click play but it has this icon here called launch editor so if I open that it gives me just a base map with nothing at all and this is a tool that people make custom maps with so if I wanted to I could for example go to like layer terrain and it brings up this palette and I could draw like grass right and then I could go to layer units and I could put a peasant down or I could put down a hero of some sort or some buildings like a farm so these units all are built into the game so they already have certain attributes you know how fast they can move what they can attack whether they can go on water or only on land or whether they can fly what upgrade trades they have Etc if I go into module object editor I can actually change the base settings on every one of these units and this is where it actually starts getting a little bit into the coding and you could actually imagine how a custom map would be created and you can also think about how the original blizzard programmers might have coded this in case you wanted to build your own the real-time strategy game which is the genre that Warcraft 3 started with so for example if I take the peasants and these are like all the properties so if you think about object-oriented programming language maybe a unit would be a class and a peasant would be an instance of the class and all of these properties would be variables inside of that class so the damage on the peasant it says zero because he's not really intended to fight he's intended to build but if I were to double click on this I could set his damage higher and now the peasant turned pink because I've modified him from the base and same thing his base damage has been changed but I can modify anything in here that I want I can make him an orc instead of a human I could give him a different graphic to make him look like a building um I could change which buildings he's allowed to build right here I could change which upgrades affect him so for example this Lumber harvesting that upgrade comes from the lumber mill but once you've purchased that upgrade this peasant is able to gather wood quicker so any of these properties can be modified as well you can create brand new units from scratch so I could right click and say new custom unit or I could take a template so say I wanted the priest I could right click and copy or and then paste him or I could say new custom unit so oh actually I guess I would want to copy and paste them so copy come down here paste so now I've got like a custom priest as a starting point and then I can modify him as much as I want so I can still leave the original priest alone if I wanted so you know this doesn't affect the entire game it's not affecting everyone that that plays the game game it's just my one specific map so when I'm done creating my map I would hit save I'll just make a folder C10 for graph3 and my map or something now the type of file so the expansion is Frozen Throne the base game was called reign of chaos so most people are that play the game are going to own the expansion so I would choose that but then it has two modes folder or not folder if you don't choose a folder it'll basically make a zip file I'm going to choose folder so you can kind of see how the it works so I'll save this and open up my folder so you can see all of these different files and some of these are text files that you could read and some might be more binary files so if I open up notepad and say I take this dot j file J stands for jazz which is a custom programming language that blizzard created and it looks similar to like a c plus and you can Google to find out what functions are available inside of this language but so for example blz stands for blizzard and I'm not certain but I would assume other blizzard games use similar Technologies so like Starcraft World of Warcraft Diablo Etc um and and jazz is kind of deprecated so I should go into the settings and switch it to Lua that's a more popular language for scripting nowadays so it is supported in the reforged version of Warcraft 3 so that's what I would suggest but anyways this is code that we could learn from and something I like though about the map editor if I go on a module and I do trigger editor the code is very user friendly for someone that's new to coding because it has a kind of a drag and drop system so this trigger editor that's kind of like an event system so you can say when certain things happen you want code to execute but instead of writing code from scratch by hand you can use this drag and drop and so for example it says the initialization of the game that's the event so if I wanted to add a condition I could right click here your new condition and it gives me a list of all the choices or I could search but I'll say so say I wanted to do a game difficulty comparison so if I click on that then it has parameters down here so it says difficulty level and if I click on it it lets me choose or like other variables but in this case because the comparison is on game difficulty there's only one choice whereas if I chose like a unit comparison it would show me all the different types of units here but anyways so it's saying equal to if I click on that I could do equal or I could do not equal and then where it says normal I click on that and I could choose easy normal or hard so that's the condition so I could so I'm basically saying I only want to run all of these actions if it's on normal difficulty so if I copied this trigger pasted say this one's normal difficulty and then I could rename this one to hard difficulty and then I would change this condition to hard and then similarly for the actions if it's on normal difficulty maybe I create an action that like gives me a free unit or something but on hard maybe it wouldn't do that it might be easier if I click the search and then just typed create or something uh let's see correct and maybe I can create space unit for searching so yeah now now the drop down only has two choices create unit facing an angle create unit facing so I guess it doesn't matter which one but I'll so it says I'm going to create one footman for player one red at the center of the map facing the default um building degree so same as before I could click any of these things and pick different settings so I want a flying guy instead of a footman and I want three of them created instead so this allows you to write code without really writing code and then the cool thing is after it's saved I could open up that code so it's 43map.j and notepad and I think I need to reload it but I could look for that code that was just generated let me see if I can find it okay so here's my hard difficulty trigger that just got created and I don't think I changed that one I think it was the but but you can see like so here's an if statement it says get game difficulty equals mapped difficulty hard then so it helps you learn how to write real code and then here's how it's creating that those units so on under normal difficulty hgyr is the code for that flying machine that I chose but it's going to create three of them for player zero which is the red um and the function it's calling is create units so kind of interesting so I really like this map editor so I'm sad that they upset their Community because I think they really could have kept the game going but this is supposed to be a hacking tutorial so there are a million different features in here I'm not going to go over them all but if you have any interest in this I suggest you buy the game and try it out but I'm going to show you how I would hack that Tower Defense I've shown you so first let's pull up the folder where the games are stored when they're downloaded so it's going to be in my documents folder so click documents and then Warcraft 3 and then Maps oh and one thing I want to mention first under custom map data data the game I was playing is was that Galaxy Tower Defense and if I open this up this file is my saved game data that is retained from game to game so I mentioned that because I'd already played once I had 50 metal tokens that stayed with me even though I was starting a brand new game where I had to start building Towers from scratch it remembered that I had earned 50 tokens from the previous game that I played so this file here is how it does that so it's code that we just barely showed but it has all this random gibberish this is basically what's remembering what my character has that's going to be retained from game to game and it's specific to the tower defense I was playing it's unrelated to every other map and I don't know what any of these symbols mean uh essentially it's encoded or encrypted so you would have to know the format of how it works but if you say pulled up a calculator and you also pulled up an ASCII chart ASCII table so the letter V in ASCII which is how letters are represented where is it these are uppercase I need the lowercase ones so it says that it's decimal equivalent is 118. if I took 118 let me switch into programming mode on the calculator so I'm going to go to decimal type in 118 then I'm going to switch to Binary I'm going to copy this so essentially this V is this now I could do the same thing for the ASCII of 4 and ask you of the Ampersand and the ASCII table of the capital S each one is going to have a whole bunch of zeros and ones just in different places right so I'm just randomly changing no once and zeros so just pretend that this is the letter V this is the number four and this is the Ampersand well I mentioned that the string is like encrypted or encoded in some way so I'd have to actually analyze the code of the tower defense game I'm playing to know what these mean but most likely each one of these zeros or ones stands for something so for example this first one might be whether or not I've ever beat the game before this next one might be the difficulty level that I beat it at and this next one might be the number of tokens that I've earned and there's a whole bunch of things that carry over from game to game different stats or whatever each of these could be storing those now binary can only store true and false so whether or not you've beaten the game before could be stored on a single spot but like the number of tokens I've had if if it's only this one spot then the maximum would be one so the number of tokens is actually probably stored in like these four because with uh binary each number can hold two values and each time you add an additional number so in this case I have four it times is it by two for how many you can have so two times two is four so there are four combinations if I have two characters if I times it again it goes to eight so a three there are now eight combinations and four they're now 16 combinations of zeros and ones so maybe these four um would store some kind of value that has 16 possible choices and then maybe these next set of like 12 stores the number of tokens I have so that's how the safe code works and the reason that will be useful is when I hack the game I'm gonna have to modify the actual map file and if I were to play online with other people they would notice that I have the wrong map file and also whoever's hosting the game chooses which map file to use so if I join somebody else's game I can't choose to use my hacked version and if I host the game somebody else when they join will notice that it's probably hacked because it will force them to download the map file from me but if they already have this game they're going to be surprised that it's downloading something so they might notice that it's been hacked and if you really wanted to cheat you don't want to be detected but what you could do is play the game game with the hacked version just in order to get a new code generated if this saved file says that you've beaten the game but you can't actually beat the game without cheating well you play the game in the Hacked mode beat the game let it save your profile to say that you have beaten the game and then you switch to the unhacked version of the game and then when it loads your profile and tracks your history of what you what happened in your previous games it'll see that you've already beaten it you get like a bonus if you've beaten the game before so your next game's a little bit easier so nobody could detect if your profile was generated through a hacked version of the game they would only notice if you're currently playing a hacked version of the game not if you previously played a hacked version of the game so that's something useful to keep in mind while we're hacking this but that's under the documents folder Warcraft 3 map data custom app data and then the name of the map but instead I'm going to go into the maps folder instead of the custom app data and then under download and I'm going to find this game that I've been playing so it's ho which I believe for Heroic yeah they're heroic Origins Galaxy TV so the first thing I want to do is I don't want to ever accidentally modify the real copy so I'm just going to hit Ctrl C or right click to copy copy and then I'm going to make a brand new folder called hacked so that way in Warcraft 3 I'll have a downloads folder which is the default where all your Maps get stored and then I'll have an extra folder called hack where I'm going to paste a copy of the map that way I can keep track of which is which and if I wanted to I could even rename this file to like Dash hacked or something but first so I'm just going to close the map that I was working on oh and something interesting so I mentioned all of these files if you are working on your own map having it in folder mode like this where each file is separate is useful if you're using a source control tool so what most people use is called GitHub if I went to github.com and I'm not going to bother to log in but say I searched for like Warcraft 3 or something this shows a whole bunch of different repositories and if you go and this isn't the right game this is World of Warcraft but if you go inside of a repository you can see all of the files and what's cool is these commits right here this is a history so you can see for each day what changes they made and if you looked at a specific file you could see what lines of code they changed and that's really useful if you're working as a team or even by yourself you know say you make a bug today but you don't notice it for a week well if it keeps a history of every change you made you could go back to previous versions of your code until the bug disappears and then that will tell you essentially which day you created it on and then once you can narrow it down to which specific commits or which day then you can look at the individual lines of code that were changed and that might help you figure out where your bug is so if you're going to make your own map file I would suggest being in folder but once you're ready to actually distribute it to people you want to save it in archive mode which is like a zip file because nobody wants to deal with all of these random files so the place that the map was stored I already mentioned was in the download and I copied it to hacked it has this w3x extension so this is just one archive that internally has similar files to what I created in the map editor now I'm going to open this in the map editor and I fully expect this to fail so I'm going to hit open download scroll down to hacked pick my file and hit ok now the reason I expect it to fail is map makers do not like people to hack their maps and so they keep a clean working copy on their computer for while they're editing but whenever they're all done and they want to distribute a new version to people they intentionally break the map and they use a protection tool or possibly they do it on their own and essentially what they do so if I go back to my folder they understand because they've been modding Warcraft for a long time they understand what each of these files does and what format they are and what tool you can open each one in and some of these files are needed by the game itself but some of the files are only needed by the map editor and so what they do is they either delete the files that are only needed by the map editor or they intentionally break something that's needed by the map editor so say I take like a hex tool let me open up one real quick so this is a hex editor if I knew that this w3i was only needed by the map editor and I'm just picking a file at random in this hex editor so you can you'll notice here that some of it's human readable so like right here it says just another Warcraft 3 map that's what I called my map because that's the default but then there's also some things that just have random gibberish just like I mentioned before with the gibberish of the gibberish of this safe code a hex editor has similar gibberish that means something if you understand the file format but otherwise it's just a bunch of random zeros and ones and I'm using a hex editor because binary is hard to look at a hex editor instead of using 0 up to one it goes up to 10 and then it switches to letters and goes up to F so the number 10 is represented by a and the number 15 is represented by F so the reason for 16 is because computers count by two whereas humans count by ten then the number 16 is a multiple of two so hexadecimal works well for computers but it kind of works okay for humans because you know binary is just way too many numbers but with hexadecimal uh it's it's not as bad anyways on the right side it's trying to show the text like human readable English characters but they look like gibberish and then on the hex they do as well so if I I really understood how the map editor worked I would maybe know that I can change this number 34 and again this is just a fake example but maybe I could change it to zeros and maybe I know that will break the map editor but it will still work in the real game so that's how they protect their Maps the problem is I don't necessarily know what they did to protect their map so I can't necessarily fix it but if I go back to the map editor you can see it still says it's loading regions but it's only loaded 90 000 regions out of I don't know how many that looks like billions so obviously something's wrong here because the map should have loaded in like five ten seconds and it's basically crashed so I'm not going to be able to use the map editor so I'm going to have to hack it a different way so let me open up this file in a hex editor here it is so heroic Origins the extension is w3x but if I look at the very beginning of the file it has the letters m p q a lot of files but not all because any company can make up their own file format a lot of them at the very beginning will have the name of the file format and sometimes it's proprietary or some sometimes it's something that everybody knows about so mpq is something proprietary to Blizzard but if I went to Google and I searched for mpq editor and I could even add Warcraft 3 on there so I don't get Starcraft or Diablo or something else they're all probably similar though I could find a program to download that will help me edit this file now because Warcraft is an old game then some of these websites might not be maintained anymore their websites or might be really old programs that they host might be old or maybe when you click to download it doesn't even work hopefully if the community revives a little bit then that'll be fixed so it may take you multiple Google searches to find what you're looking for but I've already downloaded one so let me just open that up and actually first I'll show you a different tool I have so I also have a d protection tool so right here is called the protect but I'm going to click browse and I'm going to pick this heroic Origins and hit ok now the purpose behind this is It's supposed to try to figure out what the original programmer did to protect their map and it's supposed to undo it but if I click D protect here unfortunately it's going to say it failed so there are multiple versions of the protectors but the problem with this type of approach is the programmers are coming up with ways to protect their Maps as quickly as hackers are coming up with ideas for how to deep protect so the Deep protect program is going to work on some maps but not on others because it has to figure out which specific technique it did and that's why it has all these different options but as a hacker in order to know which options to use you would really have to understand the Warcraft 3 map format really well you'd have to read a lot of tutorials online and figure those things out to know how to de-protect something and every map is going to be different so even though these deep protect tools are supposed to be just user friendly do it quick they're not always going to work there are a lot of forums online so I'll just quickly show a list of them these are places if you're wanting help with Warcraft map editing and modding these are websites you should try out so this top one I believe it just is a place to mostly download maps and then this one I think is the same but Hive Workshop is a popular one and it has more like community links where you can go to Discord or forums Etc so if you search on these forums or ask questions or look at the tutorials or resources it might have ways for you to protect de protect Etc and under like these packs and tools and code these even give you extra code that you can import into your custom app so you don't have to start from scratch so for example that other Tower Defense that we're just looking at that I'm hacking here uh I showed you that it has a saved profile that is remembered from game to game most likely the coder did not actually make that himself he probably came in here to resources and packs and or maybe tools and found some code that somebody else had written and he just imported that into his map editor so I'm actually a little bit sad that maps are protected I understand that authors don't want people to cheat and also don't want the unlicensed modded copies of their maps to be distributed because that could kind of ruin their internal Community for their map but at the same time I think it's really useful for programmers to learn by reading other people's code and looking at other people's maps and how they did it so I wish that there was a way to protect the Gaming Community but also allow the programmers to learn from each other and I guess these Community forums is kind of the best option but maybe if there was a way to detect when a map was hacked or modded so that Gamers that are serious about playing the correct version could avoid the Hacked versions then maybe Maps wouldn't have to be protected anymore so hopefully blizzard does that sometime but anyways a few other websites W3 reforged.com warcraft3.info worldeditortials.helper.net this one's actually really good also and wc3edit.net so some places you could check out if you're wanting to read either how to de-protect or how to make your own Maps but like I said the protectant work but I do already have an mpq editor and we discuss how this file is an mpq editor so I'm going to use that first of all I need to make sure Warcraft is not running with that game loaded and it's not in my toolbar right now so I'm safe the reason why is because mpq editor um well Warcraft locks the file while it's being played and the mpq editor will not be able to read it while it's locked so here's my hacked folder which the game is not yet hacked this is just a copy of the game but it will be hacked soon so I'm going to open this in the empty queue editor and if first wants me to select a list file and it doesn't have anything in the option so I'm just going to do an auto detect the list file basically tells it inside of the archive which section of the archive file contains each small file because an archive is going to have a list of maybe 20 files inside of it which is going to look just like this custom map we created so the list file tells it the location of each of these smaller files inside the larger file so because it's been protected it didn't have like a list file so that's why I have to tell it's Auto detect and generally it doesn't matter which one I choose but so I'll just pick this one now so it's able to read all of these files but again this has been protected so there's going to be something wrong with some of these files maybe some of these files don't actually even exist so for example under the size if there's one that's like really big like this one then maybe that file doesn't actually exist but the list file which is like a dictionary telling it where each file location is made that's been corrupted to make it think that this extra file is there or maybe these files extensions are not supposed to be dot XXX maybe they're supposed to be something else um you know so it's going to be a little bit confusing trying to figure out what each of these files means even if you understand the warcraft file format because it's been intentionally corrupted to protect it and for someone that's never coded with Warcraft 3 then obviously you're not going to understand any of it anyways but like if you try to follow a tutorial or ask questions online or look at a guide the guide's not going to work very well when the map's been protected and the files have been corrupted but what I'm going to do extract whole archive it says it's going to take a lot of disk space I don't care I think somewhere in the settings it says where it's going to extract to but I just remember it's under D temp D protect work so these are all of the files that it just extracted now I'm just going to search all of these files for specific code that I'm looking for so I'm going to pick this folder and I'm going to open up Visual Studio code because this is a tool I like just for searching a bunch of files at once so I'll do file open folder paste that folder in and hit select okay so the left side I'll see all my files here but if I click the search icon I can type something I want to search for so uh I forgot to highlight this one the game was open but when I typed in the cheat code the greed is good it put this error message on the screen it said detect players using cheats and then afterwards it's something like the you lose the game will now exit well I know that that particular message is not something built into the regular part of Warcraft it's something specific to the custom map I was playing so for example the game itself for Warcraft is going to be under program files so Warcraft 3. so somewhere in here is the code for all of the game but if I were to search this folder for this text it's probably not going to find it because this is a code that blizzard wrote It's not specific to the tower defense that the different programmer wrote and the reason I'm looking for a specific string of text is that's the easiest thing to search for when you want to start hacking something because it's something that is going to be human readable inside of the code so for example let's say that they had some code in there that was like if you know player gold is greater than you know like maybe that's how they're trying to figure out if I'm cheating then quit game something like this right well I'm not gonna know exactly how they're detecting that I'm cheating so for me to try to search for this code is going to be difficult but also this is the original code but code gets compiled down so once it gets compiled it's a bunch of zeros and ones because it's something that the Peter can understand rather than what the human can understand so if I search for like the word gold inside of you know like an executable exe if I'm thinking that that's a variable name it's probably not going to find it because it's been compiled down I would need the original source code and I'm not going to get that unless I break into the company's servers and download it and then I'm going to go to jail so um I'm not going to be able to search the code very easily there are tools that are called decompilers that will change the zeros and ones back to the original you know C plus plus and that could be a starting point but I want to go with the easiest option first and usually strings like this even if the code is compiled down to zeros and ones there's usually a way to search for the original strings because they don't really get compiled down so I'm going to copy this detect players using cheats and I'm not going to search the warcraft code but instead I'm going to search the map code so that was in the C temp the protect word that came from the MP Q editor where we extracted and the mpq editor was able to extract the files for the most part because the protection on the map they can't corrupt it too much because the game itself still needs to be able to play they're just trying to break the map editor so that a programmer can't modify it so they're only able to corrupt it a small amount so that's why the mpq editor is still able to read it so I've opened that folder so I'm gonna and I can see all the files here I'm going to click search and I'm going to paste in the detect players using cheat so I see that there are four places that this is used if I look at the first one it looks like this is just a string variable and the variable name is one eight four zero if I look at the next one I've got another string variable and the name of the variable is 2804 so I bet if I search for this 2804 or any of the four options I need the four variables I can find where that variable is used so it shows that it's defined here but it shows it's used in this.j file okay so here I can see call all display text the string for all players so this is essentially saying tell all the players that somebody was cheating and so I could finish reading the code inside of this function it looks like it's going to say another string 2805 I could check and see what message that is then it's going to execute a trigger called check lose so I'm going to assume that that's going to like put me out of the game or something so I could search for this trig B actions to see what calls this function or I could search for this check lose to see what happens next but first before I start analyzing this code I already kind of have a guess as what I could possibly do right so um if this lose is going to quit me out of the game maybe I could just comment out this one line of code and that might be enough or wherever this act this trigger gets called maybe I could well actually I can see it right here tricky actions maybe I could comment out where that gets called you know something like that but first because there were multiple place this is where the cheats were detected I think I want to see which of these four is the correct place because maybe there's multiple types of cheats that they're checking with different ways so the easiest way to know if you try to hack something to know if your hack is working is you want to change something that's going to render on the screen and see if it visually changes so since I know this text gets drawn on the screen I can just add something onto here like no AI gamer and then if I play the game and that name pops up then I know it's using my updated files that I've hacked instead of the original base game so I know I know that my code that I've injected into the game is working so this is an actual code this is just a string it's just text but by modifying it I can see if the text change so in this case since there's four of them I'm just going to put maybe like a dash one and a Dash two and a Dash three this way based on which one appears on the screen I can know which of the four places I should actually be modifying so I'm going to save this file and I'm going to undo this.j file I'm going to undo whatever I changed because I was just messing around and also something nice about Visual Studio code so on the bottom here it says that it's in jazz language mode if you go to extensions and you search for jazz it'll show you plugins that people have made for the Jazz language so if you install one of those plugins it's going to make it easier for you to understand the code because it's gonna that's what's causing this to be highlighted in blue or yellow or green so that makes it easier to read okay so I've modified each of these strings in this war3map.wts file but it's not yet into the mpq file so I'm going to open up the mpq editor again and open up the Hacked folder heroic Origins and then I'm going to drag this new file that I've modified in here so if I go to visual studio code I can right click and say reveal an Explorer and it'll show me exactly where the file is and then in the mpq editor I can just drag the file so now it says it already exists in the archive you want to replace it yes and then I'm going to close the archive so that it's not locked so that Warcraft 3 can view it and this is where it was important that I had made a copy of the map in the Hacked folder because if something goes wrong I still have a copy of the original that I can switch back to if I need to so I'm going to open up Warcraft again and load up that game but instead of finding it under download like before where all my maps are I'm going to open up the Hacked folder and there's just one file here and I'll choose this map it takes a second to load I'll choose easy and now I'm going to try my cheat code now I have not hacked the game yet so it still should quit me out of the game but I'm hoping it will tell me which of the four strings so I know where the code is okay so it says Dash three so I'll quit out and open up visual studio code again and now detect players using cheats I know it's going to be the one that was the three so 2806 is the variable that it was rendering on the screen so let's find its code so this says trigger C show this text on the screen quit them out of the game I and let me see where this function is used trigger C okay so if I I was going to search for it by hitting like Ctrl F and pasting it in but it's on the same screen already so once I highlight it I can see it's highlighted down here so init trig C says create a register a trigger based on a player State event so that essentially is saying like monitor for something to occur on the player and notify me when this thing occurs so then the parameters tell it what it's looking for so it says player 10 it's checking the gold in one in the first line and the lumber in the second line and it's checking if it's greater than or equal to the number one so it looks like player 10 is supposed to always have zero gold because as soon as it notices it's equal to one or higher then that's when this trigger is going to execute these actions and that's a little strange because I don't know that player 10 is necessarily me because each player is a different number so if I'm playing with a bunch of friends I might be player one someone else might be player two so I wonder if player 10 is Maybe a neutral um player that's controlled by the AI because in the map editor you can specify that certain players are going to be AI or human and I wonder if that player 10 is somehow like allied with me or something and maybe there's a setting that says we have shared gold you know I don't know something like that that's something weird because I don't know why the cheat code would cause player 10 to get gold I would expect it to get me gold but I would think that I would be player zero or if I was playing with a friend I would be zero and they would be one so it's a little odd to me you know specifically the player 10 but regardless we don't have to understand why this works because we already know that when this happens it's going to display the text on the screen and quit me out of the game so let's just double check with this check lose does so check lose is a trigger and then it has these actions so this action says display string to the player sleep for three seconds I'm not sure why it's doing that pause all units so that makes sense if if all the units are paused then I can't interact with any of my units anymore and then it so the BJ stands for blizzard Jas so Jas is the programming language and B is Blizzard but anyways it's saying custom defeat and it's doing it to zero player zero through five so this is a six player game so this makes sense to me that it's saying all six players that are Allied together they all lost basically is what the defeat is doing um so I don't know what this string is showing we could look it up real quick but it's probably something like the game is going to exit because I think I remember it saying something like that uh oh I guess just you lose okay so we know we don't want this to occur and I'll just go back to the original string I was looking for so um this is where it gets rendered we know we don't want the lose to execute I guess it doesn't hurt anything if it says we lost as long as it doesn't actually quit us out of the game but may as well not have any of these things happen so I'm just going to make it so that trigger C actions never occurs so if the events that it's looking for is for the gold to get greater than one I'm just going to delete these events because that will make it so that this trigger never happens because there's nothing monitoring for when that trigger should execute so I've saved that file or three map without those two lines of code and I'm just going to put it into the mpq editor so find the file here it is now this one is in the scripts folder so previously I was in the work folder that's where most of the files were but this one's in the scripts so I need to pay attention to that so I'll open my file so I'll drag my new file in overwrite yes file close now I can go into Warcraft and load that map again and I expect it to work this time unless there's a second section of code that's checking for cheats I'll go to the Hacked folder pick my map now I didn't explain the screen before but since we talked about the players in the code I think it's useful so you'll notice here this number one that's what team I'm on but because I'm in the very first slot so team two is um like the computer that we're against but then it has this extra green computer so all of these are AIS and the way that these line up I'm guessing that brown is the monsters that I'm supposed to kill red is the monsters that my teammate on the second slot is supposed to kill because they kind of all line up and then this extra player here I don't know what its purpose is but I believe it was players like zero through five so that it said um were the ones that got defeated uh when we cheated so zero one two three four five so that's I think what's going on here so if I click this first one it keeps moving me down to the next slot so now I would be the player five instead of player zero so yeah zero through five and then six seven eight nine ten so I'm still not entirely sure why it was looking at player 10 like why this pink guy um is the one that is checking to see if they have extra gold that's strange so and maybe this is not six through ten because I don't know who this green one is so something a little weird but I don't need to understand the code uh to hack it necessarily I just need to see if the change I made fixes it right so I'll start the game and it takes a while to load as before so what we want to pay attention to is our gold and our wood so 1210 so if I type in that command greed is good and those numbers go up and it doesn't quit me out of the game then the hack is working so I'm going to click easy mode actually I should have done hard mode that would have been more interesting but greed is good okay so it says cheat enabled that's I think built into the normal Warcraft engine um not really part of the custom app but you can see the gold one up and the wood went up so definitely working so let's see what I can build this could be kind of fun now I'm really wishing I had done the hard mode because beating easy with cheats is not really very interesting but I know typically at the beginning of the game for example you're not going gonna get a tier 3 Tower so I'm going to roll this big key here that costs 50 wood normally you don't have enough wood for that so I can get a tier 3 Tower so this gave me two purples and two greens I don't want a purple because that's a tier two I'll roll again until I get a orange which is a tier three okay right there tier three oh it says I don't have enough gold so even though I did that command the gold is 30 500. so on that I can do greed is good a second time or if I just type a bunch of numbers afterwards that's how much gold and wood to give me oh I'm about to lose even with cheating I'm gonna lose okay um hopefully he starts killing stuff quick I've got 10 seconds okay I'm good now so it says now I have 29 monsters to kill out of 35. so I spent too much time explaining and not enough time actually building Towers but uh that would be embarrassing to lose on easy mode when I'm cheating but with that greed is good when I put a bunch of nines afterwards you can see the wood and the gold both gave me a whole bunch of nines so that's the hack I mean now I could essentially upgrade all these things as much as I want where normally I mean I guess not as much as I want at some point there are no more upgrades because the map editor you know the programmer that made this didn't design it for anything more because at that point you basically beat the game which um you're not supposed to be able to unlock those until right now I'm on Wave two you know I think it's wave 30 is when the game is over when you beat it so you know the highest tier that I've just unlocked probably you're not supposed to be able to unlock it until wave 20. um and then some of these they're unlocked or they're locked still because I have not completed the quest so I have to build five tier one towers and I only have two tier three towers so I'm not gonna bother to actually play the whole game but that's pretty exciting I was able to hack it so I could basically have as many orange tier three towers as I want without so I've got four tier threes now let's do a few more so yeah I've got unlimited gold and obviously there's other ways I could hack this map this is just one particular type of hack it was free gold and free wood there's other hacks we could have done but uh yeah I'll have to play this again now that it's to see if I can beat the Insane Mode because I'm sure without cheating I would not be able to so there's okay I've got six tier three towers they're all the oranges so hopefully you enjoyed that hacking tutorial uh let me know what other games you'd like to see me hack in the future and uh write me in the comments below if you have any questions about how I did this if there's anything I didn't explain very well and if you do play Warcraft 3 send me a message and maybe I'll queue up in a game with you sometime thanks for watching

Popular posts from this blog

AoE4 Mod Tutorial: Making a Crafted Map in the Content Editor

TeamFightTactics - Rules & Strategy - Coding an AI - Part 2

Intro to JavaScript - Coding a TFT AI - Part 3