Jump to content

Move NPC to different location once player leaves area


Recommended Posts

I have an NPC from my mod at Sanctuary. If the player denies some specific things, after the player leaves the area for a while, I want to move the NPC to a different location, but only when the player has left the area. I'm sure there's an easy way to do this, but I'm a beginner to modding quests, and I can't figure this out. Thanks for any help.

Link to comment
Share on other sites

you could use the unload event in papyrus and make a single fire script that will move the npc after they are unloaded (player moved far enough away for the actor / cell to unload)

https://www.creationkit.com/fallout4/index.php?title=OnUnload_-_ObjectReference

 

alternatively you could probably use a AI Package that checks to see how far away from sanctuary the player is and then activates to make the npc move to their new location, you'd probably need to set some conditions to the ai package as well, I'd set one so that once the npc has reached their destination, they package disables, this would keep it from firing off again unless they leave the location. You can alway have the package remove itself as well after they have reached the destination, or set a control package above that one that controls the npc once they have reached the destination.

 

Either way you will probably need at least one AI package to keep the npc in their new location so they don't wander back to their editor location (default sandbox does that I believe)

Link to comment
Share on other sites

you could place an xmarker and then track the OnCellDetached() event. Inside this one you should MoveTo() your NPC.

 

Or you can create a quest of LocationChangeEvent type and add it to SM event Node (a bit more complicated than the first variant).

Link to comment
Share on other sites

Oh boy, not as simple as I thought. I've never used scripts before. I guess it's time to learn! If you wouldn't mind, would you be able to point me in the direction to learn about some basic scripting and AI packages?

Link to comment
Share on other sites

  • 1 month later...

Oh boy, not as simple as I thought. I've never used scripts before. I guess it's time to learn! If you wouldn't mind, would you be able to point me in the direction to learn about some basic scripting and AI packages?

Lol, i had the exact same reaction when after creating a NPC and a conversation, i tried to make this NPC follow me into a cell... and "Oh boy" I never used anything close to scripting or papyrus etc

And its overwehlming because its not user friendly AT ALL, it's imo the real step to modding and unfortunatly when you wan't to do something a bit elaborate it's a must path...

 

atm im gathering information, but there is not much on Fallout 4 CK atm, some video tutorial will show you scripting but it's too fast forwarded... some guys generate a script function like it's nothing( cause he used to do this, its basic it's like another alphabet for him), he will explain you what his function will do but not WHY and HOW exactly.

 

I found this : https://www.creationkit.com/fallout4/index.php?title=Actor_Script

I don't know how i can use those function yet exactly, but they are common archetype so i may found a function that do what im looking for.

 

Skyrim CK tutorial seem's to be the place to learn scripting from the very basics : http://tesalliance.org/forums/index.php?/topic/4697-class-1-start-here-for-basics/

 

Modding is very interesting and fascinating but i wish the whole script "thing" was more user friendly, i understand why people get unmotivated when this step need to be crossed

Edited by Kreyd
Link to comment
Share on other sites

The easy way is an activator trigger and a 'defaultaliasontriggerleave' script.

 

So what you're going to need to do is setup a quest with a couple of stages. I imagine this is already part of a quest, but if not we can create one just for the purpose to moving the NPC.

 

First thing, let's create a new activator trigger. I almost always start by duplicating a 'DefaultSetStageTriggerPlayerOnly'. Now drop it into the render window in the space you want the player to walk out of and trigger the NPC move. Press the '2' key while selected on it to change the dimensions of the area.

 

Create a new quest. Needs an ID but doesn't need a name, a log entry, or objectives.

 

Go to the quest stages tab. Create two quest stages numbered 10 and 20. Click the box 'RunOnStart?' on stage 10.Go the the 'Quest Aliases' tab. Right click, create a new reference alias. 'Select Specific Reference' and point it to the trigger we dropped in. Now, in the alias window click 'Add' under papyrus scripts. Search for 'defaultaliasontriggerleave'. Double click to add it, and then it will take you to the script properties. We're concerned with 3 lines in these properties. 'StageToSet' should be 20. 'preReqStage' should be 10. And, 'PlayerTriggerOnly' should have a checkmark. Now press ok. In the object window, search for 'XMarkerHeading'. Drop one into the render window where you want the NPC to be moved once the player leaves the area.

 

Go back to the 'Quest Stages' tab. Select stage 20. In the first box that says log entry, right click and it will now allow you to add notes and papyrus fragments. Go to Papyrus fragments and use this snippet of code, assuming your NPC name is Gary:

Gary.MoveTo(GarysMarker)

You can change GARY and GARYSMARKER in that script to anything that makes sense to you, but now we're going to define them as properties. Click the properties button in Papyrus fragments. Now click 'Add Property' at the bottom of the next screen. In the 'Type' dropdown box find 'Actor'. Now name it Gary, or whatever you want to change it to.(it doesn't matter as long as the property name and the script match up) Press ok. Double-click on the new property and on the right you'll be able to select who 'Gary' is in the render window as an actor for the purposes of the script. We need one more property. Click Add property again and under 'Type', select 'ObjectReference'. Name this one 'GarysMarker'. Now, point it in the render window to the xmarkerheading. Press ok on the properties. Click 'Compile'. If nothing happens, it worked. If it doesn't, repeat these steps til they do. Here's some tutorials I've written for my mod team that might help if you've never scripted or done a quest before.

 

https://www.dropbox.com/s/lckzw8fwusupzsc/Papyrus101.pdf?dl=0

https://www.dropbox.com/s/8dfup3db2srep3e/dialogue%20tutorial.pdf?dl=0

https://www.dropbox.com/s/xv5hlsh5vf5lwwk/Conditions%20and%20Advanced%20Dialogue.pdf?dl=0

 

 

 

 

 

 

 

Link to comment
Share on other sites

Wrote this because it was quick and easy. You only need to learn how to attach scripts and fill properties for it.

Scriptname MoveNPCOnPlayerLeave extends ReferenceAlias
{ to be placed on the alias you want to move }

ObjectReference property xMarkerObj auto
{ The marker placed in the destination cell you want the NPC to move to. }

Auto State WaitingForPlayerToLeave
    Event OnCellDetached()
        ; You probably dont want this to fire again in the NPCs destination cell.
        GoToState("Done")
        ; Fires when the player exits the cell.
        (GetReference() as Actor).MoveTo(xMarkerObj)
    EndEvent
EndState

State Done
    Event OnCellDetached()
    ; thrown out by game engine, nothing is processed.
    EndEvent
EndState
Edited by TheDungeonDweller
Link to comment
Share on other sites

  • Recently Browsing   0 members

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