Jump to content

MCGUFIN

  • entries
    13
  • comments
    0
  • views
    1493

Fork Followers


Monoman1

33 views

Same premise as the other 'Forks' - Single user facing surface that plugs into several popular follower frameworks providing normalized functions. 

Supports: 
AFT, 
EFF, 
NFF, 
UFO,
Vanilla. 

Functions: 
GetFollowers()
GetFollowerCount()
GetMaxFollowerCount()

IsFollower()
AddFollower()
RemoveFollower()
CanRecruit()
GetExtendedInventory()

See also 'Events' entry for 'Follower Change Event'. 

_MGF_ForkFollowers: 

Spoiler
Scriptname _MGF_ForkFollowers extends Quest  

; Fork script for when you don't give a damn which follower framework is
; installed and just want to do/check some basic stuff.

; Currently covers:
; 1 - Extensible Follower Framework (EFF)
; 2 - Amazing Follower Tweaks (AFT)
; 3 - Ultimate Follower Overhaul (UFO)
; 4 - Nether's Follower Framework (NFF)
; 5 - Vanilla (Skyrim.esm's own single-follower system) - always available. 

; Follower framework you want not here? Write the interface script. Test it. Send it to me.

Import _MGF_ArrayCreate
Import _MGF_ArrayQuery

Event OnInit()
	Mods = New String[4]
	Mods[0] = "EFFCore.esm"
	Mods[1] = "AmazingFollowerTweaks.esp"
	Mods[2] = "UFO - Ultimate Follower Overhaul.esp"
	Mods[3] = "nwsFollowerFramework.esp"
	DecideState()
	RegisterForModEvent("_MGF_LoadOrderChanged", "On_MGF_LoadOrderChanged")
EndEvent

Function DecideState()
	If Game.GetModByName(Mods[0]) != 255 ; EFF
		GoToState("Eff")
	ElseIf Game.GetModByName(Mods[1]) != 255 ; AFT
		GoToState("Aft")
	ElseIf Game.GetModByName(Mods[2]) != 255 ; UFO
		GoToState("Ufo")
	ElseIf Game.GetModByName(Mods[3]) != 255 ; NFF
		GoToState("Nff")
	Else
		GoToState("Vanilla") ; always-available fallback, not mod-gated
	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 Eff
	; The plugin filename currently in control.
	String Function GetActiveMod()
		Return Mods[0]
	EndFunction

	; Every actor currently following, per this framework's own bookkeeping.
	Actor[] Function GetFollowers()
		Return Eff.GetFollowers()
	EndFunction

	; How many followers are currently active.
	Int Function GetFollowerCount()
		Return Eff.GetFollowerCount()
	EndFunction

	; The current follower cap, however this framework defines it.
	Int Function GetMaxFollowerCount()
		Return Eff.GetMaxFollowerCount()
	EndFunction

	; Is this specific actor currently following?
	Bool Function IsFollower(Actor akActor)
		Return Eff.IsFollower(akActor)
	EndFunction

	; Recruits the actor; optionally also registers them with Devious Followers.
	Bool Function AddFollower(Actor akActor, Bool AddAsDfFollower = false)
		Bool Result = Eff.AddFollower(akActor)
		If Result && AddAsDfFollower
			Df.AddDfFollower(akActor, 0, false, -1.0)
		EndIf
		Return Result
	EndFunction

	; Dismisses the actor; optionally routes through Devious Followers first.
	Bool Function RemoveFollower(Actor akActor, Int iMessage = 0, Int iSayLine = 1, Bool AlsoRemoveDfFollower = false)
		If AlsoRemoveDfFollower
			Return Df.RemoveDfFollower(akActor, iMessage, iSayLine)
		EndIf
		Return Eff.RemoveFollower(akActor, iMessage, iSayLine)
	EndFunction

	; Is there a free follower slot right now?
	Bool Function CanRecruit()
		Return Eff.CanRecruit()
	EndFunction

	; The follower's separate/hidden inventory container, if this framework has one.
	ObjectReference Function GetExtendedInventory(Actor akActor)
		Return Eff.GetExtendedInventory(akActor)
	EndFunction
EndState

State Aft
	; The plugin filename currently in control.
	String Function GetActiveMod()
		Return Mods[1]
	EndFunction

	; Every actor currently following, per this framework's own bookkeeping.
	Actor[] Function GetFollowers()
		Return Aft.GetFollowers()
	EndFunction

	; How many followers are currently active.
	Int Function GetFollowerCount()
		Return Aft.GetFollowerCount()
	EndFunction

	; The current follower cap, however this framework defines it.
	Int Function GetMaxFollowerCount()
		Return Aft.GetMaxFollowerCount()
	EndFunction

	; Is this specific actor currently following?
	Bool Function IsFollower(Actor akActor)
		Return Aft.IsFollower(akActor)
	EndFunction

	; Recruits the actor; optionally also registers them with Devious Followers.
	Bool Function AddFollower(Actor akActor, Bool AddAsDfFollower = false)
		Bool Result = Aft.AddFollower(akActor)
		If Result && AddAsDfFollower
			Df.AddDfFollower(akActor, 0, false, -1.0)
		EndIf
		Return Result
	EndFunction

	; Dismisses the actor; optionally routes through Devious Followers first.
	Bool Function RemoveFollower(Actor akActor, Int iMessage = 0, Int iSayLine = 1, Bool AlsoRemoveDfFollower = false)
		If AlsoRemoveDfFollower
			Return Df.RemoveDfFollower(akActor, iMessage, iSayLine)
		EndIf
		Return Aft.RemoveFollower(akActor, iMessage, iSayLine)
	EndFunction

	; Is there a free follower slot right now?
	Bool Function CanRecruit()
		Return Aft.CanRecruit()
	EndFunction

	; The follower's separate/hidden inventory container, if this framework has one.
	ObjectReference Function GetExtendedInventory(Actor akActor)
		Return Aft.GetExtendedInventory(akActor)
	EndFunction
EndState

State Ufo
	; The plugin filename currently in control.
	String Function GetActiveMod()
		Return Mods[2]
	EndFunction

	; Every actor currently following, per this framework's own bookkeeping.
	Actor[] Function GetFollowers()
		Return Ufo.GetFollowers()
	EndFunction

	; How many followers are currently active.
	Int Function GetFollowerCount()
		Return Ufo.GetFollowerCount()
	EndFunction

	; The current follower cap, however this framework defines it.
	Int Function GetMaxFollowerCount()
		Return Ufo.GetMaxFollowerCount()
	EndFunction

	; Is this specific actor currently following?
	Bool Function IsFollower(Actor akActor)
		Return Ufo.IsFollower(akActor)
	EndFunction

	; Recruits the actor; optionally also registers them with Devious Followers.
	Bool Function AddFollower(Actor akActor, Bool AddAsDfFollower = false)
		Bool Result = Ufo.AddFollower(akActor)
		If Result && AddAsDfFollower
			Df.AddDfFollower(akActor, 0, false, -1.0)
		EndIf
		Return Result
	EndFunction

	; Dismisses the actor; optionally routes through Devious Followers first.
	Bool Function RemoveFollower(Actor akActor, Int iMessage = 0, Int iSayLine = 1, Bool AlsoRemoveDfFollower = false)
		If AlsoRemoveDfFollower
			Return Df.RemoveDfFollower(akActor, iMessage, iSayLine)
		EndIf
		Return Ufo.RemoveFollower(akActor, iMessage, iSayLine)
	EndFunction

	; Is there a free follower slot right now?
	Bool Function CanRecruit()
		Return Ufo.CanRecruit()
	EndFunction
EndState

State Nff
	; The plugin filename currently in control.
	String Function GetActiveMod()
		Return Mods[3]
	EndFunction

	; Every actor currently following, per this framework's own bookkeeping.
	Actor[] Function GetFollowers()
		Return Nff.GetFollowers()
	EndFunction

	; How many followers are currently active.
	Int Function GetFollowerCount()
		Return Nff.GetFollowerCount()
	EndFunction

	; The current follower cap, however this framework defines it.
	Int Function GetMaxFollowerCount()
		Return Nff.GetMaxFollowerCount()
	EndFunction

	; Is this specific actor currently following?
	Bool Function IsFollower(Actor akActor)
		Return Nff.IsFollower(akActor)
	EndFunction

	; Recruits the actor; optionally also registers them with Devious Followers.
	Bool Function AddFollower(Actor akActor, Bool AddAsDfFollower = false)
		Bool Result = Nff.AddFollower(akActor)
		If Result && AddAsDfFollower
			Df.AddDfFollower(akActor, 0, false, -1.0)
		EndIf
		Return Result
	EndFunction

	; Dismisses the actor; optionally routes through Devious Followers first.
	Bool Function RemoveFollower(Actor akActor, Int iMessage = 0, Int iSayLine = 1, Bool AlsoRemoveDfFollower = false)
		If AlsoRemoveDfFollower
			Return Df.RemoveDfFollower(akActor, iMessage, iSayLine)
		EndIf
		Return Nff.RemoveFollower(akActor, iMessage, iSayLine)
	EndFunction

	; Is there a free follower slot right now?
	Bool Function CanRecruit()
		Return Nff.CanRecruit()
	EndFunction

	; The follower's separate/hidden inventory container, if this framework has one.
	ObjectReference Function GetExtendedInventory(Actor akActor)
		Return Nff.GetExtendedInventory(akActor)
	EndFunction
EndState

State Vanilla
	; The plugin filename currently in control (Vanilla has none, so this is a stand-in).
	String Function GetActiveMod()
		Return "Skyrim.esm" ; not mod-gated - always the fallback when nothing else is active
	EndFunction

	; Every actor currently following, per this framework's own bookkeeping.
	Actor[] Function GetFollowers()
		Return Vanilla.GetFollowers()
	EndFunction

	; How many followers are currently active.
	Int Function GetFollowerCount()
		Return Vanilla.GetFollowerCount()
	EndFunction

	; The current follower cap, however this framework defines it.
	Int Function GetMaxFollowerCount()
		Return Vanilla.GetMaxFollowerCount()
	EndFunction

	; Is this specific actor currently following?
	Bool Function IsFollower(Actor akActor)
		Return Vanilla.IsFollower(akActor)
	EndFunction

	; Recruits the actor; optionally also registers them with Devious Followers.
	Bool Function AddFollower(Actor akActor, Bool AddAsDfFollower = false)
		Bool Result = Vanilla.AddFollower(akActor)
		If Result && AddAsDfFollower
			Df.AddDfFollower(akActor, 0, false, -1.0)
		EndIf
		Return Result
	EndFunction

	; Dismisses the actor; optionally routes through Devious Followers first.
	Bool Function RemoveFollower(Actor akActor, Int iMessage = 0, Int iSayLine = 1, Bool AlsoRemoveDfFollower = false)
		If AlsoRemoveDfFollower
			Return Df.RemoveDfFollower(akActor, iMessage, iSayLine)
		EndIf
		Return Vanilla.RemoveFollower(akActor, iMessage, iSayLine)
	EndFunction

	; Is there a free follower slot right now?
	Bool Function CanRecruit()
		Return Vanilla.CanRecruit()
	EndFunction
EndState

; Empty state Functions

Actor[] Function GetFollowers()
	Return ArrayActorCreate(0)
EndFunction

Int Function GetFollowerCount()
	Return 0
EndFunction

Int Function GetMaxFollowerCount()
	Return 0
EndFunction

Bool Function IsFollower(Actor akActor)
	Return false
EndFunction

Bool Function AddFollower(Actor akActor, Bool AddAsDfFollower = false)
	Return false
EndFunction

Bool Function RemoveFollower(Actor akActor, Int iMessage = 0, Int iSayLine = 1, Bool AlsoRemoveDfFollower = false)
	Return false
EndFunction

Bool Function CanRecruit()
	Return false
EndFunction

ObjectReference Function GetExtendedInventory(Actor akActor)
	; Fallback for UFO + Vanilla. 
	Return None
EndFunction

Function Test(Actor akTestActor = None)
	Debug.Trace("_MGF_ForkFollowers: Test Begin")
	Debug.Trace("_MGF_ForkFollowers: Active Mod: " + GetActiveMod())
	Debug.Trace("_MGF_ForkFollowers: GetFollowerCount(): " + GetFollowerCount())
	Debug.Trace("_MGF_ForkFollowers: GetMaxFollowerCount(): " + GetMaxFollowerCount())
	Debug.Trace("_MGF_ForkFollowers: CanRecruit(): " + CanRecruit())

	Actor[] CurrentFollowers = GetFollowers()
	Debug.Trace("_MGF_ForkFollowers: GetFollowers() count: " + CurrentFollowers.Length)
	Int i = 0
	While i < CurrentFollowers.Length
		Debug.Trace("_MGF_ForkFollowers: Follower " + i + ": " + CurrentFollowers[i])
		i += 1
	EndWhile

	If akTestActor
		Debug.Trace("_MGF_ForkFollowers: IsFollower(akTestActor) before: " + IsFollower(akTestActor))
		Bool AddResult = AddFollower(akTestActor, true)
		Debug.Trace("_MGF_ForkFollowers: AddFollower(akTestActor, AddAsDfFollower=true): " + AddResult)
		Debug.Trace("_MGF_ForkFollowers: IsFollower(akTestActor) after add: " + IsFollower(akTestActor))
		Debug.Trace("_MGF_ForkFollowers: GetFollowerCount() while following: " + GetFollowerCount())

		Actor[] FollowersWhileActive = GetFollowers()
		Debug.Trace("_MGF_ForkFollowers: GetFollowers() count while following: " + FollowersWhileActive.Length)
		Int j = 0
		While j < FollowersWhileActive.Length
			Debug.Trace("_MGF_ForkFollowers: Follower " + j + ": " + FollowersWhileActive[j])
			j += 1
		EndWhile

		Debug.Trace("_MGF_ForkFollowers: GetExtendedInventory(akTestActor): " + GetExtendedInventory(akTestActor))
		Bool RemoveResult = RemoveFollower(akTestActor, 0, 1, true)
		Debug.Trace("_MGF_ForkFollowers: RemoveFollower(akTestActor, AlsoRemoveDfFollower=true): " + RemoveResult)
		Debug.Trace("_MGF_ForkFollowers: IsFollower(akTestActor) after remove: " + IsFollower(akTestActor))
		Debug.Trace("_MGF_ForkFollowers: GetFollowerCount() after remove: " + GetFollowerCount())
	Else
		Debug.Trace("_MGF_ForkFollowers: No test actor provided - skipping Add/Remove/IsFollower checks")
	EndIf

	Debug.Trace("_MGF_ForkFollowers: Test End")
EndFunction

String[] Mods

_MGF_InterfaceEff Property Eff Auto
_MGF_InterfaceAft Property Aft Auto
_MGF_InterfaceUfo Property Ufo Auto
_MGF_InterfaceNff Property Nff Auto
_MGF_InterfaceVanilla Property Vanilla Auto
_MGF_InterfaceDf Property Df Auto

 

 

Edited by Monoman1

0 Comments


Recommended Comments

There are no comments to display.

×
×
  • Create New...