|
|
@@ -15,6 +15,8 @@ local MailExcel = require("excel.mail")
|
|
|
local HeroLogic = require("hero.HeroLogic")
|
|
|
local TriggerDefine = require("trigger.TriggerDefine")
|
|
|
local TriggerLogic = require("trigger.TriggerLogic")
|
|
|
+local effectCfg = require("excel.equip").texiao
|
|
|
+local HeroDefine = require("hero.HeroDefine")
|
|
|
|
|
|
EQUIP_BAG_MAX_CNT = 500
|
|
|
EQUIP_BAG_OP_ADD = 1 -- 增
|
|
|
@@ -27,6 +29,9 @@ EQUIP_QUALITY_WEIGHT = 10000
|
|
|
EQUIP_QUALITY_BASE_RATE = { 7000, 8000, 9000, 10000, 12000 }
|
|
|
|
|
|
|
|
|
+local EQUIP_HEROEXCLUSIVE_WEIGHT = 4000 --戒指、护符随机出英雄专属属性权重
|
|
|
+local EQUIP_NO_HEROEXCLUSIVE_WEIGHT = 6000 --戒指、护符随不出英雄专属属性权重
|
|
|
+
|
|
|
-- 转换装备洗练数据格式
|
|
|
function AttrHashToArray(attrData)
|
|
|
local _, attrInfo = next(attrData)
|
|
|
@@ -147,6 +152,122 @@ local function randAttrArray(randomAttrCfg, equipColor)
|
|
|
return attr
|
|
|
end
|
|
|
|
|
|
+---------------------------------------------------------戒指、护符随机特效---------------------------------------------------
|
|
|
+
|
|
|
+local function generateRandData(excludeTypeList)
|
|
|
+ local totalWeight = 0
|
|
|
+ local type2List = {}
|
|
|
+
|
|
|
+ for k,v in ipairs(effectCfg) do
|
|
|
+ local tp = v.type
|
|
|
+ if not excludeTypeList or not excludeTypeList[tp] then
|
|
|
+ local weight = v.weight
|
|
|
+ type2List[tp] = type2List[tp] or {weight = 0, typeList = {}}
|
|
|
+ type2List[tp].weight = type2List[tp].weight + weight
|
|
|
+ table.insert(type2List[tp].typeList, {id = k, weight = weight})
|
|
|
+ totalWeight = totalWeight + weight
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ local len = 0
|
|
|
+ local randList = {}
|
|
|
+ for _, tpData in pairs(type2List) do
|
|
|
+ len = len + 1
|
|
|
+ randList[len] = tpData
|
|
|
+ end
|
|
|
+
|
|
|
+ return totalWeight, randList
|
|
|
+end
|
|
|
+
|
|
|
+local function getIndexByRand(totalWeight, randList)
|
|
|
+ local tpList
|
|
|
+ local weight = 0
|
|
|
+ local randWeight = math.random(0, totalWeight)
|
|
|
+ for _,v in ipairs(randList) do
|
|
|
+ weight = weight + v.weight
|
|
|
+ if randWeight <= weight then
|
|
|
+ tpList = v
|
|
|
+ break
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ weight = 0
|
|
|
+ randWeight = math.random(0, tpList.weight)
|
|
|
+ for _,v in ipairs(tpList.typeList) do
|
|
|
+ weight = weight + v.weight
|
|
|
+ if randWeight <= weight then
|
|
|
+ return v.id
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+-- 随机出戒指、护符的特效
|
|
|
+local function randEffectAttrList(equipId)
|
|
|
+ local equipCfg = EquipExcel[equipId]
|
|
|
+
|
|
|
+ if equipCfg.subType ~= ItemDefine.EQUIP_SUBTYPE_RING and equipCfg.subType ~= ItemDefine.EQUIP_SUBTYPE_AMULET then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local excludeTypeList
|
|
|
+ local noEffectTimes = 0
|
|
|
+ local effectList = {}
|
|
|
+ for i=1, 3 do
|
|
|
+ local totalWeight, randList = generateRandData(excludeTypeList)
|
|
|
+ local effctId = getIndexByRand(totalWeight, randList)
|
|
|
+
|
|
|
+ if effctId == 1 then
|
|
|
+ noEffectTimes = noEffectTimes + 1
|
|
|
+ else
|
|
|
+ effectList[effctId] = 1
|
|
|
+ excludeTypeList = excludeTypeList or {}
|
|
|
+
|
|
|
+ local excludeType = effectCfg[effctId].type
|
|
|
+ excludeTypeList[excludeType] = 1
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 保底要有一条特效
|
|
|
+ if noEffectTimes >= 2 then
|
|
|
+ excludeTypeList = excludeTypeList or {}
|
|
|
+ local excludeType = effectCfg[1].type
|
|
|
+ excludeTypeList[excludeType] = 1
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ return effectList
|
|
|
+end
|
|
|
+
|
|
|
+--------------------------------------------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+---------------------------------------------------------戒指、护符随机英雄专属---------------------------------------------------
|
|
|
+
|
|
|
+
|
|
|
+local function randHeroExclusive(equipId)
|
|
|
+ local equipCfg = EquipExcel[equipId]
|
|
|
+
|
|
|
+ if equipCfg.subType ~= ItemDefine.EQUIP_SUBTYPE_RING and equipCfg.subType ~= ItemDefine.EQUIP_SUBTYPE_AMULET then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local randWeight = math.random(0, (EQUIP_HEROEXCLUSIVE_WEIGHT + EQUIP_NO_HEROEXCLUSIVE_WEIGHT))
|
|
|
+ if randWeight > EQUIP_HEROEXCLUSIVE_WEIGHT then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local heroList = HeroDefine.GetAllHighQualityHero()
|
|
|
+ local len = #heroList
|
|
|
+ if len <= 0 then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local idx = math.random(1, len)
|
|
|
+ return heroList[idx]
|
|
|
+end
|
|
|
+
|
|
|
+--------------------------------------------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
|
|
|
|
|
|
-- 随机属性
|
|
|
@@ -285,15 +406,20 @@ function getEquipMaxQuality(equipConfig)
|
|
|
return maxQuality
|
|
|
end
|
|
|
|
|
|
--- 获取装备附加属性
|
|
|
+-- 获取装备洗练属性
|
|
|
function getEquipTzAttr(equipConfig)
|
|
|
- -- if not equipConfig.randomAttr then return end
|
|
|
- -- if equipConfig.random == 1 then
|
|
|
- -- return equipConfig.randomAttr
|
|
|
+ if not equipConfig.randomAttr then return end
|
|
|
+ if equipConfig.random == 1 then
|
|
|
+ return equipConfig.randomAttr
|
|
|
+ end
|
|
|
+ -- local quality
|
|
|
+ -- if equipConfig.subType == ItemDefine.EQUIP_SUBTYPE_RING or equipConfig.subType == ItemDefine.EQUIP_SUBTYPE_AMULET then
|
|
|
+ -- quality = equipConfig.quality
|
|
|
-- end
|
|
|
- local attr = randAttrArray(Util.copyTable(equipConfig.randomAttr))
|
|
|
|
|
|
- return attr
|
|
|
+ -- local attr = randAttrArray(Util.copyTable(equipConfig.randomAttr), quality)
|
|
|
+
|
|
|
+ -- return attr
|
|
|
end
|
|
|
|
|
|
-- 返回装备背包空余格子数
|
|
|
@@ -423,26 +549,45 @@ end
|
|
|
|
|
|
-- 制造一个装备
|
|
|
function makeEquip(itemID, otherData)
|
|
|
- local equipGrid = EquipLogicGrid.createGrid(itemID)
|
|
|
- if not equipGrid then return end
|
|
|
-
|
|
|
- -- 随机属性
|
|
|
- local attr, quality = randomAttr(itemID, nil, otherData)
|
|
|
- equipGrid.attr = attr
|
|
|
- equipGrid.quality = quality
|
|
|
- checkAttr(equipGrid)
|
|
|
- return equipGrid
|
|
|
+ local equipGrid = EquipLogicGrid.createGrid(itemID)
|
|
|
+ if not equipGrid then return end
|
|
|
+
|
|
|
+ local bl = false
|
|
|
+ local equipCfg = EquipExcel[equipGrid.id]
|
|
|
+ if equipCfg.subType == ItemDefine.EQUIP_SUBTYPE_RING or equipCfg.subType == ItemDefine.EQUIP_SUBTYPE_AMULET then
|
|
|
+ otherData = equipCfg.quality
|
|
|
+ bl = true
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 随机洗练属性
|
|
|
+ local attr, quality = randomAttr(itemID, nil, otherData)
|
|
|
+ equipGrid.attr = attr
|
|
|
+
|
|
|
+
|
|
|
+ if not bl then
|
|
|
+ equipGrid.quality = quality
|
|
|
+ else
|
|
|
+ -- 装备特效
|
|
|
+ equipGrid.effectList = randEffectAttrList(itemID)
|
|
|
+
|
|
|
+ -- 英雄专属
|
|
|
+ equipGrid.exclusiveHeroId = randHeroExclusive(itemID)
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ checkAttr(equipGrid)
|
|
|
+ return equipGrid
|
|
|
end
|
|
|
|
|
|
-- 添加装备
|
|
|
function addEquip(human, itemID, itemCnt, logType, otherData)
|
|
|
if not EquipExcel[itemID] then return end
|
|
|
-
|
|
|
+
|
|
|
for i = 1, itemCnt do
|
|
|
local equipGrid = makeEquip(itemID, otherData)
|
|
|
if equipGrid then
|
|
|
- addByEquipGrid(human, equipGrid, logType)
|
|
|
- TriggerLogic.PublishEvent(TriggerDefine.EQUIP_GETQUALITY, human.db._id, equipGrid.quality, 1)
|
|
|
+ addByEquipGrid(human, equipGrid, logType)
|
|
|
+ TriggerLogic.PublishEvent(TriggerDefine.EQUIP_GETQUALITY, human.db._id, equipGrid.quality, 1)
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
@@ -485,7 +630,7 @@ function delEquip(human, index, logType, sendNotify)
|
|
|
human.db.equipBag[index] = nil
|
|
|
|
|
|
if not sendNotify then
|
|
|
- sendEquipChange(human, index, nil, EQUIP_BAG_OP_DEL)
|
|
|
+ sendEquipChange(human, index, nil, EQUIP_BAG_OP_DEL)
|
|
|
end
|
|
|
end
|
|
|
|