Wing Commander: Unknown Enemy
Please do not look at test1.pas, an example mission which I have included until you have read and tried to understand the tutorial, it should be helpful learning the appropriate formatting.
This is the introductory set of instructions and task, nothing too complicated I promise. Before starting ensure that you have downloaded and installed WCP Pascal. You may also need vcl50.zip.
You can find WCP Pascal's homepage, which will include updates and documentation, here.
Place the file called cerberus.rom in a directory called \mission in our secret ops directory. This will turn the exit pod into a simulator, the simulator is a convenient means of mission testing, do not run in a resoloution about 640*480 as this patch will no work on other resoloutions.
Step 1: Set your Secret Ops directory
Open up WCP Pascal and select file and then settings, next type in the directory where Secret Ops is located.
Step 2: Disable the map
Select File, then Settings, then Plugins and uncheck the map.
Step 3: Save the file
You know the routine, click file then save as and pick a name :)
Step 4: Labeling your mission
The first thing you need to know about WCP Pascal is how to make annotations, for the compiler to skip a line when compiling (ie so its only there for your reference) is to place a '//' before whatever you want to type, anything on that line after the '//' is then
an annotation, for example:
// Sim Mission 1 - Kilrathi Gauntlet
Step 5: Naming your mission
The first thing that you want to do when creating a mission is to decide what its name should be after compiling, the line:
tells the compiler to name the file s0.mis when compiling. Notice the semi colon at the end of the line, in Pascal this semi colon is placed at the end of all statements. s0 is actually the name of simulator mission 0, s0-9 are the sim missions and therefore these names are good for testing missions without ICIS briefings.
Step 6: Specifiying the output directory
To save you copying and pasting your mission all of the time add the line:
This statement will place the mission into the mission directory
Step 7: Including other files
Lets keep this mission simple and therefore only include the very most basic of external files, wcp (the file which contains links to all the functions used by WCP) and comms (contains all the pilot communication information). The line is:
#include wcp, consts, pilots;
Now the setup for the mission is complete I will introduce some of the basics of mission programming.
Step 8: Creating objects
Objects are the basis of missions, without them no mission exists, there are only 3 types of object you should concern yourself with for the moment:
an objects creation will look something like this:
The first line will always take the form:
object 'nameofship'(object type)
so in the above example you are declaring an object of type ship named Alpha1
obj is the name of the model to use for this object, in the above example its using the Panther model. The objects available can be found in ship.pas
x, y and z are the position co-ordinates of the object, z axis is back and forth, y is up and down and x is left and right just like in most maths problems :)
main: This is the function called by the object when the object is first created, we'll cover functions a bit later.
death: This is the function to be performed on the destruction of the object, this is not a neccessary function and for most objects the line death: *death function name* can be ommited from the object decleration.
pilot: this is the pilot the object should have for comms, for a list of pilots please see the file pilots.pas in the lib directory in the WCP Pascal directory. The pilot can be referenced by either its name or number.
ONE player ship (no more) and atleast one navpoint MUST be present in all missions.
Navpoints have a seperate declaration which looks like:
main: M_Nav1 ;
navdata: 1, 5000;
where the first number following navdata is the nav point number and the second number is the radius of the navpoint.
Step 9: Functions
Functions are a marvelously simple concept, unfortunatley for the non programmers amoung you it
may be a little much to force on you the information of how to call functions from functions and pass variables between them for just now so we'll stick to the functions you will encounter right away in even the most simple of missions, these are the main and death functions which you name after main: and death: in each objects declaration, remember whilst objects can call the same function you can not have two functions (or objects) with the same name. So say we know want to code Alpha1s main function we write the code:
all functions take the form:
function *name of function*;
the while loop (which we will cover in the section on for, until and while loops in the next tutotrial) is in place to ensure that the end of the function is NEVER reached, as true (1) is the automatic result, the condition is always met and AI_WaitSeconds is performed forever, this is due to the way WCP works and this code MUST be placed at the end of every objects main function (but not death function, it is infact important that death functions do reach the end).
Important functions for the main function:
The functions built into WCP can be found in WCP.pas, there are several which must be present in order to activate all ships (these are not neccessary for the main functions of navpoints persay):
this line of code will set whose side the ship is on (can also use ALIGN_Kilrathi, ALIGN_Evil_Kilrathi or ALIGN_Alien)
This line will activate the ship, without running this code the ship will not be viewable in game. For a navpoint use:
So for example:
The function AI_WaitSeconds() does what you would expect, it causes the routine to wait the number of seconds in the brackets until it tries to run the next line of code.
Other functions can be found in wcp.pas
One function that must be present in EVERY function is MAIN, for now it doesn't need to be any more complicated than:
this can be placed at an early point in the code (preferably before the players function).
The player function needs to be perfect ofcourse so I'll provide that here (you will also find it in the example mission)
SF_SetObjectFlag (OF_alignment,ALIGN_Confed); //sets the player to confed alligment
SF_PlayerSwitchToCam(CamID_cockpit, Player);//Switch to player cockpit
while(1) do begin
Step 10: Variables and constants
For those of you who are not programmers: in WCP Pascal variables are basically just these things you can assign a number to at any point in a mission, they can be placed inside a function or outside (ones created inside a function can only be accessed from INSIDE that function, ie they can not be viewed when running any other function). To create a variable called aliendead create a new line:
Constants are similar however their value can not be changed, they are used to hold numbers which will be needed repeatedly during a mission), for example
const numberofships = 6;
creates a constant called number of ships, its value is always equal to 6.
T E S T Y O U R S E L F
Ok you should have all the files you need, your task is quite simple:
Create a mission similiar to test1.mis and get it to take up sim mission 1 (s1)
Place in the nav point 2 confed fighters, 1 kilrathi fighter, 1 hostile kilrathi fighter and 4 nephilim morays, get the ship names from ships.pas. Make sure that each of the ships has an appropriate pilot.
I know this is a simple task however with the information I have provided this is unfortunatley all you can do at this stage, fortunatley it will come VERY quickly now. Don't hesitate to e-mail me directly with questions, although I say the task is simple thats dependant on my having explained myself well, unlikely :P So don't feel worried about questions you think might be stupid, I asked a lot of questions myself at this stage. Send the code to me as soon as you are done or if you're stuck on it and can't find out what the problem is.
Wing Commander: Unknown Enemy