Skip to content

Function list

Sthaagg Memnochs edited this page Jun 2, 2022 · 7 revisions

This script regroup base function needed by other scripts and some QoL functions that i use. Add import _SMF_Utils at the start of you script (after properties)

  • Closemenu()
    Convenient function, Close menu properly by disabling / enabling payer control quickly

  • ClosemenuAlt(string menu)
    alternate way to close menu like crafting or training

  • GetPlayerDialogueTarget()
    Detect which actor is currently talking to the player. Return Actor Ref

  • ActorIsNearPlayer(Actor akActor)
    Detect if actor is in same cell as the playern and distance is inferior to 512 units, Return true

  • GetActorPosition(Actor akSource)
    Returns an array which contains actor coordinates 0 = X, 1 = Y and 2 = Z

  • GetOffsets(Actor akSource, Float afDistance = 100.0, float afOffset = 0.0)
    Returns an array which contains objectif distance 0 = Y Distance, 1 = X distance

  • IsSitting(Actor akActor)
    Test if game considers that actor is sitting then check if he uses an appropriate furniture as game make no difference between leaning against a pole or sitting, Return True

  • ListObjectRefInCell(Int aiFormtype, ObjectReference akObject = None, Cell acCell = none)
    return an array from a cell, Uses akObject's parent cell or acCell if a cell is specified and akObject is empty

  • Min(Float afA, float afB)
    Returns the lowest value between afA & afB

  • Max(Float afA, float afB)
    Returns the highest value between afA & afB

QoL function to manipulate diverse kind of array
Add import _SMF_ArrayUtils at the start of you script (after properties)

  • ArrayAddForm(Form[] akMyArray, Form akMyForm)
    Adds a form to the first available element in the array.

  • ArrayRemoveForm(Form[] akMyArray, Form akMyForm, bool abSort = false)
    Removes a form from the array, if found. Sorts the array using ArraySortForm() if abSort is true.

  • ArraySortForm(Form[] akMyArray, int akI = 0)
    Removes blank elements by shifting all elements down.

  • ArrayClearForm(Form[] akMyArray)
    Deletes the contents of this array.

  • ArrayTotalCountForm(Form[] akMyArray)
    Counts the number of indices in this array that do not have a "none" type.

  • ArrayHasForm(Form[] akMyArray, Form akMyForm)
    Attempts to find the given form in the given array, and returns the index of the form if found.

  • ArrayCountForm(Form[] akMyArray, Form akMyForm)
    Attempts to count the number of times the given form appears in this array.

