Need help withan ending

Iceblade

Admiral
Right now here is the code. And Problem 1 is how to get this thing to end. And behind curtain no. 2 is problem 2 with was the on earth is a jump buoy, it is not a ship or a navpoint. For the ending just protect Midway and ensure destruction of the 2 capships. Also with the usual bonus-or not so bonus-objectives.
mission s0;

#include wcp, consts, pilots, utils;
#strings targetid;
#SetOutputPath("$wcso$\mission\");

object Nav1(Navpoint)
x:0;
y:0;
z:0;
main: M_Nav1;
navdata: 1, 10000;
end;

object Jump1();
x:1222;
y:222;
z:51;
main: M_Jump1;
targstr: targetid["Jump Buoy"];
end;

object Alpha1(Player)
obj: panthrbl;
x: 0;
y: 100;
z: 0;
main: M_Alpha1;
pilot: PILOT_Casey1;
targstr: targetid["Alpha 1"];
end;

object Stiletto(ship)
obj: panthrbl;
x: 240;
y: 340;
z: 110;
main: M_Stiletto;
pilot: 45;
targstr: 1;
end;

object Amazon(ship)
obj: panthrbl;
x: 300;
y: 100;
z: 400;
main: M_Amazon;
pilot: 1;
targstr: 1;
end;

object Maestro(ship)
obj: Shrike;
x: 200;
y: 100;
z: 120;
main: M_Maestro;
death: M_FDeath;
pilot: 22;
targstr: 1;
end;

object Ace(ship)
obj: AAceShip;
x: 2650;
y: 10;
z: 340;
main: M_Ace;
death: M_Death;
pilot: 95;
end;

function M_Death;
begin
m_AliveEnemies := m_AliveEnemies - 1;
m_DeadEnemies := m_DeadEnemies + 1;
end;

object Moray1(ship)
obj: Moray;
x: 2650;
y: 10;
z: 40;
main: M_Moray1;
//death: M_MDeath;
pilot: 110;
end;

object Manta1(ship)
obj: MANTA;
x: 2678;
y: 100;
z: 445;
main: M_Manta1;
pilot: 107;
end;

object Manta2(ship)
obj: MANTA;
x: 2667;
y: 290;
z: 50;
main: M_Manta2;
pilot: 108;
end;

object Manta3(ship)
obj: MANTA;
x: 2654;
y: 0;
z: 45;
main: M_Manta3;
pilot: 109;
end;

object Midway(Capship)
obj: Midway;
x: 0;
y: 0;
z: 0;
main: M_Midway;
pilot: PILOT_TCS_Midway;
direction: 0, 0, 0;
targstr: targetid["Midway"];
end;

object Destoryer(Capship)
obj: Orca;
x: 2340;
y: 555;
z: 108;
main: M_Orca;
pilot: 121;
direction: 0, 0, 0;
targstr: targetid["Orca"];
end;

object Cruiser(Capship)
obj: Hydra;
x: 6640;
y: 555;
z: 108;
main: M_Hydra;
pilot: 121;
direction: 0, 0, 0;
targstr: targetid["Hydra"];
end;

function M_Alpha1;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
SF_ActivateSelf(0);
SF_PlayerSwitchToCam(CamID_cockpit, Alpha1);
while(1) do
AI_WaitSeconds(1);
end;

function M_Stiletto;
begin
AI_AddToWing(Alpha1);
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
SF_ActivateSelf(0);
while(1) do
AI_WaitSeconds(1);
end;

function M_Amazon;
begin
AI_AddToWing(Alpha1);
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
SF_ActivateSelf(0);
while(1) do
AI_WaitSeconds(1);
end;

