Jump to content

SetPlayerAIDriven causing all NPCs to go brain-dead


Recommended Posts

For reference, this is what the code currently looks like:

 

Function OnWalkTo(Int actorFormID, Int sceneKey, Float x, Float y, Float z, Float a)


Actor targetActor = Game.GetForm(actorFormID) as Actor
ObjectReference targetActorObject = targetActor as ObjectReference


ObjectReference walkMarker = targetActorObject.PlaceAtMe(AAF_MarkerFurniture)
walkMarker.waitfor3dload()


walkMarker.SetPosition(x, y, z)
walkMarker.SetAngle(0.0, 0.0, a)


walkMarker.MoveToNearestNavmeshLocation()


If targetActor.IsInPowerArmor()
exitPowerArmor(targetActor)
EndIf


AAF_WalkToAndWaitQuest[sceneKey].Stop()
AAF_WalkToAndWaitQuest[sceneKey].Start()
(AAF_WalkToAndWaitQuest[sceneKey].GetAlias(0) as ReferenceAlias).ForceREFTo(targetActor)
(AAF_WalkToAndWaitQuest[sceneKey].GetAlias(1) as ReferenceAlias).ForceREFTo(walkMarker)
AAF_WalkToAndWaitScene2[sceneKey].ForceStart()




if(targetActor == PlayerRef)
;Game.SetPlayerAIDriven()


inputLayer = InputEnableLayer.Create()
inputLayer.DisablePlayerControls(\
abMovement = false,  \
abFighting = true,  \
abCamSwitch = true,  \
abLooking = false,  \
abSneaking = false,  \
abMenu = false,  \
abActivate = false,  \
abJournalTabs = false,  \
abVATS = false,  \
abFavorites = false,  \
abRunning = false  \
)


EndIf


;/
While (targetActor.GetCurrentPackage() != AAF_StillPackage)
Utility.Wait(2)
Endwhile
/;


If(targetActor == PlayerRef)
;Game.SetPlayerAIDriven(False)
EndIf


Var[] sendData = new Var[1]
sendData[0] = actorFormID
sendEvent("WALK_COMPLETE", sendData)
EndFunction

In the above form, it works. But, it skips running the travel scenes. If you uncomment the commented out code, it will use the travel scenes properly. But, then destroy NPC AI somehow.

Link to comment
Share on other sites

It's hard to guess what is it caused by. As I don't get the problem I asume it must be caused by some other factors used together with SetPlayerAiDriven.

Maybe you can try to change the order. I used the SlotMachineHandler quest as a reference for my quest and set all very similar to it. Just my furniture marker was spawned by alias.

If you tell me what idle/furniture anim you are trying to play, I can try to add it to my test quest to check what happens.

Link to comment
Share on other sites

Kind of a long shot. But, maybe it has something to do with the scenes I have in the main script quest from my old method. I'm not using them any more with the above code. But... I will clean all of that up and see if that helps.

 

I agree that it must be some odd combination of things because I have seen this general pattern work... Maybe some package or scene settings? I will post screens of those later to see if anyone can see something there.

 

In terms of the idle/furniture, it plays idles dynamically. So, no specific one. It is an animation framework. So, the purpose is to be able to play animations or poses from packs in a way that is easier than using the console.

Link to comment
Share on other sites

I recreated this functionality from the ground up in a new esp.

 

It is not a 100% copy at this point. But, with most of the code in, it seems to work.

 

Is it possible to have a corrupt esp that would cause symptoms like I am seeing?

Possible, but it is more than likely a non-clean save that had script / variable fragments in it... but great news to know you've got it sorted!

Link to comment
Share on other sites

Joerqc is right.It's more likely that you had a corrupted save that could not update your quest correctly. Some things get baked into your save. It's especially likely to happen if you replaced scripts, attached and removed fragments or deleted script properties after making a save.

You can also complete phase conditions to wait for some certain events instead of checking it in the script.

Link to comment
Share on other sites

Hm. In this case I did test the build that isn't working from a new game. So, not sure if it could be a bad save. Will double-check that.

 

I have made various edits with FO4Edit at different times and there are odd remnants here and there that don't appear in the rebuilt version. Things like "unknown" flags set on packages.

Link to comment
Share on other sites

Well. Not sure whether to laugh or cry.

 

I rebuilt my esp from the ground up, connected it to the exact same code and now it works. I ran the animation routine, exited, went and punched a nearby NPC and they had enough brains to punch me back. It was beautiful.

 

Lesson: esp files can become corrupt without any apparent errors given in the CK. And the result of that can be bugs that seem connected to your code (and are thus very difficult to troubleshoot). Beware!

Link to comment
Share on other sites

You could also try to rename your .esp. Renaming makes the game think that it's another/new .esp. Not sure about possiblity of the corrupted .esp. Have not encountered anything like this yet. But who knows what is be possible in this game :D

Link to comment
Share on other sites

  • Recently Browsing   0 members

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