可以制作类似果实的宝石 / 物品:玩家使用(右键)后获得额外的 Level Up Points(未分配点数)。每个角色通过该系统获得的总点数受 MaxRewardPoint 限制。
要求
- 已购买
PluginPlus功能,且Data\Plugin\Plugin.ini中有PluginPlus = 1(见 PluginPlus)。 Data\Plugin\ConsumeItem.xml中Enabled="1"。- 物品必须存在于
Data\Item\ItemList.xml以及客户端的物品列表中。已有两个示例物品 19,200 "Consume Item 1" 和 19,201 "Consume Item 2"。
工作方式
- 玩家使用列在
<Item>列表中的物品。 - 如果
(已获得的总点数 + RewardPoints) > MaxRewardPoint:物品不会被消耗,玩家收到上限提示(LangConsumeItemID 1)。 - 否则:把
RewardPoints加到未分配点数中,保存已获得的总点数,重新发送属性,提示成功(Lang ID 0),并扣除 1 个物品。
已获得的总点数按角色保存在数据库表 chr_consume_item(列 Guid、Points)中。Lua 函数 Player.GetConsumePoint(aIndex) 返回该总数,使重置属性的脚本可以退还已使用的点数。
配置
文件:Data\Plugin\ConsumeItem.xml。根元素 <ConsumeItemSystem>:
| 键 | 值 | 默认值 | 含义 |
|---|---|---|---|
Enabled | 0 / 1 | 0(缺少该属性时) | 0 = 关闭系统,1 = 开启。 |
MaxRewardPoint | 整数 | 1000000(缺少该属性时;示例文件设为 1000) | 一个角色从本文件中所有物品获得的最大总点数。 |
UseSuccessMsg, UseFailMessage | 字符串 | - | 仅为保持文件兼容,GameServer 不读取。实际内容取自 Lang。 |
每个子元素 <Item>:
| 键 | 值 | 默认值 | 含义 |
|---|---|---|---|
Cat | 0 - 127 | -1(该行被忽略) | 物品组。超出 0-127 范围则该行被忽略。 |
Index | 0 - 511 | -1(该行被忽略) | 物品在组内的序号。超出 0-511 范围则该行被忽略。 |
RewardPoints | 整数 | 0 | 每使用 1 个物品获得的 Level Up Points 点数。 |
不得在 XML 标签内部写
<!-- --> 注释(与文件中的警告行保持一致)。示例
<ConsumeItemSystem Enabled="1" MaxRewardPoint="1000" UseSuccessMsg="You received %d Level Up Points" UseFailMessage="Max points exceeds upper limit %d">
<Item Cat="19" Index="200" RewardPoints="40" />
<Item Cat="19" Index="201" RewardPoints="59" />
</ConsumeItemSystem>
提示信息(Lang)
Data\Lang 文件中的 <ConsumeItem> 段:
| ID | 内容(英文版) | 何时出现 |
|---|---|---|
| 0 | You received %d Level Up Points | 使用成功,%d = 获得的点数。 |
| 1 | Max points exceeds upper limit %d | 超出上限,%d = MaxRewardPoint。 |
重新加载
修改 ConsumeItem.xml 或 Lang 之后,点击 GameServer 控制面板上的 Reload plugin。