function M_Maestro;
begin
AI_AddToWing(Alpha1);
SF_SetObjectFlag (OF_alignment,ALIGN_Confed); //sets the player to confed alignment
SF_ActivateSelf(0);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Ace;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
m_AliveEnemies := 1;
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Moray1;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
//m_AliveEnemies := 1;
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Manta1;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Manta2;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Manta3;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Jump1;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Neutral);
SF_ActivateSelf(1);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Midway;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Orca;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Hydra;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_FDeath;
begin
end;

function M_FMain;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Confed); //sets the player to confed alignment
SF_ActivateSelf(0);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_FSpawn(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(shipId, 146, 0, @M_FMain, @M_FDeath, ox, oy, oz);
AI_WaitMilliseconds(275);
count := count - 1;
end;
end;

function M_Nav1;
begin
Nav_ActivateSelf;
SF_ActivateObject(Midway, 0);
SF_ActivateObject(Destoryer, 1);
SF_ActivateObject(Cruiser, 0);
while(1) do begin
AI_WaitSeconds(1);
until(m_AliveEnemies = 0) do
begin
AI_WaitSeconds(1);
end;
M_Spawn(2,15,3450,640,233);
M_Spawn(30,8,4450,640,233);
M_Spawn(11,6,6000,640,233);
M_FSpawn(17,3,0,0,-134);
M_FSpawn(20,3,0,0,-120);
M_Spawn(9,6,6000,650,233);
end;
end;

function MAIN;
begin
MS_RunSpaceFlight(0);
//M_WaitUntilDead;
//SF_ObjectiveSetTotalNeededForSuccess(2, 13);
//MS_MissionSuccess;
//SF_Exit;
//BRIEF_Exit;
//GF_Exit;
end;
 
A buoy is a buoy, of course. That's its object type :p. Also, it doesn't actually need a main function (but it doesn't mind having one).

As for the mission having no end:
Code:
function M_Nav1;
begin
  Nav_ActivateSelf;
  SF_ActivateObject(Midway, 0);
  SF_ActivateObject(Destoryer, 1);
  SF_ActivateObject(Cruiser, 0);
  while(1) do begin
    AI_WaitSeconds(1);
    until(m_AliveEnemies = 0) do
    begin
      AI_WaitSeconds(1);
    end;
    M_Spawn(2,15,3450,640,233);
    M_Spawn(30,8,4450,640,233);
    M_Spawn(11,6,6000,640,233);
    M_FSpawn(17,3,0,0,-134);
    M_FSpawn(20,3,0,0,-120);
    M_Spawn(9,6,6000,650,233);
  end;
end;

"While (1)" is an expression that has no end. You need one of these in the navpoint's main function, because if you don't have one, the navpoint's function will finish and the game will be confused. However, you are also spawning ships inside this expression. In short, while 1 is 1 (always), the game will wait until there are no enemies left, then spawn a new bunch, and get back to waiting for everybody to die.
Incidentally, this also means that the mission will almost certainly crash sooner or later, because if the player does his job right, at least one or two more friendlies will survive each wave, and eventually there will be so many ships that the game will crash.

As for objectives, you need to declare them (kinda like objects - see the various WCPPas help pages), and then you need to actually trigger their completion and stuff.
 
Well I got it to end, but it has never crashed by an overflow and there has been no overflow of enemies besides the ones I spawned.
 
Thank you Quarto. Now there is another problem that I didn't mention before. This mission is requesting the hydra ship iff. This may make some since except for the fact that the other capship, the Orca, doesn't require this. Quarto, any ideas? :(
 
There is no "hydra.iff". Try "marlin" and "nautilus"... one of those is the Hydra, and the other is the Leviathan, IIRC.
 
Yeah, a Hydra is actually a Marlin. The Leviathan is the Osprey.

So what's the Nautilus? It's the science vessel in the WCP intro. But I wouldn't advise using it, because its collision trees are worse than useless.

As for the buoy, I made a mistake - the type should be jumppoint.
 
Mission Accomplished

2 dead caps and a heavily damaged Midway.

Thanks guys, now I have the basics and in a few weeks should be able to do comms, more than 2 navs, TCIS briefings for simulators, etc.

Here is another problem I have though. I can auto to nav 2 but can't auto to the next nav.



mission s0;

#include wcp, consts, pilots, utils;
#strings targetid;
#SetOutputPath("$wcso$\mission\");

object Nav1(Navpoint)
x:0;
y:0;
z:0;
main: M_Nav1;
navdata: 1, 5000;
end;

object Nav2(Navpoint)
x:10000;
y:10000;
z:10000;
main: M_Nav2;
targstr: targetid["Nav_2"];
navdata: 1, 5000;
end;

object Nav3(Navpoint)
x:20000;
y:20000;
z:20000;
main: M_Nav3;
navdata: 1, 5000;
end;


object Player(Player)
obj: panthrbl;
x: 0;
y: 100;
z: 0;
main: M_Player;
pilot: PILOT_Casey1;
targstr: targetid["Alpha 1"];
end;

function M_Player;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
SF_ActivateSelf(0);
SF_PlayerSwitchToCam(CamID_cockpit, Player);
while(1) do
AI_WaitSeconds(1);
end;

function M_Nav1;
var
setup = true;
begin
while(1) do begin
if (NAV_WithinSphere(Player)) then begin
NAV_ActivateSelf;
setup := false;
end;
NAV_SetPlayerNav(2);
while(NAV_WithinSphere(Player)) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);
end;

function M_Nav2;
var
setup = true;
begin
while(1) do begin
if (NAV_WithinSphere(Player)) then begin
NAV_ActivateSelf;
setup := false;
end;
NAV_SetPlayerNav(3);
while(NAV_WithinSphere(Player)) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);
end;

function M_Nav3;
var
setup = true;
begin
while(1) do begin
if (NAV_WithinSphere(Player)) then begin
NAV_ActivateSelf;
setup := false;
end;
NAV_SetPlayerNav(1);
while(NAV_WithinSphere(Player)) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);
end;

