Creature ai scripts

Материал из YTDB DataBase

Перейти к: навигация, поиск

Содержание

Event AI Таблицы

event_scripts

eventai_summons

eventai_texts

custom_texts

Event AI Справочник

ВНИМАНИЕ: Этот справочник предполагает, что у вас есть ScriptDev2 Rev 220+ полностью и успешно установлен. Информация написанная ниже не содержит инструкцию по установке ScriptDev2.

Ревизия SD2 после последнего обновления гида: 1214 (может быть не полным)

(spacer)

Если у вас есть какие-нибудь вопросы относительно EventAI, пожалуйста, направляйте их сюда. Конечно, это хорошая идея изучить этот справочник и таблицы вашей базы данных, чем просто задавать вопросы. Если вы действительно встретили трудность и не можете её решить, то задайте свой вопрос, кликнув по ссылке указанной выше.

(spacer)

Теперь о интересном...

В начальной ревизии 220, ScriptDev2 осуществила скриптование при помощи DB-based, что позволило использовать базу данных (MySQL) для определения особых скриптов или действий существами. Скрипт называется eventAI и будет всегда так называться в остальной части гида. EventAI скрипт работает на основе двух данных: Что сделать? и Когда сделать это?. Первое (Что?) будет упоминаться как действие. В настоящее время, у одного eventAI может быть до трех действий. Второе (Когда?) будет упоминаться как случай. Любой, кто хочет создать записи для eventAI, должен ответить на эти два вопроса. Скрипты могу выполнять непрерывные действия, когда произойдет определённый случай. Некоторые события могут происходить однажды, а другие могут быть рассчитаны так, чтобы они срабатывали в указанном интервале.

Теперь, когда основная идея скрипта была объяснена, давайте перейдем к интересным деталям. Для удобства, внизу будет размещена справка в таблицах, которые будут содержать краткое описание для быстрого поиска. В остальном материале будет размещено более полное описание. Мы сначала начнем с темы, в которой будет рассказано, какие события в настоящее время определяются eventAI скриптом. Случай может использовать до трех различных параметров, и эти параметры управляют различными действиями в зависимости от случая. Если параметр не будет назван по имени случая, то он не будет использоваться для того случая.

Еще одна вещь: evenAI может поддерживать фазы. "Фаза" это только способ сгруппировать определенные события и действия вместе так, чтобы существо выполнило нужные задачи, основанные на том, какой случай в настоящее время активен. Принцип работы фаз в eventAI состоит в том, что фаза добавляется для каждого случая, это делается для того, что бы фаза ни срабатывала в случайном порядке. На первый взгляд это кажется немного запутанным, довайте рассмотрим это поближе. У существа может быть больше чем одна фаза, до 32 различных фаз (с 0 до 31). Как будет работать фаза, зависит от того, какое 32битное число содержит поле. Каждое число представляет возможную фазу, выражение равное 0 представляет собой наименее существенную фазу, выражение равное 31 максимально существенную фазу. У значения по умолчанию (0) нету никаких битов и этим контролируется, что бы случай НЕ БЫЛ вызван, в противном случаи это означало бы, что случай будет всегда вызываться независимо от текущей фазы, в которой находиться существо. Поэтому, если вы хотите определить, в какой фазе случай произойдет, вы должны сложить все соответствующие биты для всех других фаз, в которых случай не должен произойти (да... запутано).

Например, у определенного существа, использующего eventAI, будет максимум 4 фазы. Тогда мы будем иметь дело с 4-х битным значением. Далее давайте представим, что у определенного существа есть событие, которое будет вызвано в его третьей фазе (произнесение заклинания, например). Тогда поле должно содержать все фазы, в которых НЕ ДОЛЖЕН произойти случай... тогда из четырех битов мы оставляем третье в покое и включаем все другие биты, таким образом получаем 1011(двоичное), которое равно 11(десятичное), таким образом, мы вставляем 11 как противоположную маску фазы для события. Другой пример, представим тоже самое, но только для первой и четвертой фазы. Это означает, что мы должны проигнорировать вторую и третью фазы, таким образом, мы получим значение 0110, которое равно 6, полученное число вставляем как противоположную маску фазы для события. Пожалуйста, отметьте, что оба примера были написаны для существа с четырьмя и только четырьмя фазами. Если вы решаете добавить больше фаз, то нужно будет пересмотреть все битовые значения отличные от нуля для всех событий существ.

У каждого случая также есть поле, которое управляет шансом этого случая. Используя значение 0, заставит случай никогда не происходить. Можно вписывать значения от 0 до 100 (%).


Общие Вопросы

  1. Мои НИПы не выполняют заданные скрипты в подземельях!
    1. Прокрутите эту страницу вниз к самому низу, пока Вы не увидите "Флаги случаев" - вы увидите, что в поле event_flags вписывается 2-е или 3-е значение, для рейдового или героического подземелья, соответственно. Большинство людей забывают об этом.
  1. Заскриптованные элементы должны быть враждебны для взаимодействия?
    1. Это может показаться таким только на первый взгляд, поскольку самый распространненый тип события равен 0, "В бою", но созданным с пометкой "ВБ" ("Вне боя"), отлично будет работать с фракцией 35 (дружелюбный для всех). Изучите event_type 1 и 10 для принятия решения по вашему вопросу.
  1. EventAI может взаимодействовать с Игровыми Объектами (ИО)?
    1. Не совсем. The closest anyone has come out of casual experience (At least since 8/9/09) is to cast a spell which has been reconfigured via the spell_scripts table. Это может быть возможно. Выберете в таблицы spell_scripts тип действия 11, 12 и 13. Они могут вам подойти.

