引用掉落模板表存储了可重用的掉落组,这些掉落组可以被其他掉落模板表引用。这种机制允许多个不同的生物、游戏对象或其他实体共享相同的掉落组,从而简化掉落系统的管理。
reference_loot_template表的结构与其他掉落模板表(如creature_loot_template、gameobject_loot_template等)完全相同。
字段名 | 类型 | 属性 | 描述 |
---|---|---|---|
Entry | mediumint(8) unsigned | 主键,不为空,默认0 | 引用ID,通常从10000开始 |
Item | mediumint(8) unsigned | 主键,不为空,默认0 | 物品ID,对应item_template表中的entry字段 |
Reference | mediumint(8) unsigned | 不为空,默认0 | 引用ID,如果不为0,则引用另一个掉落模板 |
Chance | float | 不为空,默认100 | 掉落几率(百分比) |
QuestRequired | tinyint(1) unsigned | 不为空,默认0 | 是否需要任务(0=否,1=是) |
LootMode | smallint(5) unsigned | 不为空,默认1 | 掉落模式 |
GroupId | tinyint(3) unsigned | 不为空,默认0 | 组ID,同一组中只会掉落一个物品 |
MinCount | tinyint(3) unsigned | 不为空,默认1 | 最小数量 |
MaxCount | tinyint(3) unsigned | 不为空,默认1 | 最大数量 |
Comment | varchar(255) | 不为空,默认'' | 注释 |
引用掉落系统是一种强大的机制,允许创建可重用的掉落组。以下是其工作原理:
注意: 引用掉落可以嵌套,即一个reference_loot_template条目可以引用另一个reference_loot_template条目,但要避免循环引用。
以下SQL语句将创建一个ID为10001的矿石掉落组:
INSERT INTO reference_loot_template (Entry, Item, Chance, MinCount, MaxCount, Comment)
VALUES
(10001, 2770, 40, 1, 3, '铜矿石'),
(10001, 2771, 30, 1, 2, '锡矿石'),
(10001, 2772, 20, 1, 2, '铁矿石'),
(10001, 7912, 10, 1, 1, '纯银矿石');
以下SQL语句将为石元素(92)添加矿石掉落组的引用:
INSERT INTO creature_loot_template (Entry, Item, Reference, Chance, Comment)
VALUES (92, 10001, 10001, 75, '石元素 - 矿石掉落组');
注意: Item和Reference字段设置为相同的值,表示这是一个引用条目。Chance值75表示有75%的几率从矿石掉落组中选择物品。
以下SQL语句将创建几个不同等级的装备掉落组:
-- 低级绿色装备组
INSERT INTO reference_loot_template (Entry, Item, Chance, GroupId, Comment)
VALUES
(10100, 2264, 20, 1, '低级绿色武器 - 冰霜之刃'),
(10100, 2265, 20, 1, '低级绿色武器 - 致命的青铜短剑'),
(10100, 2266, 20, 1, '低级绿色武器 - 屠夫的利刃');
-- 中级绿色装备组
INSERT INTO reference_loot_template (Entry, Item, Chance, GroupId, Comment)
VALUES
(10101, 3577, 20, 1, '中级绿色武器 - 金色战斧'),
(10101, 3578, 20, 1, '中级绿色武器 - 雷霆之锤'),
(10101, 3579, 20, 1, '中级绿色武器 - 夜刃');
以下SQL语句将创建一个引用其他掉落组的主掉落组:
-- 主掉落组,引用其他掉落组
INSERT INTO reference_loot_template (Entry, Item, Reference, Chance, Comment)
VALUES
(10200, 10100, 10100, 60, '引用低级绿色装备组'),
(10200, 10101, 10101, 40, '引用中级绿色装备组');
以下SQL语句将为一个BOSS添加嵌套引用掉落:
INSERT INTO creature_loot_template (Entry, Item, Reference, Chance, Comment)
VALUES (1836, 10200, 10200, 100, 'BOSS - 装备掉落组');
注意: 这个BOSS有100%的几率触发10200引用组,而10200引用组会进一步引用10100或10101组,从而实现复杂的掉落逻辑。
使用以下SQL语句查询特定物品在哪些引用组中:
SELECT Entry, Item, Chance, GroupId, MinCount, MaxCount, Comment
FROM reference_loot_template
WHERE Item = 物品ID;
使用以下SQL语句查询使用特定引用组的生物:
SELECT c.Entry, c.Item, c.Reference, c.Chance, ct.name
FROM creature_loot_template c
JOIN creature_template ct ON c.Entry = ct.entry
WHERE c.Reference = 引用ID;
类似地,可以查询使用特定引用组的游戏对象:
SELECT g.Entry, g.Item, g.Reference, g.Chance, gt.name
FROM gameobject_loot_template g
JOIN gameobject_template gt ON g.Entry = gt.entry
WHERE g.Reference = 引用ID;
不需要完全重启服务器,但需要重新加载掉落模板数据:
.reload all_loot
或者只重新加载特定的掉落模板:
.reload reference_loot_template
循环引用会导致服务器崩溃或无限循环。为避免循环引用,请遵循以下原则: