MadMage999

Location local variables?

Recommended Posts

Hi all, I was in the process of making a mod that store locations and lets you teleport back to them at will, and it seems that storing locations in kotor1/2 is done a bit differently than what I'm used to (coming from scripting for nwn2).

 

What I want is to get the location of the speaker in a script fired from a conversation and store it. What I'm used to doing is using a local variable, but I don't see the function I need.

 

Does anyone know how to store the current location of the speaker so that it can be used in another script later to teleport them back?

 

Thanks!

Share this post


Link to post
Share on other sites

Can you create as Waypoint via scripting? I would think you would GetLocation of the object speaker then create a waypoint based on that which you would use to jump to. I was always a hack scripter...Just thinking out loud...

Share this post


Link to post
Share on other sites

The documentation indicates you can spawn waypoints with CreateObject but I have a vague memory of trying it and it not working, so I can't confirm if they work. However, you could achieve the same result by spawning an invisible placeable.

 

I'm curious, though - how would you go about it in NWN2?

Share this post


Link to post
Share on other sites

Like so:

 

void main(string sLocationName)
{
object oPC = GetPCSpeaker();
SetLocalLocation(oPC, sLocationName, GetLocation(oPC));
}
 
When calling the script you pass in 1,2,3,4 or 5 from the dialog to choose a slot for storage, this is arbitrary you could have as many as you wanted, at least theoretically. I chose five because it seemed like a good number.

Share this post


Link to post
Share on other sites

Interesting. I checked the NWN Lexicon to see how that function works. Looks like it stores info as a variable with the data type location (as opposed to the usual boolean, integer, or string). Yeah, there's no such function in KOTOR, and as far as I'm aware there's no support for that sort of variable either. You could theoretically do the same thing in KOTOR with four different integer variables for the X, Y, Z, and angle values, or with string and convert it to a location... but it would be a total waste of time. All you really need is

CreateObject(OBJECT_TYPE_PLACEABLE, "invisible_placeable_here_with_a_much_shorter_template_name", GetLocation(GetFirstPC(), 0);

and have some system for managing the placeables' tags and delete them as necessary, of course.

Share this post


Link to post
Share on other sites

Not sure I understand how it works, I only see a placeable being created.

 

Not sure what is meant when talking about "waypoints" either.

 

It seems I've had it very easy in nwn2 where there are functions for just about everything.

Share this post


Link to post
Share on other sites

Okay, and then I guess you would use a jump function from there. Makes sense. Thanks for the advice.

Share this post


Link to post
Share on other sites

The documentation indicates you can spawn waypoints with CreateObject but I have a vague memory of trying it and it not working, so I can't confirm if they work. However, you could achieve the same result by spawning an invisible placeable.

 

It should work. Visas' intro cut-scene spawns a waypoint before it starts, so you're moved to the same place after it plays out.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.