表概述

script_waypoint表属于Script Creature waypoints系统,定义C++脚本中生物的移动路径。与waypoint_data不同,script_waypoint是面向脚本层面而非数据库AI的路径系统。

主键为 (entry, pointid),entry对应creature_template的entry,pointid从0开始递增。每个路径点包含3D坐标和等待时间(waittime)。

表结构

字段名数据类型默认值说明
entryINT UNSIGNED0生物模板entry(主键)
pointidINT UNSIGNED0路径点编号(主键,从0开始)
location_xFLOAT0路径点X坐标
location_yFLOAT0路径点Y坐标
location_zFLOAT0路径点Z坐标(高度)
waittimeINT UNSIGNED0到达后的等待时间(毫秒)
point_commentTEXTNULL路径点描述注释

重要字段详解

waittime (等待时间)

生物到达该路径点后停留的时间,单位毫秒。常见用法:

  • 0 - 不停留,立即走向下一点
  • 3000 - 停留3秒(如对话剧情场景)
  • 10000 - 停留10秒(如守卫巡逻间歇)
与waypoint_data的区别

script_waypoint用于C++脚本控制的剧情NPC(如护送任务NPC),waypoint_data用于数据库AI控制的常规巡逻生物。script_waypoint的最后一个点通常触发脚本结束或循环逻辑。

实战案例

创建一条3个点的巡逻路径
INSERT INTO script_waypoint (entry, pointid, location_x, location_y, location_z, waittime, point_comment)
VALUES
(12000, 0, -8900.5,  -150.2,  80.0, 2000,  '起点-村口'),
(12000, 1, -8950.0,  -200.0,  80.0, 5000,  '中点-广场(停留5秒)'),
(12000, 2, -8800.0,  -250.0,  80.0, 0,     '终点-哨塔');
查询某个生物的全路径
SELECT pointid, location_x, location_y, location_z, waittime, point_comment
FROM script_waypoint
WHERE entry = 12000
ORDER BY pointid;

常见问题

Q: pointid必须连续吗?

A: 是的,pointid从0开始必须连续递增。如果中间缺少某个编号,C++脚本按pointid顺序读取时会中断移动(除非脚本有跳过逻辑)。

Q: 使用script_waypoint需要改C++代码吗?

A: 需要。C++脚本中必须明确调用script_waypoint的加载和移动逻辑。仅在表中添加数据不会自动生效,必须有对应的C++脚本实现。