Master Zionosis Posted January 23, 2007 Share Posted January 23, 2007 Can i make a trigger spread across a doorway by editing the .git file, because i cant think of any other way to spawn a person without using a door? Link to comment Share on other sites More sharing options...
stoffe Posted January 23, 2007 Share Posted January 23, 2007 Can i make a trigger spread across a doorway by editing the .git file, because i cant think of any other way to spawn a person without using a door? The only way you can add a trigger to an area is to add it to the GIT file. Triggers cannot be created via scripts. If you do this keep in mind that you should never put a GIT file in the override folder, always pack it back with the module it belongs to. Other than that you could make a "fake" trigger by creating an object in the game world with a script that continually checks if someone is moving close to it, though it'd only work for fairly large trigger areas unless it scans its surroundings very often. Link to comment Share on other sites More sharing options...
Master Zionosis Posted January 23, 2007 Author Share Posted January 23, 2007 So how do i create a custom trigger and add it to the .git file? Link to comment Share on other sites More sharing options...
stoffe Posted January 23, 2007 Share Posted January 23, 2007 So how do i create a custom trigger and add it to the .git file? First you need to create an UTT Template for your trigger. This is most easily done by making a copy of an existing base *.UTT file, renaming it and modifying it to suit your needs. So, find the newgeneric.utt file (in templates.bif), make a copy of it and rename it to a unique valid ResRef, I'll use st_tt_spawnnpc in this example. Then open this file with a GFF editor, and set up the fields like Faction = 1 (Makes the trigger "hostile" so the player may trip it.) ScriptOnEnter = st_tr_spawnnpc (The name of the script to run when the trigger is tripped) Tag = st_tt_spawnnpc (Unique tag used to access trigger from scripts) TemplateResRef = st_tt_spawnnpc (set to same as filename without extension) Type = 0 (normal trigger) * * * Then you'll have to add this trigger to the area in the GIT file, so you'll have to modify that file. Open it with a K-GFF (since all other GFF editors destroy the CameraList as far as I know), and locate the TriggerList LIST field and expand it. You should see a few STRUCT fields here if the area already contain any triggers. To avoid having to recreate all the fields by hand, copy one of the existing structs and paste it into the TriggerList field to create a new struct. Make sure its Struct ID is set to 1, then modify its fields like this: TemplateResRef - Set this to the name of the UTT file you created above, st_tt_spawnnpc in my example. XOrientation, YOrientation, ZOrientation - You'll usually want to leave all these at 0 since there is little point in rotating normal triggers. XPosition, YPosition, ZPosition - Set these to the X, Y and Z coordinates for where in the area you want your trigger object to appear. GeometryList - This defines the shape of the "hot zone" of the trigger that fires its OnEnter script when a creature passes into it. This is done by defining a number of points that the game uses to form a polygon. (Imagine drawing a number of points on a piece of paper and then drawing lines between these points to form a triagle or a rectangle or a similar shape.) You add one struct with StructID 3 for every such point that is used to make up a trigger hot zone, so you'll need at least three points (to form a triangle, since a line is not a valid area shape). Each struct contains three float fields, PointX, PointY and PointZ, that determine the position of these points. Important:These fields do not contain the coordinates in the world of these points, but rather specify where they are in relation to the coordinates you set for the trigger itself. So, in order to figure out where your points should be the game does something like: X= XPosition(trigger) + PointX(Point) Y= YPosition(trigger) + PointY(Point) Z= ZPosition(trigger + PointZ(Point) The coordinate and point offset scale is in meters, keep that in mind to get the size of your trigger right. As a simple example, to make a square trigger hot zone which is 1 meter by 1 meter large, where the trigger object location is in its lower left corner, you could create four point structs in the Geometry list like: P0 = (x=0.0, y=0.0, z=0.0) P1 = (x=1.0, y=0.0, z=0.0) P2 = (x=1.0, y=1.0, z=0.0) P3 = (x=.0., y=1.0, z=0.0) Then you save your modified GIT file and put it back into the module it belongs with. Also important: Keep in mind that this will only work if the player has not already visited the area in-game, since after that the area information is retrieved from the savegame, not from the module. Thus to playtest your changes you must use a save from before the area has ever been loaded, otherwise your trigger won't exist in the game world. Link to comment Share on other sites More sharing options...
Darth333 Posted January 23, 2007 Share Posted January 23, 2007 You'll also find some info in this thread with a sample script: http://www.lucasforums.com/showthread.php?t=145870 (edit: merged stoffe' post with the above thread) Link to comment Share on other sites More sharing options...
Master Zionosis Posted January 23, 2007 Author Share Posted January 23, 2007 Thank you both, i am about to try this method now. Thanks again. Link to comment Share on other sites More sharing options...
Darth333 Posted January 23, 2007 Share Posted January 23, 2007 Note that if it is for a recruiting mod, you should rather use stoffe's method that sets a local or global variable: http://www.lucasforums.com/showthread.php?t=174881 as my script checks if the npc is in the area and if not it will spawn another object (if it's for a placeable or a npc that will stay in the said area it's ok but if it's a recruit, I imagine you will not always travel with the npc and you will end up with "clones"). Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 How do I place a trigger so that it's inactive until after a dialog? Link to comment Share on other sites More sharing options...
Dashus Posted February 7, 2007 Share Posted February 7, 2007 In the OnEnter script for the trigger do 1 of 2 things: 1) Check some global variable you set in the dialog. You should only use this if the person that you talked to is not in the module anymore. 2) In the dialog call a_talktrue on the node you want to 'enable' the trigger. If the person you talked to in the dialog is in module, then check the return of UT_GetTalkedToBooleanFlag(<object you talked to>). If true then the dialog has happened. Note that if the dialog is triggered by you through script and not the user clicking on the person, you MUST assign the ActionStartConversation to the object to talk to or the boolean will be set on your PC rather than the PC. Link to comment Share on other sites More sharing options...
stoffe Posted February 7, 2007 Share Posted February 7, 2007 How do I place a trigger so that it's inactive until after a dialog? You can add a check to the OnEnter script of the trigger that aborts the script if a global boolean variable has not been set. Then you set that Global Boolean in your dialog when the trigger should be active. To set the variable. SetGlobalBoolean("MyGlobalVar", TRUE); To check for the variable if (GetGlobalBoolean("MyGlobalVar")) ... (You must add "MyGlobalVar", or whatever you want to call it, to globalcat.2da or they won't work.) Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 Okay, the OnEnter script of the trigger is the script that triggers when you enter the trigger-area, isn't it? If I need a script that starts a dialog, implemented with the variable, how do I do that? Link to comment Share on other sites More sharing options...
stoffe Posted February 7, 2007 Share Posted February 7, 2007 Okay, the OnEnter script of the trigger is the script that triggers when you enter the trigger-area, isn't it? If I need a script that starts a dialog, implemented with the variable, how do I do that? You mean an OnEnter script for the trigger (firing when someone crosses into the trigger area) that starts a conversation when the player crosses it? If so it may in general look something like this (since I don't know exactly what you are trying to do: void main() { [color=PaleGreen]// ST: Only allow the controlled character to trip the trigger[/color] if (GetEnteringObject() != GetPartyLeader()) return; [color=PaleGreen]// ST: If the variable has not been set the trigger should be // inactive. Or if the trigger has already been tripped once // then also abort here.[/color] if (!GetGlobalBoolean("[color=Yellow]MY_TRIGGER_VAR[/color]") || GetLocalBoolean(OBJECT_SELF, 40)) return; [color=PaleGreen]// ST: Make object start conversation with the player.[/color] object oTalker = GetObjectByTag("[color=Pink]SpeakerTag[/color]"); AssignCommand(oTalker, ClearAllActions()); AssignCommand(oTalker, ActionStartConversation(GetFirstPC(), "[color=Red]SpeakerTag[/color]", FALSE, CONVERSATION_TYPE_CINEMATIC, TRUE)); [color=PaleGreen]// ST: Prevent the trigger from being tripped more than once.[/color] SetLocalBoolean(OBJECT_SELF, 40, TRUE); } Change the yellow part to the name of your new global variable, as set in globalcat.2da. This is the variable you set in your other dialog to turn on the trigger. Change the pink part to the tag of the NPC or placeable you want to start conversation with when the player trips the trigger. Change the red part to the filename (without the .dlg extension) of the dialog file you want to use for the conversation. Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 Hmm, wait, that's for a convo that starts when entering the trigger area, not? But to activate that trigger, I first need another script, containing a Global Variable, not? How to do that? Link to comment Share on other sites More sharing options...
stoffe Posted February 7, 2007 Share Posted February 7, 2007 Hmm, wait, that's for a convo that starts when entering the trigger area, not? But to activate that trigger, I first need another script, containing a Global Variable, not? How to do that? Yes? I was under the impression that you wanted the trigger to be turned off until the player had done something else before (had another conversation?). If you want it to be triggerable at any time you could just remove the global boolean check. As it currently is, to turn on the trigger you'd run a script like... void main() { SetGlobalBoolean("[color=Yellow]MY_TRIGGER_VAR[/color]", TRUE); } ...from anywhere you want to turn on the trigger. Again replace the yellow part with the variable name set in globalcat.2da. Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 Yes? I was under the impression that you wanted the trigger to be turned off until the player had done something else before (had another conversation?). Yes. That's my intention. But then the trigger has to be activated in the conversation. Doesn't it need another script that activates that trigger? Link to comment Share on other sites More sharing options...
stoffe Posted February 7, 2007 Share Posted February 7, 2007 Yes. That's my intention. But then the trigger has to be activated in the conversation. Doesn't it need another script that activates that trigger? Yes. The one I posted in the previous post should do the trick. The trigger script checks if the global boolean has been set in order to do anything, so you turn on the trigger by setting the boolean. Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 Weird. The ERF builder crashes when I attempt to create the .mod file. Could it have something to do with the trigger? It gives as a reason of the error the following: "Index was outside the bounds of the array." Link to comment Share on other sites More sharing options...
stoffe Posted February 7, 2007 Share Posted February 7, 2007 Weird. The ERF builder crashes when I attempt to create the .mod file. Could it have something to do with the trigger? It gives as a reason of the error the following: "Index was outside the bounds of the array." The ERF Builder in KotorTool? Are you using it stand-alone or do you use the module editor? If it's just the ERF builder I doubt it has anything to do with your changes to the .GIT file. The ERF format is just an archive format, it shouldn't care what's inside the separate files. Have you tried packaging your files with another utility and seen if you get the same problem there? Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 The ERF Builder in KotorTool? Are you using it stand-alone or do you use the module editor? Stand-alone, I guess. The map I'm using isn't supported by the Module Editor. If it's just the ERF builder I doubt it has anything to do with your changes to the .GIT file. The ERF format is just an archive format, it shouldn't care what's inside the separate files. It's strange, because it has always worked. I've never had this problem, and I'm using that ERF Builder for a while now, always with the same .mod file. Have you tried packaging your files with another utility and seen if you get the same problem there? What other utility can pack these files into a .mod? Link to comment Share on other sites More sharing options...
stoffe Posted February 7, 2007 Share Posted February 7, 2007 It's strange, because it has always worked. I've never had this problem, and I'm using that ERF Builder for a while now, always with the same .mod file. Have you tried exiting KotorTool, restarting it and trying again? At least on my computer KT has a habit of spitting out exceptions every so often for no apparent reason. Trying again a few times usually works when that happens. What other utility can pack these files into a .mod? If you can't get the ERF Builder to play nice you could try the ERF/RIM Editor linked to in my signature, I think that should work. Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 When It just didn't want to work with Kotor Tool, I used your ERF/RIM Editor. It packed the files without problems, but in-game, the trigger didn't work. I still think that the crashes of the ERF Builder are due to something I've done wrong, not due to some error in KT. What I could've done wrong, I don't know. I think I put everything in the right place... Link to comment Share on other sites More sharing options...
stoffe Posted February 7, 2007 Share Posted February 7, 2007 When It just didn't want to work with Kotor Tool, I used your ERF/RIM Editor. It packed the files without problems, but in-game, the trigger didn't work. I still think that the crashes of the ERF Builder are due to something I've done wrong, not due to some error in KT. What I could've done wrong, I don't know. I think I put everything in the right place... How did you create your trigger? Have you verified (in the GIT file) that the coordinates of the trigger are correct, and that the coordinate offsets for the trigger area points are properly set? Is the TemplateResRef properly set to the name of your UTT file? Did you remember to pack the .UTT file for the trigger into the module? Is it set up to be a generic trigger? Does it have the Hostile faction (1) set? Check that you've set the OnEnter script properly in the UTT file, and that the name of the UTT file and NCS file is not longer than 16 characters. Extract the .GIT file from your MOD file and have a look at it with a GFF Editor to see if everything looks ok... Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 How did you create your trigger? Have you verified (in the GIT file) that the coordinates of the trigger are correct, and that the coordinate offsets for the trigger area points are properly set? Is the TemplateResRef properly set to the name of your UTT file? I used your example in this post: http://http://lucasforums.com/showpost.php?p=2254025&postcount=2 I used the Where Am I armband to get the coordinates needed, and then I just used your example for the GeometryList. And the Resref is correct. Check that you've set the OnEnter script properly in the UTT file, and that the name of the UTT file and NCS file is not longer than 16 characters. Eek. No longer than 16 char., I knew I'd get into trouble with that again. I hope that's the problem. Link to comment Share on other sites More sharing options...
Miltiades Posted February 7, 2007 Share Posted February 7, 2007 Okay, so the ERF Builder works again. Scriptnames were obviously the cause of the error in KT. Bad news is that the trigger still doesn't want to activate (Dialog doesn't start). Link to comment Share on other sites More sharing options...
stoffe Posted February 7, 2007 Share Posted February 7, 2007 Okay, so the ERF Builder works again. Scriptnames were obviously the cause of the error in KT. Bad news is that the trigger still doesn't want to activate (Dialog doesn't start). Have you added the new global boolean variable to globalcat.2da, and saved that modified 2DA file in your override folder? Scripts cannot use new globals unless they are defined in that 2DA file. If you have and it still doesn't work, check that the tag of the NPC who should talk, and the name of the dialog file has been properly set (again the name can be no longer than 16 characters). Also check that you've set the name of the global variable to the same in both the script that activates the trigger, and the trigger's OnEnter script. If that's also right already, try inserting a line like... SendMessageToPC(GetPartyLeader(), "DEBUG: TRIGGER RUNS!"); ... as the first line inside the main() function block in the OnEnter script of the trigger. Then (in-game) walk where the trigger should be and check the feedback screen. If "DEBUG: TRIGGER RUNS!" is posted in the feedback log then the trigger is properly configured at least. If not, then there is something wrong with how you've created the trigger. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.