Пояснения Случаев


  • 0 = EVENT_T_TIMER: ТОЛЬКО В БОЮ! - Заканчивается сначала между (Param1) и (Param2) и затем между каждым (Param3) и (Param4).
    • Parameter 1: InitialMin
    • Parameter 2: InitialMax
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 1 = EVENT_T_TIMER_OOC: ВНЕ БОЯ! - Заканчивается сначала между (Param1) и (Param2) и затем между каждым (Param3) и (Param4).
    • Parameter 1: InitialMin
    • Parameter 2: InitialMax
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 2 = EVENT_T_HP: Заканчивается, когда уровень жизней между (Param1) и (Param2). И повторится между каждым (Param3) и (Param4).
    • Parameter 1: HPMax% (Примечание: Максимум идет перед Минимум. Не запутывайтесь.)
    • Parameter 2: HPMin%
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 3 = EVENT_T_MANA: Заканчивается, когда уровень маны между (Param1) и (Param2). И повторится между каждым (Param3) и (Param4).
    • Parameter 1: ManaMax%
    • Parameter 2: ManaMin%
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 4 = EVENT_T_AGGRO: Заканчивается в момент начальной агрессии (агро) (не повторяется).
  • 5 = EVENT_T_KILL: Заканчивается в момент убийства игрока. Повторится между каждым (Param1) и (Param2).
    • Parameter 1: RepeatMin
    • Parameter 2: RepeatMax
  • 6 = EVENT_T_DEATH: Заканчивается после смерти.
  • 7 = EVENT_T_EVADE: Заканчивается в момент активации у существа EnterEvadeMode().
  • 8 = EVENT_T_SPELLHIT: Заканчивается после точного попадения заклинания. Если установлен только (param1), то закончится именно на нем. Если (param2), то истечет только на заклинания данной школы. Повторится между каждым (Param3) и (Param4).
    • Parameter 1: SpellID
    • Parameter 2: School
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 9 = EVENT_T_RANGE: Expires when the highest threat target distance is greater than (Param1) and less than (Param2). Will repeat every (Param3) and (Param4) .
    • Parameter 1: MinDist
    • Parameter 2: MaxDist
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 10 = EVENT_T_OOC_LOS: Expires when a unit moves within distance (MaxAllowedRange) of a creature. If (Param1) is zero it will expire only when unit is hostile, friendly otherwise (Param1 = 1), depends generally on faction. Will repeat every (Param3) and (Param4). Does not expire when the creature is in combat.
    • Parameter 1: Hostile-or-Not
    • Parameter 2: MaxAllowedRange
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 11 = EVENT_T_SPAWNED: Expires at initial spawn and at creature respawn (useful for setting ranged movement type)
  • 12 = EVENT_T_TARGET_HP: Expires when Current Target's HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4) .
    • Parameter 1: HPMax%
    • Parameter 2: HPMin%
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 13 = EVENT_T_TARGET_CASTING: Expires when the player is casting a spell. Will repeat every (Param1) and (Param2) .
    • Parameter 1: RepeatMin
    • Parameter 2: RepeatMax
  • 14 = EVENT_T_FRIENDLY_HP: Expires when a friendly unit in radius(param2) has at least (param1) hp missing. Will repeat every (Param3) and (Param4) .
    • Parameter 1: HPDeficit
    • Parameter 2: Radius
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 15 = EVENT_T_FRIENDLY_IS_CC: Expires when a friendly unit is Crowd controlled within the given radius (param2). Will repeat every (Param3) and (Param4) .
    • Parameter 1: DispelType
    • Parameter 2: Radius
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 16 = EVENT_T_MISSING_BUFF: Expires when a friendly unit is missing aura's given by spell (param1) within radius (param2). Will repeat every (Param3) and (Param4) .
    • Parameter 1: SpellId
    • Parameter 2: Radius
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 17 = EVENT_T_SUMMONED_UNIT: Expires after creature with entry(Param1) is spawned or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) .
    • Parameter 1: CreatureId
    • Parameter 2: RepeatMin
    • Parameter 3: RepeatMax
  • 18 = EVENT_T_TARGET_MANA:
    • Parameter 1: ManaMax%
    • Parameter 2: ManaMin%
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 21 = EVENT_T_REACHED_HOME: Expires when creature reach it's home(spawn) location after Evade.
  • 22 = EVENT_T_RECEIVE_EMOTE: Expires when creature receive emote with text emote id(enum TextEmotes). Condition can be defined. If set, then most conditions has additional value (see table enum ConditionType below.)
    • Parameter 1: EmoteId
    • Parameter 2: Condition
    • Parameter 3: CondValue1
    • Parameter 4: CondValue2
  • 23 = EVENT_T_BUFFED: Expires when creature have spell (Param1) auras applied stack greater or equal provided in Param2 amount. Will repeat every (Param3) and (Param4).
    • Parameter 1: SpellId
    • Parameter 2: AmmountInStack
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax
  • 24 = EVENT_T_TARGET_BUFFED: Expires when target unit have spell (Param1) auras applied stack greater or equal provided in Param2 amount. Will repeat every (Param3) and (Param4).
    • Parameter 1: SpellId
    • Parameter 2: AmmountInStack
    • Parameter 3: RepeatMin
    • Parameter 4: RepeatMax


Now that all of the supported events have been listed and described, we shall now move on to the actions that can be performed. Each event can take up to three actions. The actions will all be performed when the event is triggered and they will be performed in the order that they have been defined. This means that, for a certain event, action 1 will be performed first, followed by action 2, then lastly by action 3. Just like event definitions, each action can use up to three different parameters but not all actions will use all three parameters. If a parameter isn't mentioned for an action, then that action does not need that parameter.

