Trigger/ru

From Dragon Age Toolset Wiki
< Trigger
Revision as of 02:05, 27 December 2011 by Kelamor (Talk | contribs) (Триггер телепорта: Перевод)

Jump to: navigation, search
Триггеры
Начало / Русская DA Builder Wiki / Поделиться ВКонтакте
Локации
Вид триггера в редакторе локаций.

Триггеры, это нарисованные на области многоугольники, срабатывающие когда существо входит или выходит из него. Срабатываение триггера посылает движку событие, которое впоследствии, как правило, обрабатывается скриптом для выполнения каких-либо действий.

Создание триггера

Для создания нового триггера в меню "File" или на палитре ресурсов в контекстном меню выберите пункт "New -> Trigger" и отредактируйте следующие параметры:

  • Секция "General"
    • Comments: Основная информация о триггере.
    • Group: Группа, к которой принадлежит триггер. Указывается, если триггер используется в качестве ловушки.
    • Resource Name: Уникальный строковый идентификатор, используемый тулсетом и игрой для ссылок на триггер.
    • Tag: Не уникальный строковый идентификатор, в основном используемый скриптами и другими ресурсами, связанными с триггером.
  • Секция "Attributes"
    • Script: Скрипт, обрабатывающий события триггера.
    • Target Waypoint:
    • Variable 2da: Позволяет выбрать нужную таблицу переменных. Только переменные из выбранной таблицы могут устанавливаться и читаться с помощью скриптов.
    • Variables: Отображает поля выбранной выше таблицы переменных и позволяет переопределить переменные.

Теперь сохраните триггер. С этого момента вы можете разместить новый триггер на локации.

На локации триггер размещается следующим образом. Откройте нужную локацию и выберите на палитре ресурсов триггер, который вы хотите разместить. Теперь просто нарисуйте требуемую область триггера, указывая угловые точки. Двойной щелчок свяжет первую и последнюю точку, завершая рисование области триггера. Для получения более подробной информации о том, как рисовать области триггеров, смотрите статью про локации.

Обратите внимание, что плоскость триггера на локации может опуститься ниже поверхности, на которой триггер расположен. Однако это не помешает триггеру сработать, если кто-то пройдёт над ним, так как триггер чувствителен по всей вертикали.

Триггер перехода

Для создания триггера перехода между локациями необходимо подредактировать его переменные. Для этого откройте триггер, в разделе "Attributes" выберите поле "Variable" и нажмите на кнопку Ellipsis.png.

Переменные под редактирование:

  • TRIGGER_AT_DEST_TAG: тэг флажка (waypoint) назначения (флажок, на который Игрок будет телепортирован).
  • TRIGGER_AT_DEST_AREA_TAG: тэг локации с вышеуказанным флажком (если локация отличается от текущей).
  • TRIGGER_AT_DEST_AREALIST_TAG: тэг группы (arealist) вышеуказанной локации (если группа отличается от текущей).

Теперь в случае, если Игрок заденет этот триггер, он будет перенесён в указанную локацию на указанный флажок. Если перенос происходит в рамках одной локации Игрок будет перенесён внутри локации на указанный флажок.

Trigger Scripts

Any other functionality for a trigger must be put in a script manually. The trigger_core.nss script (which may change) in the _Core Scripts directory is a good template for such a script.

Without any modifications this script performs the area transition. The code to do so is in a switch statement that looks for the event matching the predefined constant EVENT_TYPE_ENTER.

Note that there is an if statement in here that checks to see if it was the player who set off the trigger, (it also checks to see if there was an area transition tag set). If you want to have the trigger do something only when the player enters it you should do a similar check, otherwise it will activate whenever any creature enters.

Example: Have a cutscene play, but only the first time the player enters the trigger.

 if(IsPartyMember(oCreature)) { 
  resource rCutscene = R"mycutscene.cut";
  LoadCutscene(rCutscene);
  PlayCutscene(oCreature);
  DestroyObject(OBJECT_SELF, 0);
 }

Comment : originally, the above example used a function called IsPlayer, which doesn't seem to exist.

If you do create a custom trigger script you should call the following after the switch statement:

 HandleEvent(ev, RESOURCE_SCRIPT_TRIGGER_CORE);

This ensures that anything your custom script doesn't process still gets processed correctly by the default script.

Once you have created your script, click on the "script" field of the attributes of the trigger, and then choose your script from the ellipsis (Ellipsis.png) browser.

Note that triggers don’t behave as expected when you use "SetObjectActive(OBJECT_SELF, FALSE)" on them. This function sets the trigger to inactive, but the trigger will still fire when inactive. So any trigger script that needs to account for whether the trigger is active should be surrounded by an "if(GetObjectActive(OBJECT_SELF))" statement to explicitly test whether it should fire. Alternately, if the trigger is never intended to fire again, use DestroyObject(OBJECT_SELF, 0); instead of setting it inactive.

Traps

Triggers are similar to how traps were defined in Neverwinter Nights, but in Dragon Age it is preferred to construct traps using placeable floor plates as triggers instead. This makes traps easier for the player to interact with in a realistic manner.

