Single Player Level exits
by Ace · 08/08/2002 (10:37 am) · 17 comments
This is a modification to Edward Gardner's
"Map Triggers that send you to another server"
I'm using head release.(right after they put shadows in)
This is an example of a 2 map singleplayer exit system.
Create an exitTrigger.cs, ( in server/scripts. }
Place the following in exitTrigger.cs:
Still in game.cs replace the cycleGame(), onCycleExec() and onCyclePauseEnd() with:
Now when you load up a map , you have to create a trigger.
Press f11
Then at the top of your screen click on Window and then World Editor Creator
Over to the right click on the + in front of Mission Objects and then the + in front of Mission and then click on trigger.
You will then see a popup, in the space for Object Name, type in: exit.
Then in the dropdown next to Data Block select: ExitTrigger
Then click OK, and it will be done.
For the second map, in the space for Object Name, type in: exit2.
Then in the dropdown next to Data Block select: ExitTrigger2
Then click OK, and it will be done also.
and you can duplicate the process for as may maps as you need.
Of course you will want to have something to mark where your exit is, a door, bush, hole, anything will do.
[edit
You can size your trigger as big as you need, by highlighting it's x,y,or z and pushing the ctrl and alt keys at the same time and moving the mouse.
]
This is just a basic singleplayer level exit system. But it works and is a good start.
pwrweapons.home.comcast.net
"Map Triggers that send you to another server"
I'm using head release.(right after they put shadows in)
This is an example of a 2 map singleplayer exit system.
Create an exitTrigger.cs, ( in server/scripts. }
Place the following in exitTrigger.cs:
//--------exit--------\ first map exit
datablock TriggerData(exitTrigger)
{
tickPeriodMS = 500;
};
//datablock AudioProfile(TeleportBuzz)
//{
// fileName = "~/data/sound/fx/electricity.wav";
// description = AudioClose3d;
// preload = true;
//};
function exitTrigger::onEnterTrigger(%data, %obj, %colObj)
{
%checkname = %obj.getName();
%client = %colObj.client;
if(!%client)
{
echo("not a client!");
return;
}
echo("Teleport client:" SPC %client);
if(%checkname $= "exit")
{
// if the player didn't recently beam over here... otherwise
// he would be looping around between the two, I guess...
//this leads to a specified map
%target = cycleGame();
$teleSched = schedule(0000,0,"goScotty",%client,%target);
//$teleSound = //serverPlay3D(TeleportBuzz,%client.player.getTransform(//));
%client.player.setCloaked(true);
}
}
//--------exit2------\second map exit
datablock TriggerData(exitTrigger2)
{
tickPeriodMS = 500;
};
function exitTrigger2::onEnterTrigger(%data, %obj, %colObj)
{
%checkname = %obj.getName();
%client = %colObj.client;
if(!%client)
{
echo("not a client!");
return;
}
echo("Teleport client:" SPC %client);
if(%checkname $= "exit2")
{
// if the player didn't recently beam over here... otherwise
// he would be looping around between the two, I guess...
//this leads to a specified map
%target = cycleGame2();
$teleSched = schedule(0000,0,"goScotty",%client,%target);
//$teleSound = //serverPlay3D(TeleportBuzz,%client.player.getTransform(//));
%client.player.setCloaked(true);
}
}In game.cs add:exec("./exitTrigger.cs");Right under:exec("./aiPlayer.cs");Still in game.cs replace the cycleGame(), onCycleExec() and onCyclePauseEnd() with:
//Singleplayer EXITs
function cycleGame()
{
// This is setup as a schedule so that this function can be called
// directly from object callbacks. Object callbacks have to be
// carefull about invoking server functions that could cause
// their object to be deleted.
if (!$Game::Cycling) {
$Game::Cycling = true;
$Game::Schedule = schedule(0, 0, "onCycleExec");
}
}
function onCycleExec()
{
// End the current game and start another one, we'll pause for a little
// so the end game victory screen can be examined by the clients.
endGame();
$Game::Schedule = schedule($Game::EndGamePause * 500, 0, "onCyclePauseEnd");
}
function onCyclePauseEnd()
{
$Game::Cycling = false;
echo("current mission file = " @ $Server::MissionFile);
%search = "yourmod/data/missions/spacestation.mis";
loadMission(%search);
}
function cycleGame2()
{
// This is setup as a schedule so that this function can be called
// directly from object callbacks. Object callbacks have to be
// carefull about invoking server functions that could cause
// their object to be deleted.
if (!$Game::Cycling) {
$Game::Cycling = true;
$Game::Schedule = schedule(0, 0, "onCycleExec2");
}
}
function onCycleExec2()
{
// End the current game and start another one, we'll pause for a little
// so the end game victory screen can be examined by the clients.
endGame();
$Game::Schedule = schedule($Game::EndGamePause * 500, 0, "onCyclePauseEnd2");
}
function onCyclePauseEnd2()
{
$Game::Cycling = false;
echo("current mission file = " @ $Server::MissionFile);
%search = "yourmod/data/missions/fortress.mis";
loadMission(%search);
}
//endace sp exitsNow when you load up a map , you have to create a trigger.
Press f11
Then at the top of your screen click on Window and then World Editor Creator
Over to the right click on the + in front of Mission Objects and then the + in front of Mission and then click on trigger.
You will then see a popup, in the space for Object Name, type in: exit.
Then in the dropdown next to Data Block select: ExitTrigger
Then click OK, and it will be done.
For the second map, in the space for Object Name, type in: exit2.
Then in the dropdown next to Data Block select: ExitTrigger2
Then click OK, and it will be done also.
and you can duplicate the process for as may maps as you need.
Of course you will want to have something to mark where your exit is, a door, bush, hole, anything will do.
[edit
You can size your trigger as big as you need, by highlighting it's x,y,or z and pushing the ctrl and alt keys at the same time and moving the mouse.
]
This is just a basic singleplayer level exit system. But it works and is a good start.
pwrweapons.home.comcast.net
About the author
Ace Owner of NoESCape.sytes.net starting from the beginning on 3d torque
#2
I had something similar to yours except was passing in the mission variable from the trigger ($mission)--it worked until the latest HEAD.
08/08/2002 (1:01 pm)
Ace, did you work this out with the latest HEAD (8-8)? If so, you may have to change the contents of clientCmdExitMap() to:loadMission($mission, false);The false indicates the next mission is not the first (since you're already in the first o r prior mission).
I had something similar to yours except was passing in the mission variable from the trigger ($mission)--it worked until the latest HEAD.
#3
08/09/2002 (6:16 am)
pointlessstuff
#4
can one of you send my the script why it does not work by me when i install it self
thx
spu9@gmx.de
and sorry for my eng. i am a german boy
02/10/2003 (12:32 pm)
hican one of you send my the script why it does not work by me when i install it self
thx
spu9@gmx.de
and sorry for my eng. i am a german boy
#5
02/12/2003 (5:36 pm)
oldstuff
#6
02/12/2003 (6:06 pm)
bttw this still works with the head of a few days ago
#7
04/14/2003 (9:28 am)
How would you modify this to have the trigger specify the location you appear in the next mission? Can this be done?
#8
05/26/2003 (4:16 pm)
I want to know the answer to the question above as well... *bump bump*
#9
06/02/2003 (8:31 am)
*bump bump*
#10
07/09/2003 (8:17 pm)
OK this is really an important topic for me.... Can Anyone answer Eric's question? *This is the last time I'm going to bump it*
#11
Updated 03-29-04
this still works with the head from a weak ago i just made 1 simple change: (endgame() to cycleGame().
And forget everything else, all you need is the following in your trigger.cs:
datablock TriggerData(exitTrigger)
{
tickPeriodMS = 500;
};
//datablock AudioProfile(TeleportBuzz)
//{
// fileName = "~/data/sound/fx/electricity.wav";
// description = AudioClose3d;
// preload = true;
//};
function exitTrigger::onEnterTrigger(%data, %obj, %colObj)
{
%checkname = %obj.getName();
%client = %colObj.client;
if(!%client)
{
echo("not a client!");
return;
}
echo("Teleport client:" SPC %client);
if(%checkname $= "exit")
{
// if the player didn't recently beam over here... otherwise
// he would be looping around between the two, I guess...
%target = cycleGame();
$teleSched = schedule(0000,0,"goScotty",%client,%target);
//$teleSound = //serverPlay3D(TeleportBuzz,%client.player.getTransform(//));
%client.player.setCloaked(true);
}
}
03/29/2004 (12:21 pm)
The spawning thing, thats a whole nother datablock in my sector, i would probably just set one spawnpoint in the map where i exit to.Updated 03-29-04
this still works with the head from a weak ago i just made 1 simple change: (endgame() to cycleGame().
And forget everything else, all you need is the following in your trigger.cs:
datablock TriggerData(exitTrigger)
{
tickPeriodMS = 500;
};
//datablock AudioProfile(TeleportBuzz)
//{
// fileName = "~/data/sound/fx/electricity.wav";
// description = AudioClose3d;
// preload = true;
//};
function exitTrigger::onEnterTrigger(%data, %obj, %colObj)
{
%checkname = %obj.getName();
%client = %colObj.client;
if(!%client)
{
echo("not a client!");
return;
}
echo("Teleport client:" SPC %client);
if(%checkname $= "exit")
{
// if the player didn't recently beam over here... otherwise
// he would be looping around between the two, I guess...
%target = cycleGame();
$teleSched = schedule(0000,0,"goScotty",%client,%target);
//$teleSound = //serverPlay3D(TeleportBuzz,%client.player.getTransform(//));
%client.player.setCloaked(true);
}
}
#12
function onCyclePauseEnd()
to:
function onCyclePauseEnd()
{
$Game::Cycling = false;
echo("current mission file = " @ $Server::MissionFile);
%search = "yourgamefolder/data/missions/yourmission.mis";
loadMission(%search);
}
and just keep duplicating the process for each map you have (with different names of course)
03/29/2004 (3:36 pm)
in game.cs you can change the function onCyclePauseEnd()
to:
function onCyclePauseEnd()
{
$Game::Cycling = false;
echo("current mission file = " @ $Server::MissionFile);
%search = "yourgamefolder/data/missions/yourmission.mis";
loadMission(%search);
}
and just keep duplicating the process for each map you have (with different names of course)
#13
cyclegame()
in the trigger.cs file and add a defaulttrigger to the missioneditor.
The work directory should be the starter.fps.
05/06/2007 (6:55 am)
I think it's very simple to add a line :cyclegame()
in the trigger.cs file and add a defaulttrigger to the missioneditor.
The work directory should be the starter.fps.
#14
10/22/2007 (1:30 pm)
What is "goScotty"? I can't find it...
#15
12/23/2007 (5:09 pm)
Hey I tried this step by step but when the player enters the trigger it goes to the stats screen and waits for a few seconds like it's suppose to, then it starts to load the next correct level but it stays there and just says "waiting for server" instead of saying "loading". Any ideas? Thanks
#16
But now I'm trying to get it to play a sound I made for the end of each mission but am having trouble getting it to work, I see he started to implement one but am not sure how to work it
12/23/2007 (5:17 pm)
nevermind, I had a typo in the mission name under the function onCyclePauseEnd2()But now I'm trying to get it to play a sound I made for the end of each mission but am having trouble getting it to work, I see he started to implement one but am not sure how to work it
#17
I realise this is an older thread, but I'm wondering if there are any specific changes to the code above to make it compatible with TGEA 1.7.1 ?
Nothing seems to happen when the player object enters my trigger zones (console does show a "teleport client : xxxx" message however). No mission loads though! :-(
EDIT: Problem solved! :-)
07/12/2009 (1:13 pm)
Hey!I realise this is an older thread, but I'm wondering if there are any specific changes to the code above to make it compatible with TGEA 1.7.1 ?
Nothing seems to happen when the player object enters my trigger zones (console does show a "teleport client : xxxx" message however). No mission loads though! :-(
EDIT: Problem solved! :-)

Torque Owner Edward Gardner