Before we start to list and explain the different actions that can be taken, we must first look at how the eventAI targeting system works. Due to technical reasons in how targetting is handled, the eventAI script cannot target anything or anyone that is not in its threat list or is not the scripted creature itself. It also can't currently target anyone specific in its threat list except by their position in the threat list. However, even then it can only target specifically the current victim, the second unit in its threat list, and the last unit in its threat list. It can also target units in its threat list at random and has two options for that: anyone in its threat list at random, or anyone in its threat list excluding the unit with the most threat. Aside from all of those external targets, the script can always target itself. More information on the target types can be found in the reference tables at the end of this guide.

One last note before we start looking at individual actions is about the texts. The eventAI script has support for localized text entries. Therefore, you can define what the mob will say in more than one language all in another table and the script will show the corresponding localized text to the corresponding client (english text to enUS/enGB clients, german text to deDE clients, etc). All of the localized text entries will have a unique text ID assigned to them and it is that text ID that will be used by any actions that require textual input.

Action Explanations


  • 0 = ACTION_T_NONE: Does nothing!
  • 1 = ACTION_T_SAY: Displays the -TextId as defined. In case -TextId2 and optionally -TextId3, the output will be randomized. Type text are defined in the eventai_texts table (say, yell, whisper, etc) along with other options for the text. All values are required to be negative.
    • Parameter 1: The entry of the text that the NPC should use from eventai_texts table. Optionally a entry from other tables can be used (such as custom_texts).Entry are required to be negative and exist in a *_texts-table. The type text to be displayed are defined in the texts-table itself (Say, Yell, Whisper, Emote Text, Boss Whisper, Boss Emote)Other options are also to be defined in the texts-table, such as a sound to be heard with the text and the language used in output (common, dwarvish, etc).In case this entry has a localized version of the text, the localized text will be displayed in client that support this locale.
    • Parameter 2: Optional. TextId can be defined in addition. The same apply to this as explained above, however eventAI will randomize between the two.
    • Parameter 3: Optional, if Parameter 2 exist. In this case, eventAI will randomize between three.
  • 2 = ACTION_T_SET_FACTION: Change faction for creature.
    • Parameter 1: FactionId of the desired faction. If param1==0, creature will revert to default faction.
  • 3 = ACTION_T_MORPH_TO_ENTRY_OR_MODEL: Set model from creature_template.entry(param1) OR set explicit modelId(param2). If param1 AND param2 both 0, demorph and revert to default model for creature.
    • Parameter 1: CreatureEntry of the npc.
    • Parameter 2: ModelId that needs to be changed to.


  • 4 = ACTION_T_SOUND: When activated, the creature will play the specified sound.
    • Parameter 1: The sound ID to be played. Sound IDs are contained in the DBC files.
  • 5 = ACTION_T_EMOTE: When activated, the creature will perform a visual emote. Unlike a text emote, a visual emote is one where the creature will actually move or perform a gesture.
    • Parameter 1: The emote ID that the creature should perform. Emote IDs are also contained in the DBC but they can be found in the mangos source as well.
  • 6 = ACTION_T_RANDOM_SAY: UNUSED
  • 7 = ACTION_T_RANDOM_YELL: UNUSED
  • 8 = ACTION_T_RANDOM_TEXTEMOTE: UNUSED
  • 9 = ACTION_T_RANDOM_SOUND: Similar to the ACTION_T_SOUND action, when this action is activated, it will choose at random a sound to play. This action needs all three parameters to be filled and it will pick a random entry from the three. NOTE: (1)
    • Parameter 1: The sound ID to be played as choice one.
    • Parameter 2: The sound ID to be played as choice two.
    • Parameter 3: The sound ID to be played as choice three.
  • 10 = ACTION_T_RANDOM_EMOTE: Similar to the ACTION_T_EMOTE action, when this action is activated, it will choose at random an emote ID to emote visually. This action needs all three parameters to be filled and it will pick a random entry from the three. NOTE: (1)
    • Parameter 1: The emote ID that the creature should perform as choice one.
    • Parameter 2: The emote ID that the creature should perform as choice two.
    • Parameter 3: The emote ID that the creature should perform as choice three.
  • 11 = ACTION_T_CAST: When activated, the creature will cast a spell specified by a spell ID on a target specified by the target type.
    • Parameter 1: The spell ID to use for the cast. The value used in this field needs to be a valid spell ID.
    • Parameter 2: The target type defining who the creature should cast on. The value in this field needs to be a valid target type as specified in the reference tables below.
    • Parameter 3: This field can only be 0 or 1. If it is 1, then the spell cast will interrupt any spells that are already in the progress of being casted; otherwise if the creature is already casting a spell and this field is 0, then this action will be skipped.
  • 12 = ACTION_T_SUMMON: When activated, the creature will summon another creature at the same spot as itself that will attack the specified target.
    • Parameter 1: The creature template ID to be summoned. The value here needs to be a valid creature template ID.
    • Parameter 2: The target type defining who the summoned creature will attack. The value in this field needs to be a valid target type as specified in the reference tables below. NOTE: Using target type 0 will cause the summoned creature to not attack anyone.
    • Parameter 3: The duration until the summoned creature should be unsummoned. The value in this field is in milliseconds or 0. If zero, then the creature will not be unsummoned until it leaves combat.
  • 13 = ACTION_T_THREAT_SINGLE_PCT: When activated, this action will modify the threat of a target in the creature's threat list by the specified percent.
    • Parameter 1: Threat percent that should be modified. The value in this field can range from -100 to +100. If it is negative, threat will be taken away and if positive, threat will be added.
    • Parameter 2: The target type defining on whom the threat change should occur. The value in this field needs to be a valid target type as specified in the reference tables below.
  • 14 = ACTION_T_THREAT_ALL_PCT: When activated, this action will modify the threat for everyone in the creature's threat list by the specified percent.
    • Parameter 1: The percent that should be used in modifying everyone's threat in the creature's threat list. The value here can range from -100 to +100. NOTE: Using -100 will cause the creature to reset everyone's threat to 0 so that everyone has the same amount of threat. It does NOT make any changes as to who is in the threat list.
  • 15 = ACTION_T_QUEST_EVENT: When activated, this action will satisfy the external completion requirement for the quest for the specified target defined by the target type. This action can only be used with player targets so it must be ensured that the target type will point to a player.
    • Parameter 1: The quest template ID. The value here must be a valid quest template ID. Furthermore, the quest should have SpecialFlags | 2 as it would need to be completed by an external event which is the activation of this action.
    • Parameter 2: The target type defining whom the quest should be completed for. The value in this field needs to be a valid target type as specified in the reference tables below.
  • 16 = ACTION_T_CASTCREATUREGO: When activated, this action will call CastedCreatureOrGO() function for the player. It can be used to give quest credit for casting a spell on the creature.
    • Parameter 1: The quest template ID. The value here must be a valid quest template ID.
    • Parameter 2: The spell ID to use to simulate the cast. The value used in this field needs to be a valid spell ID.
    • Parameter 3: The target type defining whom the quest credit should be given to. The value in this field needs to be a valid target type as specified in the reference tables below.
  • 17 = ACTION_T_SET_UNIT_FIELD: When activated, this action can change the target's unit field values. More information on the field value indeces can be found at character data.
    • Parameter 1: The index of the field number to be changed. Use character data for a list of indeces and what they control. Note that a creature shares the same indeces with a player except for the PLAYER_* ones.
    • Parameter 2: The new value to be put in the field.
    • Parameter 3: The target type defining for whom the unit field should be changed. The value in this field needs to be a valid target type as specified in the reference tables below.
  • 18 = ACTION_T_SET_UNIT_FLAG: When activated, this action changes the target's flags by adding (turning on) more flags. For example, this action can make the creature unattackable/unselectable if the right flags are used.
    • Parameter 1: The flag(s) to be set. Multiple flags can be set by using bitwise-OR on them (adding them together).
    • Parameter 2: The target type defining for whom the flags should be changed. The value in this field needs to be a valid target type as specified in the reference tables below.
  • 19 = ACTION_T_REMOVE_UNIT_FLAG: When activated, this action changes the target's flags by removing (turning off) flags. For example, this action can make the creature normal after it was unattackable/unselectable if the right flags are used.
    • Parameter 1: The flag(s) to be removed. Multiple flags can be set by using bitwise-OR on them (adding them together).
    • Parameter 2: The target type defining for whom the flags should be changed. The value in this field needs to be a valid target type as specified in the reference tables below.
  • 20 = ACTION_T_AUTO_ATTACK: This action controls whether or not the creature should stop or start the auto melee attack.
    • Parameter 1: If zero, then the creature will stop its melee attacks. If non-zero, then the creature will either continue its melee attacks (the action would then have no effect) or it will start its melee attacks on the target with the top threat if its melee attacks were previously stopped.
  • 21 = ACTION_T_COMBAT_MOVEMENT: This action controls whether or not the creature will always move towards its target.
    • Parameter 1: If zero, then the creature will stop moving towards its victim (if its victim gets out of melee range) and will be stationary. If non-zero, then the creature will either continue to follow its victim (the action would have no effect) or it will start to follow the target with the top threat if its movement was disabled before.
  • 22 = ACTION_T_SET_PHASE: When activated, this action sets the creature's event to the specified value.
    • Parameter 1: The new phase to set the creature in. This number must be an integer between 0 and 31 inclusive.
  • 23 = ACTION_T_INC_PHASE: When activated, this action will increase (or decrease) the current creature's phase.
    • Parameter 1: The number of phases to increase or decrease. Use negative values to decrease the current phase. After increasing or decreasing the phase by this action, the current phase must not be lower than 0 or exceed 31.
  • 24 = ACTION_T_EVADE: When activated, the creature will immediately exit out of combat, clear its threat list, and move back to its spawn point. Basically, this action will reset the whole encounter.
  • 25 = ACTION_T_FLEE: When activated, the creature will try to flee from combat. Currently this is done by it casting a fear-like spell on itself called "Run Away".
  • 26 = ACTION_T_QUEST_EVENT_ALL: This action does the same thing as the ACTION_T_QUEST_EVENT does but it does it for all players in the creature's threat list. Note that if a player is not in its threat list for whatever reason, he/she won't get the quest completed.
    • Parameter 1: The quest ID to finish for everyone.
  • 27 = ACTION_T_CASTCREATUREGO_ALL: This action does the same thing as the ACTION_T_CASTCREATUREGO does but it does it for all players in the creature's threat list. Note that if a player is not in its threat list for whatever reason, he/she won't receive the cast emulation.
    • Parameter 1: The quest template ID.
    • Parameter 2: The spell ID used to simulate the cast.
  • 28 = ACTION_T_REMOVEAURASFROMSPELL: This action will remove all auras from a specific spell from the target.
    • Parameter 1: The target type defining for whom the unit field should be changed. The value in this field needs to be a valid target type as specified in the reference tables below.
    • Parameter 2: The spell ID whose auras will be removed.
  • 29 = ACTION_T_RANGED_MOVEMENT: This action changes the movement type generator to ranged type using the specified values for angle and distance. Note that specifying zero angle and distance will make it just melee instead.
    • Parameter 1: The distance the mob should keep between it and its target.
    • Parameter 2: The angle the mob should use.
  • 30 = ACTION_T_RANDOM_PHASE: Randomly sets the phase to one from the three parameter choices. NOTE: (1)
    • Parameter 1: A possible random phase choice.
    • Parameter 2: A possible random phase choice.
    • Parameter 3: A possible random phase choice.
  • 31 = ACTION_T_RANDOM_PHASE_RANGE: Randomly sets the phase between a range of phases controlled by the parameters.
    • Parameter 1: The minimum of the phase range.
    • Parameter 2: The maximum of the phase range. The number here must be greater than the one in parameter 1.
  • 32 = ACTION_T_SUMMON: Summons a creature using the data specified in the separate summons table.
    • Parameter 1: The creature template ID to be summoned. The value here needs to be a valid creature template ID.
    • Parameter 2: The target type defining who the summoned creature will attack. The value in this field needs to be a valid target type as specified in the reference tables below. NOTE: Using target type 0 will cause the summoned creature to not attack anyone.
    • Parameter 3: The summon ID from the eventai_summons table controlling the position (and spawntime) where the summoned mob should be spawned at.
  • 33 = ACTION_T_KILLED_MONSTER: When activated, this action will call KilledMonster() function for the player. It can be used to give creature credit for killing a creature (note that it can be ANY creature including certain quest specific triggers). In general if the quest is set to be accompished on different creatures (e.g. "Credit" templates).
    • Parameter 1: The creature template ID. The value here must be a valid creature template ID.
    • Parameter 2: The target type defining whom the quest kill count should be given to. The value in this field needs to be a valid target type as specified in the reference tables below.
  • 34 = ACTION_T_SET_INST_DATA: Sets data for the instance. Note that this will only work when the creature is inside an instantiable zone that has a valid script (ScriptedInstance) assigned.
    • Parameter 1: The field to change in the instance script. Again, this field needs to be a valid field that has been already defined in the instance's script.
    • Parameter 2: The value to put at that field index. The number here must be a valid 32 bit number.
  • 35 = ACTION_T_SET_INST_DATA64: Sets GUID (64 bits) data for the instance based on the target. Note that this will only work when the creature is inside an instantiable zone that has a valid script (ScriptedInstance) assigned.
    • Parameter 1: The field to change in the instance script. Again, this field needs to be a valid field that has been already defined in the instance's script.
    • Parameter 2: The target type to use to get the GUID that will be stored at the field index. The value in this field needs to be a valid target type as specified in the reference tables below.
  • 36 = ACTION_T_UPDATE_TEMPLATE: This function temporarily changes creature entry to new entry, display is changed, loot is changed, but AI is not changed. At respawn creature will be reverted to original entry.
    • Parameter 1: The creature template ID. The value here must be a valid creature template ID.
    • Parameter 2: Use model_id from team : Alliance(0) or Horde (1).
  • 37 = ACTION_T_DIE: Kills the creature
  • 38 = ACTION_T_ZONE_COMBAT_PULSE: Places all players within the instance into combat with the creature. Only works in combat and only works inside of instances.
  • 39 = ACTION_T_CALL_FOR_HELP: Call any friendly creatures (if its not in combat/etc) in radius attack creature target.
    • Parameter 1: Radius from creature.
  • 40 = ACTION_T_SET_SHEATH: Let set sheath state for creature (0-no weapon show (not used mostly by creatures), 1-melee weapon show, 2-ranged weapon show)
    • Parameter 1: Sheath state of the creature.
  • 41 = ACTION_T_FORCE_DESPAWN: Despawns the creature.

