Need help withan ending

:D :D Well. I guess it crashed on you so try this end code. Also // out object nav2. Changed the code, this should work.

//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;
end;
end;

//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);
end;

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 said:
And why would anyone take you seriously now, with an avatar like that? :D
Yeah, screw you, buddy :).
I still need to come up with a more interesting title, though.

Iceblade, if you tell the game to exit the mission after all the enemies are dead, why are you surprised when it actually does it?
 
I only manage to kill a few of the Spawned enemies. I am trying to get it to end when all enemies-spawned included-are dead.
 
Hmm. Here's a piece of your code:
Code:
if(M_WaitUntilDead)
then
M_WaitUntilDead is a function that simply orders the game to wait until all enemies are dead, but does not return any output. So, let's imagine for a moment how the game might react to this piece of code:
Is M_WaitUntilDead true?
Err. Uhm.
Well, it's not false.
Ok. So... all right, sure, it's true.


...Get my point? :p You're trying to get output from a function which is not designed to give any output. Most likely, the function you wanted to use was M_EnemiesDead, which does indeed produce true or false output depending on the status of the enemies.
 
Replacing the code M_WaitUntilDead with M_EnemiesDead doesn't work, but the code still needs some fine toneing for Nav1. I will work on that tommorrow or much later today for it is nearly 0100 in Mobile.
 
I also need help getting nav2 to work.

object Nav_2(Navpoint)
x:23000;
y:23000;
z:233;
Main: M_Nav2;
navdata: 2, 13000;
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_EnemiesDead)
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;
 
Ok, I'm out :p You've added too much stuff at a time, I can't even think of where to look for a bug first.

Your navpoint functions are certainly messed up, though... You're still forgetting to check wheter setup is true before doing all the setup stuff, so your functions are still running over and over. And it looks like your Nav2 is trying to spawn constant enemies. You should spawn enemies depending on time or on the current enemy count, but instead you've just placed the spawn functions inside a loop that's always running. No good. It'd take a while to sort thru all the rest of that code, though, so you'll just have to hope Quarto is feeling lucky today (tonight?).
 
What's exactly the problem? I've seen something:

First, you have:

if(M_EnemiesDead)
then
SF_ObjectiveSetComplete(mobj_defend);
SF_SetMissionSuccess;
SF_Exit;
end;

in nav1. Shouldn't you use "then BEGIN"? Maybe it's not necessary (I don't know much Pascal). :p
 
Ouch. Good point, Ronald. You should use begin and end; whenever there is more than one function to be executed after the if. If it's just one function, you can do something like...

if (condition) then function;

Otherwise, you need this:

if (condition) then begin
function1;
function2;
function3;
end;
 
Guys, these thing is probably getting extremely screwed. And to avoid clogging up all of the bandwidth, I am going to use e-mails to get these problems solved.
 
OOOOOOOOOOPPPPPPPPPPPPSSSSSS!!!!!!!!!!! :eek: :eek: :eek: :eek:
Sorry! Didn't see this post When I wrote the e-mail. I won't do it again. (Unless the whole code is the problem :D )
 
Error 1: the spawning has now gone to constant loop now and then it crashes. Why-the loop functions are now gone?
It crashes because you get too many fighters out there. With a constant loop, fighter saturation levels can be reached pretty fast. And the reason why it does that is...

Code:
until(m_AliveEnemies = 0) do begin
  AI_WaitSeconds(1);
  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;
end;
...Just how do you expect this loop to work? Keep spawning enemies until m_AliveEnemies = 0? :p Also, "setup := false;" does absolutely nothing in this case, because you never checked if setup is true in the first place.

Error2: The navs at least now work except when I go to the next nav it gives and error. Yet for some strange reason the enemy now just sit there, like they haven't been actviated-at least not until I shoot them to kingdom come.
No idea.

Lastily the age old to fast with objective complete - I think
That's cause you're not paying attention - this problem has already been solved in this thread, three or four posts ago :p.
Code:
if(M_EnemiesDead)
then
   SF_ObjectiveSetComplete(mobj_defend);
   SF_SetMissionSuccess;
   SF_Exit;
There is no "begin...end" loop here. Only the ObjectiveSetComplete function is bound to the "if" statement. The remaining two functions have no conditions attached to them, so they'll happen regardless of whatever else is going on. Keep in mind that this won't fix the mission entirely. Even after you put it all in a begin...end loop, there will be a problem because m_EnemiesDead will be true before the player visits Nav 2, and consequently the mission will end before he can go there.

Also, you've put the NAV_SetPlayerNav(2) command in the wrong place. This command sets the player's autopilot destination, but in your code, it only happens _after_ the player is no longer within the navpoint's actionsphere.
 
It will not compile with alot of begins and ends everywhere-where you said to put them and other places. Like before

objective mobj_Defend
hidden: false;
type: MOBJ_Primary;
text: 1;
status: MOBJ_Incomplete;
counter: false;
end;

It says it is looking for a <declaration> or an end;. I put one there and it still is unhappy.
 
No, no... for object declarations (ships, objectives, navpoints et cetera), you don't need a 'begin'. Where you need it is the 'if...then' loop. Like this:

Code:
if(M_EnemiesDead)
then begin
   SF_ObjectiveSetComplete(mobj_defend);
   SF_SetMissionSuccess;
   SF_Exit;
end;

If you're still having trouble, you probably changed something that was already working. Happens a lot in debugging, actually. Try to find the problem yourself, if possible - programming WCP missions, in my experience, is 25% about coding, and 75% about fixing your own screwups ;).
 
Right! So how does it look so far? Could you tell me how many begin and ends are needed-it anymore?

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);
until(m_DeadEnemies = 6) do begin
AI_WaitSeconds(1);
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);
end;
if (setup) then begin
setup := false;
end;


NAV_SetPlayerNav(2);
until(NAV_WithinSphere(Alpha1)=false) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
AI_WaitSeconds(1);
if(M_enemiesdead)
then begin
SF_ObjectiveSetComplete(mobj_defend);
SF_SetMissionSuccess;
SF_Exit;
end;
end;

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);
if (setup) then begin
setup := false;
end;

NAV_SetPlayerNav(1);
until(NAV_WithinSphere(Alpha1)=false) do begin
AI_WaitSeconds(1);
end;
NAV_DeactivateSelf;
end;
end;
end;
 
No, but WCPPas could. What does it say when you compile the mission? If there's an error, you just gotta look at the problematic line and work backwards from there.

I can tell you, however, that you're still using the setup variable incorrectly. The point of using a variable like this (for the record, there's nothing magical about the name 'setup', so feel free to call it whatever else you like) is to have events happen only once. When the mission begins, the variable is created and set to true. So, when you get to the navpoint, you have an 'if...then' statement, and everything that needs to only happen once at that navpoint happens inside that statement. At the end of the statement, you set setup to false. That way, even if the player revisits the navpoint, that particular statement does not get triggered.
 
Again, I think you've tried to do too much at the same time, so now it's impossible to list all the screw ups, because it's impossible to tell what we're fixing and what we're making even worse. If I were you, I'd start over with some more organized code, adding one thing at a time, and always testing to see that it works out.

Also...
Quarto said:
I can tell you, however, that you're still using the setup variable incorrectly.
 
Back
Top