function MAIN;
begin
MS_RunSpaceFlight(0);
end;
 
Uh! Help! I need a basic example of an objective like defend a ship or ensure destruction of or something like that. Just something I can use as an example.
 
Iceblade said:
Here is another problem I have though. I can auto to nav 2 but can't auto to the next nav.
It's quite beyond me why you could even auto to nav 2 :p. Copying and pasting from the thread in the UE forum:

You've got all three navpoints using the same actionsphere. The line:

navdata: 1, 5000;

The second number is the diameter, so it can be identical for all navpoints. The first number is the actionsphere. The first navpoint should be 1, and the rest should increase sequentially from there.

Uh! Help! I need a basic example of an objective like defend a ship or ensure destruction of or something like that. Just something I can use as an example.

objective mobj_Defend
hidden: false;
type: MOBJ_Primary;
text: objectiv["Defend the Midway"];
status: MOBJ_Incomplete;
counter: false;
end;

Then you need to check when the conditions are fulfilled - presumably, this would mean that all the hostiles have been killed around the Midway, and the Midway is still alive. When these conditions are true:
SF_ObjectiveSetComplete(mobj_defend);
And, if that's the only objective, also use:
SF_SetMissionSuccess;

These commands can go in any ship or navpoint function.

BTW, I strongly recommend that you look through wcp.pas in the \lib folder. This file contains every (known) valid function. So, if you want to experiment a bit more with objectives, for example, just look up all the available SF_Objective functions.
Also, keep in mind that a mission which is not a success is by default not a failure. Unless you use the SF_SetMissionFailure command, the mission will be treated as incomplete - an example of this is the mission in WCP where Hawk disables your flight recorder.
 
Now it is time to Praise Quarto

HAHAHAHAHA!

Thank you very much. Given a very short period of time I should have one h##l of a mission. Thank you and the others who have helped. If anyone requires assistance, just post a thread and we will provide help. Happy programming!
 
