Origin Story
Behind any great story, there are always multiple supportive people who may or may not make themselves known behind the scenes.
Friends and Family
I was inspired by Warcraft III World Editor from the age of 7. I found it fascinating to put my own custom names on little mini people in a virtual world with swords and sorcery. For 15 years that fascination grew as I learned more about Warcraft III and how to modify the game, and accordingly more about how the game was built. I would have never made it that far without the support of friends and family; in my younger years I had supportive family when I was not allowed to use the internet because of my age, and in my older years when they moved on from Warcraft III I found myself lurking on and participating in the Hive Workshop modding website.
Reforged
On my 15th year of tinkering with World Editor, the Activision corporation announced their Reforged project. In particular because their BlizzCon stage demo utilized a technology called "normal maps," it became clear that the company that had abandoned this game for 15 years still had no interest in actually maintaining the technology stack corresponding to my particular hobby. Of course the Frozen Throne servers had been running successfully in maintenance mode all that time; when I say "maintaining the technology stack" I mean to refer to improving the efficiency with which human creativity can be expressed through World Editor. As a Warcraft III custom content developer, I enjoy a certain level of development efficiency by using simple 3D graphics. Normal maps are not a part of this efficiency, and changing the graphical display stack is uncalled for when other parts of the game experience are more in need of technological improvements to their modularity and scope.
Enter Warsmash
It was immediately evident that the World of Warcraft dealership in California wanted to assert their authority over this creative space. It was also evident that they planned to do so in a manner that did not respect the creative space itself. Within a few months, I very soon took it upon myself to draft a Project Proposal document for myself in Google Docs that declared the need for an independent technology stack to preserve the creative experience that I enjoyed.
Becoming Deprecated
Within my project document, I combined clips from the Declaration of Independence sent to Great Britain during the formation of the United States with my own thoughts about Warcraft III. The "normal maps" technology stack change is not a subjective matter of opinion about the visual end result -- it is an objective change to a creative space that previously had tens of thousands of custom 3D assets made by many, many users with immense passion for what they were doing. The boldness of an asset format change to a system that had been stable for 15 years is an ideology that seeks to invalidate the efforts of those artists by replacing the technology stack with a new one that requires new assets of a new format.
Activision immediately announced that their creation was going to have "crossplay with the original" which meant that the original wholistic game technology in the form that I enjoyed was fated to be replaced with some kind of mode-switching technology frankenstein. This was immediately evident from the moment of their announcement, by simply listening to what they were saying.
Looking Forward
Given the above information from BlizzCon 2018, I could write my Project Proposal and declare that I desired independence. But to actually obtain this type of independence would be a different matter entirely. The Frozen Throne technology stack is quite large, and creating a similar technology stack of my own would inevitably be very time consuming for a one man project.
The Plan
Follow Through
My plan was fairly straightforward, if we take for granted a certain level of software competency:
- Create a New Game with LibGDX Engine's ANGKANET4D
- Copy code from the mdx-m3-viewer ("View in 3D" button from Hive Workshop) into the new LibGDX game, manually converting from TypeScript to desktop Java
- Copy code from the HiveWE ("Hive World Editor") project's ability to render Warcraft III terrain, manually converting from C++ to Java
- Copy code from my own prior-existing strategy game to support dynamically moving units in the 3D world created in the previous steps
A similar plan to the above was described in the
2018 Project Proposal in more detail, including a list of other more niche projects to copy parts and pieces from.
Above is a recording from spring 2019 of my Forked HiveWE. I started from the existing HiveWE code, but this was my first time compiling and running a program from source on my computer that rendered multiple animated Warcraft III models in one graphical context. It was inspiring! If you want to see more, click here to see a longer YouTube video of the same test map.
Programming "in the Dark"
For the year of 2019, there was not a runnable prototype of Warsmash. Instead, it continued to be an idea in my head. Long periods of time would pass where I would forget about it. However, I always kept coming back to it: I wanted this! I wanted software freedom!
So, on occasion, I would fire up my Eclipse IDE -- the same one used to develop Retera Model Studio -- and switch instead to trying to write code for this ridiculous big idea. As 2019 wore on and the end of the year rolled around, and especially when I saw the state that Reforged Beta was in, I found myself increasingly motivated to create a working prototype. A prototype would mean that I could explain to internet friends that I was not kidding with regards to how passionately I wanted this technology freedom.
Perhaps this desire to push for a runnable prototype is why my initial work was nothing but a 1:1 port of the mdx-m3-viewer across languages.
Why Retera Model Studio Failed
Aging Codebase
Unfortunately, the code of Retera Model Studio was so bad that it would not have been feasible to repurpose those systems to display numerous models simultaneously and build a game. That project codebase started in 2011 and was reaching its 8th birthday. Unlike Ghostwolf, who rewrote the mdx-m3-viewer 5 or more times to create cleaner and cleaner code, my designs in Retera Model Studio were greedy for features. I had simply layered feature on top of feature until the end result was functioning in the manner that I desired. But internally, it had grown with me -- the older code was written more poorly, and the newer code was written with new ideas. It was a testbed where I learned to understand how the interaction with the graphics card and the vector math worked.
Code Cleaning
When I realized how beautifully Ghostwolf's code matched the Warcraft III game, and how readable his code was due to his habit of cleaning and revising it repeatedly, I first copied the math into Retera Model Studio. But where he had used OpenGL shaders that could run a thousand times in parallel, I wrote equivalent mathematics in plain beginner-level Java code that executed only on one single CPU core. It worked and allowed me to edit 3D art files, but that is not how we build a high performance game engine that can render dozens of units engaging in combat all at once.
The Prototype
Did You Know?
Ghostwolf's render engine also included a map viewer, so originally copying HiveWE terrain was unnecessary. His viewer could already preview entire Warcraft III maps from within a web browser, as shown here! Accordingly, the first prototypes of Warsmash that I bragged about online were not a novel accomplishment but rather my attempt to read and regurgitate someone else's work.
First Looks
A friend told me it would be funny if I released Warsmash at the same time that Reforged released, and I made a push to try have an actual working prototype by then. Reforged was set to release on January 28th. On January 19th, 2020, after shoveling large amounts of Ghostwolf's code into my brainstorm project at high speed, I finally got the program to where it would render Warcraft III models onto the screen. The key improvement that I was looking for here, on top of other Java code that I had written in the past, was full use of the graphics card so that I could display multiple models in one 3D context simultaneously.
Above is the first recorded output from the Warsmash repository. In the same way that Warsmash was perhaps a cult-like big idea, it seemed funny to use the multi-model rendering technology to display multiple accolytes as though they were harvesting a Haunted Gold Mine in their cult-like way.
Performance Testing
Five Acolytes, one Haunted Gold Mine, and five ground harvest ring spell effects are not nearly sufficient for an entire game. But my hypothesis was that as long as I faithfully replicated Ghostwolf's code into my favorite programming language, all of his performance optimizations would carry over. In essence, we should expect a 60 FPS output even with many unit models (at least on newer hardware).
I spun up the test simulation again, this time with 100 or so Druids of the Claw, who were each cycling through their animations in order. As expected, the port of Ghostwolf's code was decently robust, and was instantly able to output this scene with perfectly acceptable performance.
This was, perhaps, the moment when the Warsmash code repo proved itself capable of doing something that Retera Model Studio will never be able to do.
Did You Know?
The animated GIF of many Druids of the Claw was created by recording the screen live in 2020, and not by telling Warsmash to dump individual frames to a file. Accordingly, if the render pipeline had been lagging, it would have appeared in the recording as well.
Game Versus Engine
The simple model scene graph capable of beautifully mimicking Warcraft III to draw MDX files -- but to do so anywhere onscreen by simply declaring a camera, then loading a model from its filepath and from some {x, y, z} position vector, was tantalizing. I had a moment during that first week where the user CanFight called me to mod Warcraft III and hang out on Discord, where he really made me question myself. When I showed him what I was working on and explained I was going to add terrain and gameplay so that it could play melee versus maps, as a fellow technologist he understood how extremely backwards that was. CanFight had worked on making custom games within the confines of Warcraft III: Patch 1.31 and in particular he had created a flight simulator, a first-person shooter, and a clone of the game of Minecraft all within the confines of the existing game map sandbox. The technological limitations he faced that caused his work to be novel and unique time investments were rooted in the inability to decouple Warcraft III custom maps from their RTS game assumptions: it required substantial effort to escape the concepts of "Unit" or "Fog of War" or lock-step synchronous multiplayer inputs, or how the user interface was structured.
By contrast, I did not have to struggle to escape any of those, because I started at the beginning. I had combined Ghostwolf's existing render engine with the do-it-yourself, programmer-focused LibGDX game engine.
Choosing to Emulate
However, despite the feeling from that call with CanFight -- that I had already completely broken free of the constricting base assumptions -- I was determined to emulate as much of Warcraft III: The Frozen Throne as possible. I believed that when it comes to World Editor, "what is wrong is right," so to speak. In this world, we already had Unreal Engine and Unity and Godot and LibGDX and countless other game engines that allow creative people to start from the beginning on their game logic, while existing within a feature-rich visual environment. And these other game engines work incredibly well.
What doesn't work, because of the narrow-mindedness of Blizzard Entertainment, is for me to sit down and draft a custom mission on World Editor in a single evening where my hero character can hold 9 items in a 3x3 grid inventory, or where I increase the 12 unit limit on drag selection, so that my army can consist of 15 units that I select and command simultantously. And these are only a few of the countless painful, exceedingly arbitrary limitations of Warcraft III.
And so I came to feel that the greatest strengths of World Editor were in some ways its greatest weakness. It offers creative users a wide variety of hardcoded base assumptions. This is how the idea for DotA and League of Legends and so many others came to be: the creative map developer takes for granted that "a hero has four learnable abilities and possibly one passive ability" or that "a hero can hold up to six items" and inputs only basic information. The user-controlled portion is what heroes exist, or what their names are, or what items exist, or what the names of those items are. But as soon as we try to give a hero 8 items, or 8 learnable hero skills, the code design for Warcraft III falls apart. It's simply impossible without a lot -- and I do mean a lot -- of hacks or workarounds. You can try it yourself if you want to see what I mean.
NOTE: How would you make this on Blizzard's Warcraft III??
The Game Begins
And so it was that with the power to ask my computer to do anything, I began the process of asking it to play Warcraft III. But what is Warcraft III? If you ask the United States Government, they will probably tell you it is some corporate trademark. They might tell you that League of Legends or DotA 2 or Starcraft 2 are not "Warcraft III" but rather are registered under different trademarks. And yet, for the meaning of the word I intend to use, these are basically all the same game. And I wanted to be able to play that game: that idea of a real-time strategy game capable of supporting arbitrary hero characters, items, buildings, or units. But this time, I wanted the technology stack to be "free" as in "free software," like LibreOffice or GCC. "Free" in the sense of the Spanish word "libre," not necessarily "gratis." This would give me the freedom to dream up a hero who can hold 9 items, or have 15 learnable hero skills on a long and epic adventure. I needed only to input the restrictive base assumptions into the computer, so that I could then begin the process of violating them. And this meant, more than anything else, that I wanted an emulator of Warcraft III: The Frozen Throne that did not depend on the program code from Blizzard Entertainment. Knowing Reforged was already going to destabilize the original made this desire for freedom altogether too tantalizing!
The First Video
The first public video of Warsmash uploaded to my YouTube channel was published on January 27th, 2020; this was one day before the release of Reforged.
In the video, I had what gave the appearance of a functioning game world: I had dumped in basic terrain rendering code as well as the capability to select and move a single unit at a time (by left-clicking on the unit 3D model, then right-clicking where to go on the terrain.)
This was, again, not a particularly novel piece of technology -- being primarily a copy-paste job from the works of Ghostwolf -- but it was a publicity statement of sorts that allowed me to dream. All of a sudden I could "play Warsmash" on my computer.
NOTE: In my first draft, I used a row of 5 ability icons, to be different.
Evolution of the Emulator
During the summer of 2020, I upgraded the Warsmash system to allow units to attack other units, using the rules of combat damage described publicly on the classic Battle.net site. These damage equations, combined with the mathematics for a simple parabolic curve to allow attack projectiles to launch between units and arc through the air, allowed Warsmash to simulate battles between units. Additionally, by adding a concept of "death" where a unit would play a different animation on its 3D model instance and become unselectable when its hit points reached zero, I eventually allowed combat to offer a sense of victory, as well.
Movement
Besides combat, the other main focus of my efforts in the summer of 2020 was to allow units to perform some manner of automatic navigation when moving. Using the A* search algorithm pseudocode from the relevant Wikipedia article, I structured the pathing cells of the map as though they were a giant A* search graph, and allowed units to search this graph as a part of their move action. Prior to this change, units were adding a simple {x,y} offset to their visual location on each game logic update cycle based on the direction to where the player had right-clicked.
Techtree
In the fall of 2020, after some time iterating on the concept of these combat-capable unit objects, there was a memorable moment on the weekends leading up to Thanksgiving when I had a Peon click a button that instantly spawned a Burrow into the world. This was the first time ever convincing the Warsmash codebase to create a new unit object and link it with a 3D model instance in the scene while the system was already running! Prior to this, units were getting created as part of a long, winding complex loop function only called as part of the map loading process. This function began as something I had copied from the online map viewer, but I had shoveled in excess code over time without refactoring to clean it up.
After the system was capable of dynamically generating more "units" into the world while running, I added new states to units so that a building created by a peon had to sit for a long period of time before it could do anything. Additionally, the peon's 3D model instance would stop displaying during this time. When the building finished with this initial build timer, the peon would be shown again. Some buildings would then offer a list of units, which when clicked used another similar timer then created the corresponding type of unit in the world next to the building.
These simple rules gave rise to a mosaic of "base building." I found I was able to entertain myself for 30 minutes at a time, building out a base of buildings and units to test my systems and to create a little squad of units to go on an adventure fighting monsters.
Heroes
Also in the fall of 2020, I updated my project to support the notion of "hero" units that grow more powerful over time, through increases in their integer "strength," "agility," or "intelligence" values. This meant separating from the simpler idea -- that each unit of a particular type has a maximum hit points corresponding to that type -- to now instead implement the notion that some units have a maximum number of hit points that changes dynamically over the lifetime of that unit object. In particular, when the "strength" of a hero unit changes, it will push a corresponding update to the maximum hit points.
Items
In the spring of 2021, I upgraded the concept of "item" which had previously been a subroutine to draw a treasure chest 3D model on the ground in Ghostwolf's map viewer that I copied from. Instead, I upgraded this concept so that the "item" objects were likewise something a unit could "target" similar to how units could "target" other units with their attacks. But now, units could target items with an ability called "inventory" which would cause the unit to run to that item, then hide the item 3D model on the ground and instead show a 2D icon when selecting that unit. Similarly, units were also able to "drop" an item on the ground, which would cause the unit to run to the destination, remove the item's 2D icon from the unit's command card, move the item object's hidden 3D model instance to that destination, and then unhide the item's 3D model instance from the scene.
It was fun to see this come together. Although initially the items were not functional, provided no benefit, and did not display "charges" such as a healing potion that can only be clicked once, I was nevertheless able to have some fun. I recall playing a dungeon mission where I placed six items using the name and icon of Phat Lewt from Blizzard's Warcraft III, so that after defeating all of the dungeon monsters I would know I was victorious because I was the one who filled my entire 6-slot hero inventory with Phat Lewt.
Multiplayer
Once I had the foundational game pieces described above, I wanted to be able to share these digital experiences with friends and family. After trying to read a few times through the "1500 archers" blog post made by some of the folks who originally created Age of Empires, I tried my hand at convincing two simultaneous Warsmash simulations to exchange a turn counter using UDP (User Datagram Protocol) internet messaging, as well as the list of actions clicked by players during each turn. In this way, if either player commands a unit to move to a location, the only traffic needed is to send (1) when the unit was commanded, and (2) where it was told to go.
This simple sharing of player commands, combined with the two game simulations on the two computers waiting to proceed with each high-speed "turn" until the other was ready, created that same beautiful facade we see on games such as Warcraft III wherein everyone at a LAN party experiences a view into seemingly the same digital universe, but on each their own computer.
Success
After the first Warsmash multiplayer 2-hour play session with real people in the fall of 2021, most of my work on the project has been the detail-oriented process of making the emulator more accurately reflect the original.
Working With Others
Often times, when veteran World Editor users on the internet discover this project they want to use it to make their own real-time strategy game. This is a very reasonable desire for them to have; because of the hardcoded limitations of Warcraft III, the creative space feels easy to get into but extremely time consuming to become skilled at. By contrast, general game development on modern game engines is ever-so-slightly more difficult to get into but far easier and more rewarding to become skilled at.
So, perhaps predictably, the situations cause the most passionate custom game creators on Warcraft III to wake up one day to realize that they spent more time attempting to create their custom game on World Editor than it would have taken to start from zero as a general game developer in Unreal or Unity and to then create an entire game. This situation might not have been the case in 2002 when the Warcraft III World Editor was first released. However, it is definitely the situation today. This is a logical consequence of the forced stagnation of the World Editor technology given its proprietary nature as a non-open-source program, coupled with the fact that Blizzard Entertaiment all but abandoned it for the better part of over 20 years. By contrast, the Unreal Engine of today (as an example) is probably vastly more user friendly than the Unreal Engine of 2002.
So, I am empathetic towards creators who desire to find the solution to their suffering -- a solution that they sensibly wish for Warsmash to be: a platform to which they can take their RTS idea and turn it into an independent game.
The problem statement that led to the tutorial herein, however, is that Warsmash largely is not.
In my efforts to create a better and more accurate Warcraft III emulator, for the time being I created such a mess in the code that to decouple this mess would likely again be more difficult than to simply start building a new RTS game over again from the beginning.
And so I have begun this tutorial with this rather long description of "What is Warsmash," to get you, the reader, up to speed about what Warsmash is but also more importantly about what it is not.
Because if you are a creative person who would emotionally benefit from having created an RTS game to call your own, it is unlikely that Warsmash will ever stop being a Warcraft III emulator and become what you desire. Instead, it would be more useful for you to have the knowledge of how Warsmash was made. And then, when exercising that knowledge over again from the beginning, you could make decisions more suitable to your own creative vision.
And thus, for the imparting of knowledge, I have set out to make this tutorial to answer a question: how does one make a Warsmash?