Skyrim Special Edition

Importing SeedUtil

The SeedUtil script is the primary way most mods should interact with Last Seed and contains many helpful functions. To call any of the following functions, download the SDK and in your script include the line:

import SeedUtil

Alternatively, you can call SeedUtil.FunctionName() without importing SeedUtil.

Detecting Last Seed

One of the challenges with making mods with soft dependencies is checking whether the parent mod is installed. Fortunately, Last Seed allows for graceful detection using the LastSeedRunning_KWCheck Global Variable. This Global variable changes from 1 to 2 when Last Seed is started, which allows other mod authors to check if the mod is running without requiring Last Seed as a master or throwing errors in the Papyrus log.

If you would like to use this Global Variable in your mods, follow these steps:
• Open up Last Seed and your mod in XEdit.
•Copy LastSeedRunning_KWCheck as an override into your mod. As this record is injected into Update.esm, you can add it to another mod without requiring Last Seed as a master.

That's it! You can now use this Global Variable in your own papyrus scripts or record conditions. If this Global Variable is set to 2, then parts of your mod related to Last Seed can run. Otherwise, they can be ignored.


Functions
isSpecialEdition
Description:
Gets whether this is Skyrim Special Edition or not.
Syntax:
bool function isSpecialEdition() global
Parameters:
None
Return Value:
True if the player is running SSE; false otherwise.
Example:
bool isSSE = SeedUtil.isSpecialEdition()

IsPlayerFocused
Description:
Returns whether or not the player is 'focused' (e.g. in a dungeon or other qualifying area that temporarily delays needs and Vitality).
Syntax: bool function IsPlayerFocused() global
Parameters: None
Return Value: True if the player is focused; false otherwise.
Example: bool isFocused = SeedUtil.IsPlayerFocused() ; Is the player focussed?

IsLastSeedRunning
Description:
Returns true if Last Seed whether Last Seed is currently running (i.e. not deactivated).
Syntax: bool function LastSeedIsRunning() global
Parameters: None
Return Value: True if the player is focused; false otherwise.
Example: bool startup = SeedUtil.IsLastSeedRunning()

GetFoodType
Description: Returns this food's type, if any.
Syntax: int function GetFoodType(Potion akFood) global
Parameters: akFood: The form to check.
Return Value:
• 0: This item is not food, or has no known type.
• 1: This item is Bread.
• 2:  This item is Large Meat (Raw).
• 3: This item is Large Meat (Cooked).
• 4: This item is Small Game (Raw).
• 5: This item is Small Game (Cooked).
• 6: This item is Fish (Raw).
• 7: This item is Fish (Cooked).
• 8: This item is Seafood (Raw).
• 9: This item is Seafood (Cooked).
• 10: This item is a Vegetable.
• 11: This item is Fruit.
• 12: This item is Cheese.
• 13: This item is a Treat.
• 14: This item is a Pastry.
• 15: This item is Stew.
• 16: This item is a Cheese Bowl.
• 17: This item is Milk.
• 18: This item is an Alcoholic Drink or Skooma.
• 19: This item is a Non-Alcoholic Drink.
Example:
;Is the spongecake a bread, or a treat?
int result = SeedUtil.GetFoodType(cake)
if result == 1
    Debug.trace("It's bread!")
elseif result == 13
    Debug.trace("It's a treat!")
endif

setFoodRestoreAmount
Description:
Sets the amount of hunger the provided food restores
Syntax: function setFoodRestoreAmount(Potion akFood, int restoreId) global
Parameters:
• akFood: The food to set the type of.
• restoreType: The food's restore type. See below.
◦Light Amount (1)
◦Medium Amount (2)
◦Filling Amount (3)
◦Hearty Amount (4)
Return Value: None
Note: Do not set a single food to multiple types. The system does not check if a food is already set as a different type. If the food
had its type set via script previously, use
SeedUtil.clearFoodRestoreAmount() first, and then set the new type.
Example:
;Set the spongecake as a to restore a light amount
SeedUtil.SetFoodRestoreAmount(cake, 1)



