Filcz

NPC dialog initializing

Recommended Posts

Hello !

I need my NPC to initialize dialog without clicking on him (for example when i'm close to him). Is there any way to achieve it?

Thank you in advance for every advice :)

Share this post


Link to post
Share on other sites

What you're looking for are triggers. They specify an area and when something (in this case your PC) enters that area, a script is fired (in this case starting the conversation).

A trigger consists of three parts: A .utt file (the trigger itself), a script and an edit to the modules .git file.

I'll just post an abreviated version of what Fair Strides once taught me. It's from a chat conversation so it's not the best tutorial formating but hey, it has the information.

Quote

Open a .utt file in Kotor Tool.

Okay, the only important parts in the first tab are the Template Resref and tag.
Set them to the same value (preferably), and then go to the second tab.

Now open KT's Text Editor. Paste this:


void main()
{
object oPC = GetEnteringObject(); // Get the object that just entered the trigger's zone.

if(oPC != GetFirstPC())
{
// Nothing to worry about, the player didn't enter the trigger's area...
}
else
{
AssignCommand(oPC, ActionStartConversation(GetObjectByTag("1"), "2", 0, CONVERSATION_TYPE_CINEMATIC, 1));
}
}

The script above basically will be used in the OnEntered event for the trigger and checks to see if the object that triggered the script is the PC.
 You'll need to replace the "1" with the tag of the NPC (keep the quotes) and if the name of the .dlg file is what's in their .utc file, replace "2" with "". Otherwise, replace "2" with the name of the dialog file, again with the quotes.

Then you can save and compile the script.

Now enter the script's name as the OnEntered in the Trigger.

Erase any other scripts set.

After that, you can save the trigger (make sure to keep it's name the same as the template resref).

Next, you'll need to open the .git file of your module. You'll find that one in the .rim file of the corresponding model and you'll need a gff editor to edit it. Once you have that open continue below:

Quote

Close all the branches (hit the [ key) and then open a trigger.

Okay, now copy a trigger (right-click the main trigger's branch, above the geometry branch and select Copy) and then paste it by right-clicking on the main Triggers branch and then paste it.

Okay, without knowing jack about where you're placing this, let me give you some guidelines:

1. The XYZ coordinate things are where it's spawned.

2. The Geometry numbers are RELATIVE to the XYZ above.

So now you should be all set to at least test things. You might need to work the Geometry a bit into the right shape (you can add or delete Points, just make sure they never "cross" each other and are just one shape (like a square instead of two triangles).

After that, it's all in the script.

The final thing to note: You have to pack the .git file into a .mod file instead of placing it into your Override folder as it would otherwise reset the area everytime it's loaded. The script and the .utt can go into the Override though.

Share this post


Link to post
Share on other sites
1 hour ago, Kexikus said:

The script and the .utt can go into the Override though.

If you are packing everything else into a MOD, then you should also inject any custom additions like scripts and GFF files into the MOD as well. Keeps the Override clean and makes it easier to uninstall.

Share this post


Link to post
Share on other sites
Guest Qui-Gon Glenn

Trigger is unnecessarily complicated for scripting.

Make custom on_perception for said NPC. You can then make the NPC wave, or walk towards your PC, or attack or cower or ask for milk.

Edit: if your intention is to package this into a .mod, either method works fine. The trigger method should always work, but in my experience it has had some issues with reliability. 

The scripted method is pretty failsafe. It requires a little more fiddling with the .utc, but that isn't hard.

Share this post


Link to post
Share on other sites

When I open the trigger in the k-gff here's what is shown - and there is no such thing as geometry.  

Is it supposed to look like that or did I do something wrong during saving the file? 

question.thumb.png.519ddd65e185d25e590ffb42c10b2f0c.png

Share this post


Link to post
Share on other sites

"Close all the branches (hit the [ key) and then open a trigger.

Okay, now copy a trigger (right-click the main trigger's branch, above the geometry branch and select Copy) and then paste it by right-clicking on the main Triggers branch and then paste it."

Maybe I'm stupid but when i open .git file in k-gff where am i suppoused to open that trigger? In k-gff as well?  Because from what I understand after I  open somewhere the trigger there should be a node with geometry list and other nodes with positions.

Share this post


Link to post
Share on other sites

Uh sorry for the unclear wording. Open the .git in k-gff, then fold all branches. Unfold the main struct and you'll see a TriggerList. Unfold that one as well and copy one of the triggers in there by right-clicking it, selecting "Copy STRUCT" and then right-clicking the TriggerList and selecting "Paste STRUCT". Then do the geometry edits and other required edits to that copied trigger.

You also need to make the edits to the .utt file. You can do that with KotOR Tool or with k-gff.

Capture.JPG.9fb24160290a5b1be49665e52b29e8e9.JPG

Those Structs in the TriggerList are the "triggers" or at least the trigger information that's stored in the .git.

Share this post


Link to post
Share on other sites

Okay, so by the edits in .utt file you mean the things i did before saving it (changing resref, tag, and attaching script) or there is more to it?

Share this post


Link to post
Share on other sites

Yes, that's all there is to it.

To be more precise: Everything in the first quote of my first post is done in the .utt or part of the script. Everything in the second quote is done in the .git.

Share this post


Link to post
Share on other sites

I was trying to apply the trigger in my module but it did't work, so i replaced one of the existing triggers (tatooine - the one that triggers the dialog with Dark Jedi) with my own and it still doesn't work. I suspect that something may be wrong with my script but i'm not sure. I'm attaching everything i did in that matter so if anyone could tell me where i did a mistake I would be grateful :)

game.png.a2d5252476efbd742c51b2cc4912727a.png

script.png.79c7a61714c74c907049b82484b073a0.png

trigger1.PNG.aeb713a962f6e05126203aa163385006.PNGtrigger2.PNG.4c90061f59518571f6117f130528de42.PNG

git.PNG.47d5620b864572cf415febd28906b314.PNG

Share this post


Link to post
Share on other sites

Looks fine from what I can tell.

Have you been to Anchorhead before in that savegame? If so then that's why it's not working. Changes to the .git in a .mod only take effect when you're loading the module for the very first time in a savegame.

Share this post


Link to post
Share on other sites

When i got rid of conditional in the script it started to work out of nowhere so there must be something with it.

Share this post


Link to post
Share on other sites

Probably yes. Anyway i menaged to make it work just like i wanted. Thanks for all the tips they were really helpful ;) 

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.