Using a trigger to exit and load a new mission
by David Dougher · in Torque Game Engine · 01/17/2002 (7:48 pm) · 7 replies
I'm working on a gate system for my game and I'm curious if anyone else is working on using triggers to exit one mission and load another. It initially seemed very straightforward and I'm certain that it is possible, but I'm trying to decide if I have to add a new client to server command to duplicate the actions of the disconnect() function or if someone has already gotten another client to server command to do the job of closing the old mission.
About the author
Owner - Pariah Games, Adjunct Professor - Bristol Community College, Mentor - Game Design - Met School Newport, Mentor - Game Design - Met School Providence
#2
01/18/2002 (10:35 pm)
You might run into trouble changing the mission from within the trigger callback because changing the mission will delete the trigger object. You should schedule a loadMission call and few ms in the future. You should be able to schedule loadMission() directly. You don't need any new functions or client-server commands, unless I'm misunderstanding what your trying to do.
#3
Hehe.. all fun!
Phil.
01/20/2002 (7:19 am)
Seems reasonable, only other issue is to get everything to freeze. I wonder if there's a "freeze everything while I load this mission" function.Hehe.. all fun!
Phil.
#4
I just want to make sure I close down the old mission properly. So, I was looking for a way to cleanly close the old mission. Mission closure now goes through a messagebox which brings up a dialog box. I want to eliminate the dialog box and transition to a new mission thru scripts only if I can. The reason for doing it this way is both for my game which may have several such transitions and to turn this into a tutorial that can be used by everybody - i.e. no code changes.
01/20/2002 (8:08 am)
Thanks for the help. I had planned on a screen effect to hide the transition. I figured loadmission() would not need any changes. And Tim's suggestion to use a delay to load a new mission makes a lot of sense. I just want to make sure I close down the old mission properly. So, I was looking for a way to cleanly close the old mission. Mission closure now goes through a messagebox which brings up a dialog box. I want to eliminate the dialog box and transition to a new mission thru scripts only if I can. The reason for doing it this way is both for my game which may have several such transitions and to turn this into a tutorial that can be used by everybody - i.e. no code changes.
#5
01/22/2002 (9:16 am)
How would the loadMission() call be "triggered"?
#6
06/02/2002 (2:06 pm)
*bump*
#7
What I have below works perfectly for either local or remote connections.
One thing I'm not sure of is whether resources are being released properly (i.e., I've come across missionCleanup code in some scripts). I think endGame does it but I'm not yet sure.
function clientCmdfireTarget(%trigger)
06/17/2002 (8:23 pm)
I got parts of this from fi Developer's webparser code and the GG clientConnection code as a starting point. I could not get the disconnect() to work properly in the local connect but it does work in the remote connect. What I have below works perfectly for either local or remote connections.
One thing I'm not sure of is whether resources are being released properly (i.e., I've come across missionCleanup code in some scripts). I think endGame does it but I'm not yet sure.
if((includedInString("localhost", %cleanurl)) ||
(includedInString("127.0.0.1", %cleanurl)))
{
$mission = nextToken(%cleanurl, %url, "@");
echo("---->mission = " @ $mission);
// The server isn't started unless a mission has been specified. This section handles local connections.
if ($mission !$= "")
{
endGame();
$Game::Schedule = schedule($Game::EndGamePause * 0, 0, "onLocalGameEnd");
}
else
{
echo("No mission specified (use -mission filename)");
}
}
else
{
//%password = nextToken(%cleanurl, server, "@");
//This section handles remote connection with no password
schedule(0,0, "Disconnect");
connect(%cleanurl, $Client::Password, $pref::Player::Name);
}I'm passing the url via a trigger (in server/scripts/triggers.cs) that sends the trigger data to a client command (in client/scripts/triggerClient.cs) which in turn calls the function above:function clientCmdfireTarget(%trigger)
Torque Owner David Dougher
Pariah Games