Mission/scenario changing code
by Eric Morata · 04/14/2005 (11:29 pm) · 17 comments
It was a long thread, but here it is. Tom had more trouble trying to understand my errors than anything, in fact, this is his code.
in... game.fps/server/scripts/trigger.cs:
in... game.fps/server/scripts/game.cs:
Inside the mission, you add a spawnpoint with the list name 'spawnsphere_name' INSIDE the mission group "MissionGroup/PlayerDropPoints" (specified in the pickSpawnPoint(),%groupName variable).
...and that's it! The link between scenarios and missions is at large.
Once again my thanks to Tom Spilman. Without him, this resource simple wouldn't exist.
in... game.fps/server/scripts/trigger.cs:
$scene0="starter.fps/data/missions/fps.mis";
//------------to mission zero(/fps.mis), entrance 1
datablock TriggerData(name_of_teleport)
{
tickPeriodMS = 100;
};
function name_of_teleport::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LaunchMission( $scene0, "spawnsphere_name" );
}
//this triggerdata and function must be cretated
// for every exit that connects to a specifc spawnsphere.
//in this case, you'll be sent to $scene0, in the spawnpoint named "spawnsphere_name"
//Tom Spilman code snipet
// Launches another %mission after %timeout milliseconds at
// the %spawn point desired. %timeout and %spawn can be zero.
function LaunchMission( %mission, %spawn, %timeout )
{
if ( !$Game::LaunchingMission ) {
$Game::NextMission = %mission;
$Game::NextSpawn = %spawn;
$Game::LaunchingMission = true;
schedule( %timeout, 0, "onLaunchMission" );
}
}
function onLaunchMission()
{
$Game::LaunchingMission = false;
loadMission( $Game::NextMission );
}
//-------------in... game.fps/server/scripts/game.cs:
//Tom Spilman pickspawnpoint():
function pickSpawnPoint()
{
%groupName = "MissionGroup/PlayerDropPoints";
if ( $Game::NextSpawn !$= "" ) {
%spawn = nameToID( %groupName @ "/" @ $Game::NextSpawn );
$Game::NextSpawn = "";
if ( %spawn != -1 )
return %spawn.getTransform();
}
%group = nameToID(%groupName);
if (%group != -1) {
%count = %group.getCount();
if (%count != 0) {
%index = 0; //getRandom(%count-1);
%spawn = %group.getObject(%index);
return %spawn.getTransform();
}
else
error("No spawn points found in " @ %groupName);
}
else
error("Missing spawn points group " @ %groupName);
// Could be no spawn points, in which case we'll stick the
// player at the center of the world.
return "0 0 300 1 0 0 0";
}Inside the mission, you add a spawnpoint with the list name 'spawnsphere_name' INSIDE the mission group "MissionGroup/PlayerDropPoints" (specified in the pickSpawnPoint(),%groupName variable).
...and that's it! The link between scenarios and missions is at large.
Once again my thanks to Tom Spilman. Without him, this resource simple wouldn't exist.
#2
... and this is just as useful... might resource local teleports, if anyone didn't... ;)
04/15/2005 (8:35 am)
No, Chris. You are sended to the mission loading screen, and all lightining and loading bars appears in front of you. That's just unavoidable, but no biggie.Of course, an instantaneous loading just happens on LOCAL teleports - meaning that you do not change mission, but location inside one.... and this is just as useful... might resource local teleports, if anyone didn't... ;)
#3
It's not unavoidable, you can get away with it by scripting, even. You use OnConnect (or whatever the function is, it's in the same file) and when you're switching server, you could customize it so the screen stays what it was with a text in the middle saying "Loading.." or something along that style.
04/15/2005 (8:50 am)
Quote:
No, Chris. You are sended to the mission loading screen, and all lightining and loading bars appears in front of you. That's just unavoidable, but no biggie.
It's not unavoidable, you can get away with it by scripting, even. You use OnConnect (or whatever the function is, it's in the same file) and when you're switching server, you could customize it so the screen stays what it was with a text in the middle saying "Loading.." or something along that style.
#4
you mean freezing the player screen, eh? That's interesting... wich instruction does that?do you have the code? Can you post it?
If not... code, anyone? Please? ;)
04/15/2005 (10:17 am)
Hei, great! Quote:
You use OnConnect (or whatever the function is, it's in the same file) and when you're switching server, you could customize it so the screen stays what it was ...
you mean freezing the player screen, eh? That's interesting... wich instruction does that?do you have the code? Can you post it?
If not... code, anyone? Please? ;)
#5
04/15/2005 (2:07 pm)
I'll try to work out something where it doesn't play the gui but it is still loading but you see your character sparkling or something. I'm pretty busy but I'll see if I can do anything.
#6
04/15/2005 (7:16 pm)
Lets say that you have two computers and one of them is the server, the other is the client. Is it possible for this resource to have it where if the client goes to another mission while the server is at same mission which the server started?
#7
Stephen, i only work in single player modes, but hypotheticaly speaking, if the actual source code work's in a way where the server do all the level managing, then... no. Of course, maybe with some codework, but the server would be managing TWO levels at the same time... espect a slide-show framerate! Logically, i suppose, the solution would be the client loading and managing the entire level alone, only sending vital information trought the connection that would be vital for the game.
And that would heavilly depend of what the game is all about. If is too much info, you know... a programmer's happy weekend pulling his hair out! :P
04/16/2005 (7:56 am)
Thanks, Treb. We'll be in the waiting.Stephen, i only work in single player modes, but hypotheticaly speaking, if the actual source code work's in a way where the server do all the level managing, then... no. Of course, maybe with some codework, but the server would be managing TWO levels at the same time... espect a slide-show framerate! Logically, i suppose, the solution would be the client loading and managing the entire level alone, only sending vital information trought the connection that would be vital for the game.
And that would heavilly depend of what the game is all about. If is too much info, you know... a programmer's happy weekend pulling his hair out! :P
#8
On thing I noticed:
[quote]
//this triggerdata and function must be cretated
// for every exit that connects to a specifc spawnsphere.
//in this case, you
04/19/2005 (12:08 am)
Nice resource, guys.On thing I noticed:
[quote]
//this triggerdata and function must be cretated
// for every exit that connects to a specifc spawnsphere.
//in this case, you
#9
I have a problem with missions cycling in my game. I think I made it in similar way like in this resource, but it doesn't work.
It's single player game. I want simply end the first mission after 5 minutes and load the next one. Between missions I don't display any "load screen".
The program runs in this way: first mission ends, next mission loads but doesn't start. I debugged the scripts and noticed that server sent commandToClient "MissionStartPhase1" but program doesn't enter to function clientCmdMissionStartPhase1 on the client side. I have no idea where this message has gone. More information about this problem is on www.garagegames.com/mg/forums/result.thread.php?qt=29159
Each hint will be appreciated.
04/20/2005 (1:30 pm)
Hi everyone,I have a problem with missions cycling in my game. I think I made it in similar way like in this resource, but it doesn't work.
It's single player game. I want simply end the first mission after 5 minutes and load the next one. Between missions I don't display any "load screen".
The program runs in this way: first mission ends, next mission loads but doesn't start. I debugged the scripts and noticed that server sent commandToClient "MissionStartPhase1" but program doesn't enter to function clientCmdMissionStartPhase1 on the client side. I have no idea where this message has gone. More information about this problem is on www.garagegames.com/mg/forums/result.thread.php?qt=29159
Each hint will be appreciated.
#10
05/06/2005 (2:41 pm)
Cool... i didn't know this was submitted as a resource.
#11
11/16/2005 (10:18 pm)
I cant get it to work. Just a load screen apears with "Waitting for Sever" and nothing happens.
#12
02/09/2007 (8:43 pm)
Does this resource work with tge 1.5? Also, when you mention the code above is this replacing or adding to?
#13
02/11/2007 (7:19 pm)
I got the resource to work but does this work with multiplayer as well? Also, a NPC ran into the area and was able to take me to point B. In multi-player (like for an MMO) you don't want others using this feature to change what happens to you. Does this make sense?
#14
Thanks Eric and Tom for this.
06/09/2008 (7:17 am)
Great resource just what i needed! Works perfectly in TGE 1.5.2, just hoping it can work in multiplayer too.Thanks Eric and Tom for this.
#15
In my game, each set of NPCs follows a path and they all do a pathfinding routine that is based on schedules. So all of that crap needs to be deleted upon the cycling of the mission.
What is the best way to do this?
11/06/2008 (9:31 pm)
The main thing I need to deal with is how to handle spawning a new set of NPCs in each mission, according to the mission. For example, robots in level one, but trolls in level 2, etc.In my game, each set of NPCs follows a path and they all do a pathfinding routine that is based on schedules. So all of that crap needs to be deleted upon the cycling of the mission.
What is the best way to do this?
#16
09/10/2009 (2:46 pm)
has anyone tried this in TGEA 1.8.1? i changed the filepath for the scene and it is bringing me into the next mission just fine, but i'm not spawning at my specified spawnpoint
#17
02/23/2010 (4:22 am)
How about T3D? 
Torque Owner Chris Labombard
Premium Preferred