Jump to content

How to make NPC use PathToReference?


Recommended Posts

I was able to get the players character to be controlled via PathToReference. See this thread for reference: https://forums.nexusmods.com/index.php?/topic/6464556-how-to-make-player-use-pathtoreference/

 

I expected the same code to work on NPC characters. But, it does not. The NPC characters just continue to sandbox instead. It appears that the PathToReference call is being over-ridden by other packages/keywords on the NPCs.

 

I have tried adding them to the "WorkshopNoPackages" faction. No apparent effect.

 

So, any ideas on how to take control of the NPC and make them walk to a marker? Preferably, I would like to use an all code solution rather than packages, etc. in the CK. It seems like it has to be possible given that I've done it for the player character...

 

Thank you for any help.

Link to comment
Share on other sites

I have continued to try and troubleshoot this with no luck so far.

 

The demo code on the wiki doesn't even appear to work: https://www.creationkit.com/fallout4/index.php?title=PathToReference_-_Actor

 

I am running this code on characters in Sanctuary Hills (Marcy Long, etc.). I've used the exact code from the wiki link and the character does not move toward me.

 

Additionally, I am tracking the return value. After maybe 5 seconds of the NPC not pathing anywhere, it actually returns true. Every time. So, the engine seems to think that the character is going to where they should...

 

This makes me think that the pathing is meant for really long distances like moving the NPC to the same general area as the reference? But, then, if that is the case, why does it work more precisely when I apply it to the player?

 

Any insight into this would be greatly appreciated. Even remote clues! Or, maybe someone can provide a snippet of code where they got this to work and I can see some mistake I am making?

Edited by dagobaking
Link to comment
Share on other sites

I have continued to try and troubleshoot this with no luck so far.

 

The demo code on the wiki doesn't even appear to work: https://www.creationkit.com/fallout4/index.php?title=PathToReference_-_Actor

 

I am running this code on characters in Sanctuary Hills (Marcy Long, etc.). I've used the exact code from the wiki link and the character does not move toward me.

 

Additionally, I am tracking the return value. After maybe 5 seconds of the NPC not pathing anywhere, it actually returns true. Every time. So, the engine seems to think that the character is going to where they should...

 

This makes me think that the pathing is meant for really long distances like moving the NPC to the same general area as the reference? But, then, if that is the case, why does it work more precisely when I apply it to the player?

 

Any insight into this would be greatly appreciated. Even remote clues! Or, maybe someone can provide a snippet of code where they got this to work and I can see some mistake I am making?

 

I believe that what you should do in the Quest is to add the npc as an alias and create a new package in the same alias properties page. This package must have the action of travel to ref, and the condition that says must complete. Additionally you can use that package in a scene and condition that only the packages of the scene are executed, it is one of the options in the page of scenes, this cancels any other active package of the npc. Just remember to call the function of evaluatepackages at the beginning and end when you release the alias so that it returns to its original packages.
Sorry if I'm not very clear, I speak Spanish.
Link to comment
Share on other sites

 

I believe that what you should do in the Quest is to add the npc as an alias and create a new package in the same alias properties page. This package must have the action of travel to ref, and the condition that says must complete. Additionally you can use that package in a scene and condition that only the packages of the scene are executed, it is one of the options in the page of scenes, this cancels any other active package of the npc. Just remember to call the function of evaluatepackages at the beginning and end when you release the alias so that it returns to its original packages.
Sorry if I'm not very clear, I speak Spanish.

 

 

Thank you. I understood.

 

I may have to use that approach. But, I am hoping to avoid it because it relies on referencealiases. I want to have this same effect through code only for two reasons. One, to keep the code more clean (simply sending an Actor reference to a function). And two, using referencealiases means that you are limited to using only those aliases at a given time. What if I want to apply this effect to 12 actors at one time? Then I have to have an ugly stack of 12+ referencealiases on the quest and code to manage handing out these spots to requests as they come in.

Edited by dagobaking
Link to comment
Share on other sites

Keeping the code clean is not always doing everything in a script, if you do not get the most out of each functionality. You can do it by code, forcing the npc to delete their original packages and then after finishing them to assign them again, but it is cleaner and correct to use the aliases and the scenes. If you look at the quest of bethesda you will notice that they handle a lot the scenes for that type of manipulation of the npc. Now to use several aliases everything depends on the use you are going to give it, there is Alias and Collection Alias, you can create a collection Alias that starts empty and by means of a script fill it with the npc reference. The collection alias is an array and by means of code you can add or delete references, the info: https://www.creationkit.com/fallout4/index.php?title=RefCollectionAlias_Script

 

In the way the Creation Engine script works, it is safer and more functional to do those actions through scenes. If you do it by code sometimes it will work and in many others it will only ignore the instruction because it has another AI quest that has higher priority (Packages).

 

The Alias, Reference Alias, Collection Alias, can be used to store any reference not only actors, and adjusting them correctly in their configuration you can make an Alias not linked to a fixed reference all the time, that if you can change it in the script. The important thing is that you add a blank alias, in the options you mark it as optional and it can be reused, that is at the top of the alias configuration page. By doing that the quest can start without error even if the alias is empty and already by means of code you can assign it to an actor, object, etc.

Edited by snikegear
Link to comment
Share on other sites

Keeping the code clean is not always doing everything in a script, if you do not get the most out of each functionality. You can do it by code, forcing the npc to delete their original packages and then after finishing them to assign them again, but it is cleaner and correct to use the aliases and the scenes. If you look at the quest of bethesda you will notice that they handle a lot the scenes for that type of manipulation of the npc. Now to use several aliases everything depends on the use you are going to give it, there is Alias and Collection Alias, you can create a collection Alias that starts empty and by means of a script fill it with the npc reference. The collection alias is an array and by means of code you can add or delete references, the info: https://www.creationkit.com/fallout4/index.php?title=RefCollectionAlias_Script

 

