Torque Engine Startup

From TorqueWiki

Jump to: navigation, search

Contents

[edit] Links

http://eviwo.free.fr/projects/scriptarchi.html

http://www.gametheory.ch/index.jsp?positionId=66118&displayOption=

[edit] Mission loading

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=11604


[edit] Script Files Overview (also for more than one mission)

Name of the main mod:

$defaultGame = "game";

You can add mod to this variable or remove if needed. DeafultGame should be the last one. "creator" should be removed when the final version of the game is released:

$userMods = "creator;" @ $defaultGame;

[edit] Commands and Functions

  • Loaddir("common")

Execute the main.cs script in the directory send in parameters

   * Loadmods($usermods)

this function excutes all the "mains.cs" scripts belonging to the directory set in $userMods

   * onStart()

this function call all the onStart() function belonging to $userMods/main.cs at the condition that the function onStart() in the $userMods/main.cs are declared as "Parent::onStart()".


   * Torque is launched and wait for the events ( mouse, click , keyboard , scheduler, .... ) 

The events are defined in the script launched by the onStart() function below.


[edit] All the scripts are launch by loaddir and loadmod

The list of scripts launched is done by

./main.cs script.
./common/main.cs

This function load the function needed to manage the client/server

OnStart() : parent of Onstart() in ./main.cs

This function loads the very basic functions used everywhere in order :

  • to manage the dialog (GUI).
  • to manage the audio
onExit() : parent of onExit() in ./main.cs

Save different parameters in common.

./game/main.cs
   * activagepackage() {
on start()
./client/init.cs
./server/init.cs
./data/init.cs
$mod/server/init.cs initServer()
if ($Server::Dedicated)
      initDedicated()
else
     $mod/client/init.cs initClient()

The function initServer and initClient are launched

on exit()
   save ./client/prefs.cs
   save ./client/config.cs
   save ./server/prefs.cs
   save ./server/banlist.cs
}

./creator.main.cs

OnStart() : parent of Onstart() in ./main.cs


[edit] client server base initialisation

The function initServer and initClient are launched by the OnStart function

$mod/server/init.cs
$mod/server/init.cs initServer()

Initialise the server : it is just the basement. The hosting of the game is done later on.

If you have only one mission the scripts could be loaded at this stage.

$mod/client/init.cs
$mod/client/init.cs initClient()

Initialise : -The client basement. The connection to teh server is done later on -The GUI game environement. -The configuration and parameters of the client are loaded as saved last time.

If you have only one mission the scripts could be loaded at this stage. But in case of several missions you have to do it later and the call of the scripts relative to the mission shouled be put in comment.

If $JoinGameAddress is set the client connect directly to the game and the main menu is displayed. If it is not the case the GUI to choose the game host , or join server is displayed => loadStartup() is launched

$mod/client/init.cs loadMainMenu()

This function call the MainMenuGui.gui scripts

$mod/data/init.cs

Data common to all the game could be downloaded

$mod/client/ui/StartUpGui.gui

The function loadStartup() displayed a picture during a period of time and launch the main menu

Customise this function if you want to change the splash screen displayed when the game starts.

[edit] the main menu

This level displays the main menu GUI used by the players and launch the different actions in order  : to host a game, or to connect to a hosted game or to play solo.

$mod/client/ui/MainMenuGui.gui
$mod/client/ui/JoinServerGui.gui
$mod/client/ui/optionsDlg.gui
$mod/client/ui/startMissionGui.gui

This program display the list of mission that could be loaded.

$mod/client/ui/startMissionGui.gui SM_start()

This function is updated in order to load and start the mission selected

[edit] load the mission

$mod/client/StartMisssion.cs startMissionGame

This new program is created in order to load and start the mission in different context :

  • from a menu
  • after an event during the game : the new mission is loade automatically in function of an event in the game ( a trigger )

This function delete the context of the previous mission and create the new one

$mod/client/StartMisssion.cs startMissionInit

This function initilaise and load the .cs file specific to use by the game :

/client/scripts/"  mission selected  "/mission.cs" ;
/server/scripts/" mission selected "/mission.cs" ;

The scripts specifics to the mission should be stored into a directory with the same name than the name of the mission file.

$ mod/client/StartMisssion.cs startMissionSchedule This function should be used to launch the game after an event. The "startMissionGame" is scheduled.

[edit] the game

All the actions of the players on the game are based on 2 principles :

  • the actions on the keyboard, mouse
  • the triggers
$mod/client/scripts/default.bind.cs

The player actions on key or mouse call specific function defined in this scripts


$mod/server/scripts/"mission"/mission.cs"

this script calls the other scripts needed by the missions

$mod/server/scripts/"mission"/* when the scripts are specific to a mission 
$mod/server/scripts/* when the scripts are common to all the missions.

The trigger is started automatically by the core torque in function of events. The trigger could be associated to one of the datablocks defined with the editor or defined manually when they are the moving objects or characters or AI or ...

If a new mission should be lauched , depending on the context, the function tiggered should be updated in order to call the mission to load :

$mod/client/StartMisssion.cs startMissionSchedule("mission")
Personal tools
Games
Game Development
Modeling for Torque
Torque Game Builder (2D)
Console