UnSetFoodRestoreAmount
Description:
Unsets the amount of hunger the provided food restores
Syntax: function unsetFoodRestoreAmount(Potion akFood, int restoreId) global 
Parameters:
• akFood: The food to set the type of.
• restoreType: The food's restore type. See below.
◦Light Amount (1)
◦Medium Amount (2)
◦Filling Amount (3)
◦Hearty Amount (4)
Return value: None.
Example: 
;Unset the spongecake as a to restore a minor
amountSeedUtil.UnsetFoodType(cake, 1)  


clearFoodRestoreAmount

Description:
Clears all settings for the amount of hunger the provided food restores
Syntax: function clearFoodRestoreAmount(Potion akFood) global
Parameters:
• akFood: The food to clear the type of. Return Value: None.
Example:

;Clear the spongecake's food restore
amountSeedUtil.clearFoodRestoreAmount(cake)


SetAlcoholAmount
Description:
Sets the alcohol/Skooma level for the provided beverage
Syntax: function setAlcoholAmount(Potion akFood, int alcoholId) global
Parameters: 
• akFood: The alcohol to set the type of.
• alcoholId: The alcohol type. See below.
◦ 1: Ale
◦ 2: Wine
◦ 3: Spirit
◦ 4: Weak Skooma
◦ 5: Strong Skooma
Return Value:  None.
Notes:
Do not set a single beverage to multiple types. The system does not check if a beverage is already set as a different type. If the beverage had its type set via script previously, use unsetAlcoholAmount() first, and then set the new type.
Example:
;Set the Tequila to a spirit.
SeedUtil.setAlcoholAmount(Tequila, 3)


clearAlcoholAmount
Description:
Clears the alcohol type for the provided beverage
Syntax: function clearAlcoholAmount(Potion akFood) global
Parameters: 
• akFood: The alcohol clear.
Return Value: None. 
Example: 
;Clear the Tequila alcohol type
SeedUtil.clearAlcoholAmount(Tequila)


SetFoodType
Description: Sets the food's identity to the provided type.
Syntax: function SetFoodType(Potion akFood, int aiType) global
Parameters:
    • akFood: The food to set the type of.
    • aiType: The food's type. See below.
        ◦ 0: This item is not food, or has no known type.
        ◦ 1: This item is Bread.
        ◦ 2:  This item is Large Meat (Raw).
        ◦ 3: This item is Large Meat (Cooked).
        ◦ 4: This item is Small Game (Raw).
        ◦ 5: This item is Small Game (Cooked).
        ◦ 6: This item is Fish (Raw).
        ◦ 7: This item is Fish (Cooked).
        ◦ 8: This item is Seafood (Raw).
        ◦ 9: This item is Seafood (Cooked).
        ◦ 10: This item is a Vegetable.
        ◦ 11: This item is Fruit.
        ◦ 12: This item is Cheese.
        ◦ 13: This item is a Treat.
        ◦ 14: This item is a Pastry.
        ◦ 15: This item is Stew.
        ◦ 16: This item is a Cheese Bowl.
        ◦ 17: This item is Milk.
        ◦ 18: This item is an Alcoholic Drink or Skooma.
        ◦ 19: This item is a Non-Alcoholic Drink.
Return Type: None
Note: Do not set a single food to multiple types. The system does not check if a food is already set as a different type. If the food
had its type set via script previously, use SeedUtil.UnsetFoodType()
first, and then set the new type.
Example:
;Set the spongecake as a treat.
SeedUtil.SetFoodType(cake, 13)


UnsetFoodType
Description: Unsets the food's identity from the provided type.
Syntax: function UnsetFoodType(Potion akFood, int aiType) global
Parameters:
• akFood: The food to unset the type of.
• aiType: The food's current type. See below.
◦ 1:    This item is Bread.
◦ 2:    This item is Large Meat (Raw).
◦ 3:    This item is Large Meat (Cooked).
◦ 4:    This item is Small Game (Raw).
◦ 5:    This item is Small Game (Cooked).
◦ 6:    This item is Fish (Raw).
◦ 7:    This item is Fish (Cooked).
◦ 8:    This item is Seafood (Raw).
◦ 9:    This item is Seafood (Cooked).
◦ 10:   This item is a Vegetable.
◦ 11:   This item is Fruit.
◦ 12:   This item is Cheese (sliced, unpreserved).
◦ 13:   This item is a Treat.
◦ 14:   This item is a Pastry.
◦ 15:   This item is Stew.
◦ 16:   This item is a Cheese Bowl.
◦ 17:   This item is Milk.
◦ 18:   This item is an Alcoholic Drink.
◦ 19:   This item is a Non-Alcoholic Drink.
Return Value: None.
Example:
;Unset the spongecake as a treat.
SeedUtil.UnsetFoodType(cake, 13)


