Level Streaming

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting(Redirected from HPL3/Scripting/Level Streaming)
Jump to navigation Jump to search


Map streaming loads the next map’s assets before the transition. SOMA’s Curie Outside script shows how preloading, transfer-area preservation and a readiness check fit together.

Follow the Curie transition

  1. Include helpers/helper_map.hps in the map script. The following are excerpts from maps/chapter02/02_01_ms_curie_outside/02_01_ms_curie_outside.hps, rather than a complete transition script.
  2. Begin preloading the destination:
Map_Preload("02_02_ms_curie_inside.hpm", eWorldStreamPriority_Low);

The inspected helper declares a priority argument, but only forwards the map name to cLux_PreloadMap. To change the priority, the stock script calls the separate helper:

Map_SetPreloadPriority(eWorldStreamPriority_Normal);
  1. Before changing maps, the stock transition calls:
Map_Deload("Transfer2122");

The helper’s source comment describes the named transfer area as preserving objects inside it from deloading. Transfer2122 belongs to this stock transition; it is not a universal area name.

  1. The timer callback waits for readiness before changing maps. If loading is incomplete, it schedules another check after 0.55 seconds:
if(Map_IsPreloadCompleted())
{
    // Other stock transition cleanup occurs here.
    Map_ChangeMap("02_02_ms_curie_inside.hpm", "", "Transfer2122", "", "");
}
else Map_AddTimer("ChangeMap", 0.55f, "PreloadTimer");

This excerpt abbreviates the entity cleanup preceding Map_ChangeMap. The full stock script also copies global settings, fades an environment preset and changes the preload priority through its timer events.

Understand the change-map arguments

The five-argument overload takes the destination map, player-start name, transfer-area name, start sound and end sound. The four-argument overload leaves out the transfer-area argument and supplies an empty name internally. Both stop the grab state before forwarding the transition to the native function.

Adapt the pattern

Use destination, player-start and transfer-area names that exist in your own map setup. Keep the readiness check and its timer callback together; copying the timer call alone does not define PreloadTimer.

See also