Jump to content

Teleport player and NPC to a cell upon dialogue choice.


Recommended Posts

I want to essentially teleport the player and an npc they are speaking to, to a private cell upon a dialogue choice.

 

Steps

1. upon dialogue choice player and NPC speaker transported to cell.

2. No companions come with.

3. they fight.

4. upon victory the player is transported back to the start location.

 

(the dialogue will take place in a town, even "teleporting" the parties to the wilderness outside of town would be fine).

 

Link to comment
Share on other sites

In your target location, place three xMarkers. One will be where you will move the NPC. One will be where you will move the player. The third will be moved to the player before porting them. That way you have something to move them to afterwards.

 

The things you'll need (not a full script - will not function as-is):

 

in the empty state

ObjectReference Property myNPCmarker Auto
ObjectReference Property myPlayerMarkerEnter Auto
ObjectReference Property myPlayerMarkerExit Auto
Actor Property myNPC Auto ;unless there is a built in way to get the NPC that is participating in the dialog.

inside a function, event or fragment

sends player and NPC to designated location

Actor PlayerRef = Game.GetPlayer()
myPlayerMarkerExit.MoveTo(PlayerRef)
PlayerRef.MoveTo(myPlayerMarkerEnter)
myNPC.MoveTo(myNPCmarker)

inside a function, event or fragment

sends player back to starting location

Actor PlayerRef = Game.GetPlayer()
PlayerRef.MoveTo(myPlayerMarkerExit)

 


Link to comment
Share on other sites

In your target location, place three xMarkers. One will be where you will move the NPC. One will be where you will move the player. The third will be moved to the player before porting them. That way you have something to move them to afterwards.

 

The things you'll need (not a full script - will not function as-is):

 

in the empty state

 

Much thanks.

Link to comment
Share on other sites

Just an update. Worked well thanks for the tips. Added the Xmarkers and just teleported on close of dialogue and back in the on death event for the NPC. Still needs some fine tuning. The NPC clearly gets there before me and is already up my butt attacking me the moment I load in from the teleport.

Edited by tsdobbi
Link to comment
Share on other sites

  • 3 years later...

I'm trying to do something similar:

- Upon dialogue option > teleport the player to a location.

Can you be more thorough on how to do this for a noob? I see something about "in an empty state" where can the empty state be found?

I attempted to use the 

Actor PlayerRef = Game.GetPlayer()
myPlayerMarkerExit.MoveTo(PlayerRef)
PlayerRef.MoveTo(myPlayerMarkerEnter)
myNPC.MoveTo(myNPCmarker)

after opening my quest > entering "Scene" tab > double clicking response to cause teleport > Pressing the "Run Fragment" bubble in the "OnEnd" section

This leads to the compile failing; additionally, it won't allow me to set a property and reference the marker in the reference window. What am I doing wrong here? 

Link to comment
Share on other sites

By "in the empty state", Ishara means "at the top level of the file, outside any function, event or state declaration".

In your case, you are attempting to use this in a fragment... your code layout needs to be different from the case that Ishara described:

  • The four property declarations in her 1st block need to be done with the "properties" button in the "scene data tab".  In the popup that will open, create four properties, with the types and names given in Ishara's example.  Fill them.
  • Then you can put the four code lines you quoted in the "OnEnd" fragment in that same "scene data tab".

If you manage it correctly, it should then compile.

If the properties button is greyed out or ineffective, start with a semicolon in the "OnEnd" fragment, close the scene tab, reopen it.  This forces an empty script to be created and associated with the scene.  The properties box will then work.

Close the scene data tab and the scene tab, reopen it, and double check that the properties are filled and the values are what you need.  Only test in game after double checking the property values.

Link to comment
Share on other sites

Perhaps I am confused and you are using a "dialogue topic info" end fragment instead of the "scene data tab" end fragment.

In that case, it's all the same, except for that detail: semicolon, properties, close scene, reopen it, add your code, close, reopen, check filled in values....

Link to comment
Share on other sites

 myNPC is undefined

@IsharaMeradin said 

;unless there is a built in way to get the NPC that is participating in the dialog.

I just explain it more  under the spoiler

Spoiler

If it is dialogue, just think NPC is the speaker and player is the player,  ¯\_(ツ)_/¯ you do this with no properties, just saying..

akSpeaker.MoveTo()
Game.GetPlayer().MoveTo()

Even if the dialogue calls a Quest Script, Function, you do not need an actor property just pass it with parameter, same with if the quest script calls or casts a spell / magic effects..  

 the NPC and the player in the Magic Effect from the dialogue  with no properties, though a Quest script, and the are respectively

akTarget (NPC)
akCaster  (Player)

Even in the magic effect you do not need variable for the Target is it

Actor Function GetTargetActor() native
if not passed by a parameter.... in other functions, Bethesda does a lot of the heavy lifting for you, use it to your advantage

Properties are over rated just sayin, I once recall @Chesko saying the same thing, over his dynamic code.. when criticise for not using properties

BUT having said that, for For scenes I never really made them, but the only thing I cannot see is how the myNPC is being filled.. it may be empty FYI NULL or None,  whatever you get the gist, else your code looks fine 

also check the other variables are fill correctly, the code to simple to be wrong and it is fine.. so the problems gotta be the variables either Property or Function Parameter passing the Scene Actor, BTW if the Scene uses Random NPC then properties will never work. and you must rely the actor pass thru the Function Parameter by Bethesda... and I am not sure what happen there ¯\_(ツ)_/¯

Please post the entire script.. from top to bottom so I can see what actor(s) are passed to you..  I am not opening the KIT, and remember to check those xMarker properties are filled... 

BTW for the scene the actor(s) may also be passed by the environment , and not be in the Frag whatsoever  (maybe) like I said I have never made a scene, but I can code, and I am aware of environment variables.. do scene use them, I do not know, but one would think they would

The scene / dialogue actor(s) are dynamic, and passed by Bethesda to you,  and require no properties and xMarker(s) are static and need properties, in case  I confuse or overwhelm you

Link to comment
Share on other sites

  • Recently Browsing   0 members

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