(1) = Use -1 to specify that if this param is picked to do nothing. Random is constant between actions within an event. So if you have a random Yell and a random Sound they will match up (ex: param2 with param2)

Reference Tables


All of the events, actions, and target types are summarized in tabular format for convenience purposes and fast lookup. NU = Not Used; * - optional

Events

ID Name Param 1 Param 2 Param 3 Param 4 Description
0 EVENT_T_TIMER InitialMin InitialMax RepeatMin RepeatMax COMBAT ONLY - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4).
1 EVENT_T_TIMER_OOC InitialMin InitialMax RepeatMin RepeatMax OUT OF COMBAT - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4).
2 EVENT_T_HP HPMax% HPMin% RepeatMin RepeatMax Expires when HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4).
3 EVENT_T_MANA ManaMax% ManaMin% RepeatMin RepeatMax Expires once Mana% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4).
4 EVENT_T_AGGRO n/a n/a n/a n/a Expires upon initial aggro (does not repeat).
5 EVENT_T_KILL RepeatMin RepeatMax n/a n/a Expires upon killing a player. Will repeat every (Param1) and (Param2).
6 EVENT_T_DEATH n/a n/a n/a n/a Expires upon Death.
7 EVENT_T_EVADE n/a n/a n/a n/a Expires upon creature EnterEvadeMode().
8 EVENT_T_SPELLHIT SpellID School RepeatMin RepeatMax Expires upon Spell hit. If (param1) is set will only expire on that spell. If (param2) will only expire on spells of that school. Will repeat every (Param3) and (Param4) .
9 EVENT_T_RANGE MinDist MaxDist RepeatMin RepeatMax Expires when the highest threat target distance is greater than (Param1) and less than (Param2). Will repeat every (Param3) and (Param4) .
10 EVENT_T_OOC_LOS Hostile-or-Not MaxAllowedRange RepeatMin RepeatMax Expires when a unit moves within distance (MaxAllowedRange) of a creature. If (Param1) is zero it will expire only when unit is hostile, friendly otherwise (Param1 = 1), depends generally on faction. Will repeat every (Param3) and (Param4). Does not expire when the creature is in combat.
11 EVENT_T_SPAWNED n/a n/a n/a n/a Expires at initial spawn and at creature respawn (useful for setting ranged movement type)
12 EVENT_T_TARGET_HP HPMax% HPMin% RepeatMin RepeatMax Expires when Current Target's HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4) .
13 EVENT_T_TARGET_CASTING RepeatMin RepeatMax n/a n/a Expires when the player is casting a spell. Will repeat every (Param1) and (Param2) .
14 EVENT_T_FRIENDLY_HP HPDeficit Radius RepeatMin RepeatMax Expires when a friendly unit in radius(param2) has at least (param1) hp missing. Will repeat every (Param3) and (Param4) .
15 EVENT_T_FRIENDLY_IS_CC DispelType Radius RepeatMin RepeatMax Expires when a friendly unit is Crowd controlled within the given radius (param2). Will repeat every (Param3) and (Param4) .
16 EVENT_T_MISSING_BUFF SpellId Radius RepeatMin RepeatMax Expires when a friendly unit is missing aura's given by spell (param1) within radius (param2). Will repeat every (Param3) and (Param4) .
17 EVENT_T_SUMMONED_UNIT CreatureId RepeatMin RepeatMax n/a Expires after creature with entry(Param1) is spawned or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) .
18 EVENT_T_TARGET_MANA ManaMax% ManaMin% RepeatMin RepeatMax
21 EVENT_T_REACHED_HOME n/a n/a n/a n/a Expires when creature reach it's home(spawn) location after Evade.
22 EVENT_T_RECEIVE_EMOTE EmoteId Condition CondValue1 CondValue2 Expires when creature receive emote with text emote id(enum TextEmotes). Condition can be defined. If set, then most conditions has additional value (see enum ConditionType)
23 EVENT_T_BUFFED SpellId AmmountInStack RepeatMin RepeatMax Expires when creature have spell (Param1) auras applied stack greater or equal provided in Param2 amount. Will repeat every (Param3) and (Param4).
24 EVENT_T_TARGET_BUFFED SpellId AmmountInStack RepeatMin RepeatMax Expires when target unit have spell (Param1) auras applied stack greater or equal provided in Param2 amount. Will repeat every (Param3) and (Param4).

