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/)