You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Description:

// MAP 2/14/2009
// EXPERIMENTAL
// Creates a new area based on an existing area.  The new area is loaded from
// disk (so created/destroyed contetns in the original area will not be duplicated)
// however the walkmesh is shared with the existing area to reduce
// lag during load time, as well as to keep memory consumption lower.

object CreateInstancedAreaFromSource(object oArea);


NWN2 introduced near the end of it's Update Life cycle a very powerful function - allowing people to uniquely instance off areas. For single player modules, this is not very important but for Persistent Worlds or any module dealing with concurrent amounts of players trying explore the same area or location - the usefulness grows exponentially.

This function does have a few quirks and issues that need to be designed around, especially if you want to properly recycle areas and avoid memory leaks.


Overview:

  • Each uniquely instanced area is loaded from disk preserving the original state of that area
    • Any changes to the area during run time, Created or Destroyed Objects will not follow to the instanced version.
    • Walkmesh is shared among each instance to reduce lag and lower memory usage
  • Can only instance an area that is created in the toolset and has it's own .TRX / Walkmesh.
    • You cannot instance an instance of an area.
  • Instances created can never be deleted (NWN2 has no way of deleting Areas or Freeing Memory)
  • Everytime you create a unique instance of an area, the memory footprint in RAM will increase to allocate space for this instance, as a side effect -  all instances of a single area will be reallocated in RAM and their tags will be reset to the same as the base area.
  • No labels