User Tools

Site Tools


modding:xml:game_lifecycle

Creating a New Game

When a new game is created, the engine follows these steps:

  1. 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.
  2. 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.
  3. <OnGlobalTypesInit> is called for all design types. This is your chance to create dynamic types specific to this game instance.
  4. Any <TemplateType> elements are evaluated and types are generated for them.
  5. Player chooses a ship.
  6. gPlayer defined: The engine creates the gPlayer object. Note that gPlayerShip is not yet defined.
  7. 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.
  8. Crawl screen displayed.
  9. Universe set to initial conditions: All items become unknown; all data stored in design types is deleted; etc.
  10. gPlayer is undefined: Why? Don't ask.
  11. Create the topology
    1. <SystemMap> types are processed (nodes are created and topology processors are run).
    2. <OnGlobalTopologyCreated> is called for all design types.
  12. Determine the starting node.
  13. Create all systems in the game.
  14. Add initial credits to the player.
  15. Create the player ship.
  16. “Welcome to Transcendence!” message displayed.
  17. gPlayer and gPlayerShip defined.
  18. <OnGlobalUniverseCreated> is called for all design types.
  19. <OnGlobalSystemStarted> is called for all design types.
  20. <OnGlobalPlayerEnteredSystem> is called for all design types.
  21. <OnPlayerEnteredSystem> is called for all objects in the system.
  22. Starting node becomes known.
  23. Game is running.

Creating a New System

When a new system is created the engine follows these steps:

  1. 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>.)
  2. The system gets an <OnCreate> event.
  3. All types in the system get an <OnGlobalSystemCreated> event.
  4. Deferred creation for objects:
    1. Each object gets an <OnCreate> event.
    2. If a ship has an <OnCreate> element in its creation element, then it gets called here.
    3. Ships get an <OnCreateOrders> event.
  5. 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:

  1. <OnGlobalPlayerLeftSystem> called for all types.
  2. gPlayerShip set to Nil
  3. The current system continues updating for a few ticks.
  4. <OnGlobalSystemStopped> called for all types (for the old system).
  5. The current system is changed to the new system.
  6. <OnGlobalSystemStarted> called for all types (for the new system).
  7. The current (new) system updates for a few ticks.
  8. gPlayerShip is defined
  9. <OnGlobalPlayerEnteredSystem> called for all types.
  10. <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