Jump to content

SetPlayerAIDriven causing all NPCs to go brain-dead


Recommended Posts

Of course, now that I fixed one thing, a new problem has shown up that I had not seen before.

 

My scene has two phases. Walk and then Wait. Previously, this worked reliably for NPC and PC actors.

 

Now, the PC does not want to shift from the Walk to the Wait phase. I have a while loop that is waiting for them to complete the walk. It measures that by looking to see if the wait package exists or not on the actor. But, that is not happening.

 

Any ideas on that one? Is there a way to force the shift via code? Because I can poll for the distance from the marker (which is less than 1) and force the switch if there is a way?

Link to comment
Share on other sites

You can use conditions for phase complete . Click on the phase to open condition tab and select complete conditions: Then add a new condition: "GetDistance <= 20" . Use your aliases to define subject(npc) and marker. With such condition you don't need any code checking. Though you might need to add a general timer that will stop or restart the quest...You can't fully control npc and something can go wrong...like the marker can spawn in a bad place where they can't reach it, so your phase can get stuck and you need a mechanism to manage such situations. I don't know why do you even need 2 phases unless you want NPC to wait near the marker for some time. And it's just a bit difficult to suggest an efficient way without understanding what is this framework for and how it's supposed to be used.

Edited by kitcat81
Link to comment
Share on other sites

You can use conditions for phase complete . Click on the phase to open condition tab and select complete conditions: Then add a new condition: "GetDistance <= 20" . Use your aliases to define subject(npc) and marker. With such condition you don't need any code checking. Though you might need to add a general timer that will stop or restart the quest...You can't fully control npc and something can go wrong...like the marker can spawn in a bad place where they can't reach it, so your phase can get stuck and you need a mechanism to manage such situations. I don't know why do you even need 2 phases unless you want NPC to wait near the marker for some time. And it's just a bit difficult to suggest an efficient way without understanding what is this framework for and how it's supposed to be used.

 

I got ahead of myself. The problem is not that the phase doesn't change. The PC never actually starts into the scene at all. I trace the formID of the package during that wait loop. When it is an NPC it shows a number as expected. But, when I run this on the PC it shows as 0 and the log reports an error for running GetFormID on a None object.

 

Here is the relevant snippet of code:

 

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_WalkToAndWaitScene[sceneKey].Start()

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_WaitPackage)
;Debug.Notification("D: " + sceneKey + " : " + targetActor.GetDistance(walkMarker))
Debug.Notification("P: " + sceneKey + " : " + targetActor.GetCurrentPackage().GetFormID())
Utility.Wait(2)
Endwhile

Debug.Notification("WALK DONE: " + sceneKey)

I do want the actor (NPC or PC) to wait at the marker for some time. They are waiting for a second actor to reach the same marker. Sometimes the marker is away from both actors. Sometimes it is at the location of one or the other. So, when they reach it, they need to wait for the other to also reach it before the code proceeds.

 

The framework is more a generic toolset that can be used for multiple things rather than designed for one use. This walking and positioning part of it allows modders to group actors together for scenes where they might run different animations or poses.

Edited by dagobaking
Link to comment
Share on other sites

Added note as I'm testing: The problem of not being able to populate the ref alias with the PC seems to be context dependent. That's why it seemed to work before and not now.

 

I was able to go to a different location and it then worked. Maybe I need to set a flag somewhere to ignore some kind of alert state?

Link to comment
Share on other sites

To get the effect you then need to set the same condition for both actors in the phase complete conditions. So the phase will only end when both actors are near their markers. And you can additionally add a timer action to wait 5-7 seconds before they use the furniture.

 

Unfortunately, can't tell why it does not work for player without looking at your scene. You should have the package action added for both actors in your scene. The only difference with my test quest that I can see right now is that I created a special alias pointed at player that was applied automatically on quest start. While in game you can go in console and type: SQV YouQuesEditortID . It will show you if the aliases are filled and some other useful info.

 

I had a very similar working quest for player and companion and hugging animation. It worked ,i just did not like the camera settings of the animation, it looked bad from player perspective so I turned it into a quest for settlers that randomly runs in day time. It selects 2 settlers of different gender, makes them walk to markers , wait for each other, hug and stay hugging and chatting for 30-40 seconds. Most things work without any script help apart from marker positioning and deleting.

 

Thanks for clarifying. I just know there are many mods with animation markers where you can assign npc to use them so I was curious what other functionality you want to have that is unavailable with such mods.

Edited by kitcat81
Link to comment
Share on other sites

If you're up to looking, I can share screenshots of the scene panel, etc.?

 

Thank you for the tip on SQV. I really need to learn more about console commands for this kind of thing.

 

Is your hugging mod posted? Might be helpful for me to review the esp in CK.

 

The fact that it works as expected in some cases leads me to believe that the ref alias part is already ok. It seems like the problem has to do with different game conditions that might prevent populating the alias (dialogue situation, combat alert, etc.).

 

Going to have to pick this back up tomorrow. Out of synapse power tonight. Thanks again and good night!

Link to comment
Share on other sites

Yes. Please do send the mod. What I am doing is essentially a dynamic version of that. So, in theory, instead of a modder having to code it all, they just make the animations and give my mod some instructions and it handles the rest of the process for them.

 

Here is the alias screen:

 

 

 

See anything there that should be set to allow populating with PC more consistently?

 

 

Link to comment
Share on other sites

Dude... allow reserved - enable it - even though you are forcing via papyrus.

 

Because if the NPC is 'Reserves This Reference' on any other quest alias, they might not fill the alias, regardless of the ForceRefTo in the source code... Im just not sure either way, but better safe than not.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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