Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

.git made trigger

Page: 1 of 1
 Master Zionosis
01-22-2007, 9:45 PM
#1
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?
 stoffe
01-22-2007, 10:46 PM
#2
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.
 Master Zionosis
01-22-2007, 10:59 PM
#3
So how do i create a custom trigger and add it to the .git file?
 stoffe
01-23-2007, 9:05 AM
#4
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.
 Darth333
01-23-2007, 11:26 AM
#5
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)
 Master Zionosis
01-23-2007, 11:40 AM
#6
Thank you both, i am about to try this method now. Thanks again.
 Darth333
01-23-2007, 11:49 AM
#7
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").
 Miltiades
02-06-2007, 8:07 PM
#8
How do I place a trigger so that it's inactive until after a dialog?
 Dashus
02-06-2007, 8:16 PM
#9
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.
 stoffe
02-06-2007, 8:19 PM
#10
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.)
 Miltiades
02-07-2007, 10:45 AM
#11
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?
 stoffe
02-07-2007, 11:27 AM
#12
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() {
// ST: Only allow the controlled character to trip the trigger
if (GetEnteringObject() != GetPartyLeader())
return;

// 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.
if (!GetGlobalBoolean("MY_TRIGGER_VAR") || GetLocalBoolean(OBJECT_SELF, 40))
return;


// ST: Make object start conversation with the player.
object oTalker = GetObjectByTag("SpeakerTag");
AssignCommand(oTalker, ClearAllActions());
AssignCommand(oTalker, ActionStartConversation(GetFirstPC(), "SpeakerTag", FALSE, CONVERSATION_TYPE_CINEMATIC, TRUE));

// ST: Prevent the trigger from being tripped more than once.
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.
 Miltiades
02-07-2007, 11:37 AM
#13
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?
 stoffe
02-07-2007, 11:43 AM
#14
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("MY_TRIGGER_VAR", TRUE);
} ...from anywhere you want to turn on the trigger. Again replace the yellow part with the variable name set in globalcat.2da.
 Miltiades
02-07-2007, 11:56 AM
#15
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?
 stoffe
02-07-2007, 11:58 AM
#16
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.
 Miltiades
02-07-2007, 12:07 PM
#17
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."
 stoffe
02-07-2007, 12:12 PM
#18
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?
 Miltiades
02-07-2007, 12:17 PM
#19
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?
 stoffe
02-07-2007, 12:25 PM
#20
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.
 Miltiades
02-07-2007, 12:39 PM
#21
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...
 stoffe
02-07-2007, 12:45 PM
#22
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...
 Miltiades
02-07-2007, 12:54 PM
#23
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.
 Miltiades
02-07-2007, 1:02 PM
#24
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).
 stoffe
02-07-2007, 1:11 PM
#25
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. :)
 Miltiades
02-07-2007, 1:32 PM
#26
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.

Yes, I did all that, thought I didn't know, in the 2DA file, what type it was. It just typed in Boolean.


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. :)

Done that, and it says "DEBUG:TRIGGER RUNS!". So it's properly configured, but it still doesn't want to activate the dialog.
 stoffe
02-07-2007, 1:37 PM
#27
Done that, and it says "DEBUG:TRIGGER RUNS!". So it's properly configured, but it still doesn't want to activate the dialog.

Hmm... then I would guess that either the tag of the NPC or the name of the DLG file is set incorrectly. Also, have you run the script that sets the Global Boolean to TRUE before walking onto the trigger?

If that's not the problem, does the NPC who should talk to the player when triggered exist in the area already, or are you spawning it in at the same time? If you are spawning it you'll need to delay the conversation by half a second or so to allow the NPC to be properly created before issuing it actions.
 Miltiades
02-07-2007, 1:47 PM
#28
If that's not the problem, does the NPC who should talk to the player when triggered exist in the area already, or are you spawning it in at the same time? If you are spawning it you'll need to delay the conversation by half a second or so to allow the NPC to be properly created before issuing it actions.

The NPC already exist in the area. Something of possible importance is that the dialog file can't be attached to him because he already has another dialog file. Not that this is a problem, because with the script you gave me before, the dialog file doesn't have to be attached to the NPC.


Also, have you run the script that sets the Global Boolean to TRUE before walking onto the trigger?

Yes, I linked the script with a node in a previous dialog file.
 stoffe
02-07-2007, 1:53 PM
#29
The NPC already exist in the area. Something of possible importance is that the dialog file can't be attached to him because he already has another dialog file. Not that this is a problem, because with the script you gave me before, the dialog file doesn't have to be attached to the NPC.

Hmm, strange. Try moving the Feedback Debug line you added down to to the bottom of the main() function block instead, just above the last } character. Does it still get printed to the feedback screen when you trip the trigger?
 Miltiades