Iceblade said:
HAHAHAHAHA!
Uh, ok... evil-sounding laugh is not exactly the response I was expecting, but I guess you're not about to destroy the Earth or anything, so I'll let it slide :p.
 
What? :confused:
Ummm!!
Hahahaha wasn't meant as an evil laugh but as a chuckle or a "friendly" type laugh. Sorry if you got the wrong idea.
 
AAAARGHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!! :mad: :mad: :mad:
THIS CODE ISN"T CO-OPERATING!!

Auto will not work to nav2, the mission succeeds and exits before all spawned enemies are dead-problem I think in nav1 function. Take note that the M_Spawn and M_Waituntildead ruotines are the same as those in utils.pas. NEED ASSISTANCE-God this is getting rediculous, I thought the hard part was over. Is this how the objectives are supposed to be done.


mission s1;

#include wcp, consts, pilots, utils;
#strings targetid;
#SetOutputPath("$wcso$\mission\");

object Nav1(Navpoint)
x:0;
y:0;
z:0;
main: M_Nav1;
navdata: 1, 10000;
end;

object Jump1(Jumppoint)
x:1222;
y:222;
z:51;
main: M_Jump1;
targstr: targetid["Jump Buoy"];
end;

object Nav_2(Navpoint)
x:23000;
y:23000;
z:233;
Main: M_Nav2;
navdata: 2, 13000;
end;

object Alpha1(Player)
obj: panthrbl;
x: 0;
y: 100;
z: 0;
main: M_Alpha1;
pilot: PILOT_Casey1;
direction: -255,0,0;
targstr: targetid["Alpha 1"];
end;

object Stiletto(ship)
obj: panthrbl;
x: 240;
y: 340;
z: 110;
main: M_Stiletto;
pilot: 45;
targstr: 1;
end;

object Amazon(ship)
obj: panthrbl;
x: 300;
y: 100;
z: 400;
main: M_Amazon;
pilot: 1;
targstr: 1;
end;

object Maestro(ship)
obj: Shrike;
x: 200;
y: 100;
z: 120;
main: M_Maestro;
death: M_FDeath;
pilot: 22;
targstr: 1;
end;

object Ace(ship)
obj: AAceShip;
x: 2650;
y: 10;
z: 340;
main: M_Ace;
death: M_Death;
pilot: 95;
end;

function M_Death;
begin
m_AliveEnemies := m_AliveEnemies - 1;
m_DeadEnemies := m_DeadEnemies + 1;
end;

object Moray1(ship)
obj: Moray;
x: 2650;
y: 10;
z: 40;
main: M_Moray1;
//death: M_MDeath;
pilot: 110;
end;



object Manta1(ship)
obj: MANTA;
x: 2678;
y: 100;
z: 445;
main: M_Manta1;
pilot: 107;
end;

object Manta2(ship)
obj: MANTA;
x: 2667;
y: 290;
z: 50;
main: M_Manta2;
pilot: 108;
end;

object Manta3(ship)
obj: MANTA;
x: 2654;
y: 0;
z: 45;
main: M_Manta3;
pilot: 109;
end;


object Midway(Capship)
obj: Midway;
x: 0;
y: 0;
z: 0;
main: M_Midway;
pilot: PILOT_TCS_Midway;
direction: 0, 0, 0;
targstr: targetid["Midway"];
end;

object Destoryer(Capship)
obj: Orca;
x: 2340;
y: 555;
z: 108;
main: M_Orca;
pilot: 121;
direction: 0, 0, 0;
targstr: targetid["Orca"];
end;

object Cruiser(Capship)
obj: Marlin;
x: 6640;
y: 555;
z: 108;
main: M_Hydra;
pilot: 121;
direction: 0, 0, 0;
targstr: targetid["Hydra"];
end;



function M_Alpha1;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
SF_ActivateSelf(0);
SF_PlayerSwitchToCam(CamID_cockpit, Alpha1);
while(1) do
AI_WaitSeconds(1);
end;

