Empires Callbacks: Difference between revisions

From Archon Wiki
Jump to navigation Jump to search
No edit summary
m (Andrewg moved page AEP Callbacks to Empires Callbacks)
 
(6 intermediate revisions by the same user not shown)
Line 7: Line 7:
Called when a new game is started, immediately after InitScenario.
Called when a new game is started, immediately after InitScenario.


=== StartMap ===
=== StartMap(flags) ===
Called each time the scenario is opened (new game, loading a saved game, loading the scenario in the editor).
Called each time the scenario is opened (new game, loading a saved game, loading the scenario in the editor).
Under some circumstances, StartMap can be called again during a play session, for example when a snapshot or replay state from an older play session is loaded. Bit 0 of the flags parameter will be set when this is the case, although generally the game should respond the same way.


=== StartTurn ===
=== StartTurn ===
Line 25: Line 27:
Called each frame after all of the update callbacks.  Primarily used for drawing UI elements over the map
Called each frame after all of the update callbacks.  Primarily used for drawing UI elements over the map


=== StartGroup(id) ===
=== StartGroupVisuals(id) ===
Expected to set up the visuals for a group (including call SetGroupAsset).  Called at various points during game flow (expect it to be called multiple times as needed for the same group).
Expected to set up the visuals for a group (including call SetGroupAsset).  Called at various points during game flow (expect it to be called multiple times as needed for the same group).  Must not modify gameplay values for object.


=== StartStructure(id) ===
=== StartStructureVisuals(id) ===
Expected to set up the visuals for a structure (including call SetStructureAsset).  Called at various points during game flow (expect it to be called multiple times as needed for the same structure).
Expected to set up the visuals for a structure (including call SetStructureAsset).  Called at various points during game flow (expect it to be called multiple times as needed for the same structure).  Must not modify gameplay values for object.


=== PathfindingData(region, group, ...) ===
=== PathfindingData(region, group, ...) ===
Request for connection info for a group leaving a region.  For each region the group can enter from the requested region, the script must call SetPathfindingData.
Request for connection info for a group leaving a region.  For each region the group can enter from the requested region, the script must call SetPathfindingData.
=== UI_UPDATE_GROUP(groupID, zoom, mouseX, mouseY, buttons) ===
Called once per frame for each group visible on the map to update the UIGroup layout for the current frame.  zoom is the height of the camera above the ground.  Return <= 0 if there is nothing to be drawn.  If the mouse is over any visible component of the UI, GetMouseGroup will return that group ID as it would if the mouse was over the group's on-map 3d object.  The root of the UI is automatically placed to draw immediately below the base of the group's on-map 3d object.


== Scenario.bsf callbacks ==
== Scenario.bsf callbacks ==
Line 39: Line 44:
Called when a new game is started, immediately after InitMap.
Called when a new game is started, immediately after InitMap.


=== StartScenario ===
=== StartScenario(flags) ===
Called each time the scenario is opened (new game, loading a saved game), immediately after StartMap
Called each time the scenario is opened (new game, loading a saved game), immediately after StartMap.  The flags parameter has the same meaning as in StartMap.


=== StartTurn ===
=== StartTurn ===
Line 63: Line 68:
# StartMap
# StartMap
# StartScenario
# StartScenario
# StartStructure x X
# StartRegionVisuals x N
# StartGroup x X
# StartGroupVisuals x N
# show PreScenario UI (single player)
## UpdateMap
## UpdateScenario
## repeat until script calls StartScenario command
# StartTurn in Map.bsf
# StartTurn in Map.bsf
# StartTurn in Scenario.bsf
# StartTurn in Scenario.bsf
Line 88: Line 97:
# StartMap
# StartMap
# StartScenario
# StartScenario
# StartStructure x X
# StartStructureVisuals x X
# StartGroup x X
# StartGroupVisuals x X
# UpdateMap
# UpdateMap
# UpdateScenario
# UpdateScenario

Latest revision as of 20:07, 8 July 2019

Map.bsf callbacks

InitMap