Same functions exist for each kind of data you want to store in your array (you can't store multiple type in one array), check script for more details, all are build on same template.

Type list:

  • Form
  • Int
  • Float
  • Keyword
  • Actor
  • ObjectReference

Optimized Dress / Undress player script, based on Outfit Switcher by White Shadow and Updated Outfit Switcher by Spanksh.
Dress UnDress NPC Script

DressUndressPlayer(Form[] akListEquip,form[] akListL, bool abUnequiped)

To use this script you need to use an array, a form and a bool properties
Ex:
_Form[] Property SMF_EquipList Auto Hidden; (store player outfit)
_Form[] Property SMF_EquipListL Auto Hidden; Store Left hand item
_bool property SMF_UnequipGearAlreadyExecuted = False Auto Hidden; Script status
You must initialise array with these numbers :
_SMF.SMF_EquipList = new Form[32] ;It is the equip slot number avialable
_SMF.SMF_EquipListL = new Form[1] ;Left hand will need only one slot.
_Use function like this : _
__SMF_UnequipGearAlreadyExecuted = DressUndressPlayer(_SMF_EquipList, _SMF_EquipListL, SMF_UnequipGearAlreadyExecuted)
First time the function is called it will undress the player, and switch the bool to true
Second time it will dress the player and switch the bool to false.
Danwguard and DragonBorn amnos are added by script to ensure compatibility with mod that requires to disable it (like enderal)
The amnolist use a hardcoded array to share it with other mods wich uses this script to avoid useless multiple detection and ressource sake.

See script for more detail.

QoL function to detect player location or weather condition.
To spare ressource, it pick campfire / frostfall result if they are isntalled instead of doing detection by itself.
_Add import _SMF_LocationUtils

  • IsunderShelter()
    Detect if player is under a shelter, return true or false

  • IsunderTent()
    Detect if player is under a campfire tent, return true or false

All location test compare location keyword with keyword array (faster than form) build at SMF initialisation

  • GetPlayerlocationType()
    Return a int who matches location category (check script for value)

All following functions are used to categorize player location to fit my needs for different mod, name are easy to understand.
All return true / false

Check _SMF_API.psc to understand better how location are classified.

General category:

  • IsInDangerousPlace()
  • IsinSafePlace()
  • IsInUnhealthyArea()
  • IsInHealthyArea()

Detailed category:

  • IsInSupernaturalAndultraUnhealthyPlace()
  • IsInAbandonnedAndVeryUnhealthyPlace()
  • IsInCampAndHighUnhealthyPlace()
  • IsInCampAndAverageUnhealthyPlace()
  • IsInDwemerAndLowUnhealthyPlace()
  • IsInCaveAndLowUnhealthyPlace()
  • IsInLowPopulatedAndLowHealthyPlace()
  • IsInPopulatedSafeAndAverageHealthyPlace()
  • IsInSupernaturalAndHighHealthyPlace()
  • IsInPopulatedAndHighHealthyPlace()
  • IsInSafeAndUltraHealthyPlace()

Test weather condition:

  • IsPleasant()
  • IsCloudy()
  • IsRaining()
  • IsSnowing()

_Add import _SMF_TeamUtils

To be able to add NPC manually or to build a ignore list, you must create two array:
Form[] Property _YourMod_ActorArray Auto Hidden; Empty, Store manual added
Form[] Property _YourMod_ExlusionList Auto Hidden; Empty, Store NPCs which must be ignored

  • AutoDetectTeam(form[] akExlusionList)
    Useful function for mod which manage follower and teammate, it is what I use in Better Facelight or Keep It Clean
    This function get the alias from dedicated quest and store them in an Array, this one is hardcoded so it can be shared by any mod which use this feature, due to how follower/temamate are detected it will be a waste of ressource to use different array.
    **_SMF_AutoDetectTeam quest must be started if you want to use AutoDetectTeam() function **

  • AddActortoTeamList(Actor akTeammate, Form[] akActorArray, Form[] akExlusionList, Int aiMode = 1)
    by default use Mode 2
    Mode 1 (default) use to add non-supported follower to your array
    Mode 2 add NPC to an exclusion list
    Array used by mode 2 & 3 are configurable as user can wish to add or remove some followers depending of mod purposes.

  • ResetTeammateList(Form[] akClearedArray = none, Int aiMode = 2)
    Convenient function to reset follower/teammate
    Mode 1 Reset hardcoded auto-filled teammate list
    Mode 2 reset the custom one filled by user in the function (akClearedArray).

_Add import _SMF_TimeUtils Set of QoL function to manipulate time

  • PassTime(float afTimePassed) Make time advance

  • GetTimeStamp(int aiUnit)
    If aiUnit 1 Result is returned in Hour, 2 in Day
    Result is returned as a float so it needs to be called in a variable

  • CalculTimePassed(Float afPreviousTime, int aiUnit)
    Mode 1 Result is returned in Hour, 2 in Day
    **You must use same unit as the one used with GameTimeStamp() or from the variable you use ** Result is returned as a float so it needs to be called in a variable

  • CountTotalDaysSpent()
    Returns the number of fully passed ingame days since game start Result is returned as a Int so it needs to be called in a variable

  • CountTotalhourSpent() Returns the number of fully passed hour ingame
    Result is returned as a Int so it needs to be called in a variable

  • GetCurrentGameTimeInHour()
    Returns the number of passed hour ingame
    Result is returned as a float so it needs to be called in a variable

  • GetCurrentDayHour()
    Returns what hour it is. (like 12)
    Result is returned as a Int so it needs to be called in a variable

  • GetDayOfWeek()
    returns the current ingame day of the week as int.
    Check script for complete instruction

  • GetCurrentMoonphase()
    Returns an integer representing the current phase of the moons Masser and Secunda based on "SkyrimClimate".
    Check script for complete instruction

  • GetCurrentMoonSync()
    returns an integer that resembles where we are in the 5 day cycle of the Snychronisation between the moons.
    Check script for complete instruction

QoL script to disable physics properly Extended version place object to its original location
Attach script to object to use it

  • IsCloseToWaterfall(Actor akActor)
    Detect if actor is next a Waterfall (detection is not very accurate due to game limitation)

  • IsInWater(Actor akActor)
    Detect if actor stand in the water (but he is not underwater)