设置物品掉落

目录

creature_loot_template | gameobject_loot_template | item_loot_template:掉落表

reference_loot_template:掉落池

应用举例


creature_loot_template | gameobject_loot_template | item_loot_template 掉落表

creature_loot_template 用于设置生物(creature)的物品掉落
gameobject_loot_template 用于设置游戏对象(gameobject)的物品掉落
item_loot_template 用于设置除前两者之外的物品掉落(如箱子、袋子等)

  • Entry 物品(掉落池)掉落编号
    • creature_loot_template 为 creature 的 Entry 或 GUID
    • gameobject_loot_template 为gameobject 的 Entry 或 GUID
    • item_loot_template 为item 的 Entry,或 reference_loot_template 的 Entry
  • Item 物品编号
    • 6.0以前为 item_template.entry,6.0以后item数据封装到Item.db2中
    • 设置为掉落池时为 reference_loot_template.Entry
  • Reference 掉落池编号(10.2.7以前适用)
    • reference_loot_template 表读取掉落数据合并到当前的掉落列表
  • ItemType 掉落类型(11.0以后适用)
    • 0:Item
    • 1:Reference
    • 2:Currency
  • Chance 掉落几率(0-100)
    • 当 groupId = 0 时为当前物品掉落几率
    • 当 groupId>0 时为每组掉落组的掉落几率
    • 特别注意:此处 Chance = 0 时,无论掉落池内 Chance 字段设置为多少,当前物品(掉落池内物品)均无法掉落
  • QuestRequired
    • 字段值为 0 时表示非任务所需物品
    • 字段值为 1 时表示任务所需物品
    • 当设置为1时,未接到任务前,此任务物品不会掉落,只有在接到任务且该任务 quest_template.RequiredItemId[1-6] 字段(高版本为 quest_objectives.ObjectID 字段,quest_objectives.type=1)里包含该任务物品的编号,且已收集的物品数量比任务目标数量少时,掉落才会生效
  • LootMode 掉落模式,取值参考源码 SharedDefines.hLootModes 定义
LootModeMaskValueComment

LOOT_MODE_DEFAULT

0x11默认值
LOOT_MODE_HARD_MODE_10x22
LOOT_MODE_HARD_MODE_20x44
LOOT_MODE_HARD_MODE_30x88
LOOT_MODE_HARD_MODE_40x1016
LOOT_MODE_JUNK_FISH0x800032768
  • GroupId 掉落组
    • GroupId = 0 时,为独立掉落,GroupId>0时,为分组掉落
    • 分组掉落时,相同 GroupId 内所有 chance 加起来不能超过100,否则服务端红字报错
    • 服务端隐藏设定,一个对象掉落的物品最多不能超过16,超过部分不会掉落
  • MinCount 最小掉落数量

    • groupId = 0 时,为当前物品(掉落池)掉落的最小数量
    • groupId>0 时,为每组掉落组内物品掉落的最小数量
  • MaxCount 最大掉落数量

    • groupId = 0 时为当前物品(掉落池)掉落的最大数量
    • groupId>0 时为每组掉落组内物品掉落的最大数量

reference_loot_template 掉落池

  • Entry 掉落池编号
  • Reference 掉落池编号,可嵌套其他掉落池数据合并到当前的掉落池列表(10.2.7以前适用)
  • Chance 物品相对掉落池的掉落(0-100)
  • GroupId 掉落组
    • GroupId = 0时,为独立掉落,GroupId>0时,为分组掉落
    • 分组掉落时,相同 GroupId 内所有 chance 加起来不能超过100,否则服务端红字报错

应用举例

例1(11.0之前适用)

以艾索雷葛斯为例,其 creature_templete.entry = 6109,如想按以下设定掉落

  • 独立掉落1件任务物品,掉落几率为60%
  • 分组掉落:30%几率在两个紫色图纸中随机掉落1个紫色图纸,60%几率在6件紫色装备中随机掉落1-2件紫装,100%几率在6件蓝色装备中随机掉落1-2件蓝装
  • creature_loot_template 表设置:
  • ItemReferenceEntryChanceQuestRequiredLootModeGroupIdMinCountMaxCountComment
    18704061096011011任务物品
    3400434004610910001012蓝装
    340053400561096001012紫装
    340063400661093001011图纸
  • reference_loot_template 表设置:
  • EntryItemReferenceChanceQuestRequiredLootModeGroupIdMinCountMaxCountComment
    34004130000001111蓝装
    34004130010001111蓝装
    34004130020001111蓝装
    34004130040001111蓝装
    34004130060001111蓝装
    34004130070001111蓝装
    34005182020001111紫装
    34005182080001111紫装
    34005185410001111紫装
    34005185420001111紫装
    34005185450001111紫装
    34005185470001111紫装
    34006127170001111图纸
    34006127280001111图纸
