瀏覽代碼

修改合成概率

huangyuhao80 2 月之前
父節點
當前提交
7a8093a64c
共有 1 個文件被更改,包括 45 次插入39 次删除
  1. 45 39
      meta/userapi/lua/ItemSynthesis.lua

+ 45 - 39
meta/userapi/lua/ItemSynthesis.lua

@@ -64,8 +64,7 @@ function ItemSynthesis.synthesis(actor, msgData)
64 64
     local removeItemIndex = {}
65 65
     local successRateReal = ConfigDataManager.getTableValue("cfg_synthesis", "successRateReal", "id", synthesisCfgId)
66 66
     -- 装备等级概率
67
-    local addSuccessRateReal =
68
-        ItemSynthesis.consum_add_rate(actor, synthesisCfgId, splitConsume, special, assistantItem)
67
+    local addSuccessRateReal = ItemSynthesis.consum_add_rate(actor, splitConsume, special, assistantItem)
69 68
     successRateReal = successRateReal + addSuccessRateReal
70 69
     -- 最高概率
71 70
     local maxRate = tonumber(ConfigDataManager.getTableValue("cfg_synthesis", "maxRate", "id", synthesisCfgId) or 10000)
@@ -190,48 +189,55 @@ function ItemSynthesis.changeItemAtt(actor, itemId, changeItemId)
190 189
 end
191 190
 
192 191
 -- 消耗增加概率
193
-function ItemSynthesis.consum_add_rate(actor, synthesisCfgId, consumeItems, special, assistantItem)
192
+function ItemSynthesis.consum_add_rate(actor, consumeItems, special, assistantItem)
194 193
     local configList = ConfigDataManager.getList("cfg_synthesis_material")
195 194
     local allEquip = EquipAndAppear.getLuaItemExtData(actor)
196 195
     -- 获取合成增加概率
197
-    local function _get_item_rate(actor, sId, itemId)
198
-        local equip = getequipinfo(actor, itemId, 1)
199
-        if equip == nil or allEquip[itemId] == nil then
200
-            return 0
201
-        end
202
-
196
+    local function _get_item_rate(actor, itemId)
203 197
         for _, v in ipairs(configList) do
204
-            if v.synthesisCfgId == sId and v.materialId == itemId then
205
-                -- 装备强化等级
206
-                local strengthlv = allEquip[itemId].strengthlv
207
-                -- 装备追加等级
208
-                local appendlv = allEquip[itemId].appendlv
209
-                -- 是否符合等级要求
210
-                local isMatch = false
211
-                if v.related == 1 then
212
-                    -- 同时满足强化等级以及追加等级
213
-                    if strengthlv >= v.minLevel and appendlv >= v.minAppend then
214
-                        isMatch = true
215
-                    end
216
-                end
217
-                if v.related == 2 then
218
-                    -- 强化等级或追加等级满足其中一个
219
-                    if strengthlv >= v.minLevel or appendlv >= v.minAppend then
220
-                        isMatch = true
221
-                    end
198
+            if v.materialId == itemId then
199
+                -- 材料
200
+                if v.type == 0 then
201
+                    return v.addRateBase or 0
222 202
                 end
223
-                if isMatch then
224
-                    local addRate = v.addRateBase or 0
225
-                    local addStrengthRate = (strengthlv - v.minLevel) * (v.perAddRateLevel or 0)
226
-                    local addAppendRate = (appendlv - v.minAppend) * (v.perAddRateAppend or 0)
227
-                    if v.related == 1 then
228
-                        addRate = addRate + addStrengthRate + addAppendRate
203
+                -- 装备
204
+                if v.type == 2 then
205
+                    local isMatch = true
206
+                    local equip = getequipinfo(actor, itemId, 1)
207
+                    if equip == nil or allEquip[itemId] == nil then
208
+                        isMatch = false
209
+                    else
210
+                        -- 装备强化等级
211
+                        local strengthlv = allEquip[itemId].strengthlv
212
+                        -- 装备追加等级
213
+                        local appendlv = allEquip[itemId].appendlv
214
+                        -- 是否符合等级要求
215
+                        if v.related == 1 then
216
+                            -- 同时满足强化等级以及追加等级
217
+                            if strengthlv < v.minLevel or appendlv < v.minAppend then
218
+                                isMatch = false
219
+                            end
220
+                        end
221
+                        if v.related == 2 then
222
+                            -- 强化等级或追加等级满足其中一个
223
+                            if strengthlv < v.minLevel and appendlv < v.minAppend then
224
+                                isMatch = false
225
+                            end
226
+                        end
229 227
                     end
228
+                    if isMatch then
229
+                        local addRate = v.addRateBase or 0
230
+                        local addStrengthRate = (strengthlv - v.minLevel) * (v.perAddRateLevel or 0)
231
+                        local addAppendRate = (appendlv - v.minAppend) * (v.perAddRateAppend or 0)
232
+                        if v.related == 1 then
233
+                            addRate = addRate + addStrengthRate + addAppendRate
234
+                        end
230 235
 
231
-                    if v.related == 2 then
232
-                        addRate = addRate + math.max(addStrengthRate, addAppendRate)
236
+                        if v.related == 2 then
237
+                            addRate = addRate + math.max(addStrengthRate, addAppendRate)
238
+                        end
239
+                        return addRate
233 240
                     end
234
-                    return addRate
235 241
                 end
236 242
             end
237 243
         end
@@ -245,14 +251,14 @@ function ItemSynthesis.consum_add_rate(actor, synthesisCfgId, consumeItems, spec
245 251
         local consumeItemCfgId = tonumber(consumeInfo[1])
246 252
         local consumeItemCount = tonumber(consumeInfo[2])
247 253
 
248
-        addRate = addRate + _get_item_rate(actor, synthesisCfgId, consumeItemCfgId)
254
+        addRate = addRate + _get_item_rate(actor, consumeItemCfgId)
249 255
     end
250 256
     -- 公式特殊消耗道具
251 257
     if special then
252 258
         for index, value in pairs(special) do
253 259
             local itemId = value["itemId"]
254 260
             local itemIndex = value["itemIndex"]
255
-            addRate = addRate + _get_item_rate(actor, synthesisCfgId, itemId)
261
+            addRate = addRate + _get_item_rate(actor, itemId)
256 262
         end
257 263
     end
258 264
     -- 辅助消耗道具
@@ -260,7 +266,7 @@ function ItemSynthesis.consum_add_rate(actor, synthesisCfgId, consumeItems, spec
260 266
         for index, value in pairs(assistantItem) do
261 267
             local itemId = value["itemId"]
262 268
             local itemIndex = value["itemIndex"]
263
-            addRate = addRate + _get_item_rate(actor, synthesisCfgId, itemId)
269
+            addRate = addRate + _get_item_rate(actor, itemId)
264 270
         end
265 271
     end
266 272