目录
一、介绍
smart_script 表位于 TrnityCore 数据库 world 下,主要通过事件触发(event)和动作响应(action),定义游戏内玩家与对象的交互,是一种简易的AI脚本。通过设置 smart_script 可以制作出复杂多变的交互效果。
二、字段解释
-
entryorguid
- 取值由 source_type 决定
- 当设置AI的 creature / game object / etc 选取 entry 时,字段取 creature_template.entry / gameobject_template.entry / etc
- 当设置AI的 creature / game object / etc 选取 guid 时,字段取 creature.guid / gameobject.guid / gameobject.guid / etc 的相反数(取负值)
- creature 和 gameobject 的 entryorguid 按照前两条规定取值
- areatrgger 的 entryorguid 按照 areatrigger_template.id 取值
- actionlist 的 entryorguid 按照 smart_scripts.entryorguid 取值
-
source_type
- 事件对象的类型,相关取值参考下表(以下为 master 分支取值,4,6,8,9暂未完成)
Name | Value | Source | Script name | Base Object |
---|---|---|---|---|
SMART_SCRIPT_TYPE_CREATURE | 0 | creature_template.entry creature.guid | creature_template.AIName SmartAI | Creature |
SMART_SCRIPT_TYPE_GAMEOBJECT | 1 | gameobject_template.entry or gameobject.guid | gameobject_template.AIName SmartGameObjectAI | GameObject |
SMART_SCRIPT_TYPE_AREATRIGGER | 2 | Areatrigger.db2 (ID) | areatrigger_scripts.ScriptName SmartTrigger | Player |
SMART_SCRIPT_TYPE_EVENT | 3 | event_script_names.Id | event_script_names.ScriptName SmartEventTrigger | Player, Creature or GameObject |
SMART_SCRIPT_TYPE_GOSSIP | 4 | |||
SMART_SCRIPT_TYPE_QUEST | 5 | quest_template.ID | quest_template_addon.ScriptName SmartQuest | Player |
SMART_SCRIPT_TYPE_SPELL | 6 | |||
SMART_SCRIPT_TYPE_TRANSPORT | 7 | |||
SMART_SCRIPT_TYPE_INSTANCE | 8 | |||
SMART_SCRIPT_TYPE_TIMED_ACTIONLIST | 9 | smart_scripts.entryorguid | Creature, GameObject or AreaTrigger | |
SMART_SCRIPT_TYPE_SCENE | 10 | scene_template.id | scene_template.ScriptName SmartScene | Player |
SMART_SCRIPT_TYPE_AREATRIGGER _ENTITY | 11 | areatrigger_template.Id (IsServerSide = 0) | areatrigger.ScriptName SmartAreaTriggerAI | AreaTrigger |
SMART_SCRIPT_TYPE_AREATRIGGER _ENTITY_SERVERSIDE | 12 | areatrigger_template.Id (IsServerSide = 1) | areatrigger.ScriptName SmartAreaTriggerAI | AreaTrigger |
-
id
- 从0开始,一次递增(0,1,2,3,…),可以理解为每个事件的执行编号
-
link
- 用于表述2个事件的触发关系
- 如下表,id=9 的这个事件只有在 id=8 的事件触发后才会触发
-
event_phase_mask
- 用于表述事件发生的阶段
- 只有在当前事件处于选择的阶段时,事件才有可能发生
- 默认的事件阶段取值应为 0
- 如想让事件仅发生在1和4阶段, 则 event_phase_mask = 1+8 = 9
- 如何改变事件阶段
- 将事件由1阶段转换到3阶段,有以下两种方法:
- 将 SMART_ACTION_INC_EVENT_PHASE(23)的 param1设置为2(param1为增加值,param2为减少值)
- 将 SMART_ACTION_SET_EVENT_PHASE(22)的 param1设置为3
- 将事件由6阶段转换到2阶段,有以下两种方法:
- 将 SMART_ACTION_INC_EVENT_PHASE(23)的 param2设置为4(param1为增加值,param2为减少值)
- 将 SMART_ACTION_SET_EVENT_PHASE(22)的 param1设置为2
- 将事件由1阶段转换到3阶段,有以下两种方法:
-
event_chance
-
事件发生的几率 (0-100)
-
-
event_flags
- 事件标识(以下为 master 分支取值)
Name | Flag | Hex | Comment |
---|---|---|---|
SMART_EVENT_FLAG_NOT_REPEATABLE | 1 | 0x01 | Event can not repeat |
SMART_EVENT_FLAG_DIFFICULTY_0_DEPRECATED | 2 | 0x02 | UNUSED, DO NOT REUSE |
SMART_EVENT_FLAG_DIFFICULTY_1_DEPRECATED | 4 | 0x04 | UNUSED, DO NOT REUSE |
SMART_EVENT_FLAG_DIFFICULTY_2_DEPRECATED | 8 | 0x08 | UNUSED, DO NOT REUSE |
SMART_EVENT_FLAG_DIFFICULTY_3_DEPRECATED | 16 | 0x10 | UNUSED, DO NOT REUSE |
SMART_EVENT_FLAG_ACTIONLIST_WAITS | 32 | 0x20 | Timed action list will wait for action from this event to finish before moving on to next action |
SMART_EVENT_FLAG_RESERVED_6 | 64 | 0x40 | |
SMART_EVENT_FLAG_DEBUG_ONLY | 128 | 0x80 | Event only occurs in debug build |
SMART_EVENT_FLAG_DONT_RESET | 256 | 0x100 | Event will not reset in SmartScript::OnReset() |
SMART_EVENT_FLAG_WHILE_CHARMED | 512 | 0x200 | Event occurs even if AI owner is charmed |
SMART_EVENT_FLAG_ACTIONLIST_WAITS 目前支持以下动作:
- SMART_ACTION_TALK
- SMART_ACTION_SIMPLE_TALK
- SMART_ACTION_CAST
- SMART_ACTION_SELF_CAST
- SMART_ACTION_INVOKER_CAST
- SMART_ACTION_MOVE_OFFSET
- SMART_ACTION_WP_START
- SMART_ACTION_MOVE_TO_POS
- SMART_ACTION_CROSS_CAST
- SMART_ACTION_ACTIVATE_TAXI
- SMART_ACTION_JUMP_TO_POS
- SMART_ACTION_START_CLOSEST_WAYPOINT
-
event_type
- 事件类型,即通过何种事件来触发相应动作
- 链接:event_type
-
action_type
- 动作类型,即触发的动作类型
- 链接:action_type
-
target_type
- 用于确定事件触发时指向的目标
- 链接:target_type