Explorar o código

修改合成增加的概率计算

huangyuhao80 hai 2 meses
pai
achega
f26e955560
Modificáronse 1 ficheiros con 66 adicións e 33 borrados
  1. 66 33
      meta/userapi/lua/ItemSynthesis.lua

+ 66 - 33
meta/userapi/lua/ItemSynthesis.lua

@@ -190,57 +190,88 @@ end
190
 
190
 
191
 -- 消耗增加概率
191
 -- 消耗增加概率
192
 function ItemSynthesis.consum_add_rate(actor, consumeItems, special, assistantItem)
192
 function ItemSynthesis.consum_add_rate(actor, consumeItems, special, assistantItem)
193
-    local configList = ConfigDataManager.getList("cfg_synthesis_material")
193
+    local confMaterialList = ConfigDataManager.getList("cfg_synthesis_material")
194
+    local confAssistantList = ConfigDataManager.getList("cfg_synthesis_assistant")
194
     local allEquip = EquipAndAppear.getLuaItemExtData(actor)
195
     local allEquip = EquipAndAppear.getLuaItemExtData(actor)
195
     -- 获取合成增加概率
196
     -- 获取合成增加概率
196
-    local function _get_item_rate(actor, itemId)
197
-        for _, v in ipairs(configList) do
198
-            if v.materialId == itemId then
199
-                -- 材料
200
-                if v.type == 0 then
201
-                    return v.addRateBase or 0
202
-                end
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
197
+    local function _get_item_rate(actor, itemId, groupId)
198
+        -- 装备强化等级
199
+        local strengthlv = 0
200
+        -- 装备追加等级
201
+        local appendlv = 0
202
+        local equip = getequipinfo(actor, itemId, 1)
203
+        if equip and allEquip[itemId] then
204
+            strengthlv = allEquip[itemId].strengthlv
205
+            appendlv = allEquip[itemId].appendlv
206
+        end
207
+        -- 获取配置
208
+        local conf = nil
209
+        if groupId == nil then
210
+            for _, v in ipairs(confMaterialList) do
211
+                if v.materialId == itemId then
212
+                    -- 装备,增加等级判断
213
+                    if v.type == 2 then
214
                         -- 是否符合等级要求
214
                         -- 是否符合等级要求
215
                         if v.related == 1 then
215
                         if v.related == 1 then
216
                             -- 同时满足强化等级以及追加等级
216
                             -- 同时满足强化等级以及追加等级
217
-                            if strengthlv < v.minLevel or appendlv < v.minAppend then
218
-                                isMatch = false
217
+                            if strengthlv >= v.minLevel and appendlv >= v.minAppend then
218
+                                conf = table.copy(v)
219
+                                break
219
                             end
220
                             end
220
                         end
221
                         end
221
                         if v.related == 2 then
222
                         if v.related == 2 then
222
                             -- 强化等级或追加等级满足其中一个
223
                             -- 强化等级或追加等级满足其中一个
223
-                            if strengthlv < v.minLevel and appendlv < v.minAppend then
224
-                                isMatch = false
224
+                            if strengthlv >= v.minLevel or appendlv >= v.minAppend then
225
+                                conf = table.copy(v)
226
+                                break
225
                             end
227
                             end
226
                         end
228
                         end
229
+                    else
230
+                        conf = table.copy(v)
231
+                        break
227
                     end
232
                     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)
233
+                end
234
+            end
235
+        else
236
+            for _, v in ipairs(confMaterialList) do
237
+                if v.groupId == groupId and v.itemId == itemId then
238
+                    -- 装备,增加等级判断
239
+                    if v.type == 2 then
240
+                        -- 是否符合等级要求
232
                         if v.related == 1 then
241
                         if v.related == 1 then
233
-                            addRate = addRate + addStrengthRate + addAppendRate
242
+                            -- 同时满足强化等级以及追加等级
243
+                            if strengthlv >= v.minLevel and appendlv >= v.minAppend then
244
+                                conf = table.copy(v)
245
+                                break
246
+                            end
234
                         end
247
                         end
235
-
236
                         if v.related == 2 then
248
                         if v.related == 2 then
237
-                            addRate = addRate + math.max(addStrengthRate, addAppendRate)
249
+                            -- 强化等级或追加等级满足其中一个
250
+                            if strengthlv >= v.minLevel or appendlv >= v.minAppend then
251
+                                conf = table.copy(v)
252
+                                break
253
+                            end
238
                         end
254
                         end
239
-                        return addRate
255
+                    else
256
+                        conf = table.copy(v)
257
+                        break
240
                     end
258
                     end
241
                 end
259
                 end
242
             end
260
             end
243
         end
261
         end
262
+        if conf then
263
+            local addRate = conf.addRateBase or 0
264
+            local addStrengthRate = (strengthlv - (conf.minLevel or 0)) * (conf.perAddRateLevel or 0)
265
+            local addAppendRate = (appendlv - (conf.minAppend or 0)) * (conf.perAddRateAppend or 0)
266
+            if conf.related == 1 then
267
+                addRate = addRate + addStrengthRate + addAppendRate
268
+            end
269
+
270
+            if conf.related == 2 then
271
+                addRate = addRate + math.max(addStrengthRate, addAppendRate)
272
+            end
273
+            return addRate
274
+        end
244
         return 0
275
         return 0
245
     end
276
     end
246
 
277
 
@@ -258,7 +289,8 @@ function ItemSynthesis.consum_add_rate(actor, consumeItems, special, assistantIt
258
         for index, value in pairs(special) do
289
         for index, value in pairs(special) do
259
             local itemId = value["itemId"]
290
             local itemId = value["itemId"]
260
             local itemIndex = value["itemIndex"]
291
             local itemIndex = value["itemIndex"]
261
-            addRate = addRate + _get_item_rate(actor, itemId)
292
+            local groupId = value["groupId"]
293
+            addRate = addRate + _get_item_rate(actor, itemId, groupId)
262
         end
294
         end
263
     end
295
     end
264
     -- 辅助消耗道具
296
     -- 辅助消耗道具
@@ -266,7 +298,8 @@ function ItemSynthesis.consum_add_rate(actor, consumeItems, special, assistantIt
266
         for index, value in pairs(assistantItem) do
298
         for index, value in pairs(assistantItem) do
267
             local itemId = value["itemId"]
299
             local itemId = value["itemId"]
268
             local itemIndex = value["itemIndex"]
300
             local itemIndex = value["itemIndex"]
269
-            addRate = addRate + _get_item_rate(actor, itemId)
301
+            local groupId = value["groupId"]
302
+            addRate = addRate + _get_item_rate(actor, itemId, groupId)
270
         end
303
         end
271
     end
304
     end
272
 
305