Actions

ID Name Param 1 Param 2 Param 3 Description
1 ACTION_T_SAY -TextId1, -TextId2, -TextId3 Displays the -TextId as defined. In case -TextId2 and optionally -TextId3, the output will be randomized. Type text are defined in the text table itself(say, yell, whisper, etc) along with other options for the text. All values are required to be negative.
2 ACTION_T_SET_FACTION FactionId UNUSED UNUSED Change faction for creature. If param1==0, creature will revert to default faction.
3 ACTION_T_MORPH_TO_ENTRY_OR_MODEL CreatureEntry ModelId UNUSED Set model from creature_template.entry(param1) OR set explicit modelId(param2). If param1 AND param2 both 0, demorph and revert to default model for creature.
4 ACTION_T_SOUND Sound ID NU NU Creature plays sound
5 ACTION_T_EMOTE Emote ID NU NU Creature does visual emote
6 ACTION_T_RANDOM_SAY UNUSED UNUSED UNUSED UNUSED
7 ACTION_T_RANDOM_YELL UNUSED UNUSED UNUSED UNUSED
8 ACTION_T_RANDOM_TEXTEMOTE UNUSED UNUSED UNUSED UNUSED
9 ACTION_T_RANDOM_SOUND Sound ID 1 Sound ID 2 Sound ID 3 Picks a sound ID at random and plays it; -1 = action skipped if chosen
10 ACTION_T_RANDOM_EMOTE Emote ID 1 Emote ID 2 Emote ID 3 Picks an emote ID at random and does visual emote; -1 = action skipped if chosen
11 ACTION_T_CAST Spell ID T-Type Cast Flag Casts spell on a target with specified cast flags (see table below).
12 ACTION_T_SUMMON Creature ID T-Type Duration* Summons a creature at itself for a given duration (infinite if zero) that will attack a target.
13 ACTION_T_THREAT_SINGLE_PCT Threat % T-Type NU Modifies the target's threat by a percent
14 ACTION_T_THREAT_ALL_PCT Threat % NU NU Modifies everyone's threat by a percent
15 ACTION_T_QUEST_EVENT Quest ID T-Type NU Satisfies external script objective for a quest for the target (must be a player)
16 ACTION_T_CASTCREATUREGO Quest ID Spell ID T-Type Emulates spell cast on the creature for the target (must be a player)
17 ACTION_T_SET_UNIT_FIELD Index Value T-Type Sets unit field at the index to the value given for the target
18 ACTION_T_SET_UNIT_FLAG Flag(s) T-Type NU Sets flag(s) on the target
19 ACTION_T_REMOVE_UNIT_FLAG Flag(s) T-Type NU Removes flag(s) from the target
20 ACTION_T_AUTO_ATTACK Boolean NU NU If 0, stops auto melee; else continues/starts it
21 ACTION_T_COMBAT_MOVEMENT Boolean NU NU If 0, stops combat movement; else continues/starts it
22 ACTION_T_SET_PHASE Phase # NU NU Sets current phase to number given
23 ACTION_T_INC_PHASE Number NU NU Increments (or decrements) the phase by given number.
24 ACTION_T_EVADE NU NU NU Force creature reset. Exit combat + lose threat
25 ACTION_T_FLEE NU NU NU Force creature to flee from combat
26 ACTION_T_QUEST_EVENT_ALL Quest ID NU NU Satisfies external objective for a quest for all players in threat list
27 ACTION_T_CASTCREATUREGO_ALL Quest ID Spell ID NU Emulates spell cast on creature for all players in threat list
28 ACTION_T_REMOVEAURASFROMSPELL T-Type Spell ID NU Removes all auras from a spell ID from the target.
29 ACTION_T_RANGED_MOVEMENT Distance Angle NU Uses ranged movement generator keeping the creature at a distance.
30 ACTION_T_RANDOM_PHASE Phase 1 Phase 2 Phase 3 Randomly chooses a phase from the list of three phases.
31 ACTION_T_RANDOM_PHASE_RANGE Min Phase Max Phase NU Chooses a random phase in the range specified.
32 ACTION_T_SUMMON Creature ID T-Type Summon ID Summons a creature at the coords specified for the given summon id that will attack a target.
33 ACTION_T_KILLED_MONSTER Creature ID T-Type NU Simulates a kill for a mob of ID given for the player from the target type.
34 ACTION_T_SET_INST_DATA Field Value NU Sets new value for the field given in the instance script.
35 ACTION_T_SET_INST_DATA64 Field T-Type NU Stores target's GUID at the field given in the instance script.
36 ACTION_T_UPDATE_TEMPLATE Entry Fraction NU Temporarily changes creature entry to new entry.
37 ACTION_T_DIE NU NU NU Kills the creature.
38 ACTION_T_ZONE_COMBAT_PULSE NU NU NU Places all players within the instance into combat with the creature. Only works in combat and only works inside of instances.
39 ACTION_T_CALL_FOR_HELP Radius NU NU Call any friendly creatures (if its not in combat/etc) in radius attack creature target.
40 ACTION_T_SET_SHEATH Sheath NU NU Let set sheath state for creature (0-no weapon show (not used mostly by creatures), 1-melee weapon show, 2-ranged weapon show)
41 ACTION_T_FORCE_DESPAWN NU NU NU Despawns the creature


