This was a really fun short-lived project that had one main goal: make custom dungeons within gmod using the WoW api (since I originally learned lua with it). I wanted to start by making the barbershop, then my favorite raid called Trial of the Crusader, then the Lich King fight from Icecrown Citadel. Unfortunately I hit a roadblock with NPC navigation on custom collision. The NPC Nav Mesh had compatibility issues with physics props, meaning NPCs couldn’t actually move anywhere. This ultimately caused the downfall of the project. Since the whole thing only lasted about a week, it wasn’t the end of the world.
The SQL Mimicker
I started by making a script that emulated a MySQL database, that contains creatures, game objects, models to precache and retrieve, etc. This will let me spawn in maps and raids on demand. I used tables as opposed to a sql database to inject the info into. I call these functions through my gamedata init file. Given the time span of creation, it turned out fine and working as intended. See the code here.
Game Data Initializing
Garry’s Mod NPCs all have their unique entity folders, which wasn’t very efficient given what I wanted to do. I wanted to easily create as many NPCs as I want with just a couple lines of code to initiate each one. Using my SQL Mimicker script, I did exactly that. I used WoWHead models and sounds, The GMod workshop for a couple character and NPC models, and the WoWModelViewer models for environment models.
Here is the initialization script. First, I add all the models with an ID attached to them. These models are all precached on the loading screen. I then create each gameobject using just their name and ID, and then add a spawn location for them. Using this, I can create a bunch of spawn locations from the same ID defined on the insert_into_gameobject_names line. I can then tie each object to a map, which lets me spawn them when I spawn each map in, using insert_into_map_objects. I do the same thing for creatures (like NPCs), lights, portals, and sounds using a similar format in this script. Each map has their own initialize function which is run when the map is spawned. Each function can be declared using insert_into_map_init( 1, function ).
Using the system above, I can initialize the barbershop using the NPC Poach Clipperson, an orc with a menu that sends you to the barbershop chair. I define the initialize function using insert_into_map_init( 1, Barbershop_Initialize ), and use this initialize script in the barbershop script. The creature spawns, gameobjects spawns, and map initialize script ends up looking like this:
In order to accomplish the goal of making the encounters and raids use the WoW function names. Functions like GetUnitByID(34816) and SendGameObjectAnim( 15267, “Open”, 1 ) don’t exist within Garry’s Mod. My solution was simple: make a script with WoW’s function names, and make the GMod equivalent functions. A basic example is getting the player’s health. In WoW, GetHealthPct() is used. In GMod, Health() is used. The solution is to make functions like following.
I did this for the functions relevant to my objective.
Raid – Trial of the Crusader
Since TotC is my favorite raid, I wanted to make that. The arena’s gameobjects are complete, main NPCs like Tirion, Garrosh, Thrall, and Varian Wrynn are in place. For the script, the goal was to make it as if it were a WoW script, using WoW’s functions. Using the function equivalent script from earlier, I made my (incomplete) version of TotC.