Called when a new game is started. Also called each time the scenario is opened in the editor.

InitFinal

Called when a new game is started, immediately after InitScenario.

StartMap(flags)

Called each time the scenario is opened (new game, loading a saved game, loading the scenario in the editor).

Under some circumstances, StartMap can be called again during a play session, for example when a snapshot or replay state from an older play session is loaded. Bit 0 of the flags parameter will be set when this is the case, although generally the game should respond the same way.

StartTurn

Called at the beginning of the planning phase of each turn.

EndTurn

Called at the end of the resolution phase of each turn. Happens during the TurnResolveComplete command.

UpdateMap(tick)

Called each frame. If the tick parameter is 0, it means that this is an 'extra' frame because the game is rendering faster than its 'logical' framerate (30 fps). Things that should happen at a constant speed (such turn resolution) should only happen if tick is 1, things that should happen as fast as possible (such as UI handling) should happen regardless of tick. In practice, there should be very few places you need to look at the tick parameter.

UpdateAI(faction)

Called for each AI controlled faction until it returns a non-zero value. It is expected to run a small slice AI planning each call. Called after UpdateScenario. AI factions which have the INACTIVE attribute set to non-zero will be skipped.

RenderMap

Called each frame after all of the update callbacks. Primarily used for drawing UI elements over the map

StartGroupVisuals(id)

Expected to set up the visuals for a group (including call SetGroupAsset). Called at various points during game flow (expect it to be called multiple times as needed for the same group). Must not modify gameplay values for object.

StartStructureVisuals(id)

Expected to set up the visuals for a structure (including call SetStructureAsset). Called at various points during game flow (expect it to be called multiple times as needed for the same structure). Must not modify gameplay values for object.

PathfindingData(region, group, ...)

Request for connection info for a group leaving a region. For each region the group can enter from the requested region, the script must call SetPathfindingData.

UI_UPDATE_GROUP(groupID, zoom, mouseX, mouseY, buttons)

Called once per frame for each group visible on the map to update the UIGroup layout for the current frame. zoom is the height of the camera above the ground. Return <= 0 if there is nothing to be drawn. If the mouse is over any visible component of the UI, GetMouseGroup will return that group ID as it would if the mouse was over the group's on-map 3d object. The root of the UI is automatically placed to draw immediately below the base of the group's on-map 3d object.

Scenario.bsf callbacks

InitScenario

Called when a new game is started, immediately after InitMap.

StartScenario(flags)

Called each time the scenario is opened (new game, loading a saved game), immediately after StartMap. The flags parameter has the same meaning as in StartMap.

StartTurn

Call each turn, immediately after Map.bsf StartTurn

EndTurn

Called each turn, immediately before Map.bsf EndTurn. Happens during the TurnResolveComplete command.

UpdateScenario

Called each frame, immediately after UpdateMap

RenderScenario

Called each frame after, immediately after RenderMap

Callback sequence

New Game Example

  1. InitMap
  2. InitScenario
  3. InitFinal
  4. StartMap
  5. StartScenario
  6. StartRegionVisuals x N
  7. StartGroupVisuals x N
  8. show PreScenario UI (single player)
    1. UpdateMap
    2. UpdateScenario
    3. repeat until script calls StartScenario command
  9. StartTurn in Map.bsf
  10. StartTurn in Scenario.bsf
  11. UpdateMap
  12. UpdateScenario
  13. RenderMap
  14. RenderScenario
  15. UpdateMap
  16. ...
  17. UpdateMap
  18. UpdateScenario
  19. UpdateAI
  20. ...
  21. EndTurn in Scenario.bsf
  22. EndTurn in Map.bsf
  23. StartTurn in Map.bsf
  24. StartTurn in Scenario.bsf
  25. UpdateMap
  26. ...

Loading Saved Game Example

  1. StartMap
  2. StartScenario
  3. StartStructureVisuals x X
  4. StartGroupVisuals x X
  5. UpdateMap
  6. UpdateScenario
  7. RenderMap
  8. RenderScenario
  9. UpdateMap
  10. ...