Target Types (T-Type)

ID Name Description
0 TARGET_T_SELF Targets itself
1 TARGET_T_HOSTILE Targets the current victim (usually the one with the most threat)
2 TARGET_T_HOSTILE_SECOND_AGGRO Targets the unit with the second most threat in the threat list
3 TARGET_T_HOSTILE_LAST_AGGRO Targets the unit with the least threat in the threat list
4 TARGET_T_HOSTILE_RANDOM Targets a random unit from the threat list
5 TARGET_T_HOSTILE_RANDOM_NOT_TOP Targets a random unit from the threat list excluding the one with the most threat
6 TARGET_T_ACTION_INVOKER Targets the unit that caused the event; only for certain events only.

Cast Flags

Bit / Value* Name Description
0 / 1 CAST_INTURRUPT_PREVIOUS Interrupts any previous spell casting.
1 / 2 CAST_TRIGGERED Forces the cast to be instant and ignores any mana/reagents requirements.
2 / 4 CAST_FORCE_CAST Forces spell to cast even if the target is possibly out of range or the creature is possibly out of mana
3 / 8 CAST_NO_MELEE_IF_OOM Prevents creature from entering melee if out of mana or out of range
4 / 16 CAST_FORCE_TARGET_SELF Forces the target to cast this spell on itself
5 / 32 CAST_AURA_NOT_PRESENT Only casts the spell on the target if the target does not have the aura from that spell on itself already.