ClearFoodType
Description: Unsets all the food's identities.
Syntax: function ClearFoodType(Potion akFood) global
Parameters:
• akFood: The food to clear
Return Value: None.
Example:
;Clear the spongecake's food type.
SeedUtil.ClearFoodType(cake)


SetNotFood
Description: Set whether or not a food should be explicitly ignored by last seed.
Syntax: function SetAsNotFood(Potion akFood, bool notFood = true) global
Parameters:
• akFood: The food to set.
• notFood (optional): Whether or not to exclude this food. Default: True.
Return Value: None
Example:
;Set pepper to not be a food.
SeedUtil.SetAsNotFood(pepper) 


IsFoodPreserved
Description: Checks whether or not the food is "preserved" (does not spoil).
Syntax: bool function IsFoodPreserved(Potion akFood) global
Parameters:
• akFood: The food to check.
Return Value:
• True:     The food is preserved and does not spoil.
• False:    The food is not preserved and will spoil (if spoilage is enabled).
Note: Drinks of type Alcoholic and Non-Alcoholic always return 'true'.
Example:
Debug.trace("Will the twinkie ever spoil?")
bool result = SeedUtil.IsFoodPreserved(twinkie)
if result == false     Debug.trace("Guess not.")
endif


SetFoodPreserved
Description: Set whether or not the food is preserved.
Syntax: function SetFoodPreserved(Potion akFood, bool abIsPreserved = true) global
Parameters:
• akFood: The food to set.
• abIsPreserved (optional): Whether or not the food is preserved. Default: True.
Return value: none
Note: Food defaults to not being preserved; there is no need to call this function to mark it as "not preserved".
Examples:
;Set the spongecake to never spoil.
SeedUtil.SetFoodPreserved(cake) 

;Set the waffle to spoil (if previously set to spoil).
SeedUtil.SetFoodPreserved(waffle, false)

SetFoodSalted
Description: Set whether or not the food is salted.
Syntax: function SetFoodSalted(Potion akFood, bool abIsSalted = true) global
Parameters:
• akFood: The food to set.
• abIsSalted (optional): Whether or not the food is salted. Default: True.
Return Value: None.
Example:
;Set the jerky to reduce thirst
SeedUtil.SetFoodSalted(jerky)


GetFoodMaxPerishDurationByType
Description: Returns the number of hours it takes for a specific food type to spoil.
Syntax: int function GetFoodMaxPerishDurationByType(int aiFoodType) global
Parameters:
• aiFoodType: The food type to check.
Return Value: The duration (in hours) it takes this type of food to spoil to the next stage. -1 indicates an invalid type, or this food does not spoil.
Example:

Debug.trace("How many hours does it take raw fish to spoil?")
int result = SeedUtil.GetFoodMaxPerishDurationByType(6)


IsFood
Description: Returns whether the item is food.
Syntax: bool function IsFood(Form akBaseItem) global
Parameters:
• akBaseObject: The form to check.
Return Value: True if the form is food; false otherwise.
Example:
;Is the squibble something I can eat?
bool is_food = SeedUtil.IsFood(squibble)


IsKnownFood
Description: Returns whether the item is a food items that has already been registered in Last Seed.
Syntax: bool function IsKnownFood(Form akBaseItem, bool includePerished, bool includeNotFoodList) global
Parameters:
• akBaseObject: The form to check.
Return Value: True if the form is a currently registered food; false otherwise.
Example:
;Is the squibble a known food?
bool is_food = SeedUtil.IsKnownFood(squibble)