function M_Stiletto;
begin
AI_AddToWing(Alpha1);
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
SF_ActivateSelf(0);
while(1) do
AI_WaitSeconds(1);
end;

function M_Amazon;
begin
AI_AddToWing(Alpha1);
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
SF_ActivateSelf(0);
while(1) do
AI_WaitSeconds(1);
end;

function M_Maestro;
begin
AI_AddToWing(Alpha1);
SF_SetObjectFlag (OF_alignment,ALIGN_Confed); //sets the player to confed alignment
SF_ActivateSelf(0);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Ace;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
m_AliveEnemies := m_AliveEnemies + 1;
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Moray1;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
//m_AliveEnemies := 1;
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Manta1;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Manta2;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Manta3;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
SF_ActivateSelf(1);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Jump1;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Neutral);
SF_ActivateSelf(1);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Midway;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Confed);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Orca;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_Hydra;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Alien);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_FDeath;
begin
end;

function M_FMain;
begin
SF_SetObjectFlag (OF_alignment,ALIGN_Confed); //sets the player to confed alignment
SF_ActivateSelf(0);
while(1) do begin
AI_WaitSeconds(1);
end;
end;

function M_FSpawn(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(shipId, 146, 0, @M_FMain, @M_FDeath, ox, oy, oz);
AI_WaitMilliseconds(275);
count := count - 1;
end;
end;
objective mobj_Defend
hidden: false;
type: MOBJ_Primary;
text: 1;
status: MOBJ_Incomplete;
counter: false;
end;
function M_Nav1;
var
setup = true;

begin

while(1) do begin
if (NAV_WithinSphere(Alpha1)) then begin
Nav_ActivateSelf;
SF_ActivateObject(Midway, 0);
SF_ActivateObject(Destoryer, 1);
SF_ActivateObject(Cruiser, 0);
while(1) do begin
AI_WaitSeconds(1);
until(m_AliveEnemies = 0) do
begin
AI_WaitSeconds(1);
end;
M_FSpawn(17,3,0,0,-134);
M_FSpawn(20,3,0,0,-120);
M_Spawn(2,15,2100,640,233);
M_Spawn(30,8,6650,640,233);
M_Spawn(11,6,6600,640,233);
setup := false;

if(M_WaitUntilDead)
then
SF_ObjectiveSetComplete(mobj_defend);
SF_SetMissionSuccess;
SF_Exit;
end;
end;
end;
while(NAV_WithinSphere(Alpha1)) do begin
NAV_SetPlayerNav(2);
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);

function M_Nav2;
var
setup = true;
begin
while(1) do begin
if (NAV_WithinSphere(Alpha1)) then begin
Nav_ActivateSelf;
M_Spawn(2,17,12000,1000,2330);
M_Spawn(30,10,11000,1200,2333);
end;
while(NAV_WithinSphere(Alpha1)) do begin
NAV_SetPlayerNav(1);
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);
end;

function MAIN;
begin
MS_RunSpaceFlight(0);
end;
 
Eder and the funny Simpsons guy will help you, don´t worry. :)

BTW, I don´t know if you saw my post in the other thread, Eder needs some help to code some missions for a SO mod he is developing, called Standoff. Looks like you know some programming, perhaps you can help him...?
 
It is a Capship mission that puts you through your pases in destorying torps and bombers with a heavy escort. Unfortunatly his objectives and ending are non-existant and this mission needs a lot of work to get it to work.

Objectives-primary is to ensure destrution of Cruiser and Destoryer and defend the Midway
secondary-ensure that the Midway recieves no damage and take out the incoming strike force at Nav2
bonus-kill AlienAce pilot, destory 50% of fighters and 75% of bombers

Good luck getting it to work! ;)

Starkey, I am already going to help with Standoff, but I need to get a good mission going first.
 
Back
Top