例2(11.0之后适用)
  • 多个任务物品掉落
DELETE FROM `world`.`creature_loot_template` WHERE `Item` IN (59057,59058,59059,59060);
INSERT INTO `world`.`creature_loot_template` (`Entry`, `ItemType`, `Item`, `Chance`, `QuestRequired`, `LootMode`, `GroupId`, `MinCount`, `MaxCount`, `Comment`) VALUES 
(2521, 1, 59057, 100, 1, 1, 0, 1, 1, 'Skymane Gorilla - Quest 26605'),
(43417, 1, 59057, 100, 1, 1, 0, 1, 1, 'Skymane Bonobo - Quest 26605');
INSERT INTO `world`.`reference_loot_template` (`Entry`, `ItemType`, `Item`, `Chance`, `QuestRequired`, `LootMode`, `GroupId`, `MinCount`, `MaxCount`, `Comment`) VALUES 
(2521, 1, 59057, 80, 1, 1, 0, 1, 1, 'Skymane Gorilla - Quest 26605'),
(43417, 1, 59057, 80, 1, 1, 0, 1, 1, 'Skymane Bonobo - Quest 26605'),
(59057, 0, 59060, 0, 1, 1, 1, 1, 1, 'Reference Loot Quest 26605'),
(59057, 0, 59059, 0, 1, 1, 1, 1, 1, 'Reference Loot Quest 26605'),
(59057, 0, 59058, 0, 1, 1, 1, 1, 1, 'Reference Loot Quest 26605'),
(59057, 0, 59057, 0, 1, 1, 1, 1, 1, 'Reference Loot Quest 26605');
  • 多个物品掉落

下面是一个基本的Unity游戏背包丢弃物品物品掉落在地上的代码系统。请注意,这是一个非常基本的示例,你可能需要进行修改和优化以适应你的具体游戏需求。 ``` using UnityEngine; using System.Collections.Generic; public class Inventory : MonoBehaviour { public List<GameObject> items = new List<GameObject>(); // 存储物品的列表 public GameObject itemPrefab; // 物品的预制体 public void DropItem(int index) { // 检查物品索引是否有效 if (index < 0 || index >= items.Count) { Debug.LogError("Invalid item index"); return; } // 从列表中删除物品 GameObject item = items[index]; items.RemoveAt(index); // 创建一个新的物品实例,并将其放置在玩家位置上方一定高度处 Vector3 playerPos = transform.position; Vector3 dropPos = new Vector3(playerPos.x, playerPos.y + 1.0f, playerPos.z); GameObject dropItem = Instantiate(itemPrefab, dropPos, Quaternion.identity); // 将物品的模型设置为刚被删除的物品的模型,并添加一个附加物体以存储物品数据 dropItem.GetComponentInChildren<MeshFilter>().mesh = item.GetComponentInChildren<MeshFilter>().mesh; dropItem.GetComponentInChildren<MeshRenderer>().material = item.GetComponentInChildren<MeshRenderer>().material; dropItem.AddComponent<ItemData>().item = item.GetComponent<ItemData>().item; } } public class ItemData : MonoBehaviour { public Item item; // 物品数据 } public class Item : MonoBehaviour { public string itemName; // 物品名称 public int itemID; // 物品ID // 其他物品数据... } ``` 在这个代码示例中,`Inventory`类存储了一个包含物品的列表`items`,并提供了一个方法`DropItem()`来丢弃列表中的物品。当调用该方法时,它将从列表中删除指定索引处的物品,然后将其实例化为一个新的物体,将其放置在玩家位置上方一定高度处,并将物品模型和数据添加到新的物体上。 `ItemData`类是一个用于存储物品数据的附加物体。它包含一个名为`item`的公共变量,该变量存储了一个指向`Item`类的引用,`Item`类包含了有关物品的所有数据。 请注意,这个代码示例是非常基础的,你可能需要在其基础上进行扩展和优化以满足你的具体游戏需求。例如,你可能需要在物品上添加其他组件以实现交互或特殊效果,或者你可能需要在物品丢弃时产生不同的动画或声音效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值