Filcz 0 Posted June 9, 2018 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 Quote Share this post Link to post Share on other sites
Kexikus 995 Posted June 10, 2018 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. Quote Share this post Link to post Share on other sites
DarthParametric 3,785 Posted June 10, 2018 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. Quote Share this post Link to post Share on other sites
Guest Qui-Gon Glenn Posted June 10, 2018 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. Quote Share this post Link to post Share on other sites
Filcz 0 Posted June 11, 2018 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? Quote Share this post Link to post Share on other sites
Kexikus 995 Posted June 11, 2018 You opened the trigger .utt file. The geometry is specified in the .git file of the module. Quote Share this post Link to post Share on other sites
Filcz 0 Posted June 11, 2018 "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. Quote Share this post Link to post Share on other sites
Kexikus 995 Posted June 11, 2018 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. Those Structs in the TriggerList are the "triggers" or at least the trigger information that's stored in the .git. Quote Share this post Link to post Share on other sites
Filcz 0 Posted June 11, 2018 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? Quote Share this post Link to post Share on other sites
Kexikus 995 Posted June 11, 2018 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. Quote Share this post Link to post Share on other sites
Filcz 0 Posted June 11, 2018 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 Quote Share this post Link to post Share on other sites
Kexikus 995 Posted June 11, 2018 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. Quote Share this post Link to post Share on other sites
Filcz 0 Posted June 12, 2018 When i got rid of conditional in the script it started to work out of nowhere so there must be something with it. Quote Share this post Link to post Share on other sites
Kexikus 995 Posted June 12, 2018 I always use that exact conditional part and it's working for me, so I'd guess that something else was wrong too. Quote Share this post Link to post Share on other sites
Filcz 0 Posted June 12, 2018 Probably yes. Anyway i menaged to make it work just like i wanted. Thanks for all the tips they were really helpful Quote Share this post Link to post Share on other sites
Kexikus 995 Posted June 12, 2018 Glad to hear that Quote Share this post Link to post Share on other sites