In the way the Creation Engine script works, it is safer and more functional to do those actions through scenes. If you do it by code sometimes it will work and in many others it will only ignore the instruction because it has another AI quest that has higher priority (Packages).

 

The Alias, Reference Alias, Collection Alias, can be used to store any reference not only actors, and adjusting them correctly in their configuration you can make an Alias not linked to a fixed reference all the time, that if you can change it in the script. The important thing is that you add a blank alias, in the options you mark it as optional and it can be reused, that is at the top of the alias configuration page. By doing that the quest can start without error even if the alias is empty and already by means of code you can assign it to an actor, object, etc.

 

Thank you. I appreciate this. I do know about reference aliases and collections and have used them a little before. And I agree that using the CK for some of these pieces is what is intended by Bethesda and thus is arguably "correct". But, the major reason why the CK exists is to allow Bethesda to hire non-developers to help make content on a large team. From an individual modder perspective, it's not the best situation to not have full functionality available from the code. Unless you are making very Vanilla-like content mods.

 

Anyway, I appreciate your help and don't want to get too philosophical about it. :)

 

Given the NPC control strategy that you describe, how would you approach this task:

 

1) Have a function in papyrus like this:

Function walkTo(Actor target, ObjectReference marker)
     ; some code to start the process
EndFunction

2) Using scenes, reference aliases, etc. control any actor (NPC or player) to walk to any marker and run the following function upon reaching the destination:

Function walkComplete(Actor target)
     ; run some other code now that the walking has completed with access to the Actor that did the walking
EndFunction

Keep in mind that it needs to be capable of taking any number of actors going to unique markers at the same time.

Link to comment
Share on other sites

1) Seeing the implementation that you did and showed on another page of the forum, I think that this part of controlling the player and you have done it, allowed me to try it and it works. I had fun watching my character go from Sanctuary to DiamondCity.


2) To control any npc I would use the Collection Alias, I have one that works more or less that way, in my case they are npcs that are created by spending a certain time in the game. I add them to the collection through a Stage using the example of: https://www.creationkit.com/fallout4/index.php?title=PlaceActorAtMe_-_ObjectReference.


Steps Example:


Stage 10 (create new npcs using in base actors)

In the properties of this Stage I add the npcs that I will need, in this case they are fixed referenced to an ActorBase. Then I use:


RefCollectionAliasX.AddRef (xMarker.PlaceActorAtMe (BaseActorX1, 4))

RefCollectionAliasX.AddRef (xMarker.PlaceActorAtMe (BaseActorX2, 4))

wait ...


You know that, let's do an example mod and in the week I'll pass it on, so it will be easier. Maybe you can avoid the part of the scene by adding the package directly to the collection, let me do tests.

Link to comment
Share on other sites

 

1) Seeing the implementation that you did and showed on another page of the forum, I think that this part of controlling the player and you have done it, allowed me to try it and it works. I had fun watching my character go from Sanctuary to DiamondCity.

 

There is something satisfying about it, right? It's like going to Disneyland and taking the tour train ride. Finally, you just let them take you around the park. :D

 

 

2) To control any npc I would use the Collection Alias, I have one that works more or less that way, in my case they are npcs that are created by spending a certain time in the game. I add them to the collection through a Stage using the example of: https://www.creationkit.com/fallout4/index.php?title=PlaceActorAtMe_-_ObjectReference.

 

1) Seeing the implementation that you did and showed on another page of the forum, I think that this part of controlling the player and you have done it, allowed me to try it and it works. I had fun watching my character go from Sanctuary to DiamondCity.
2) To control any npc I would use the Collection Alias, I have one that works more or less that way, in my case they are npcs that are created by spending a certain time in the game. I add them to the collection through a Stage using the example of: https://www.creationkit.com/fallout4/index.php?title=PlaceActorAtMe_-_ObjectReference.
Steps Example:
Stage 10 (create new npcs using in base actors)
In the properties of this Stage I add the npcs that I will need, in this case they are fixed referenced to an ActorBase. Then I use:
RefCollectionAliasX.AddRef (xMarker.PlaceActorAtMe (BaseActorX1, 4))
RefCollectionAliasX.AddRef (xMarker.PlaceActorAtMe (BaseActorX2, 4))
wait ...
You know that, let's do an example mod and in the week I'll pass it on, so it will be easier. Maybe you can avoid the part of the scene by adding the package directly to the collection, let me do tests.

 

 

 

Forum ate my previous reply!

 

For "2)", wouldn't that send everyone to the same spot? What about sending each NPC in the collection to a different, uniquely placed marker?

 

I think that a demo file would be very helpful for a lot of people setting something similar up. I can't be alone. Very interested in seeing that.

Edited by dagobaking
Link to comment
Share on other sites

Why you don't want to use a package(travel package in this case)? For me this would be the easier route.

 

It's not scalable. You have to run the package with set reference aliases.

 

I want to make something that can accept a command to one NPC, 3, 9 or 20+ at the same time.

 

The existence of the PathToReference command and the fact that this does work on the player character makes me believe that it is technically possible with code only. But, conflicting packages and keywords complicate it to the point that nobody (I'm aware of) has figured it out.

 

Currently, I'm planning to just use the packages/alias as everyone recommends and make 30 reference aliases to handle multiple instances. Just not thrilled about it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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