OP2 Mission Tutorial

From OPU Wiki

So you always wanted to make a new mission for OP2, but never knew how? Well now you can.

What you need to start

  • Microsoft Visual C++ 5 or 6
  • Outpost 2
  • Recent copy of the OP2 Mission SDK
  • OP2Mapper for editing terrain
  • Text Editor for making techtrees (notepad works)

Getting started

You do not necessarily need C++ experience to code OP2 missions. It's a nice thing to have but you don't need it. (Mission coding is not as hard as it looks. This article will try to tell you all you need in order to write good missions). However any programming or computer logic knowledge would be immensely helpful.

To get started, unzip the Mission SDK you downloaded to a folder, and make sure MSVC and OP2 are installed.

Go into the folder, then into the Multiplayer Hooville folder. Double click "OP2Script.dsw" to open the MSVC workspace for the project.

To compile the project, go to Build > Build All and wait a few moments. Once the compile has completed, go back to the folder and you should see a ReleaseMinSize folder, open that. Copy the OP2Script.dll to your Outpost 2 game folder. You have successfully compiled your first mission!

OP2 DLL Structure

Now on to explain how OP2 DLLs work. DLL files in Windows are really just big pieces of code with different parts, or functions that do a specific task. Many DLL's have thousands of functions, for example the core of Windows itself. In OP2 missions, there are specialized code functions that the game invokes in the mission DLL to perform a specific task. If you have ever worked with functions or procedures in other programming languages, or C++ even, DLL functions are identical, however other programs are allowed to use them. (Or you may have used them yourself in other languages)

In OP2 Missions there are DLL variables (pieces of data) in addition to code functions. These functions and data do things like telling the game what type of mission it is, what terrain map to use, what units exist, and much more. I'll go over each thing that all OP2 missions must have.

Note: From this point forward, I'll refer to DLL variables and functions as "exports" which is really the technical name for them.

  • DescBlock: This export tells OP2 what type of mission the DLL is. There are four fields that hold different vital pieces of data:

(See RequiredExports.h in the project for this)

// Structure for important data exports needed for OP2 to recognize the level
struct SDescBlock{
 int missionType;		// Mission type (defined above) or mission number (positive values) for campaign games
 int numPlayers;		// Number of players (on a multipalyer map)
 int maxTechLevel;		// Maximum tech level (Set to 12 to enable all techs)
 int boolUnitMission;		// Set to 1 to disable most reports (suitable for unit-only missions)
};
  • MapName: This export tells OP2 what .map file to use for the level terrain. You can create new .map files with the Map Editor, and distribute them with your level.
  • TechtreeName: This tells OP2 what tech tree data file to use for the level. For most colony games and multiplayer missions MULTITEK.TXT should be sufficient, tutorials use TUTORTEK.TXT, and campaigns use EDENTEK.TXT and PLY_TEK.TXT.
  • And that's enough for now... wait for the next installment =D
Personal tools