modding:xml:game_lifecycle
Table of Contents
Creating a New Game
When a new game is created, the engine follows these steps:
- Load adventure: We load the adventure that the player has selected. This may potentially enable or disable various extensions based on the requirements of each extension and the adventure itself.
- Run <Globals>: Next we run the code in any <Globals> that we loaded. Note that there is no guarantee that the code will run; for example, if the adventure was already loaded, we will not run <Globals> again. The only guarantee is that the code in <Globals> will run at least once before the game starts.
- <OnGlobalTypesInit> is called for all design types. This is your chance to create dynamic types specific to this game instance.
- Any <TemplateType> elements are evaluated and types are generated for them.
- Player chooses a ship.
- gPlayer defined: The engine creates the gPlayer object. Note that gPlayerShip is not yet defined.
- Adventure's <OnGameStart> called: The code may call gamSetCrawlText and gamSetCrawlImage to set the intro crawl screen. If neither is called, the crawl screen is skipped.
- Crawl screen displayed.
- Universe set to initial conditions: All items become unknown; all data stored in design types is deleted; etc.
- gPlayer is undefined: Why? Don't ask.
- Create the topology
- <SystemMap> types are processed (nodes are created and topology processors are run).
- <OnGlobalTopologyCreated> is called for all design types.
- Determine the starting node.
- Create all systems in the game.
- Add initial credits to the player.
- Create the player ship.
- “Welcome to Transcendence!” message displayed.
- gPlayer and gPlayerShip defined.
- <OnGlobalUniverseCreated> is called for all design types.
- <OnGlobalSystemStarted> is called for all design types.
- <OnGlobalPlayerEnteredSystem> is called for all design types.
- <OnPlayerEnteredSystem> is called for all objects in the system.
- Starting node becomes known.
- Game is running.
Creating a New System
When a new system is created the engine follows these steps:
- Objects defined by the system type are created. Note that we defer calling the <OnCreate> for these objects until after the entire system is created. (Why? Because some objects like to enumerate all objects in the system in their <OnCreate>.)
- The system gets an <OnCreate> event.
- All types in the system get an <OnGlobalSystemCreated> event.
- Deferred creation for objects:
- Each object gets an <OnCreate> event.
- If a ship has an <OnCreate> element in its creation element, then it gets called here.
- Ships get an <OnCreateOrders> event.
- Any stations with an <OnCreate> in their creation element get called here.
Entering a Stargate
When the player enters a stargate the engine follows these steps:
- <OnGlobalPlayerLeftSystem> called for all types.
- gPlayerShip set to Nil
- The current system continues updating for a few ticks.
- <OnGlobalSystemStopped> called for all types (for the old system).
- The current system is changed to the new system.
- <OnGlobalSystemStarted> called for all types (for the new system).
- The current (new) system updates for a few ticks.
- gPlayerShip is defined
- <OnGlobalPlayerEnteredSystem> called for all types.
- <OnPlayerEnteredSystem> called for all objects in system (and all active missions).
modding/xml/game_lifecycle.txt · Last modified: 2014/12/27 04:40 by 127.0.0.1