02-07-2007, 2:10 PM
#30
No, it doesn't...
 stoffe
02-07-2007, 2:18 PM
#31
No, it doesn't...

Hmm, strange. Insert the debug feedback printout between the two If-statements at the top to see which of the conditions is blocking the script execution...

Also try adding this debug line at the top of the script:
SendMessageToPC(GetPartyLeader(), "VALUE = " + (GetGlobalBoolean("MY_TRIGGER_VAR") ? "TRUE" : "FALSE"));


Change the yellow part to the name of your new global boolean, and check the feedback log in the game. If it says "VALUE = FALSE" in the Feedback log after the trigger should be active there is something wrong with how you set the variable.
 Miltiades
02-07-2007, 2:30 PM
#32
Hmm, strange. Insert the debug feedback printout between the two If-statements at the top to see which of the conditions is blocking the script execution...

Nothing appears in the Feedback when I put the debug line between the two If-statements.


Also try adding this debug line at the top of the script:
SendMessageToPC(GetPartyLeader(), "VALUE = " + (GetGlobalBoolean("MY_TRIGGER_VAR") ? "TRUE" : "FALSE"));


If it says "VALUE = FALSE" in the Feedback log after the trigger should be active there is something wrong with how you set the variable.

Where exactly do I need to put this? I've put this as the first line in the main() function block, but nothing appeared in the Feedback.

Edit: Oh yeah, did it matter that I used both lines at once?
 stoffe
02-07-2007, 3:22 PM
#33
Nothing appears in the Feedback when I put the debug line between the two If-statements.

Hmm, strange. Try replacing the line...

if (GetEnteringObject() != GetPartyLeader())

...with...

if (GetEnteringObject() != GetFirstPC())

...and see if that makes a difference. I can't see why it should, but it seems like this line is blocking the script for some reason. You are running this script from the triggers OnEnter event, right?



Where exactly do I need to put this? I've put this as the first line in the main() function block, but nothing appeared in the Feedback.

It should have worked if you insert it as the first line of the main function block. If it didn't, are you sure you recompiled the script and put the NCS file in the MOD or override? If it's on the first line there should be nothing blocking its execution if the script gets fired at all.
 Miltiades
02-07-2007, 3:41 PM
#34
You are running this script from the triggers OnEnter event, right?

Yep. Using the Debug line together with the Value line in one script doesn't give any problems, does it?
 Miltiades
02-07-2007, 3:47 PM
#35
Okay, the "Debug:Trigger Run!" can again been seen (I think I have to make my trigger area bigger, 'cause I think that's why I couldn't see the Debug line before. So I think the "if (GetEnteringObject() != GetPartyLeader())" isn't wrong).

On the other hand, the Value line also worked, but gave "Value=False". So I did something wrong with the variable then?
 stoffe
02-07-2007, 7:00 PM
#36
On the other hand, the Value line also worked, but gave "Value=False". So I did something wrong with the variable then?

If you have run the script that should enable the trigger then the global variable should be set to TRUE. If it's not, then you probably either have a typo in the variable name in either of the scripts or in globalcat.2da, or the script that sets the boolean/enables the trigger is not run properly (check that there are no typos when you specify the script name in the DLG file, and that it isn't longer than 16 characters).
 Miltiades
02-07-2007, 7:49 PM
#37
Everything is filled in correctly. No typos, neither in the scripts nor in the 2DA. The name of the scripts are no longer than 16 char.,and in the dialog file, the script has the correct name. But I was wondering, do I have to put something in the String Param column in the dialog file?
 stoffe
02-07-2007, 7:55 PM
#38
Everything is filled in correctly. No typos, neither in the scripts nor in the 2DA. The name of the scripts are no longer than 16 char.,and in the dialog file, the script has the correct name. But I was wondering, do I have to put something in the String Param column in the dialog file?

Hmm, very odd. You could try to modify the script where you set the global to immediately print out the value of the variable it just set to the feedback log to see if the error lies there.

As for script parameters in the dialog, that depends on how the script you are using is made. If it uses the string parameter for something you may need to fill it in. If you use the standard game scripts in TSL for setting globals you set the variable name there. How does the scripts you currently use look?
 Miltiades
02-07-2007, 8:01 PM
#39
It may sound weird now, but it worked! I don't know if it's because I put the name of the trigger (utc file) in the String Param, or if it's because the trigger square didn't work (the dialog only started when I walked exactly at the spot where I got my coordinates).

It's really strange, because not only does the trigger activate just on that one spot, the Debug en Value line can only be seen when on some places of the square I made, and the Value actually says False.

It's still not what it has to be, and I think the geometry has something to do with it. But it's a start.

Edit: Fixed the geometry thing, now it works like a charm ;)
Page: 1 of 1