Condition Type (For Event_type 22)

Condition Value 1 Value 2* Description
0 None 0 0 Nothing.
1 Aura SpellID "effindex" If the SpellID's aura is on you.
2 Item ItemID Amount If you have the item in your inventory.
3 Item Equipped ItemId Amount If you have the item equipped on your character.
4 Zone ID ZoneID 0 Taken from AreaTable.dbc.
5 Reputation FactionID Minimum Rank Taken from FactionTemplate.dbc. Exalted is 42000.
6 Team Team# 0 In "Team#" use 469 if alliance, 67 if Horde.
7 Skill SkillID Min Amount Values taken from SkillLine.dbc.
8 Quest Rewarded QuestID 0 If you have already completed that QuestID.
9 Quest Taken QuestID 0 If you are currently on that QuestID.
12 Active Event EventID 0 This is not from your database. This value is from the DBC file enum HolidayIds.
* - If the value is listed as 0, then leave it as 0.


Event Flags

Bit / Value* Name Description
0 / 1 EFLAG_REPEATABLE Event repeats (Does not repeat if this flag is not set)
1/2 EFLAG_NORMAL Event only occurs in Normal instance difficulty.
2/4 EFLAG_HEROIC Event only occurs in Heroic instance difficulty.
7 / 128 EFLAG_DEBUG_ONLY Not yet implemented!

* = Represents what the value in the field would be with no other additive flags. For help on Binary Addition, read the "Working With Phases" portion of the guide below.


(Spacer)

Summary for the meek

If you still don't understand what EventAI is, it's understandable. It's a very powerful table and can look confusing at first glance. I will elaborate on some of the concepts here.

The event_type field determines what you need to put into the event_param1 - event_param4 fields. If your event_type is 0, (In-combat.) your parameters will need to be lengths of time (in milliseconds) in which the action will take place. If your event_type is 6, (on death) we won't need any parameters, as the condition has no possible parameters to work with. Death is death. We can't define what kind of death it should be, so there are no parameters necessary.


Working with Phases

Working with phases requires a certain amount of math. You will have to know a few things before we begin.

  1. You should have an idea of how many phases the NPC will have.
  2. You will have to know Binary Addition. Don't worry, I'll show you how to do it.

