Jump to content

Trouble With Companion Script


MackenzieBeyer

Recommended Posts

So I'm trying to have an NPC become your companion after you complete a quest, so I created this script and attached it to the actor.

Scriptname rubeyhasbeencompanion extends Actor Const

Quest Property animalsisters Auto Const

Faction Property CurrentCompanionFaction Auto Const

Actor Property Rubey Auto Const

Event
if 
animalsisters.GetStageDone(30) == 1
rubey.setfactionrank(currentcompanionfaction, -1)
EndEvent
Endif

But I keep getting EOF errors and "Object reference not set to an instance of an object."

Can someone tell me what I'm doing wrong here? I'm just trying to add them to the appropriate faction
Link to comment
Share on other sites

If you'd like to use the game's default method to set an NPC a follower, you could use a Quest Fragment. This is for a "primary" companion.

;BEGIN FRAGMENT Fragment_Stage_0000_Item_00
Function Fragment_Stage_0000_Item_00()
;BEGIN CODE
FollowersScript.GetScript().SetCompanion(Alias_YOURCOMPANION.GetActorReference())
;END CODE
EndFunction
;END FRAGMENT


ReferenceAlias Property Alias_YOURCOMPANION Auto Const


;For Dismiss
FollowersScript.GetScript().DismissCompanion(Alias_YOURCOMPANION.GetActorReference())

For creating a temporary follower, aka "secondary" companion, a Quest script is the best method I think.


ReferenceAlias Property Alias_YOURCOMPANION Auto Const
Int Property Status Auto conditional                    ;this property can be used for the follower AI package. Don't forget to flag the script as "Conditional" too
{ 0 = home, 1 = follow}
Faction Property CurrentCompanionFaction Auto Const
Quest Property Followers Auto mandatory



Function PickUp()

	Actor Companion = Alias_YOURCOMPANION.GetActorRef()
	Status = 1
	Companion.SetPlayerTeammate(True, True, False)
	Companion.AddToFaction(CurrentCompanionFaction)

	Companion.EvaluatePackage()
	Utility.Wait(1.0)

	If Companion.HasKeyword(PlayerCanStimpak) == 0        ;So you can use a stimpak on them
		Companion.AddKeyword(PlayerCanStimpak)
	EndIf

EndFunction
	
;For Dismiss

Function SendHome()

	Actor Companion = Alias_YOURCOMPANION.GetActorRef()
	Status = 0
	Companion.SetPlayerTeammate(False, True, False)
	Companion.RemoveFromFaction(CurrentCompanionFaction)


	Companion.EvaluatePackage()
	Utility.Wait(1.0)

	If Companion.HasKeyword(PlayerCanStimpak) == 1
		Companion.RemoveKeyword(PlayerCanStimpak)
	EndIf

EndFunction

Faction ranks aren't necessary. (CurrentCompanionFaction is 1 or 0). "If" and the actual condition

 

(like "If Companion.IsInFaction(CurrentCompanionFaction) == 1" have to be in the same line.

 

You can also use:


If Alias_YOURCOMPANION.GetActorRef().IsInFaction(CurrentCompanionFaction) == 1

EndIf

;This is also OK:

Actor Companion = Alias_YOURCOMPANION.GetActorRef()
If Companion.IsInFaction(CurrentCompanionFaction) == 1

EndIf

If you use the "primary" companion method, you don't have to create scripts for vertibird travel, etc.. The Followers quest handles that.

Edited by LarannKiar
Link to comment
Share on other sites

  • Recently Browsing   0 members

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