Jump to content

[Condition] Check if player has companion


Zorkaz

Recommended Posts

Not that I have found. so created a conditional function:

Scriptname SKK_XXXConditionalScript extends Quest Conditional

Quest Property pFollowers Auto Const Mandatory
Faction Property pCurrentCompanionFaction Auto Const Mandatory
ReferenceAlias Property Alias_Companion Auto Const Mandatory ;linked to followers quest alias
ReferenceAlias Property Alias_DogmeatCompanion Auto Const Mandatory ;linked to followers quest alias

Bool bPlayerHasCompanion = False Conditional ;GetVmQuestVariable QuestName bPlayerHasCompanion

;********************************************************************

Event OnQuestInit()

Self.RegisterForCustomEvent((pFollowers as FollowersScript), "CompanionChange") 
UpdatePlayerHasCompanion()
    
EndEvent

;********************************************************************

Event FollowersScript.CompanionChange(FollowersScript akSender, Var[] akArgs)

UpdatePlayerHasCompanion()

EndEvent

;********************************************************************

Function UpdatePlayerHasCompanion()

bPlayerHasCompanion = False

Actor thisActor = Alias_Companion.GetActorRef()
If(thisActor != None) && (thisActor.IsInFaction(pCurrentCompanionFaction) == true)
    bPlayerHasCompanion = True
EndIf

Actor thisDog = Alias_DogmeatCompanion.GetActorRef() ; allow for dogmeat +1 multiple companions 
If(thisDog != None) && (thisDog.IsInFaction(pCurrentCompanionFaction) == true)
    bPlayerHasCompanion = True
EndIf

EndFunction

;********************************************************************

Link to comment
Share on other sites

Bethesda used the global variable "PlayerHasActiveCompanion" (00145867) for this. That's what the Lone Wanderer perk relies on, as well as multiple quest and follower-related checks. There is also a second global for Dogmeat, which is "PlayerHasActiveDogmeatCompanion" (00145868), though that one appears to see less use.

For a bit of context, this is the perk entry condition for Lone Wanderer:

image.thumb.png.4d4eff428cd8139d84ec9aeb5de0e64a.png

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...