Restarting a Mission in Torque 3D
by Joshua Allison · in Torque 3D Beginner · 02/18/2010 (12:49 pm) · 6 replies
Hi I am looking for a way to restart a mission in torque 3D. In 1.5 i used loadMyMission() however that function doesnt appear to exsist in torque 3d. I did find a resetMission() burried in the GameCore.cs but using that function has resulted in nothing but failure. What I want to do is
function clientCmdShowVictory(%score)
{
echo("show victory called");
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
//Reset code here
quit());
}
I tried
loadMyMission(), // This failed of course with a 'unable to find function loadMyMission
resetMission(), // This failed with a "Unable to find object 'game' attempting to call 'onMissionReset'"
loadMission($server::filename), //This failed at the compiling of the function
I did track down the function resetMission its located at line 145-166 in scripts/server/GameCore.cs and reads as follows
//////////////////////////////////////////////////
function resetMission()
{
//echo("c4 -> resetMission() override success");
echo("*** MISSION RESET");
// Remove any temporary mission objects
//if (isObject(game)){ //Object Showed up here
// echo("Object Exsists");
//}
MissionCleanup.delete();
//if (isObject(game)){ //But not here
// echo("Object Exsists");
//}
$instantGroup = ServerGroup;
new SimGroup(MissionCleanup);
$instantGroup = MissionCleanup;
if (isObject(game))
{
game.deactivatePackages();
game.delete();
game.onMissionReset();
game.onMissionEnded();
}
clearServerpaths();
Game.onMissionReset();
}
/////////////////////////
Any Suggestions? Thanks for your time
function clientCmdShowVictory(%score)
{
echo("show victory called");
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
//Reset code here
quit());
}
I tried
loadMyMission(), // This failed of course with a 'unable to find function loadMyMission
resetMission(), // This failed with a "Unable to find object 'game' attempting to call 'onMissionReset'"
loadMission($server::filename), //This failed at the compiling of the function
I did track down the function resetMission its located at line 145-166 in scripts/server/GameCore.cs and reads as follows
//////////////////////////////////////////////////
function resetMission()
{
//echo("c4 -> resetMission() override success");
echo("*** MISSION RESET");
// Remove any temporary mission objects
//if (isObject(game)){ //Object Showed up here
// echo("Object Exsists");
//}
MissionCleanup.delete();
//if (isObject(game)){ //But not here
// echo("Object Exsists");
//}
$instantGroup = ServerGroup;
new SimGroup(MissionCleanup);
$instantGroup = MissionCleanup;
if (isObject(game))
{
game.deactivatePackages();
game.delete();
game.onMissionReset();
game.onMissionEnded();
}
clearServerpaths();
Game.onMissionReset();
}
/////////////////////////
Any Suggestions? Thanks for your time
#2
onMissionReset and onMissionEnded are both defined on lines 309 - 332 as seen below.
function GameCore::onMissionEnded(%game)
{
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onMissionEnded");
// Called by endMission(), right before the mission is destroyed
// Normally the game should be ended first before the next
// mission is loaded, this is here in case loadMission has been
// called directly. The mission will be ended if the server
// is destroyed, so we only need to cleanup here.
physicsStopSimulation("server");
%game.endGame();
cancel($Game::Schedule);
$Game::Running = false;
$Game::Cycling = false;
}
function GameCore::onMissionReset(%game)
{
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onMissionReset");
%game.startGame();
}
As you can see they are part of GameCore. Any Further suggestions. or perhaps a developer written function to reset a mission.
02/19/2010 (2:17 pm)
Im sorry, But i think you are incorrect about thatonMissionReset and onMissionEnded are both defined on lines 309 - 332 as seen below.
function GameCore::onMissionEnded(%game)
{
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onMissionEnded");
// Called by endMission(), right before the mission is destroyed
// Normally the game should be ended first before the next
// mission is loaded, this is here in case loadMission has been
// called directly. The mission will be ended if the server
// is destroyed, so we only need to cleanup here.
physicsStopSimulation("server");
%game.endGame();
cancel($Game::Schedule);
$Game::Running = false;
$Game::Cycling = false;
}
function GameCore::onMissionReset(%game)
{
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onMissionReset");
%game.startGame();
}
As you can see they are part of GameCore. Any Further suggestions. or perhaps a developer written function to reset a mission.
#3
02/19/2010 (2:55 pm)
Hmm, it's odd that those definitions didn't come up during my find in files search. I'll have to take a look at it again in a couple days when I get back to a computer with the engine installed.
#4
I never found a restart function However I did find
disconnect(); will return you to the main menu.
05/04/2010 (10:25 am)
UPDATE:I never found a restart function However I did find
disconnect(); will return you to the main menu.
#5
looking to do this in t3d 1.1 b3
11/08/2010 (9:10 pm)
did you ever get this working? I am wanting to set up mission rounds and need the mission reset for each round its played. So I need a reset function call to reset the map before the round starts.looking to do this in t3d 1.1 b3
#6
11/16/2010 (9:43 pm)
This would be useful, saves having to reload the mission again. I guess you'd need to go through what needs to be reset in the game mission first such as scores etc
Associate Scott Burns
GG Alumni
Something to keep in mind with using this method, as the package is deactivated and the game object is deleted, is that everything will have to be loaded again. In a recent project I avoided this by creating my own reset function in which I deleted the NPC's, reset global variables, set the player's transform back to the the spawn point, and respawned the NPC's.
Moved to the Torque 3D forums.