Jump to content

Making "OnLocationChange" function work for NPC


Recommended Posts

Trying to make the OnLocationChange Script, or something similar, work on an NPC:

https://www.creationkit.com/fallout4/index.php?title=OnLocationChange_-_Actor

 

Scenario is: NPC is shot by a special type of teleport gun. The gun does no damage. All it does is teleport the NPC to a new cell. That part works fine.

 

But, once the game detects the NPC in the new cell, I want it to advance the quest to the next quest stage.

 

The default OnLocationChange script compiles:

 

Event OnLocationChange(Location akOldLoc, Location akNewLoc)
if (Game.GetPlayer().GetCurrentLocation() == akOldLoc)
Debug.Trace("We have left the player's location!")
endIf
endEvent
But if I replace "Game.GetPlayer()" with a defined reference alias, an error comes back that: "GetCurrentLocation is not a function or does not exist".
OnLocationChange seems to only work on the player. So I can't even enter the next part of the script to set the next quest stage once the NPC changes cells.
Any suggestions for a workaround?
To clarify, the player is supposed to talk to an NPC at quest stage 100. Finishing the conversation leads to stage 110. That's no problem.
Issue is, if player shoots the NPC with the teleport gun before talking to the NPC, it will break the quest unless there's a mechanism that advances to stage 110 upon detecting that the NPC has changed cells.
Shooting and killing the NPC with a regular gun is also no issue since the DefaultAliasOnDeath handles advancing the quest stage. Only problem is shooting the NPC with the teleport gun, which moves the NPC to a new cell, but doesn't kill them.
Appreciate any help, thank you!

 

Link to comment
Share on other sites

Spoke too soon, the below appears to work. If anyone has a better way though, would love to hear it -thanks!

 

Scriptname OAR_AliasLocationChangeSetStage extends ReferenceAlias

Event OnLocationChange(Location akOldLoc, Location akNewLoc)
if akNewLoc != NewLocation
QuestName.SetStage(StageToSet)
endIf
endEvent

Int Property StageToSet Auto Const

Location Property NewLocation Auto Const

Quest Property QuestName Auto Const

Link to comment
Share on other sites

  • Recently Browsing   0 members

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