| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719 |
- EquipFunc = {}
- local filename = "EquipFunc"
- function EquipFunc.getEquipIsSpecial(cfgId)
- local isSpecial = ConfigDataManager.getTableValue("cfg_item", "isSpecial", "id", cfgId)
- isSpecial = tonumber(isSpecial) or 0
- return isSpecial == 1
- end
- -- 获取装备等级(道具表字段 只参与价值计算)
- function EquipFunc.getItemCalculatelevel(actor, itemId)
- local equipInfo = getequipinfo(actor, itemId, 1)
- local cfgId = equipInfo.cfgid
- local Calculatelevel = ConfigDataManager.getTableValue("cfg_item", "calculatelevel", "id", cfgId)
- return tonumber(Calculatelevel) or 0
- end
- -- 获取装备强化等级
- function EquipFunc.getEquipStrengthLevel(actor, itemId)
- return API.GetItemData(actor, itemId, "strengthlv") or 0
- end
- -- 获取全身装备强化等级
- function EquipFunc.GetAllStrengthLevel(actor)
- local allEquip = getallequipinfo(actor)
- local allStrengthLevel = 0
- for i, v in pairs(allEquip) do
- allStrengthLevel = allStrengthLevel + EquipFunc.getEquipStrengthLevel(actor, v.id)
- end
- return allStrengthLevel
- end
- -- 获取装备强化类型 1=武器类型 2=防具和翅膀首饰除外 3盾牌
- function EquipFunc.getEquipStrengthType(actor, itemId)
- local equipType = 0
- local equipInfo = getequipinfo(actor, itemId, 1)
- local cfgId = equipInfo.cfgid
- local itemData = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1]
- local mainType = tonumber(itemData.type)
- local subType = tonumber(itemData.subtype)
- local name = itemData.name
- if mainType == 2 then
- if subType == 1 or subType == 2 or subType == 3 then
- equipType = 1
- if string.find(name, "盾") ~= nil then
- equipType = 3
- end
- elseif subType == 4 or subType == 5 or subType == 6 or subType == 7 or subType == 8 or subType == 9 then
- equipType = 2
- elseif subType == 10001 then
- equipType = 4
- elseif subType == 10002 then
- equipType = 5
- end
- end
- return equipType
- end
- -- 获取装备Power
- function EquipFunc.getEquipPower(actor, itemId)
- local equipInfo = getequipinfo(actor, itemId, 1)
- local cfgId = equipInfo.cfgid
- local Power = ConfigDataManager.getTableValue("cfg_item", "Power", "id", cfgId) or 0
- return Power
- end
- -- 整合所有强化属性
- function EquipFunc.getEquipAllStrengthAttr(actor, itemId)
- local tAttr = {}
- local tBaseAttr = EquipFunc.getEquipStrengthBaseAttr(actor, itemId) -- 获取装备强化基础属性
- if next(tBaseAttr) then
- table.concatTable(tAttr, tBaseAttr)
- end
- local tStrengthAttr = EquipFunc.getEquipStrengthAttr(actor, itemId) -- 获取装备强化属性
- if next(tStrengthAttr) then
- table.concatTable(tAttr, tStrengthAttr)
- end
- return tAttr
- end
- -- 获取装备强化基础属性
- function EquipFunc.getEquipStrengthBaseAttr(actor, itemId)
- local lv = EquipFunc.getEquipStrengthLevel(actor, itemId)
- local tAttr = {}
- local equipInfo = getequipinfo(actor, itemId, 1)
- local basicattr = equipInfo.basicattr
- local equipType = EquipFunc.getEquipStrengthType(actor, itemId)
- for i = 1, #basicattr do
- local attId = basicattr[i].attrid
- local val = basicattr[i].value
- if equipType == 1 then
- if attId == 200011 or attId == 200021 then -- 最小/最大 攻击/魔法
- local val1 = lv * 3
- if lv > 9 then
- val1 = val1 + (lv - 9) * (lv - 8) / 2
- end
- table.insert(tAttr, {attId, val1})
- end
- elseif equipType == 2 then
- if attId == 206011 then -- 防御
- local val1 = lv * 3
- if lv > 9 then
- val1 = val1 + (lv - 9) * (lv - 8) / 2
- end
- table.insert(tAttr, {attId, val1})
- end
- elseif equipType == 3 then
- if attId == 206011 then -- 防御
- local val1 = lv
- table.insert(tAttr, {attId, val1})
- end
- if attId == 211011 then -- 防御率
- local val1 = lv * 3
- if lv > 9 then
- val1 = val1 + (lv - 9) * (lv - 8) / 2
- end
- table.insert(tAttr, {attId, val1})
- end
- elseif equipType == 4 then
- table.insert(tAttr, {attId, val})
- elseif equipType == 5 then
- local val1 = lv * 3
- if lv > 9 then
- val1 = val1 + (lv - 9) * (lv - 8) / 2
- end
- table.insert(tAttr, {attId, val + val1})
- end
- end
- return tAttr
- end
- function EquipFunc.getEquipStrengthWearAddAttr(actor, itemId)
- local equipInfo = getequipinfo(actor, itemId, 1)
- local lv = EquipFunc.getEquipStrengthLevel(actor, itemId)
- local curAttr = EquipFunc.getEquipStrengthAllAttr(equipInfo, lv)
- local baseAttr = EquipFunc.getEquipStrengthAllAttr(equipInfo, 0)
- for index, value in ipairs(curAttr) do
- local k, v = table.findByCondi(baseAttr, function(a)
- return a[1] == value[1];
- end)
- if k ~= nil then
- value[2] = value[2] - v[2]
- end
- end
- local realAttr = {}
- for index, value in ipairs(curAttr) do
- realAttr[tostring(value[1])] = tostring(value[2])
- end
- return realAttr;
- end
- -- 获取装备强化属性
- function EquipFunc.getEquipStrengthAttr(actor, itemId)
- local lv = EquipFunc.getEquipStrengthLevel(actor, itemId)
- local equipInfo = getequipinfo(actor, itemId, 1)
- return EquipFunc.getEquipStrengthAllAttr(equipInfo, lv)
- end
- function EquipFunc.getEquipStrengthAllAttr(equipInfo, lv)
- local basicattr = equipInfo.basicattr
- local tAttr = {}
- local tAttId1 = {
- [202021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [202011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [201011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [201021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [206011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [205051] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [202041] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [201041] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [200043] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [311012] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
- [313012] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
- [100017] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
- [100018] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
- [202052] = {350, 350, 350, 350, 350, 350, 350, 350, 350, 400, 400, 500, 600, 600, 600},
- [205052] = {350, 350, 350, 350, 350, 350, 350, 350, 350, 400, 400, 500, 600, 600, 600},
- [304012] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}
- }
- local tAttId2 = {
- [202021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [202011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [201011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [201021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [206011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [205051] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [202041] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [201041] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [200043] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- [311012] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100},
- [313012] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100},
- [100017] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100},
- [100018] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
- [202052] = {350, 350, 350, 350, 350, 350, 350, 350, 350, 400, 400, 500, 600, 600, 600},
- [205052] = {350, 350, 350, 350, 350, 350, 350, 350, 350, 400, 400, 500, 600, 600, 600},
- [304012] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}
- }
- local sequips = {
- [21320011] = tAttId2,
- [21320011] = tAttId2,
- [21320021] = tAttId2,
- [21320031] = tAttId2,
- [21320041] = tAttId2,
- [21320051] = tAttId2,
- }
- local tAttId = sequips[equipInfo.cfgid] ~= nil and sequips[equipInfo.cfgid] or tAttId1
- for i = 1, #basicattr do
- local attId = basicattr[i].attrid
- local val = basicattr[i].value
- local values = tAttId[attId];
- if values then
- local val1 = 0
- for index, value in ipairs(values) do
- if index > lv then
- break
- end
- val1 = val1 + values[index]
- end
- val1 = math.floor(val1)
- -- if lv <= 9 then
- -- val1 = math.floor(lv * 3)
- -- -- if isZhuoYue then
- -- -- val1 = math.floor(Power + (25*Power/itemLevel+5)) / 2 + lv * 3.5
- -- -- else
- -- -- val1 = math.floor(Power + 0) / 2 + lv * 3.5
- -- -- end
- -- else
- -- local num = lv - 9
- -- local beginVal = 4;
- -- local endVal = 4 + num - 1
- -- val1 = math.floor(9 * 3) + (beginVal + endVal) * num / 2
- -- -- if isZhuoYue then
- -- -- val1 = math.floor(Power + (25*Power/itemLevel+5)) / 2 + lv * 3.5 + (lv-9) * (lv-8)/2
- -- -- else
- -- -- val1 = math.floor(Power + 0) / 2 + lv * 3.5 /2
- -- -- end
- -- end
- table.insert(tAttr, {attId, val + val1})
- end
- end
- return tAttr
- end
- -- 获取装备强化佩戴条件
- function EquipFunc.getEquipStrengthNeed(actor, itemId)
- local item = getequipinfo(actor, itemId, 1)
- local cfgId = item.cfgid
- local lv = EquipFunc.getEquipStrengthLevel(actor, itemId)
- local tAttr = {}
- local itemLevel = EquipFunc.getItemCalculatelevel(actor, itemId)
- local isZhuoYue = EquipFunc.IsZhuoYueEquip(cfgId)
- local tNeedAtt = {
- [10001] = 1,
- [10002] = 1,
- [10003] = 1,
- [10004] = 1,
- [10005] = 1
- }
- local itemData = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1]
- local useAttLimit = ConfigDataManager.getTableValue("cfg_equip_entryLib", "useAttLimit", "id", cfgId) or {}
- useAttLimit = string.getAttrByStr(useAttLimit) -- string.split(useAttLimit,"#")
- for attId, _ in pairs(useAttLimit) do
- local need = 0
- attId = tonumber(attId)
- if attId == 10001 then
- need = itemData.qianghuall
- elseif attId == 10002 then
- need = itemData.qianghuamj
- elseif attId == 10003 then
- need = itemData.qianghuazl
- elseif attId == 10004 then
- need = itemData.qianghuatl
- elseif attId == 10005 then
- need = itemData.qianghuallts
- end
- need = tonumber(need)
- need = need or 0
- if tNeedAtt[attId] then
- if isZhuoYue then
- need = math.floor(3 * (3 * lv + itemLevel + 25) * (need / 100) + 20)
- else
- need = math.floor(3 * (3 * lv + itemLevel) * (need / 100) + 20)
- end
- end
- need = math.floor(need)
- table.insert(tAttr, {attId, need})
- end
- return tAttr
- end
- -- 每日最大回收次数
- function EquipFunc.getMaxHuiShouNum(actor)
- return 600
- end
- -- 是否是卓越装备
- function EquipFunc.IsZhuoYueEquip(cfgId)
- local Outstanding = ConfigDataManager.getTableValue("cfg_item", "Outstanding", "id", cfgId) or 0
- return Outstanding == "1" or Outstanding == "2" or Outstanding == "3", tonumber(Outstanding)
- end
- -- 获取卓越属性数量
- function EquipFunc.getZhuoYueEquipNum(actor, itemId)
- local tZhuoYueAttIndex = API.GetItemData(actor, itemId, "tZhuoYueAttIndex") or {}
- return table.count(tZhuoYueAttIndex)
- end
- -- 获取装备追加等级
- function EquipFunc.getEquipAppendLevel(actor, itemId)
- return API.GetItemData(actor, itemId, "appendlv") or 0
- end
- -- 获取全身装备追加等级
- function EquipFunc.GetAllAppendLevel(actor)
- local allEquip = getallequipinfo(actor)
- local allAppendLevel = 0
- for i, v in pairs(allEquip) do
- allAppendLevel = allAppendLevel + EquipFunc.getEquipAppendLevel(actor, v.id)
- end
- return allAppendLevel
- end
- -- 获取装备是否激活幸运
- function EquipFunc.getEquipIsXingYun(actor, itemId)
- return API.GetItemData(actor, itemId, "IsLuck") == 1
- end
- function EquipFunc.GetEquipIsLuck(item)
- local IsLuck = false
- if item and item.entries ~= nil then
- for index, value in ipairs(item.entries) do
- if value.attrid == 900 then
- IsLuck = true
- break
- end
- end
- end
- return IsLuck
- end
- -- 获取装备是否激活技能
- function EquipFunc.getEquipIsSkill(actor, itemId)
- return API.GetItemData(actor, itemId, "skillName") or nil
- end
- -- 获取装备价值
- function EquipFunc.getEquipJiaZhi(actor, itemId)
- -- 强化系数
- local tQiangHuaXiShu = {
- [5] = 4,
- [6] = 10,
- [7] = 25,
- [8] = 45,
- [9] = 65,
- [10] = 95,
- [11] = 135,
- [12] = 185,
- [13] = 245,
- [14] = 305,
- [15] = 365
- }
- local equipInfo = getequipinfo(actor, itemId, 1)
- local cfgId = equipInfo.cfgid
- local name = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
- if name == "祝福宝石" then
- return 60000
- elseif name == "灵魂宝石" then
- return 20000
- elseif name == "玛雅之石" then
- return 40000
- elseif name == "创造宝石" then
- return 450000
- elseif name == "生命宝石" then
- return 450000
- elseif name == "合成幸运符" then
- return 200000
- end
- local type = ConfigDataManager.getTableValue("cfg_item", "type", "id", cfgId)
- type = tonumber(type)
- if not type or type ~= 2 then
- return 0
- end
- -- local value = ConfigDataManager.getTableValue("cfg_item", "value", "id", cfgId)
- -- value = tonumber(value)
- -- if value and value > 0 then
- -- return value
- -- end
- -- 装备等级(道具表字段 只参与价值计算)
- local level = EquipFunc.getItemCalculatelevel(actor, itemId)
- -- 强化等级
- local strengthLevel = EquipFunc.getEquipStrengthLevel(actor, itemId)
- -- 装备系数
- local equipXiShu = level + strengthLevel * 3
- if tQiangHuaXiShu[strengthLevel] then
- equipXiShu = equipXiShu + tQiangHuaXiShu[strengthLevel]
- end
- -- 装备价值
- local equipCost = 0
- local tmpXiShu = equipXiShu
- -- 是否是卓越装备
- if EquipFunc.IsZhuoYueEquip(cfgId) then
- tmpXiShu = equipXiShu + 25
- end
- equipCost = math.ceil(((tmpXiShu + 40) * tmpXiShu * tmpXiShu / 8 + 100) / 100) * 100
- -- local mainType = ConfigDataManager.getTableValue("cfg_item", "type", "id", cfgId)
- local subType = ConfigDataManager.getTableValue("cfg_item", "subType", "id", cfgId)
- -- 翅膀
- if subType == 13 then
- equipCost = math.ceil((equipXiShu + 40) * equipXiShu * equipXiShu * 11) + 40000000
- end
- -- 单手武器衰减
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strPart", "id", cfgId)
- if strPart == 1 or strPart == 2 then
- equipCost = equipCost * 80 / 100
- end
- ---装备价值不能超出
- if equipCost > 3000000000 then
- equipCost = 3000000000
- end
- return math.floor(equipCost)
- end
- -- 获取合成时装备价值
- function EquipFunc.getEquipSynValue(actor, itemId)
- -- 强化系数
- local tQiangHuaXiShu = {
- [4] = 40,
- [5] = 45,
- [6] = 55,
- [7] = 65,
- [8] = 75,
- [9] = 85,
- [10] = 95,
- [11] = 135,
- [12] = 185,
- [13] = 245,
- [14] = 305,
- [15] = 365
- }
- local equipInfo = getequipinfo(actor, itemId, 1)
- local cfgId = equipInfo.cfgid
- local name = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
- if name == "祝福宝石" then
- return 60000
- elseif name == "灵魂宝石" then
- return 20000
- elseif name == "玛雅之石" then
- return 40000
- elseif name == "创造宝石" then
- return 450000
- elseif name == "生命宝石" then
- return 450000
- elseif name == "合成幸运符" then
- return 200000
- end
- local type = ConfigDataManager.getTableValue("cfg_item", "type", "id", cfgId)
- type = tonumber(type)
- if not type or type ~= 2 then
- return 0
- end
- -- local value = ConfigDataManager.getTableValue("cfg_item", "value", "id", cfgId)
- -- value = tonumber(value)
- -- if value and value > 0 then
- -- return value
- -- end
- -- 装备等级(道具表字段 只参与价值计算)
- local level = EquipFunc.getItemCalculatelevel(actor, itemId)
- -- 强化等级
- local strengthLevel = EquipFunc.getEquipStrengthLevel(actor, itemId)
- -- 追加等级
- local appendLevel = EquipFunc.getEquipAppendLevel(actor, itemId)
- -- 是否有幸运属性
- local equipInfo = getequipinfo(actor, itemId, 1)
- local isLuck = false
- if equipInfo ~= nil then
- isLuck = EquipFunc.GetEquipIsLuck(equipInfo)
- end
-
- -- 装备系数
- local equipXiShu = level + strengthLevel * 3
- if tQiangHuaXiShu[strengthLevel] then
- equipXiShu = equipXiShu + tQiangHuaXiShu[strengthLevel]
- end
- if appendLevel > 0 then
- equipXiShu = equipXiShu + (appendLevel - 1) * 10
- end
-
- -- 幸运属性加成
- if isLuck then
- equipXiShu = equipXiShu + 10
- end
- -- 装备价值
- local equipCost = 0
- local tmpXiShu = equipXiShu
- -- 是否是卓越装备
- if EquipFunc.IsZhuoYueEquip(cfgId) then
- tmpXiShu = equipXiShu + 25
- end
- equipCost = math.ceil(((tmpXiShu + 40) * tmpXiShu * tmpXiShu / 8 + 100) / 100) * 100
- -- local mainType = ConfigDataManager.getTableValue("cfg_item", "type", "id", cfgId)
- -- local subType = ConfigDataManager.getTableValue("cfg_item", "subType", "id", cfgId)
- -- 翅膀
- -- if subType == 13 then
- -- equipCost = math.ceil((equipXiShu + 40) * equipXiShu * equipXiShu * 11) + 40000000
- -- end
- -- 单手武器衰减
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strPart", "id", cfgId)
- if strPart == 1 or strPart == 2 then
- equipCost = equipCost * 80 / 100
- end
- ---装备价值不能超出
- if equipCost > 3000000000 then
- equipCost = 3000000000
- end
- return math.floor(equipCost)
- end
- -- 获取可回收物品列表
- function EquipFunc.getRescoverItemList(actor)
- local allItemInfo = getallbagiteminfo(actor)
- local tRecoverItem = {}
- if not next(allItemInfo) then
- return tRecoverItem
- end
- for _, item in pairs(allItemInfo) do
- local cfgId = item.cfgid
- local itemData = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1]
- local recoveryGroup = itemData.recoverygroup or 0
- if recoveryGroup ~= 0 then
- table.insert(tRecoverItem, item)
- end
- end
- return tRecoverItem
- end
- -- 获取回收价格
- function EquipFunc.getEquipRecoverCost(actor, itemId)
- local equipInfo = getequipinfo(actor, itemId, 1)
- local cfgId = equipInfo.cfgid
- local value = ConfigDataManager.getTableValue("cfg_item", "value", "id", cfgId)
- if tonumber(value) then
- return tonumber(value)
- end
- -- if value ~= "" then
- -- return tonumber(value)
- -- end
- local equipCost = EquipFunc.getEquipJiaZhi(actor, itemId)
- -- 出售价格
- local sellPrice = 0
- -- 是否卓越装备
- local isZhuoYue = EquipFunc.IsZhuoYueEquip(cfgId)
- -- 卓越条数
- local ZhuoYueEquipNum = EquipFunc.getZhuoYueEquipNum(actor, itemId)
- -- 追加等级
- local appendLevel = EquipFunc.getEquipAppendLevel(actor, itemId)
- -- 幸运
- local IsXingYun = EquipFunc.getEquipIsXingYun(actor, itemId)
- -- 技能
- local IsSkill = EquipFunc.getEquipIsSkill(actor, itemId)
- if not sellPrice or sellPrice == 0 then
- if IsSkill then
- sellPrice = equipCost + equipCost * 2.5
- end
- if IsXingYun then
- sellPrice = equipCost + equipCost * 1.25
- end
- if appendLevel > 0 then
- if appendLevel == 1 then
- sellPrice = equipCost + equipCost * 1.6
- elseif appendLevel == 2 then
- sellPrice = equipCost + equipCost * 2.4
- elseif appendLevel == 3 then
- sellPrice = equipCost + equipCost * 3.8
- elseif appendLevel == 4 then
- sellPrice = equipCost + equipCost * 6.6
- end
- end
- if isZhuoYue then
- sellPrice = equipCost + equipCost * 2 * ZhuoYueEquipNum
- end
- -- 道具表 useLevelLimit 字段
- if EquipFunc.getEquipIsSpecial(cfgId) then
- sellPrice = equipCost + equipCost * 1.16
- end
- -- local useLevelLimit = ConfigDataManager.getTableValue("cfg_item", "useLevelLimit", "id", cfgId)
- -- useLevelLimit = tonumber(useLevelLimit)
- -- if useLevelLimit >= 380 then
- -- sellPrice = equipCost + equipCost *1.16
- -- end
- sellPrice = math.ceil(equipCost / 4) ---向上取整
- end
- return math.floor(sellPrice)
- end
- function EquipFunc.getEquipExchangeCost(equip)
- local attrNum = #equip.entries
- if EquipFunc.GetEquipIsLuck(equip) then
- attrNum = attrNum - 3
- else
- attrNum = attrNum - 1
- end
- attrNum = math.max(attrNum, 0)
- local ISZY, ZyType = EquipFunc.IsZhuoYueEquip(equip.cfgid)
- local num = 0
- if ZyType == 1 then -- 卓越准备
- num = 20
- elseif ZyType == 3 then -- 卓越套装
- num = 100
- end
- return attrNum * num
- end
- -- 装备修理费用
- function EquipFunc.getXiuLiPrice(actor, itemId, equipInfo2)
- local equipInfo = nil
- if equipInfo2 ~= nil then
- equipInfo = equipInfo2
- else
- equipInfo = getequipinfo(actor, itemId, 1)
- end
- local cfgId = equipInfo.cfgid
- local equipCost = EquipFunc.getEquipJiaZhi(actor, itemId) / 3
- -- 修理系数
- local XiuLiXiShu = math.ceil(equipCost / 100) * 100
- local nowDurabilityPct = EquipDurability.getNowDurabilityPct(actor, itemId)
- local DurabilityXiShu = 1 - nowDurabilityPct / 100
- local X = math.sqrt(XiuLiXiShu)
- local Y = math.sqrt(X)
- -- 修理费用
- local xiuliPrice = 0
- -- 是否卓越装备
- local isZhuoYue = EquipFunc.IsZhuoYueEquip(cfgId)
- if isZhuoYue then
- xiuliPrice = (((3 * X * Y) * DurabilityXiShu) + 1) * 0.85
- else
- xiuliPrice = (3 * X * Y) * DurabilityXiShu + 1
- end
- -- 是否自动修理
- local autoXiuLi = false
- -- 是否远程修理
- local yuanchengXiuLi = false
- if autoXiuLi or yuanchengXiuLi then
- xiuliPrice = xiuliPrice * 2
- end
- return math.ceil(xiuliPrice)
- end
- -- 缓存时装表
- EquipFunc.tSuitList = {}
- function EquipFunc.setSuitIdList()
- -- local itemData = ConfigDataManager.getTable("cfg_equip_suit")
- local cfg_equip_suit = ConfigDataManager.getList("cfg_equip_suit")
- info("时装表开始缓存")
- for i = 1, #cfg_equip_suit do
- local id = cfg_equip_suit[i].id
- local tSuitItemId = string.split(cfg_equip_suit[i].suitItemId, "#")
- for j = 1, #tSuitItemId do
- local itemId = tSuitItemId[j]
- EquipFunc.tSuitList[itemId] = id
- end
- end
- info("时装表缓存结束")
- end
- -- 根据道具cfgId获取时装id
- function EquipFunc.getSuitId(cfgId)
- return EquipFunc.tSuitList[cfgId] or 0
- end
- -- 登录
- GameEvent.add(EventCfg.onLoginEnd, function(actor)
- -- 推送红点
- sendluamsg(actor, LuaNetMsg.Equip_DuanZao_MsgID, {
- sendType = 10
- })
- end, filename)
- -- 重载配置
- GameEvent.add(EventCfg.onReloadScript, function(actor)
- EquipFunc.setSuitIdList()
- -- 推送红点
- sendluamsg(actor, LuaNetMsg.Equip_DuanZao_MsgID, {
- sendType = 10
- })
- end, filename)
|