RestorePlayerHunger
Description: Restores the player's hunger by the provided amount.
Syntax: function RestorePlayerHunger(float afAmount, float target = -1.0) global
Parameters:

• afAmount: The amount to restore hunger by.
• target: The maximum level to restore hunger to.
Return Value: None.
Example:
;Restore the player's hunger up to the next level.
SeedUtil.RestorePlayerHunger(20.0)


GetPlayerHunger
Description: Gets the player's current Hunger.
Syntax: float function GetPlayerHunger() global
Parameters:
None.
Return Value: The player's current Hunger value.
Example:
;How hungry is the player?
float hunger = SeedUtil.GetPlayerHunger()


GetPlayerHungerLevel
Description: Return the player's current hunger level. May be easier to use than GetPlayerHunger() if you don't need to know the actual hunger value.
Syntax: int function GetPlayerHungerLevel() global
Parameters:
None.
Return Value: The player's current hunger level:
•  0 = Well Fed
•  1 = Satisfied
•  2 = Hungry
•  3 = Very Hungry
•  4 = Ravenous
•  5 = Starving
Example:
;Are you hungry?
float hng_level = SeedUtil.GetPlayerHungerLevel()


RestorePlayerThirst
Description: Restores the player's thirst by the provided amount.
Syntax: function RestorePlayerThirst(float afAmount, float target = -1.0) global
Parameters:

• afAmount: The amount to restore thirst by.
• target: The maximum level to restore thirst to.
Return Value: None.
Example:
;Restore the player's thirst up to the next level.
SeedUtil.RestorePlayerthirst(20.0)


GetPlayerThirst
Description: Gets the player's current Thirst.
Syntax: float function GetPlayerThirst() global
Parameters:
None.
Return Value: The player's current Thirst value.
Example:
;How thirsty is the player?
float thirst = SeedUtil.GetPlayerThirst()


GetPlayerThirstLevel
Description: Return the player's current thirst level. May be easier to use than GetPlayerThirst() if you don't need to know the actual thirst value.
Syntax: int function GetPlayerThirstLevel() global
Parameters:
None.
Return Value: The player's current thirst level:
•  0 = Quenched
•  1 = Refreshed
•  2 = Thirsty
•  3 = Very Thirsty
•  4 = Parched
•  5 = Dehydrated
Example:
;Is the player thirsty?
float thirst_level = SeedUtil.GetPlayerThirstLevel()
if thirst_level >= 2
     debug.notification("Man I'm thirsty!")
endif


GetPlayerFatigue
Description: Gets the player's current Fatigue.
Syntax: float function GetPlayerFatigue() global
Parameters:
None.
Return Value: The player's current Fatigue value.
Example:
;How fatigued is the player?
float fatigue = SeedUtil.GetPlayerFatigue()


GetPlayerFatigueLevel
Description: Return the player's current fatigue level. May be easier to use than
GetPlayerFatigue() if you don't need to know the actual fatigue value.
Syntax: int function GetPlayerFatigueLevel() global
Parameters:
None.
Return Value: The player's current fatigue level:
•  0 = Rested / Well Rested / Lover's Comfort / Parent's Love
•  1 = Sharp
•  2 = Tired
•  3 = Very Tired
•  4 = Haggard
•  5 = Exhausted
Example:
;Is the player tired?
float fatigue_level = SeedUtil.GetPlayerFatigueLevel()
if fatigue_level >= 2
     debug.notification("Man I'm tired!")
endif

getTrackedPartyCount
Description: The current number of followers in the party
Syntax: int function getTrackedPartyCount() global
Parameters: None.
Return Value: The current number of followers in the party
Note:
This method differs from CampUtil.GetTrackedFollowerCount() in that it also checks if the player has manually overriden thier party size through the MCM. If you want to check the actual number of follwers the player has, you should use CampUtil.GetTrackedFollowerCount() instead.
Example:

if SeedUtil.getTrackedPartyCount() == 0 
debug.notification("You feel lonely")
endif

RestorePartyHunger
Description: Restores the party’s hunger by the provided amount.
Syntax: function RestorePartyHunger(float afAmount, float target = -1.0) global
Parameters:

