Stranded: Alien Dawn

Stranded: Alien Dawn

Not enough ratings
Guide for using the Mod Utility Helpers
By injto4ka
As the mod utility helpers contain too many functions, the mod description is not enough to describe them. Therefore this guide has been made.
Mod link: https://steamproxy.net/sharedfiles/filedetails/?id=3018711913
   
Award
Favorite
Favorited
Unfavorite
Data Extractors
  • ExtractHierarchyInfo
    function ExtractHierarchyInfo(obj)
    Extracts the available hierarchy information in the object. That includes attached objects (e.g. weapons, clothing, etc), parent object (if attached), contained objects (e.g. a wall is made by several wall slab objects), container object (if contained), child objects (e.g. scavenge sites).
    Arguments:
    1. obj - The object to be extracted. The argument is optional and its default value is the selected object.

  • ExtractEntityInfo
    function ExtractEntityInfo(obj)
    Extracts useful object entity data. That includes spots, states, and other entity related info.
    Arguments:
    1. obj - The object to be extracted. The argument is optional and its default value is the selected object.

  • ExtractMaterialInfo
    function ExtractMaterialInfo(obj_or_material)
    Extracts entity material information. As the data could be large, it is a separate procedure.
    Arguments:
    1. obj_or_material - The object to be extracted, or the material name. The argument is optional and its default value is the selected object.

  • ExtractClassInfo
    function ExtractClassInfo(obj_or_classname)
    Extracts class hierarchy information.
    Arguments:
    1. obj_or_classname - The object to be extracted, or the class name. The argument is optional and its default value is the selected object.

  • ExtractCommonAncestors
    function ExtractCommonAncestors(objs)
    Extract the common ancestor classes shared between multiple objects.
    Arguments:
    1. objs - Multiple objects. The argument is optional and its default value are the selected objects.

  • GetObjectByHandle
    function GetObjectByHandle(handle)
    Get a reference to an object with that handle. Used to pass an object to the functions expecting objects as arguments.
    Arguments:
    1. handle - A unique number used to identify an object.

  • ExtractTranslation
    function ExtractTranslation(mod_title_or_id)
    Search for a mod with a given title or id and extracts the strings for translation form it. The tool is now officially supported.
    Arguments:
    1. mod_title_or_id - Mod title or id.

  • FindCFunction
    function FindCFunction(address)
    Search for a C function name by address string. Useful to debug the fatal persist error "Attempt to persist a C function: <address>"
    Arguments:
    1. address - String containing the function's hexadecimal address (e.g. 00000001403441D0).
Editor features
The mod add additional features in the vanilla editors.

  • Save in mod
    Vanilla presets can be saved into a given mod folder. The presets will be just saved in a subfolder Presets in an unpacked local mod folder. This will not include them in the mod items.

  • Copy Code
    Vanilla presets now have a button in the toolbar allowing to copy the preset code into the clipboard. The copied code represents a serialized version of the preset. Executing the code would create the preset.

Tests
  • TestMeshBlend
    function TestMeshBlend(torn_pct, dirty_pct, weight_pct, target)
Allows blending of the selected survivor's mesh
Arguments:
  1. torn_pct - percentage of cloth's wear and tear (provide false to get the real one)
  2. dirty_pct - percentage of blood stains (provide false to get the real one)
  3. weight_pct - percentage of fatness (provide false to get the real one)
  4. target - the survivor (the selected one by default)

Debug
Most of these functions are available as built-in routines when running the game via the modding debug executable. Only when in normal non-debug mode, the functions will be provided from the mod.

  • DbgAddText

    function DbgAddText(text, pos_or_obj, color, font_face)
    Places a text on a specified map position.
    Arguments:
    1. text - any value that can be converted to text.
    2. pos_or_obj - a valid map position or map object.
    3. color - color in format ARGB. Default is white (0xFFFFFFFF)
    4. font_face - the font name to use.
    Test code on a selected object:
    DbgAddText(SelectedObj.class, SelectedObj)

  • DbgAddPoly

    function DbgAddPoly(poly, color)
    Places a polyline connecting all provided points
    Arguments:
    1. poly - a list if points or objects
    2. color - color in format ARGB. Default is white (0xFFFFFFFF)
    Test code on multiple selected objects:
    DbgAddPoly(Selection, yellow)
    Test code on a moving unit:
    DbgAddPoly(SelectedObj:GetPath(), cyan)

  • DbgAddVector

    function DbgAddVector(origin, vector, color)
    Places a line in a vector direction
    Arguments:
    1. origin - where the vector is starting
    2. vector - vectoir direction or a number indicating only a Z direction.
    3. color - color in format ARGB. Default is white (0xFFFFFFFF)
    Test code on a moving unit:
    DbgAddVector(SelectedObj, SelectedObj:GetVelocityVector(), red)

  • DbgAddSegment

    function DbgAddSegment(from, to, color)
    Places a segment connecting 2 points
    Arguments:
    1. from, to - points
    2. color - color in format ARGB. Default is white (0xFFFFFFFF)
    Test code on a selected object:
    DbgAddSegment(SelectedObj, GetTerrainCursor())

  • DbgAddTriangle

    function DbgAddTriangle(pt0, pt1, pt2, color)
    Places a triangle
    Arguments:
    1. pt0, pt1, pt2 - points
    2. color - color in format ARGB. Default is white (0xFFFFFFFF)

  • DbgAddCircle

    function DbgAddCircle(center, radius, color)
    Places a circle
    Arguments:
    1. center - center position or object
    2. radius - radius value
    3. color - color in format ARGB. Default is white (0xFFFFFFFF)
    Test code on a selected object:
    DbgAddCircle(SelectedObj, SelectedObj:GetRadius(), green)

  • DbgAddSphere

    function DbgAddSphere(center, radius, color)
    Places a sphere. Same as DbgAddCircle.

  • DbgAddBox

    function DbgAddBox(box, color)
    Places a box.
    Arguments:
    1. box - box to show
    2. color - color in format ARGB. Default is white (0xFFFFFFFF)
    Test code on a selected object:
    DbgAddBox(SelectedObj:GetObjectBBox(), blue)

  • DbgClear

    function DbgClear(once)
    Clears all placed debug visuals. Uses the Clear Screen shortcut (F9)
    Arguments:
    1. once - clear only once per millisecond. Usefull to avoid clearing visuals placed in a loop.

  • DbgSetVectorZTest

    function DbgSetVectorZTest(enable)
    Changes the Z test checks (occlusion) when drawing debug visuals
    Arguments:
    1. enable - boolean

  • DbgBreak

    function DbgBreak(value, silent)
    Simulates a debug breakpoint. Stops the game, prints the argument, the call stack and the local variables in the debug output.
    The execution will continue after unpausing the game. If not silent, displays a message on the screen with the contents of the argument.
    Arguments:
    1. value - value to be displayed
    2. silent - no message on the screen
    Note: When using the debug executable, a breakpoint can be set via the external debugger.

  • ToggleVisualizeLOD
    function ToggleVisualizeLOD()
    Displays a color coded visualization of the objects LOD (Level-Of-Detail) property
    Also triggered from shortcut Ctrl-Alt-Z

