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

Compare with Current View Page History

« Previous Version 16 Current »

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 contents 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);

Overview:

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 multiple concurrent amounts of players trying explore the same area or location - the usefulness grows exponentially.

That said, 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.

Guide Lines:

  • 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)
  • Every time 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 *Appear* to be reallocated in RAM and their tags always reset to the same as the base area.
    • This means tracking instanced areas by area tag can be unreliable.
  • DM Client will not see newly Instanced Areas unless you relog
  • When iterating over instanced areas using the GetAreaByTag function it appears base area will always be the last entry (n-1, because of 0-indexing)
  • No labels