lfnetwork.com mark read register faq members calendar

Thread: How to set triggers
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 03-09-2005, 11:08 PM   #1
Darth333
Administraterror
 
Darth333's Avatar
 
Status: Administrator
Join Date: Feb 2004
Location: In my secret dungeon...
Posts: 8,292
How to set triggers

How to set a trigger

Original thread for discussion is here


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/showthrea...hreadid=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/v1...3/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/Bi...ger_Format.pdf or here http://www.lucasforums.com/attachmen...4&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. 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:

Code:
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/v1...3/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/
Darth333 is offline   you may: quote & reply,
Old 01-23-2007, 08:05 AM   #2
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Original thread is here

Quote:
Originally Posted by master zionosis
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.


Last edited by stoffe; 08-04-2007 at 04:51 PM.
stoffe is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Tutorials: General Tutorials + Tools > How to set triggers

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:07 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.