• afAmount: The amount to restore hunger by.
• target: The maximum level to restore hunger to.
Return Value:
None
Example:
;Restore your follower's hunger up to the next level.
SeedUtil.RestorePartyHunger(20.0)


GetPartyHunger
Description: Gets the party's current Hunger.
Syntax: float function GetPartyHunger() global
Parameters:None.
Return Value: The party's current Hunger value.
Example:

;How hungry are your followers?
float hng_level = SeedUtil.GetPartyLevel()


GetPartyHungerLevel
Description: Return the party's current hunger level. May be easier to use than
GetPartyHunger() if you don't need to know the actual hunger value.
Syntax: int function GetPartyHungerLevel() global
Parameters:
None.
Return Value: The party's current hunger level:
•  0 = Well Fed
•  1 = Satisfied
•  2 = Hungry
•  3 = Very Hungry
•  4 = Ravenous
•  5 = Starving
Example:
;Are your followers hungry?
float hng_level = SeedUtil.GetPartyHungerLevel()


RestorePartyThirst
Description: Restores the party's thirst by the provided amount.
Syntax: function RestorePartyThirst(float afAmount, float target = -1.0) global
Parameters:

• afAmount: The amount to restore thirst by.
• target: The maximum level to restore thirst to.
Return Value:
None
Example:
;Restore the party's thirst up to the next level.
SeedUtil.RestorePartythirst(20.0)


GetPartyThirst
Description: Gets the party's current Thirst.
Syntax: float function GetPartyThirst() global
Parameters: None.
Return Value: The party's current Thirst value.
Example:

;How thirsty is the party?
float thirst = SeedUtil.GetPartyThirst()


GetPartyThirstLevel
Description: Return the party's current thirst level. May be easier to use than
GetpartyThirst() if you don't need to know the actual hunger value.
Syntax: int function GetPartyHungerLevel() global
Parameters:
None.
Return Value: The party's current thirst level:
•  0 = Quenched
•  1 = Refreshed
•  2 = Thirsty
•  3 = Very Thirsty
•  4 = Parched
•  5 = Dehydrated
Example:
;Is the party thirsty?
float thirst_level = SeedUtil.GetPartyThirstLevel()
if thirst_level >= 2     debug.notification("Man I'm thirsty!")
endif


GetPlayerVitality
Description: Gets the player's current Vitality.
Syntax: float function GetPlayerVitality() global
Parameters:
None.
Return Value: The player's current Vitality value.
Example:
;How high is the player's Vitality?
float vitality = SeedUtil.GetPlayerVitality()


GetPlayerVitalityLevel
Description: Return the player's current vitality level. May be easier to use than GetPlayerVitality() if you don't need to know the actual vitality value.
Syntax: int function GetPlayerVitalityLevel() global
Parameters:
None.
Return Value: The player's current vitality level:
 • 0 = Dying
• 1 = Ruined
• 2 = Weakened
• 3 = Drained
• 4 = Healthy
• 5 = Very Healthy
• 6 = Vigorous
• 7 = Peak Condition
Note: Unlike other needs, higher vitality is better.
Example:

;Is the player healthy?
float vitality_level = SeedUtil.GetPlayerVitalityLevel()
if vitality_level >= 5
     debug.notification("I'm a health nut!")
endif


RestorePlayerNeedsVampire
Description: Completely restores the player's hunger and thirst when feeding as a vampire.
Syntax: function VampireFeed() global
Parameters:
None
Return Value: None.
Example:
;Restore player hunger and thirst (vampire only)
SeedUtil.
VampireFeed()


GetPlayerAlcoholLevel
Description: Return the player's current alcohol level.
Syntax: int function GetPlayerAlcoholLevel() global
Parameters: None
Return Value: The player's current alcohol level.
 • 0 = Sober
 • 1 = Relaxed
 • 2 = Tipsy
 • 3 = Drunk
 • 4 = Very Drunk
 • 5 = Hungover
Example:
;Is the player drunk?
float alc_level = SeedUtil.GetPlayerAlcoholLevel()
if alc_level >= 2
     debug.notification("Man I'm drunk!")
endif