Mod Management
The Mod Utility Helpers provide the following mod management capabilities:

- A toggle is included in the mod options is provided to enable or disable automatic mod syncing with saved games upon loading, so that any save can be loaded successfully.
- Removed the warning about the risks of using mods, as we already know that.
- Removed the message "Your code has been loaded and is currently active in the game."
- Added an UI to save and load the enabled state of the mods
- The following functions to make mod management easier for modders via the debug console.

  • SetEnabledMods

    function SetEnabledMods(mods, enable_only)
    Enables a list of mods
    Arguments:
    1. mods - a list of mod IDs
    2. enable_only - a boolean flag to enable only

  • GetEnabledMods

    function GetEnabledMods()
    Returns a list of the IDs of the currently enabled mods

  • ModCaptureStore

    function ModCaptureStore(name)
    Stores the currently active mods under a name into a persistant storage, to be restored later
    Arguments:
    1. name - the name of the mod capture
    Example:
    ModCaptureStore("MyMods")

  • ModCaptureRestore

    function ModCaptureRestore(name)
    Restores a previously stored mod capture
    Arguments:
    1. name - the name of the mod capture
    Example:
    ModCaptureRestore("MyMods")

  • ModCaptureRemove

    function ModCaptureRemove(name)
    Removes an existing stored mod capture
    Arguments:
    1. name - the name of the mod capture
    Example:
    ModCaptureRemove("MyMods")


  • ModCaptureList

    function ModCaptureList()
    Lists all of the stored mod capture names


  • OpenModList

    function OpenModList()
    Opens a list of all local mods to let the modder choose to open one for edit.



Fixes
  • Blender Export

    The mod package includes a new version of the blender exporter plugin script BlenderExport.py, that allows multiple meshes to be exported under the same entity, mesh and state names. The resulting entity would have multiple meshes with different materials.
    Also the same fix allows to include the LOD (Level-Of-Detail) meshes, making the entity toggle different meshes for different camera distances.
    The script file has to be replaced in the game directory ModTools, usually located at
    SteamLibrary\steamapps\common\Stranded Alien Dawn\ModTools
Notes
  • Analysing data
    These functions are invoked in the game console, and work by default with the selected object. Having the game started via the modding debug executable, will greatly help the readability of the output of the extractor functions. If so then the dev data inspector is unlocked. So for example type:
    ~ExtractEntityInfo()
    The symbol '~' placed in front triggers the inspector that opens an ingame UI window to inspect the extracted data. It is a very powerful debug tool! Also, in map editing mode (F3), all objects are selectable, thus making the helper more useful. Only the group selection needs to be disabled via the button with icon "1" in the bottom right corner or via the shortcut Ctrl-Q. If the inspector is not used, it could print a large amount of texts that in many cases will not fit the screen. In that case invoke the function by:
    OutputDebugStringNL(TableToLuaCode(ExtractEntityInfo()))
    This print could be accessed in the ouput window of an attached Visual Studio debugger. Another way is to copy the text into the clipboard using CopyToClipboard function, and then paste it in a text editor.

  • Extracting data from child objects
    if the object of interest is a child object, it cannot be selected and thus it is difficult to extract data from it. Therefore a handle is attributed to each object in order to obtain the object reference by using that handle. The function that returns the actual object is GetObjectByHandle. For example the entity info of an object with handle 100 is accessed by:
    ExtractEntityInfo(GetObjectByHandle(100))
    In the data obtained from ExtractHierarchyInfo these handles can be seen for each object. Positive handles are persisted with the objects on the map, while the negative ones are only temporally, generated only for the purposes of GetObjectByHandle.

  • Additional notes
    All metric values are in mm, which is the game unit in the game. Thus one meter ('guim' constant) equals 1000. Also the game units are always an integer number without a fractional part. But be aware that in Blender, and other 3D modeling software, the units can be different (cm), and there could be numbers with a fractional part.

    All colors are 4 byte number values in format ARGB. A helper function RGBA(red, green, blue, alpha) or RGB(red, green, blue) can be used for conversion. Also certain colors have a global names (e.g. red, green, blue, white, yellow, etc).