From Mods Repository Wiki
Payload is a Co-op mod of the Seelow level from the Singleplayer/Co-op campaign. Players must push a tractor along a path to secure it into the farm, after which, a surprise ending ensues.
It's a simple and short mod, but demonstrates how a SP/Co-op map + mod works on a technical level via the source files, how to set it up via the structure of those files, and how to run a SP/Co-op map + mod.
How To Run It
When you start Launcher, you should see Payload listed in the map list. On the compile level options check:
Compile BSP Compile Lights Connect Paths Compile Reflections Build FastFiles Run Map After Compile
Then proceed to click the Compile Level button, Launcher will go through the process of compiling the map and preparing it to be played in-game. At the end of the process, the map will automatically launch for you to play.
How It Works
All functions below are found in payload.gsc in raw\maps.
Payload starts off by assigning players classes and specific weapons per those classes. In the level script there are Co-op Callback functions defined at the bottom, the one in particular we're looking at is onPlayerSpawned(). This function makes a call to onPlayerSpawned_ChooseClass() with the player owning the function which determines their class and gives them a load out.
There is a similar class system for the AI which micromanages how the AI normally would react since this is a mod after all. The high level function is chooseClass( howManyCanSpawn, eLocos ). Inside, classes are defined and randomly assigned to an AI as they spawn, based upon their class, the script then finds the best suitable spawner based on their class weapon since we are changing weapons on the fly and do not want AI using flamethrower animations for firing a MG42. npcClassInit( classToSpawn, weapon ) then takes that AI and adjusts their attributes and micromanages how they act in the map.
A humorous element was added that makes AI go flying into the air when their dead. This was achieved by forcing them into ragdolls on their death notification and calling a physics explosion sphere on their origin. The function is called flyingBodies().
Originally the Payload was a jeep that clamped to the ground better, but going with the whole farm idea the vehicle jeep was switched to a script_model Tractor. The path consists of a series of script_structs, and is built in script using getGoals() function. The tractor has a trigger_radius that is always moves with the Tractor handled by payload_trig_update() function. payload_movement() detects if a player is touched the trigger_radius, then detects how many, and moves the Tractor to speed * amount of players.
Those things falling from the sky in the map, those are cows, and they splash milk when they land. cowThink() is the high level function that is parents from triggers in the map. The triggers are targeted to a script_struct in the sky, which is the spawn location for the cow. The spawn location in the sky is then targeted to a script_struct on the ground for where the cow will fall to. When the cow hits the ground a milky splash plays and any players within a radius of the splash get drips on their screen.
This was a cute idea that had to get cut unfortunately but the script is still there. Throughout the map planes would fly by in the sky dropping dogs in chutes to attack the players. This was a bit more dynamic than the cow mortars in that the dogs spawn from the plane at a random time, a bullet trace is done from the dog to the ground, and the dog chutes down to that position which is handled by the parachuteThink( goal ) function.
dogChuteThink() is the high level function for how the dogs are handled. The parachute plays an animation while in the sky, and plays another animation when the dog reaches the ground. The DogSplat( anchor, harness ) function checks for whether the dog takes a bullet while in the air, and if so, the chute breaks dropping the dog to its death.
The end surprise when you get the Payload to the tractor is to destroy 30 zombies before the timer runs out. The timer is handled by zombTimer() function, the amount of time changes dependent upon how many players there are. BarnSpawn() is the high level function that spawns the Zombies continuously, this is a modification of Nazi Zombie in that there are 30 zombies rushing you in a running motion.
Map Source & Scripts
Bessie.map is a portion of the Seelow map and campaign level in the game. This section was used because it provided a nice linear path for the Payload to move and provided spawn locations for the enemies along the way (houses, shacks, hay stacks, etc...).
Payload.map is the script layer that has the spawners, triggers, nodes, and other important entities that make it function properly.
payload.gsc is the actual script that contains all the functions discussed on this page. The script handles the AI in the map, as well as the Co-op call backs.
Sources: Treyarch's Wiki