See the Trap system for details on how to handle traps.

Talk triggers

A talk trigger is a trigger that initiates a conversation. This occurs so frequently in Dragon Age's game design that a generic script, gen00tr_talk.nss, is available for this purpose. To use it with a trigger, set the trigger's "Script" property to "gen00tr_talk" and set the "Variable 2da" property to "var_trigger_talk".

The following set of variables are available in the var_trigger_talk variable 2da:

Variable name Type Default Description
TRIG_TALK_ACTIVE_FOR_FLAG int triggers only if a specific plot/flag is active - works with TRIG_TALK_ACTIVE_FOR_PLOT
TRIG_TALK_ACTIVE_FOR_PLOT string triggers only if a specific plot/flag is active - works with TRIG_TALK_ACTIVE_FOR_FLAG
TRIG_TALK_DIALOG_OVERRIDE resource a dialog file to override the default one for the NPC. Type it in the format of "gen000_example.dlg" (without the quotes)
TRIG_TALK_INACTIVE_FOR_FLAG and FLAG2 int triggers only if a specific plot/flag is inactive - works with TRIG_TALK_ACTIVE_FOR_PLOT
TRIG_TALK_INACTIVE_FOR_PLOT and PLOT2 string triggers only if a specific plot/flag is inactive - works with TRIG_TALK_ACTIVE_FOR_FLAG
TRIG_TALK_LISTENER string a string for an NPC listener. Should be used for ambient conversations
TRIG_TALK_REPEAT int 1 so the trigger can re-fire, 0 - the trigger fires only once
TRIG_TALK_SET_FLAG and FLAG2 int sets the plot and flag when triggered, works with TRIG_TALK_SET_PLOT
TRIG_TALK_SET_PLOT and PLOT2 string sets the plot and flag when triggered, works with TRIG_TALK_SET_FLAG
TRIG_TALK_SPEAKER string NPC initiating the dialog - this is the only mandatory field

Variables

The following set of variables are available if you're using the basic var_trigger 2da:

Variable name Type Default Description
TRIGGER_ACTIVATE_TEAM_HELP int Activates team-help system on a team of creatures using SetLocalVarOnTeam(oCreature, TRIGGER_ACTIVATE_TEAM_HELP, AI_HELP_TEAM_STATUS, 1);
TRIGGER_ACTIVATE_TEAM_STATIONARY_HARD int Activates a team to be stationary (AI system) using SetLocalVarOnTeam(oCreature, TRIGGER_ACTIVATE_TEAM_STATIONARY_HARD, AI_FLAG_STATIONARY, 2);
TRIGGER_ACTIVATE_TEAM_STATIONARY_SOFT int Activates a team to be stationary (AI system) using SetLocalVarOnTeam(oCreature, TRIGGER_ACTIVATE_TEAM_STATIONARY_SOFT, AI_FLAG_STATIONARY, 1);
TRIGGER_AT_DEST_AREA_TAG string The tag of the area that this trigger sends the player to (area transition)
TRIGGER_AT_DEST_TAG string The tag of the waypoint within the destination area this trigger sends the player to (area transition)
TRIGGER_COUNTER_1 to 3 int
TRIGGER_DO_ONCE_A and B int
TRIGGER_ENCOUNTER_TEAM int
TRIGGER_PARTY_TRIGGER_LOCATION int
TRIGGER_ROOM_TEXT int

These are in the var_trigger_ambient 2da, for use with the gentr_ambient.nss script:

Variable name Type Default Description
AMBIENT_ANIM_FREQ_OVERRIDE float If non-zero, takes precedence over AMBIENT_ANIM_FREQ value set on the creature's template. Format is a float (x.y) to play a random number of animations between x and y. Specify -1.0 to play all animations (in order) listed in ambient_ai.xls.
AMBIENT_ANIM_OVERRIDE_COUNT int
AMBIENT_ANIM_PATTERN_OVERRIDE int Index into ambient_ai.xls. If non-zero, this value takes precedence over the AMBIENT_ANIM_PATTERN value set on the creature's template.
AMBIENT_TARGET_FILTER string The creature entering or in the trigger will have its ambient behaviour overridden if its tag appears somewhere in this comma-separated list.
AMBIENT_TRIGGER_FILTER string The ambient behaviour of the target creature will be overridden when a creature with a tag somewhere in this coma-separated list enters the trigger. Use <hero> to specify the player. Will default to AMBIENT_TARGET_FILTER if blank.

Properties

General
Comments
Group The group to which this trigger belongs. Used when the trigger is used as a trap trigger.
Resource Name A unique string identifier the toolset and the game both use to refer to this resource.
Tag A non-unique string identifier used mostly by scripts and other resources to refer to this resource.
Attributes
Script Event script assigned to the resource
Target Waypoint
Variable 2da Allows selection of a variable table. Only the values in the table can be set and retrieved by scripting.
Variables Displays the table selected in the variable 2da field. Allows initial values to be defined.


Язык: English  • русский