游戏对象掉落模板表存储了游戏对象(如箱子、矿脉、草药等)被打开或采集时可能掉落的物品信息。这个表定义了物品的掉落几率、数量范围和掉落条件等属性。
gameobject_loot_template表的结构与其他掉落模板表(如creature_loot_template、reference_loot_template等)完全相同。
字段名 | 类型 | 属性 | 描述 |
---|---|---|---|
Entry | mediumint(8) unsigned | 主键,不为空,默认0 | 游戏对象模板ID,对应gameobject_template表中的entry字段 |
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) | 不为空,默认'' | 注释 |
不同类型的游戏对象有不同的掉落机制:
注意: 游戏对象的掉落ID通常在gameobject_template表的Data1字段中定义,而不是直接使用entry字段。
以下SQL语句将为一个宝箱(ID为2843)添加掉落物品:
INSERT INTO gameobject_loot_template (Entry, Item, Chance, MinCount, MaxCount, Comment)
VALUES
(2843, 2589, 80, 1, 3, '亚麻布'),
(2843, 2592, 60, 1, 2, '羊毛'),
(2843, 4306, 40, 1, 1, '丝绸'),
(2843, 11137, 5, 1, 1, '幻影之尘');
以下SQL语句将为铜矿脉(ID为1731)添加掉落物品:
INSERT INTO gameobject_loot_template (Entry, Item, Chance, MinCount, MaxCount, Comment)
VALUES
(1731, 2770, 100, 1, 4, '铜矿石'),
(1731, 2835, 10, 1, 1, '劣质石头');
以下SQL语句将为银叶草(ID为1617)添加掉落物品:
INSERT INTO gameobject_loot_template (Entry, Item, Chance, MinCount, MaxCount, Comment)
VALUES
(1617, 765, 100, 1, 3, '银叶草'),
(1617, 2449, 10, 1, 1, '地根草');
以下SQL语句将为一个钓鱼点(ID为4000)添加掉落物品:
INSERT INTO gameobject_loot_template (Entry, Item, Chance, GroupId, MinCount, MaxCount, Comment)
VALUES
(4000, 6289, 30, 1, 1, 1, '生鱼片'),
(4000, 6291, 30, 1, 1, 1, '生鲑鱼'),
(4000, 6308, 20, 1, 1, 1, '生鳟鱼'),
(4000, 6358, 10, 1, 1, 1, '黑口鱼'),
(4000, 6522, 5, 1, 1, 1, '魔尘');
以下SQL语句将为一个宝箱(ID为4500)添加引用掉落,引用ID为10001的掉落模板:
INSERT INTO gameobject_loot_template (Entry, Item, Reference, Chance, Comment)
VALUES (4500, 10001, 10001, 100, '宝箱 - 矿石掉落组');
以下SQL语句将为一个宝箱(ID为4600)添加一个任务物品掉落,只有有相关任务的玩家才能看到和拾取:
INSERT INTO gameobject_loot_template (Entry, Item, Chance, QuestRequired, MinCount, MaxCount, Comment)
VALUES (4600, 5797, 100, 1, 1, 1, '心灵之眼');
使用以下SQL语句查询特定游戏对象的掉落ID:
SELECT entry, name, type, Data1
FROM gameobject_template
WHERE entry = 游戏对象ID;
注意: 对于箱子(type=3),Data1字段通常包含掉落ID。
使用以下SQL语句查询特定物品在哪些游戏对象中掉落:
SELECT gl.Entry, gt.name, gl.Chance, gl.MinCount, gl.MaxCount
FROM gameobject_loot_template gl
JOIN gameobject_template gt ON gl.Entry = gt.Data1
WHERE gl.Item = 物品ID AND gt.type = 3;
不需要完全重启服务器,但需要重新加载掉落模板数据:
.reload all_loot
或者只重新加载游戏对象掉落模板:
.reload gameobject_loot_template
可能的原因包括:
使用GroupId字段将多个物品放在同一组中,同一组中只会掉落一个物品:
INSERT INTO gameobject_loot_template (Entry, Item, Chance, GroupId, MinCount, MaxCount)
VALUES
(5000, 1, 30, 1, 1, 1),
(5000, 2, 30, 1, 1, 1),
(5000, 3, 40, 1, 1, 1);
注意: 同一组中的物品掉落几率总和不需要等于100%。如果总和小于100%,则有可能不掉落任何物品。