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.

How to set triggers

Page: 1 of 1
 Darth333
03-09-2005, 11:08 PM
#1
How to set a trigger

Original thread for discussion is here (http://www.lucasforums.com/showthread.php?s=&threadid=145847)


Triggers are used when you want to fire an event when your PC crosses a certain area such as such as spawning npcs, turning npcs hostile, strarting a dialogue, etc...

Triggers are in GFF format and use the .utt extension.

1. Editing the .utt file with Kotor tool:

Info contained in this section is a combination of what appears in the Bioware information document and personal additions.


Basic Tab

Basic Tabe
TemplateResRef: the entry here has to be the same as the file name. Per example, if your .utt file is called abc.utt then type abc here.
Tag: err…the tag of your trigger. It is an identifier.
Name: The name of the trigger. Make sure you set the language correctly according to your game version.
Faction: The faction of the trigger. the factions that are mostly used for triggers in Kotor are:
1: is the most commonly used faction (ennemy) type number 1 if you want to trigger dialogue when your PC crosses the trigger area.
13: is used for traps (mines)
Type: type one of the following numbers:
0 = Generic
1 = Area Transition
2 = Trap (mines)
Cursor: The number here refers to a cursors.2da. row number. i tis used to specifiy a special mouse cursor icon to use when the player mouses over the Trigger. 0 means there is no mouseover cursor feedback. Game should use the specified cursor only if the
OnClick event is non-empty. Area Transition triggers should always have the cursor set to 1 by the toolset. For Area Transitions, the game ignores the Cursor value anyway and always uses Cursor 1.
Scripts Tab
For more information, read this thread: http://www.lucasforums.com/showthread.php?s=&threadid=143452)

OnClick: indicate the name of the script you want to fire when the player clicks on the trigger.
OnDisarm: indicate the name of the script you want to fire when the player disarms the trigger the trigger (example: play a sound). Used for traps (mines) only.
OnTrapTriggered: indicate the name of the script you want to fire when the player triggers the mine (note: this is not what will make the mine explode: you don’t need to attach any specific script of you want the mines to explode – but you can use this filed to fire another event).
ScriptHeartBeat: indicate the name of the script you want to fire On Heartbeat
ScriptOnEnter: indicate the name of the script you want to fire when your PC enters the trigger area.
ScriptOnExit: indicate the name of the script you want to fire when the PC exits the trigger area
ScriptUserDefine: indicate the name of the script you want to fire using a User Define event (examples: on damaged event, on death event) .
Trap Tab

TrapDetectable: 1 if Trap can be detected, 0 if not (if it is visible or not)
trapDetectDC: if the trap can be detected insert the DC required to make it visible (must within a 1-250 range).
trapDisarmable: 1 if Trap can be disarmed, 0 if not… (in kotor 2, all traps I have looked at seem to be set at 1)…
DisarmDC: This is used for mines. If the Trigger is a Trap (Type has to be set at 2), put the DC required
to disarm the trap. DC has to be in the 1-250 range.
TrapFlag: 1 if the Trigger is a mine or similar trap, 0 if not
trapOneShot: 1 if the Trap disappears after firing, 0 otherwise
TrapType: used for mines only; refers to a row number in traps.2da corresponding to the type of mine
KeyName: field not used
AutoRemoveKey: this field is not used
Comments Tab

Comment: put whatever romance you want here or simply skip this field


If you open the .git file with a GFF editor, you’ll notice that there are a few additional fields:
HighlightHeight: Some Triggers have a highlight color ingame (Area Transitions are blue, Traps are red, and clickable generic triggers are green). If the trigger highlights, this is the height in metres above the ground that the highlight extends.
LoadScreenID: Refers to a row number in loadscreens.2da. It is used to specify a loading screen to use if the trigger is usedto transport the player in another area. If 0 is entered, then the game will load the default loading screen duyring area transition.
PaletteID: not too sure what these numbers refer too…perhaps someone else knows…
PortraitID: ??? what does this has to do with triggers


1. Editing the .git file:

Triggers are placed in the .git file the same way as placeables, creatures, doors, etc. but under the triggers list.

If you open an existing .git file, you should see something like this under the triggers list:
http://img.photobucket.com/albums/v144/Darth333/gff_trig.jpg)

o The XYZ Position is the location of the trigger. When your PC crosses this spot, the event will be fired.

o In the TemplateResRef field: put the the .utt filename.

o The geometry XYZ points define how big is the trigger area. It is like an imaginary polygon. I recommend using 4 sets of coordinates here (polygon with 4 sides). If the trigger area is too small, the risks are that if your npc doesn't step exactly on "the spot" you will miss the trigger. If it's too big and it overlaps other triggers, then you will have funny (and less funny) effects. (make sure you read pages 9 and 10 of this document concerning geometry: http://nwn.bioware.com/developers/Bioware_Aurora_Trigger_Format.pdf) or here http://www.lucasforums.com/attachment.php?attachmentid=3024&d=1333406490) )


You can get all the coordinates you need with the Whereami armband: http://www.starwarsknights.com/tools.php)

If you are making a mod for Kotor 1, then maybe you can use Kotor Tool integrated module editor if the map you are editing is available (http://www.starwarsknights.com/maps.php). This will greatly facilitate the positioning of triggers.

3. Now, let’s use an example:

For the following tutorial, we will spawn a NPC with the ABC tag near your PC who will engage conversation when your pc crosses the trigger area.

1. Make the script that will fire when your PC enters the trigger area:


void main()
{
object oEntering = GetEnteringObject();
object oPC=GetFirstPC();
if (GetIsPC(oEntering) && (!GetIsObjectValid(GetObjectByTag("ABC"))))

{
CreateObject(OBJECT_TYPE_CREATURE, "ABC", GetLocation(oPC));
AssignCommand((GetObjectByTag("ABC")),ActionMoveToObject(oPC));
AssignCommand((GetObjectByTag("ABC")), ActionDoCommand(ActionStartConversation(oPC)));

//This line prevents the scene from firing each time you enter the trigger. You can also set a variable if you intend to re-use the trigger
DestroyObject(OBJECT_SELF);

}
}


Save the script as spawning_abc.nss and compile.

2. Edit the .utt file:

Set the fields as follow:

Basic Tab
TemplateResRef: spawn_abc (make sure you save your .utt file with the same name: spawn_abc.utt).
Tag: spawn_abc (it doesn’t the same as the TemplateResRef field but I always name it the same to avoid mixing up names)
Name: The name of the trigger. Make sure you set the language correctly according to your game version.
Faction: 1
Type: 0 (it’s not a mine nor an area transition)
Cursor: 0
Scripts Tab
OnClick: [leave blank]
OnDisarm: [leave blank]
OnTrapTriggered: [leave blank]
ScriptHeartBeat: [leave blank]
ScriptOnEnter: spawning_abc (the name of the script you want to fire)
ScriptOnExit: [leave blank]
ScriptUserDefine: [leave blank]
Trap Tab

TrapDetectable: check this box
trapDetectDC: 0
trapDisarmable: check this box
DisarmDC: 0
TrapFlag: 0
trapOneShot: check this box
TrapType: 0
KeyName: [leave blank]
AutoRemoveKey: [leave blank]
Comments Tab

Comment: [leave blank or type whatever you want]


3. Edit the .git file, to position the trigger where you want and define the area it will cover. Type the name of your .utt file in the TemplateResRef field as in this screenshot:

http://img.photobucket.com/albums/v144/Darth333/trigger1.jpg)

Note: do not put the .git file directly in your override folder. Or you’ll end up with side effects, including messed up triggers. You have to pack it as a .mod file along with the .are and the .ifo files for the module and the other module specific files (you can do this with KotOR tool). Unless you are using tk102's K-GFF you will also need to use CAMedit to fix the corrupted cameras in the .git file: http://www.pcgamemods.com/5276/)
 stoffe
01-23-2007, 8:05 AM
#2
Original thread is here (http://www.lucasforums.com/showthread.php?t=174916)

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.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.
Page: 1 of 1