Fork Needs
Fork Needs is similar to ForkPregnancy - A interoperability adapter layer that presents a single unified surface for modders to integrate with.
ForkNeeds grants seamless access to Rnd, iNeed, Last Seed & Sunhelm without the modder needing to know or understand the underlying mod. Expanding the system to include another needs mod simply involves authoring a new backend interface. Once that backend interface is in place then any mod accessing Needs functions via MGF is automatically compatible with the new needs mod without any changes on their end. Very handy!
Highlights:
- GetHungerPercent(), ModHungerPercent(), SetHungerPercent(), GetHungerLevelString()
- Same as above but for thirst and fatigue.
There are additional forks for pregnancy, warmth (Frostfall, Sunhelm) and some others but I don't want to commit on those just yet.
_MGF_ForkNeeds:
Scriptname _MGF_ForkNeeds extends Quest ; Fork script for when you don't give a damn which needs mod is installed and ; just want to do/check some basic stuff. ; Currently covers: ; 1 - Realistic Needs and Diseases ; 2 - iNeed ; 3 - Last Seed ; 4 - SunHelm - Wilderness Survival (hunger/thirst/fatigue component only - ; see _MGF_ForkWarmth for its cold/exposure component) ; Needs mod you want not here? Write the interface script. Test it. Send it to me. Import _MGF_ArrayCreate Import _MGF_ArrayEdit Import _MGF_ArrayQuery Event OnInit() Mods = New String[4] Mods[0] = "RealisticNeedsandDiseases.esp" Mods[1] = "iNeed.esp" Mods[2] = "LastSeed.esp" Mods[3] = "SunHelmSurvival.esp" DecideState() RegisterForModEvent("_MGF_LoadOrderChanged", "On_MGF_LoadOrderChanged") EndEvent Function DecideState() If Game.GetModByName(Mods[0]) != 255 ; Rnd GoToState("Rnd") ElseIf Game.GetModByName(Mods[1]) != 255 ; iNeed GoToState("Ineed") ElseIf Game.GetModByName(Mods[2]) != 255 ; Last Seed GoToState("Seed") ElseIf Game.GetModByName(Mods[3]) != 255 ; SunHelm GoToState("Sunhelm") Else GoToState("") EndIf EndFunction Event On_MGF_LoadOrderChanged(Bool OrderChanged, Bool ModsAdded, Bool ModsRemoved, Bool ModsModified) If ModsAdded || ModsRemoved String[] ModsAddedList = _MGF_Util.GetAddedMods() String[] ModsRemovedList = _MGF_Util.GetRemovedMods() ModsAddedList = ArrayStringIntersectionValues(Mods, ModsAddedList) ModsRemovedList = ArrayStringIntersectionValues(Mods, ModsRemovedList) If ModsAddedList.Length > 0 || ModsRemovedList.Length > 0 DecideState() EndIf EndIf EndEvent String Function GetActiveState() Return GetState() EndFunction String Function GetActiveMod() Return "" EndFunction State Rnd String Function GetActiveMod() ; Returns the name of the mod this script is currently hooking into. Return Mods[0] EndFunction ; ============================================================================ ; Hunger ===================================================================== ; ============================================================================ Float Function GetHungerPercent() ; Returns hunger as 0-100% ; 0% = No hunger ; 100% = Maximum hunger Return Rnd.GetHungerPercent() EndFunction Function ModHungerPercent(Float Percentage) ; Percentage: -100.0 to +100.0 ; +100.0 = become maximally hungry. ; -100.0 = completely satisfy hunger. ; -50.0 = half-satisfy hunger. Rnd.ModHungerPercent(Percentage) EndFunction Function SetHungerPercent(Float Percentage) ; Percentage: 0.0 to 100.0 ; 0% = No hunger. ; 100% = Maximum hunger ; Directly sets hunger to the specified percentage Rnd.SetHungerPercent(Percentage) EndFunction Int Function GetHungerLevel() ; 0 - Gluttony ; 1 - Satiated ; 2 - Peckish ; 3 - Hungry ; 4 - Very Hungry ; 5 = Starving Return Rnd.GetHungerLevel() EndFunction Int Function GetHungerLevelMax() ; The maximum level of hunger for this mod Return Rnd.GetHungerLevelMax() EndFunction String Function GetHungerLevelString() ; 0 - Glutted ; 1 - Satiated ; 2 - Peckish ; 3 - Hungry ; 4 - Very Hungry ; 5 = Starving Return Rnd.GetHungerLevelString() EndFunction Bool Function GetIsBeggingHungry() ; Is hungry enough to beg Return Rnd.GetBegIsHungry() EndFunction ; ============================================================================ ; Thirst ===================================================================== ; ============================================================================ Float Function GetThirstPercent() Return Rnd.GetThirstPercent() EndFunction Function ModThirstPercent(Float Percentage) Rnd.ModThirstPercent(Percentage) EndFunction Function SetThirstPercent(Float Percentage) Rnd.SetThirstPercent(Percentage) EndFunction Int Function GetThirstLevel() ; 0 - Quenched ; 1 - Slightly Thirsty ; 2 - Thirsty ; 3 - Very Thirsty ; 4 - Dehydrated Return Rnd.GetThirstLevel() EndFunction Int Function GetThirstLevelMax() Return Rnd.GetThirstLevelMax() EndFunction String Function GetThirstLevelString() Return Rnd.GetThirstLevelString() EndFunction Bool Function GetIsBeggingThirsty() ; Is thirsty enough to beg Return Rnd.GetBegIsThirsty() EndFunction ; ============================================================================ ; Fatigue ==================================================================== ; ============================================================================ Float Function GetFatiguePercent() Return Rnd.GetFatiguePercent() EndFunction Function ModFatiguePercent(Float Percentage) Rnd.ModFatiguePercent(Percentage) EndFunction Function SetFatiguePercent(Float Percentage) Rnd.SetFatiguePercent(Percentage) EndFunction Int Function GetFatigueLevel() ; 0 - Not Tired ; 1 - Slightly Tired ; 2 - Tired ; 3 - Very Tired ; 4 - Exhausted Return Rnd.GetFatigueLevel() EndFunction Int Function GetFatigueLevelMax() Return Rnd.GetFatigueLevelMax() EndFunction String Function GetFatigueLevelString() Return Rnd.GetFatigueLevelString() EndFunction ; ============================================================================ ; Utility ==================================================================== ; ============================================================================ Bool Function IsDesperate() ; Player is at the maximum level of thirst or hunger Return Rnd.IsDesperate() EndFunction EndState State Ineed String Function GetActiveMod() Return Mods[1] EndFunction ; ============================================================================ ; Hunger ===================================================================== ; ============================================================================ Float Function GetHungerPercent() Return Ineed.GetHungerPercent() EndFunction Function ModHungerPercent(Float Percentage) Ineed.ModHungerPercent(Percentage) EndFunction Function SetHungerPercent(Float Percentage) Ineed.SetHungerPercent(Percentage) EndFunction Int Function GetHungerLevel() ; 0 - Satiated ; 1 - Mild Hunger ; 2 - Moderate Hunger ; 3 - Severe Hunger Return Ineed.GetHungerLevel() EndFunction Int Function GetHungerLevelMax() ; The maximum level of hunger for this mod Return Ineed.GetHungerLevelMax() EndFunction String Function GetHungerLevelString() ; 0 - Satiated ; 1 - Mild Hunger ; 2 - Moderate Hunger ; 3 - Severe Hunger Return Ineed.GetHungerLevelString() EndFunction Bool Function GetIsBeggingHungry() ; Is hungry enough to beg Return Ineed.GetBegIsHungry() EndFunction ; ============================================================================ ; Thirst ===================================================================== ; ============================================================================ Float Function GetThirstPercent() Return Ineed.GetThirstPercent() EndFunction Function ModThirstPercent(Float Percentage) Ineed.ModThirstPercent(Percentage) EndFunction Function SetThirstPercent(Float Percentage) Ineed.SetThirstPercent(Percentage) EndFunction Int Function GetThirstLevel() ; 0 - Well hydrated ; 1 - Mild thirst ; 2 - Moderate thirst ; 3 - Severe thirst Return Ineed.GetThirstLevel() EndFunction Int Function GetThirstLevelMax() Return Ineed.GetThirstLevelMax() EndFunction String Function GetThirstLevelString() ; 0 - Well hydrated ; 1 - Mild thirst ; 2 - Moderate thirst ; 3 - Severe thirst Return Ineed.GetThirstLevelString() EndFunction Bool Function GetIsBeggingThirsty() ; Is thirsty enough to beg Return Ineed.GetBegIsThirsty() EndFunction ; ============================================================================ ; Fatigue ==================================================================== ; ============================================================================ Float Function GetFatiguePercent() Return Ineed.GetFatiguePercent() EndFunction Function ModFatiguePercent(Float Percentage) Ineed.ModFatiguePercent(Percentage) EndFunction Function SetFatiguePercent(Float Percentage) Ineed.SetFatiguePercent(Percentage) EndFunction Int Function GetFatigueLevel() ; 0 - Rested ; 1 - Mild fatigue ; 2 - Moderate fatigue ; 3 - Severe fatigue Return Ineed.GetFatigueLevel() EndFunction Int Function GetFatigueLevelMax() Return Ineed.GetFatigueLevelMax() EndFunction String Function GetFatigueLevelString() ; 0 - Rested ; 1 - Mild fatigue ; 2 - Moderate fatigue ; 3 - Severe fatigue Return Ineed.GetFatigueLevelString() EndFunction ; ============================================================================ ; Utility ==================================================================== ; ============================================================================ Bool Function IsDesperate() ; Player is at the maximum level of thirst or hunger Return Ineed.IsDesperate() EndFunction EndState State Seed String Function GetActiveMod() Return Mods[2] EndFunction ; ============================================================================ ; Hunger ===================================================================== ; ============================================================================ Float Function GetHungerPercent() Return Seed.GetHungerPercent() EndFunction Function ModHungerPercent(Float Percentage) Seed.ModHungerPercent(Percentage) EndFunction Function SetHungerPercent(Float Percentage) Seed.SetHungerPercent(Percentage) EndFunction Bool Function GetIsBeggingHungry() ; Is hungry enough to beg Return Seed.GetBegIsHungry() EndFunction Int Function GetHungerLevel() ; 0 - Well Fed ; 1 - Satisfied ; 2 - Hungry ; 3 - Very Hungry ; 4 - Ravenous ; 5 = Starving Return Seed.GetHungerLevel() EndFunction Int Function GetHungerLevelMax() ; The maximum level of hunger for this mod Return Seed.GetHungerLevelMax() EndFunction String Function GetHungerLevelString() ; 0 - Well Fed ; 1 - Satisfied ; 2 - Hungry ; 3 - Very Hungry ; 4 - Ravenous ; 5 = Starving Return Seed.GetHungerLevelString() EndFunction ; ============================================================================ ; Thirst ===================================================================== ; ============================================================================ Float Function GetThirstPercent() Return Seed.GetThirstPercent() EndFunction Function ModThirstPercent(Float Percentage) Seed.ModThirstPercent(Percentage) EndFunction Function SetThirstPercent(Float Percentage) Seed.SetThirstPercent(Percentage) EndFunction Int Function GetThirstLevel() ; 0 = Quenched ; 1 = Refreshed ; 2 = Thirsty ; 3 = Very Thirsty ; 4 = Parched ; 5 = Dehydrated Return Seed.GetThirstLevel() EndFunction Int Function GetThirstLevelMax() Return Seed.GetThirstLevelMax() EndFunction String Function GetThirstLevelString() ; 0 = Quenched ; 1 = Refreshed ; 2 = Thirsty ; 3 = Very Thirsty ; 4 = Parched ; 5 = Dehydrated Return Seed.GetThirstLevelString() EndFunction Bool Function GetIsBeggingThirsty() ; Is thirsty enough to beg Return Seed.GetBegIsThirsty() EndFunction ; ============================================================================ ; Fatigue ==================================================================== ; ============================================================================ Float Function GetFatiguePercent() Return Seed.GetFatiguePercent() EndFunction Function ModFatiguePercent(Float Percentage) Seed.ModFatiguePercent(Percentage) EndFunction Function SetFatiguePercent(Float Percentage) Seed.SetFatiguePercent(Percentage) EndFunction Int Function GetFatigueLevel() ; 0 = Rested - Well Rested - Lover's Comfort - Parent's Love ; 1 = Sharp ; 2 = Tired ; 3 = Very Tired ; 4 = Haggard ; 5 = Exhausted Return Seed.GetFatigueLevel() EndFunction Int Function GetFatigueLevelMax() Return Seed.GetFatigueLevelMax() EndFunction String Function GetFatigueLevelString() ; 0 = Rested - Well Rested - Lover's Comfort - Parent's Love ; 1 = Sharp ; 2 = Tired ; 3 = Very Tired ; 4 = Haggard ; 5 = Exhausted Return Seed.GetFatigueLevelString() EndFunction ; ============================================================================ ; Utility ==================================================================== ; ============================================================================ Bool Function IsDesperate() ; Player is at the maximum level of thirst or hunger Return Seed.IsDesperate() EndFunction EndState State Sunhelm String Function GetActiveMod() Return Mods[3] EndFunction ; ============================================================================ ; Hunger ===================================================================== ; ============================================================================ Float Function GetHungerPercent() Return Sunhelm.GetHungerPercent() EndFunction Function ModHungerPercent(Float Percentage) Sunhelm.ModHungerPercent(Percentage) EndFunction Function SetHungerPercent(Float Percentage) Sunhelm.SetHungerPercent(Percentage) EndFunction Int Function GetHungerLevel() ; 0 - Well Fed (< 40) ; 1 - Satisfied (40-79) ; 2 - Peckish (80-139) ; 3 - Hungry (140-239) ; 4 - Ravenous (240-359) ; 5 - Starving (>= 360) Return Sunhelm.GetHungerLevel() EndFunction Int Function GetHungerLevelMax() Return Sunhelm.GetHungerLevelMax() EndFunction String Function GetHungerLevelString() ; 0 - Well Fed (< 40) ; 1 - Satisfied (40-79) ; 2 - Peckish (80-139) ; 3 - Hungry (140-239) ; 4 - Ravenous (240-359) ; 5 - Starving (>= 360) Return Sunhelm.GetHungerLevelString() EndFunction Bool Function GetIsBeggingHungry() ; Is hungry enough to beg Return Sunhelm.GetIsBeggingHungry() EndFunction ; ============================================================================ ; Thirst ===================================================================== ; ============================================================================ Float Function GetThirstPercent() Return Sunhelm.GetThirstPercent() EndFunction Function ModThirstPercent(Float Percentage) Sunhelm.ModThirstPercent(Percentage) EndFunction Function SetThirstPercent(Float Percentage) Sunhelm.SetThirstPercent(Percentage) EndFunction Int Function GetThirstLevel() ; 0 - Quenched (< 40) ; 1 - Sated (40-59) ; 2 - Thirsty (60-119) ; 3 - Parched (120-179) ; 4 - Dehydrated (180-299) ; 5 - Severely Dehydrated (>= 300) Return Sunhelm.GetThirstLevel() EndFunction Int Function GetThirstLevelMax() Return Sunhelm.GetThirstLevelMax() EndFunction String Function GetThirstLevelString() ; 0 - Quenched (< 40) ; 1 - Sated (40-59) ; 2 - Thirsty (60-119) ; 3 - Parched (120-179) ; 4 - Dehydrated (180-299) ; 5 - Severely Dehydrated (>= 300) Return Sunhelm.GetThirstLevelString() EndFunction Bool Function GetIsBeggingThirsty() ; Is thirsty enough to beg Return Sunhelm.GetIsBeggingThirsty() EndFunction ; ============================================================================ ; Fatigue ==================================================================== ; ============================================================================ Float Function GetFatiguePercent() Return Sunhelm.GetFatiguePercent() EndFunction Function ModFatiguePercent(Float Percentage) Sunhelm.ModFatiguePercent(Percentage) EndFunction Function SetFatiguePercent(Float Percentage) Sunhelm.SetFatiguePercent(Percentage) EndFunction Int Function GetFatigueLevel() ; 0 - Well Rested (< 80) ; 1 - Rested (80-159) ; 2 - Slightly Tired (160-239) ; 3 - Tired (240-359) ; 4 - Weary (360-479) ; 5 - Exhausted (>= 480) Return Sunhelm.GetFatigueLevel() EndFunction Int Function GetFatigueLevelMax() Return Sunhelm.GetFatigueLevelMax() EndFunction String Function GetFatigueLevelString() ; 0 - Well Rested (< 80) ; 1 - Rested (80-159) ; 2 - Slightly Tired (160-239) ; 3 - Tired (240-359) ; 4 - Weary (360-479) ; 5 - Exhausted (>= 480) Return Sunhelm.GetFatigueLevelString() EndFunction ; ============================================================================ ; Utility ==================================================================== ; ============================================================================ Bool Function IsDesperate() ; Player is at the maximum level of thirst or hunger Return Sunhelm.IsDesperate() EndFunction EndState ; Empty state Functions ================================================= Float Function GetHungerPercent() Return 0.0 EndFunction Function ModHungerPercent(Float Percentage) EndFunction Function SetHungerPercent(Float Percentage) EndFunction Int Function GetHungerLevel() Return 0 EndFunction Int Function GetHungerLevelMax() Return 0 EndFunction String Function GetHungerLevelString() Return "" EndFunction Bool Function GetIsBeggingHungry() ; Is hungry enough to beg Return false EndFunction Float Function GetThirstPercent() Return 0.0 EndFunction Function ModThirstPercent(Float Percentage) EndFunction Function SetThirstPercent(Float Percentage) EndFunction Int Function GetThirstLevel() Return 0 EndFunction Int Function GetThirstLevelMax() Return 0 EndFunction String Function GetThirstLevelString() Return "" EndFunction Bool Function GetIsBeggingThirsty() ; Is thirsty enough to beg Return false EndFunction Float Function GetFatiguePercent() Return 0.0 EndFunction Function ModFatiguePercent(Float Percentage) EndFunction Function SetFatiguePercent(Float Percentage) EndFunction Int Function GetFatigueLevel() Return 0 EndFunction Int Function GetFatigueLevelMax() Return 0 EndFunction String Function GetFatigueLevelString() Return "" EndFunction Bool Function IsDesperate() ; Player is at the maximum level of thirst or hunger Return false EndFunction Function Test() Debug.Trace("_MGF_ForkNeeds: Test Begin") Debug.Trace("_MGF_ForkNeeds: Active Mod: " + GetActiveMod()) Debug.Trace("_MGF_ForkNeeds: HUNGER ===================================") Debug.Trace("_MGF_ForkNeeds: GetHungerLevel(): " + GetHungerLevel()) Debug.Trace("_MGF_ForkNeeds: GetHungerLevelMax(): " + GetHungerLevelMax()) Debug.Trace("_MGF_ForkNeeds: GetHungerLevelString(): " + GetHungerLevelString()) Float OldValue = GetHungerPercent() Debug.Trace("_MGF_ForkNeeds: GetHungerPercent(): " + GetHungerPercent()) ModHungerPercent(30.0) Debug.Trace("_MGF_ForkNeeds: ModHungerPercent(30%): " + GetHungerPercent()) ModHungerPercent(-30.0) Debug.Trace("_MGF_ForkNeeds: ModHungerPercent(-30%): " + GetHungerPercent()) SetHungerPercent(0.0) Debug.Trace("_MGF_ForkNeeds: SetHungerPercent(0%): " + GetHungerPercent()) SetHungerPercent(100.0) Debug.Trace("_MGF_ForkNeeds: SetHungerPercent(100%): " + GetHungerPercent()) Debug.Trace("_MGF_ForkNeeds: GetIsBeggingHungry(): " + GetIsBeggingHungry()) SetHungerPercent(OldValue) Debug.Trace("_MGF_ForkNeeds: Thirst ===================================") OldValue = GetThirstPercent() Debug.Trace("_MGF_ForkNeeds: GetThirstPercent(): " + GetThirstPercent()) ModThirstPercent(30.0) Debug.Trace("_MGF_ForkNeeds: ModThirstPercent(30.0): " + GetThirstPercent()) ModThirstPercent(-30.0) Debug.Trace("_MGF_ForkNeeds: ModThirstPercent(-30.0): " + GetThirstPercent()) SetThirstPercent(0.0) Debug.Trace("_MGF_ForkNeeds: SetThirstPercent(0.0): " + GetThirstPercent()) SetThirstPercent(100.0) Debug.Trace("_MGF_ForkNeeds: SetThirstPercent(100.0): " + GetThirstPercent()) SetThirstPercent(OldValue) Debug.Trace("_MGF_ForkNeeds: GetThirstLevel(): " + GetThirstLevel()) Debug.Trace("_MGF_ForkNeeds: GetThirstLevelMax(): " + GetThirstLevelMax()) Debug.Trace("_MGF_ForkNeeds: GetThirstLevelString(): " + GetThirstLevelString()) Debug.Trace("_MGF_ForkNeeds: GetIsBeggingThirsty(): " + GetIsBeggingThirsty()) Debug.Trace("_MGF_ForkNeeds: Fatigue ===================================") OldValue = GetFatiguePercent() Debug.Trace("_MGF_ForkNeeds: GetFatiguePercent(): " + GetFatiguePercent()) ModFatiguePercent(30.0) Debug.Trace("_MGF_ForkNeeds: ModFatiguePercent(30.0): " + GetFatiguePercent()) ModFatiguePercent(-30.0) Debug.Trace("_MGF_ForkNeeds: ModFatiguePercent(-30.0): " + GetFatiguePercent()) SetFatiguePercent(0.0) Debug.Trace("_MGF_ForkNeeds: SetFatiguePercent(0.0): " + GetFatiguePercent()) SetFatiguePercent(100.0) Debug.Trace("_MGF_ForkNeeds: SetFatiguePercent(100.0): " + GetFatiguePercent()) SetFatiguePercent(OldValue) Debug.Trace("_MGF_ForkNeeds: GetFatigueLevel(): " + GetFatigueLevel()) Debug.Trace("_MGF_ForkNeeds: GetFatigueLevelMax(): " + GetFatigueLevelMax()) Debug.Trace("_MGF_ForkNeeds: GetFatigueLevelString(): " + GetFatigueLevelString()) Debug.Trace("_MGF_ForkNeeds: Test End") EndFunction String[] Mods _MGF_InterfaceRnd Property Rnd Auto _MGF_InterfaceIneed Property Ineed Auto _MGF_InterfaceLastSeed Property Seed Auto _MGF_InterfaceSunhelm Property Sunhelm Auto
Edited by Monoman1
0 Comments
Recommended Comments
There are no comments to display.