Wcppas sample mission code

--------------------------------------------- 
mission s0; // S0 = Slot 0 on the sim

#AddToSearchPath ("$soscr$"); // SO path
#AddToSearchPath("$wcso$\language\"); // SO /language path
#sector: "a.sec"; //sector file
#include wcp;
#include consts; //wcppas constants list
#include comms; //comms files
#include pilots; //pilots list
#include ships; //ships list


#strings spacefli; // spacefli.eng
#strings targetid; // targets id

#SetOutputPath ("$wcso$\mission\"); // output path

object Nav1(Navpoint) //navpoint
x: 500; // x coord
y: 200; // y coord
z: 1000; // z coord
main: M_NAV1; // navpoint main function
name: Spacefli["Nav 1"]; // points to a string on spacefli.eng
navdata: 1, 30000; // nav id, diameter
end; / /end object function

object Nav2(Navpoint)
x: -1000;
y: 0;
z: 62000;
main: M_NAV2;
name: Spacefli["Nav 1"];
navdata: 2, 30000;
end;

object Nav3(Navpoint)
x: 80000;
y: 40000;
z: -62000;
main: M_NAV3;
name: Spacefli["Nav 2"];
navdata: 3, 30000;
end;

object Nav4(Navpoint)
x: 80000;
y: -20000;
z: -62000;
main: M_NAV4;
name: Spacefli["Nav 3"];
navdata: 4, 30000;
end;

object Wingman_1(Ship) //wingman
obj: panther; //wingman ship
x: 200; // x coord
y: 600; // y coord
z: 1200; // z coord
main: M_Wingman; // wingman main function
targstr: targetid["Alpha 2"]; // points to a string in targetid.eng
pilot: Pilot_Veil; // pilot
end; // end object function

object Wingman_2(Ship)
obj: panther;
x: 400;
y: 600;
z: 1200;
main: M_Wingman;
targstr: targetid["Alpha 3"];
pilot: Pilot_Foxtrot;
end;

object Wingman_3(Ship)
obj: panther;
x: 400;
y: 600;
z: 1200;
main: M_Wingman;
targstr: targetid["Alpha 4"];
pilot: Pilot_Maestro;
end;

object Player(Player) // player function, indispensable
obj: panther; // player ship
x: 300; // x coord
y: 400; // y coord
z: 1200; // z coord
main: M_Player; // player main function
pilot: Pilot_Casey1; // pilot
end; // end object function

// ********** BEGIN Spwaning Routines for Alien **********

function M_SpawnNearObjectAlien(shipId, count, obj); forward;

var
m_AliveAliens,
m_DeadAliens;

function S_Alien;
begin
SF_SetObjectFlag(OF_alignment,
ALIGN_ALIEN);
SF_BindToActionSphere(0);
SF_ActivateSelf(0);
m_AliveAliens := m_AliveAliens + 1;

while (1) do
AI_WaitSeconds(1);
end;

function S_AlienDeath;
begin
m_DeadAliens := m_DeadAliens + 1;
end;

function M_SpawnAlien(shipId, count, x, y, z);
var
ox, oy, oz;
begin
while(count > 0) do begin
ox := x + SYS_Random(600) - 300;
oy := y + SYS_Random(600) - 300;
oz := z + SYS_Random(600) - 300;

NAV_CreateShip(2, PILOT_Confed, 0, @S_Alien, @S_AlienDeath, ox, oy, oz);
AI_WaitMilliseconds(275);
count := count - 1;
end;
end;

function M_SpawnNearObjectAlien(shipId,
count, obj);
var
x, y, z,
ox, oy, oz;
begin
x := SF_GetXObj(Player);
y := SF_GetYObj(Player);
z := SF_GetZObj(Player);

while(count > 0) do begin
ox := x + SYS_Random(600) + 500;
oy := y + SYS_Random(600) + 500;
oz := z + SYS_Random(600) + 500;

NAV_CreateShip(shipId, PILOT_Alien1, 0, @S_Alien, @S_AlienDeath, ox, oy, oz);
AI_WaitMilliseconds(275);
count := count - 1;
end;
end;

function M_CountAliens;
begin
Result := m_AliveAliens - m_DeadAliens;
end;

function M_WaitUntilDeadAlien;
begin
until(m_DeadAliens = m_AliveAliens) do
AI_WaitSeconds(1);
end;
// *********** END Spwaning Routines for Alien ***********


function M_NAV1; // nav1 main function
var
setup = true;
begin
while(1) do begin
if (NAV_WithinSphere(Player)) then begin
NAV_ActivateSelf; // if player within nav1 sphere, activate it
AI_WaitSeconds(1);
NAV_SetPlayerNav(2); // set new autopilot coords
while(NAV_WithinSphere(Player)) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf; //deactivate navpoint
end;
AI_WaitSeconds(1);
end;
end;

function M_NAV2;
begin
while(1) do begin
if (NAV_WithinSphere(Player)) then begin
NAV_ActivateSelf;
M_SpawnNearObjectAlien(SHIP_Moray, 3, Player);
//spawn rotine (shipid, number, spwan near ship)
NAV_SetPlayerNav(3);
while(NAV_WithinSphere(Player)) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);
end;
end;

function M_NAV3;
begin
while(1) do begin
if (NAV_WithinSphere(Player)) then begin
NAV_ActivateSelf;
AI_WaitSeconds(1);
M_SpawnNearObjectAlien(SHIP_Manta, 3, Player);
NAV_SetPlayerNav(4);
while(NAV_WithinSphere(Player)) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);
end;
end;

function M_NAV4;
begin
while(1) do begin
if (NAV_WithinSphere(Player)) then begin
NAV_ActivateSelf;
AI_WaitSeconds(1);
M_SpawnNearObjectAlien(SHIP_AAceship, 3, Player);
M_WaitUntilDeadAlien; // wait until all enemies are dead
AI_WaitSeconds(4);
SF_SetMissionSuccess; // set the mission as a success
AI_WaitSeconds(4);
SF_Exit; // end the mission
while(NAV_WithinSphere(Player)) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);
end;
end;


function M_Wingman; //wingman main function
begin
SF_SetObjectFlag(OF_Alignment, ALIGN_CONFED);
//ship alignment (neutral, confed, alien, or evil-kilrathi)
AI_WaitSeconds(1);
SF_BindToActionSphere(0);
//navpoints where the player will appear (0=all)
SF_ActivateSelf(0);
AI_AddToWing(Player); // wing
while(1) do AI_WaitSeconds(1);
end;

function M_Player; //player main function
begin
SF_SetObjectFlag(OF_Alignment, ALIGN_CONFED); //alignment
SF_BindToActionSphere(0); // navpoint it will appear,always 0 (0=all)
SF_ActivateSelf(0); // automatic activate the object
while(1) do AI_WaitSeconds(1);
end;

function MAIN; // game main function
begin
MS_RunGameflow(0); // start gameflow
MS_RunSpaceflight(0); // start engine
end;
---------------------------------------------

Tutorial by KillerWave