- Binary Addition -

  • 0110 = 6 (base 10)
  • 0111 = 7 (base 10)
  • ____ = __
  • 1101 = 13 (base 10)


  • 07 06 05 04 03 02 01 00 <-- The place values.
  • 64 32 16 08 04 02 01 00 <-- Note how it doubles in size. This is what you add.

_

  • _1 __ 1 __ 1
  • 04 + 02 + 01 = 07.

_

  • _1 __ 0 __ 1 __ 1 __ 0 <-- Note how place 1, 2, and 4 are 1, but place 3 is not.
  • 08 + 04 + 02 + 01 + 00 = 11.

So you add 1, 2, and 8 together to get 11. You do not add the 4, because its bit was a 0.

__ __ __

Now back to Phases.

The overall concept (not method, just yet!) of a phase, is a "section" of activities that the NPC will act on. Hypothetically speaking, if a boss uses Attack "X" only when above 50% health, and only uses attack "Y" only when below 50% health, the boss will be using two different phases.

The concept: The "event_inverse_phase_mask" field is the field controlling phase information. Read the following sentence very carefully and memorize it. The number in this field represents the phases that this action will not be initiated in, including up to and less than the NPC's total number of phases. Keep this in the back of your head. The reason for this is because this number also casually tells the script how many phases the NPC has. It's surprisingly ingenious.


This is where the Binary Addition comes into play. Suppose your NPC has three phases. It will start off in phase 1. (*) It will remain in phase 1 unless specifically told to by Action Types 22, 23, 30, and 31, which control phases mid-game once the script is already running.

* (I should mention right here that anything with an event_inverse_phase_mask of 0 will happen in all phases.)

Suppose we wanted to have an attack that is only used in the NPC's first phase. You know that the NPC will have three phases. You would set up the attack as usual, but in the event_inverse_phase_mask field, you would put a 6. Why the six? Let's take a look.

We have three phases. We will represent these like this:

  • _3__2__1__<-- Represents the Phase Number and the bit.
  • 04 02 01

Phase 1's bit is 1. Phase 2's bit is 2. Phase 3's bit is 4. (If we had a phase 4, it would be 8, and phase 5 would be 16, etc.) To get 6, we have added the 2 and the 4 from the 2nd and 3rd phases. As was mentioned above, the number that goes into that field represents the bitmask of the phases that the action will not take place in.

Quick Phase Reference

This list is for an easy reference of what phase equates to what number, if you're not very phase-savvy. The "Value" column is what goes into the "event_inverse_phase_mask" field. The "Phase" column indicates the phase number that the hypothetical mob or boss is in that the event WILL happen in. This field relies on the next field, the "Max Phases" field. That is the amount of total phases the mob has. (I.e. my boss has 2 phases, or my boss has 4 phases.) Then there is a description field for any numerical work involved. It is the least important field, and can safely be ignored.

Remember, anything with "0" as a phase will occur in all phases. It is 0 by default.

Again, this is based on the following number patterns:

00 + 01 + 02 + 03 + 04 + 05 + 06 + 07 + 008 - Represents Phases.

00 + 01 + 02 + 04 + 08 + 16 + 32 + 64 + 128 - The numerical representations of those phases.

And, once again, how this works, is:

  1. You look at the total number of phases. Suppose it's 3.
  2. You cover up all the numbers to the right of phase 3, which corresponds to the 04 right below it.
  3. Then you decide which phase you want the event to occur in.
  4. Then you look at all other phases, and add up the number beneath them.
  5. The number you come up with goes in the "Value" field below in that chart, and what will go into the event_inverse_phase_mask field.
Value Phase Max Phases Description
2 1 2 2
1 2 2 1
Value Phase Max Phases Description
6 1 3 2+4
5 2 3 1+4
3 3 3 1+2
4 1+2 3 4
1 2+3 3 1
2 1+3 3 2
Value Phase Max Phases Description
14 1 4 2+4+8
13 2 4 1+4+8
11 3 4 1+2+8
7 4 4 1+2+4
12 1+2 4 4+8
10 1+3 4 2+8
6 1+4 4 2+4
9 2+3 4 1+8
5 2+4 4 1+4
3 3+4 4 1+2
8 1+2+3 4 8
1 2+3+4 4 1
4 1+2+4 4 4
2 1+3+4 4 2
Value Phase Max Phases Description
30 1 5 2+4+8+16
29 2 5 1+4+8+16
27 3 5 1+2+8+16
23 4 5 1+2+4+16
15 5 5 1+2+4+8
28 1+2 5 4+8+16
26 1+3 5 2+8+16
22 1+4 5 2+4+16
20 1+5 5 2+4+8
25 2+3 5 1+8+16
21 2+4 5 1+4+16
13 2+5 5 1+4+8
19 3+4 5 1+2+16
11 3+5 5 1+2+8
7 4+5 5 1+2+4
24 1+2+3 5 8+16
17 2+3+4 5 1+16
3 3+4+5 5 1+2
6 1+4+5 5 2+4
12 1+2+5 5 4+8
10 1+3+5 5 2+8
9 2+3+5 5 1+8
16 1+2+3+4 5 16
1 2+3+4+5 5 1
2 1+3+4+5 5 2
4 1+2+4+5 5 4
8 1+2+3+5 5 8

The reference chart will only go down to 4 phases for now. There is no small limit on the amount of phases except for your patience, and possibly 255. If anyone wants to fill in the rest of the chart, many thanks will be due to the brave and bored soul who does it.


Reminder: Once again, if your creatures don't perform your actions within Dungeons, you need to add "1" to the current value of the "Event_flags" column.

Личные инструменты