AlcoholConsumed
Description: Increases player's alcohol level.
Syntax: function AlcoholConsumed(int type) global
Parameters:
 • type: The type of alcohol consumed
◦ 1: weak alcohol (e.g. ale)
◦ 2: moderate alcohol (e.g. wine)
◦ 3: strong alcohol (e.g. brandy)
Return Value: None
Example:
;Have a glass of wine
SeedUtil.AlcoholConsumed(2)

GetPlayerSkoomaLevel
Description: Return the player's current Skooma level.
Syntax: int function GetPlayerSkoomaLevel() global
Parameters: None
Return Value: The player's current Skooma level.
• 0: Clear-headed
• 1: Buzz
• 2: High
• 3: Very High
• 4: Delirious
Example:
;Is the player high?
float Skooma_level = SeedUtil.GetPlayerSkoomaLevel()
if Skooma_level >= 2
     debug.notification("Man I'm high!")
endif


SkoomaConsumed
Description: Increases player's Skooma level.
Syntax: function SkoomaConsumed(int type) global
Parameters:
 • type: The type of alcohol consumed
◦ 1: Weak Skooma (e.g. Balmora Blue)
◦ 2: strong Skooma (e.g. Double-Distilled Skooma)
Return Value:
None
Example:
;Have a Skooma
SeedUtil.SkoomaConsumed(1)


applyRandomDisease
Description: Adds random disease to the player
Syntax: function applyRandomDisease(Int DiseaseChance) global
Parameters:
 • DiseaseChance: percent chance of contracting the disease
Return Value:
None
Example:
; Give the player a random disease, guaranteed
SeedUtil.applyRandomDisease(100)


getDiseaseChance
Description: Gets the hazard level for the location the player is currently in.
Syntax: int function getLocationHazardLevel() global
Parameters: None
Return Value:
The hazard level as an int
• 1: best (player homes and temples)
• 2: good (houses and inns)
• 3: average (everwhere else)
• 4: not confortable (giant camps, mines, farms and prison)
• 5: Not Good (Dungeons, cemeteries, dragon lairs, vampire lairs, werewolf lairs and Dwemer ruins)
• 6: Terrible (Crypts, Hagraven nests, animal dens, Dragon Priest lairs, shipwrecks, Spriggan groves and Falmer hives)
Example:
; Is the player currently safe?
SeedUtil.
getDiseaseChance(DirtyWater, PlayerRef)

getLocationHazardLevel
Description: Gets the hazard level for the location the player is currently in.
Syntax: int function getLocationHazardLevel() global
Parameters: None
Return Value:
The chance of catching the disease, where 0 is no chance and 100 is guaranteed.
Example:
;Is the player in a safe location?
float hazardLevel = SeedUtil.
getLocationHazardLevel()
if
hazardLevel > 3
     debug.notification("This is not a safe place.")
endif


isInOblivion
Description: Checks if the player is currently in Oblivion
Syntax: bool function isInOblivion() global
Parameters: None
Return Value:
None
Example:
;Is the player in Oblivion?
if
SeedUtil.isInOblivion()
     debug.notification("I am no longer on the mortal plane.")
endif


CatchRandomDisease
Description: Adds random disease to the player.
Syntax: catchRandomDisease(float DiseaseChance, bool includeVampirism = false) global
Parameters:
  • DiseaseChance: percent chance of contracting the disease.
  • includeVampirism: Determines whether the player could catch Sanguinare Vampiris.

Return Value: None
Example:
;Catch a random disease, including vampirism.
catchRandomDisease(100, true)



GetDiseaseChanceFloat
Description: Gets the chance of catching a disease from a food or drink
Syntax: getDiseaseChanceFloat(Form akBaseObject, Actor Target) global
Parameters:
  • akBaseObject: the food item being eaten.
  • Target: The actor eating the food.
Return Value: the chance of catching the disease, where 0 is no chance and 100 is guaranteed.
Example:
;Check the disease chance of food
float diseaseChance = getDiseaseChanceFloat(theFood, PlayerRef)
if (diseaseChance > 0)
debug.notification("That's gross, I'm not eating that!")
endif

Article information

Added on

Edited on

Written by

Aytrus