Author Topic: Teleporting NPCs  (Read 584 times)

Legacy_uberdowzen

  • Newbie
  • *
  • Posts: 41
  • Karma: +0/-0
Teleporting NPCs
« on: November 10, 2010, 03:51:05 am »


               I'm working on my first module at the moment and was wanting some scripting help. I've got two NPCs who I want to spawn in an area once a monster has been killed. Any advice on how to do this? I assume I'd have to create two waypoints that denote where the NPCs are going to spawn and then add something to the Monster's onDeath script. A few pointers would be much appreciated.

EDIT: also what would I have to do to have a VFX placeable spawn as the NPCs teleport? I assume it'd be a similar script?
               
               

               


                     Modifié par uberdowzen, 10 novembre 2010 - 03:52 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Teleporting NPCs
« Reply #1 on: November 10, 2010, 04:08:50 am »


               You don't have to choose a location in any given way. You could even find the coordinates using the mouse (they show in the bottom right of the toolset) and manually enter them into a vector, then build a location from it. You have to get the correct area somehow (again, many ways, the best depends on whether you're in the same area or not, among other things), but the rest is as follows:

//get area somehow - this assumes the caller is in the same area
object oArea = GetArea(OBJECT_SELF);

//enter your coordinates from your toolset read
float fX = 10.0;//x coord
float fY = 15.5//y coord
float fZ = 0.0//z coord
vector vVec = Vector(fX, fY, fZ);
float fFacing = 0.0;//I'm assuming you don't care much which way he spawns in facing - this can get tricking as scripted facing is 90 degrees off from toolset facing

//and voila, we have the location, no waypoint needed
location lLoc = Location(oArea, vVec, fFacing);

//of course, you can always just do it with a waypoint:
object oWay = GetObjectByTag("TAGOFWAYPOINT");//I'm not a fan of this function, but it serves for this example

location lLoc2 = GetLocation(oWay);

//From there you just spawn in the creatures, using CreateObject

object oSpawn1 = CreateObject(OBJECT_TYPE_CREATURE, "resref_of_beast", lLoc2);

Funky
               
               

               


                     Modifié par FunkySwerve, 10 novembre 2010 - 04:09 .
                     
                  


            

Legacy_uberdowzen

  • Newbie
  • *
  • Posts: 41
  • Karma: +0/-0
Teleporting NPCs
« Reply #2 on: November 10, 2010, 04:31:40 am »


               Cheers, that's awesome, thanks.
               
               

               
            

Legacy_uberdowzen

  • Newbie
  • *
  • Posts: 41
  • Karma: +0/-0
Teleporting NPCs
« Reply #3 on: November 12, 2010, 04:24:33 am »


               Actually, I just realised after doing some testing, spawning the NPCs again isn't going to work as it screws up the conversation they have. Is there actually some way of moving the characters from one area (which the PC visited earlier) to the area they're in at the moment?
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Teleporting NPCs
« Reply #4 on: November 12, 2010, 04:45:18 am »


               Sure, you can use Jump functions. In the script editor, just type Jump into the search box and look at the functions that pop up. The help window at the bottom will tell you the parameters you need.



Funky
               
               

               
            

Legacy_uberdowzen

  • Newbie
  • *
  • Posts: 41
  • Karma: +0/-0
Teleporting NPCs
« Reply #5 on: November 12, 2010, 05:13:19 am »


               Ack! Still not working!



I'll try and explain my problem. In the starting area of my module there are two NPCs who the player talks with to get a quest. You venture through some more areas and eventually reach a boss. When the boss dies I want the NPCs from earlier to appear in the area the boss is in. I've got getting them to spawn or jump in the room working, the problem is that there conversation then stops reacting to the scripts I've set up for the quest and the conversation ends whenever the second NPC is supposed to chime in.



Any ideas on how I could make this work? Thanks for your prompt and useful responses so far though '<img'>
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Teleporting NPCs
« Reply #6 on: November 12, 2010, 02:32:58 pm »


               Can't you have two different blueprints for each NPC and have them with different parts of the conversation? So the player gets the quest from Bob 1 who has the "go do this" part of the convo, later they kill the boss, so you then spawn in a different copy (Bob 2) who has the "good job, you did what I asked" half of the convo? Give the blueprints each unique tags/ResRefs and you can then deal with them seperately via other scripts or whatever.



Maybe I'm totally not understanding your problem here.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Teleporting NPCs
« Reply #7 on: November 12, 2010, 05:43:20 pm »


               Knightmare's suggestion is an option as well. We do that on HG, in fact, for the only NPC who appears in more than one place. Are you sure you're getting the conversation stopping problem with the Jump? Normally I would suspect that you had an incorrect tag on one of the speakers, likely resulting from spawning them in again using a palette version that didn't match the instance. With jumping that wouldn't be an issue, though.



It's also possible that you're using variables set on the creature during the conversation. If you are, that would screw up the conversation on a freshly spawned creature, because it'd lack those variables, but jumping it to a different area would resolve that.



You might also be using variables set on the creature's area. That is one of the few things I can think of that would screw up the convo regardless of whether you spawn a new npc or just jump in the old one. That, or an actual area check somewhere in your scripts. Without seeing the convo, it's pretty hard to say definitively.
               
               

               
            

Legacy_uberdowzen

  • Newbie
  • *
  • Posts: 41
  • Karma: +0/-0
Teleporting NPCs
« Reply #8 on: November 12, 2010, 08:11:30 pm »


               So you'd recommend that the first thing I should do is to check through all my scripts and tags etc to see if they're right? If so, I'll get back to you once I've done that.
               
               

               
            

Legacy_uberdowzen

  • Newbie
  • *
  • Posts: 41
  • Karma: +0/-0
Teleporting NPCs
« Reply #9 on: November 12, 2010, 08:17:10 pm »


               I just had a quick look and can't see any problems. The weird thing is, once the quest has been accepted in the first area then the second part of the conversation (the "you're off doing my quest" part) works fine but when they jump to the new area they go back to the first part of the conversation.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Teleporting NPCs
« Reply #10 on: November 12, 2010, 09:28:13 pm »


               How are you storing the info for the quest. In other words how do you determine how far along in the quest the PC is? Is the info stored on a no drop item the PC has, a database, on the NPC?
               
               

               
            

Legacy_uberdowzen

  • Newbie
  • *
  • Posts: 41
  • Karma: +0/-0
Teleporting NPCs
« Reply #11 on: November 12, 2010, 10:02:00 pm »


               I've got a local variable which can be set to 0 (quest not accepted yet), 100 (quest in progress) and 200 (quest completed). The part of the conversation which doesn't seem to be triggering requires the PC to have an item which they get from slaying a boss.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Teleporting NPCs
« Reply #12 on: November 12, 2010, 10:45:12 pm »


               What I meant was where are you storing the int?
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Teleporting NPCs
« Reply #13 on: November 12, 2010, 10:45:38 pm »


               But Baragg is asking where the variable IS.  If the variable is on the PC or a PC item then it goes with the PC. If you put it on an NPC and then go talk to another NPC the variable will not be there and will return 0. When you try to get it.
               
               

               


                     Modifié par Mudeye, 12 novembre 2010 - 10:45 .
                     
                  


            

Legacy_uberdowzen

  • Newbie
  • *
  • Posts: 41
  • Karma: +0/-0
Teleporting NPCs
« Reply #14 on: November 12, 2010, 11:20:33 pm »


               Oh right, this is my first module so bare with me. Do I need to define the variable somehow? I've just been assigning values using the script wizard.