From 16062d6765654dc6528e4ac2fe287655c0afc424 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 06 六月 2019 16:02:19 +0800
Subject: [PATCH] 7140 【后端】【2.0】新增智能部位保底掉落规则

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py |    3 +++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py |   51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 PySysDB/PySysDBPY.h                                                                  |    1 +
 3 files changed, 54 insertions(+), 1 deletions(-)

diff --git a/PySysDB/PySysDBPY.h b/PySysDB/PySysDBPY.h
index b82a80a..634bf0f 100644
--- a/PySysDB/PySysDBPY.h
+++ b/PySysDB/PySysDBPY.h
@@ -506,6 +506,7 @@
 	dict		EquipColorMaxDropCount;	//装备颜色最大掉落物品数 {颜色:上限数量,...}
 	dict		EquipColorSuitInfo;	//装备颜色对应套装概率 {颜色:套装概率, ...}
 	dict		EquipPartKeyRateInfo;	//装备部位集合信息 {(颜色,是否套装):部位集合key, ...}
+	BYTE		ColorSuitPartOptimization;	//部位颜色套评分优选掉落,十位代表颜色,个位代表套装
 	dict		KillCountDropEquipPub;	//第x次击杀附加必掉装备 {次数:[阶,颜色,是否套装,部位集合key], ...}
 	dict		ItemIDDropRate;	//指定物品ID掉率信息 {物品ID:概率, ...}
 	dict		ItemIDMaxDropCount;	//指定物品ID最大掉落个数,没配默认1次 {物品ID:随机次数,...}
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
index d765ac4..915a280 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -422,6 +422,7 @@
                         ("dict", "EquipColorMaxDropCount", 0),
                         ("dict", "EquipColorSuitInfo", 0),
                         ("dict", "EquipPartKeyRateInfo", 0),
+                        ("BYTE", "ColorSuitPartOptimization", 0),
                         ("dict", "KillCountDropEquipPub", 0),
                         ("dict", "ItemIDDropRate", 0),
                         ("dict", "ItemIDMaxDropCount", 0),
@@ -2272,6 +2273,7 @@
         self.EquipColorMaxDropCount = {}
         self.EquipColorSuitInfo = {}
         self.EquipPartKeyRateInfo = {}
+        self.ColorSuitPartOptimization = 0
         self.KillCountDropEquipPub = {}
         self.ItemIDDropRate = {}
         self.ItemIDMaxDropCount = {}
@@ -2300,6 +2302,7 @@
     def GetEquipColorMaxDropCount(self): return self.EquipColorMaxDropCount # 装备颜色最大掉落物品数 {颜色:上限数量,...}
     def GetEquipColorSuitInfo(self): return self.EquipColorSuitInfo # 装备颜色对应套装概率 {颜色:套装概率, ...}
     def GetEquipPartKeyRateInfo(self): return self.EquipPartKeyRateInfo # 装备部位集合信息 {(颜色,是否套装):部位集合key, ...}
+    def GetColorSuitPartOptimization(self): return self.ColorSuitPartOptimization # 部位颜色套评分优选掉落,十位代表颜色,个位代表套装
     def GetKillCountDropEquipPub(self): return self.KillCountDropEquipPub # 第x次击杀附加必掉装备 {次数:[阶,颜色,是否套装,部位集合key], ...}
     def GetItemIDDropRate(self): return self.ItemIDDropRate # 指定物品ID掉率信息 {物品ID:概率, ...}
     def GetItemIDMaxDropCount(self): return self.ItemIDMaxDropCount # 指定物品ID最大掉落个数,没配默认1次 {物品ID:随机次数,...}
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
index 8778e5b..a35eba0 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
@@ -1013,6 +1013,10 @@
     colorMaxDropCntDict = ipyDrop.GetEquipColorMaxDropCount() # {颜色:上限数量,...}
     colorSuitRateDict = ipyDrop.GetEquipColorSuitInfo() # 装备颜色对应套装概率 {颜色:套装概率, ...}
     colorSuitPlaceKeyInfoDict = ipyDrop.GetEquipPartKeyRateInfo() # 装备部位集合信息 {(颜色,是否套装):部位集合key, ...}
+    colorSuitPartOptimization = ipyDrop.GetColorSuitPartOptimization() # 部位颜色套评分优选掉落,十位代表颜色,个位代表套装
+    optColor, optIsSuit = colorSuitPartOptimization / 10, colorSuitPartOptimization % 10
+    optPlace = None # 优选部位
+    
     for dropEquipInfo in dropEquipInfoList:
         classLV, color = dropEquipInfo[:2]
         if color in colorMaxDropCntDict:
@@ -1040,11 +1044,20 @@
                 GameWorld.ErrLog("未配置颜色是否套装对应部位集合key! npcID=%s,color=%s,isSuit=%s" % (npcID, color, isSuit))
                 continue
             placeKey = colorSuitPlaceKeyInfoDict[colorSuitKey]
+            # 掉落优选部位处理
+            if color == optColor and isSuit == optIsSuit and placeKey in placeKeyListDict and optPlace == None:
+                optPlace = __GetOptimizationEquipPlace(dropPlayer, classLV, optColor, optIsSuit, placeKeyListDict[placeKey])
             jobList = itemJobList
         if placeKey not in placeKeyListDict:
             GameWorld.ErrLog("部位集合key不存在!npcID=%s,placeKey=%s" % (npcID, placeKey))
             continue
-        placeList = placeKeyListDict[placeKey]
+        if optPlace > 0:
+            GameWorld.DebugLog("    最终优选部位: %s" % optPlace)
+            placeList = [optPlace]
+            jobList = [dropPlayer.GetJob()]
+            optPlace = 0 # 只有一次性的,置为0
+        else:
+            placeList = placeKeyListDict[placeKey]
         randEquipIDList = __GetEquipIDList(npcID, classLV, color, isSuit, placeList, jobList)
         if not randEquipIDList:
             continue
@@ -1114,6 +1127,42 @@
         GameWorld.ErrLog("Boss没有掉落物品,NPCID=%s" % (npcID), dropPlayer.GetPlayerID())
     return dropIDList, auctionIDList, dropMoneyCnt, moneyValue
 
+def __GetOptimizationEquipPlace(dropPlayer, classLV, optColor, optIsSuit, optPlaceList):
+    ''' 获取掉落优选部位
+        几个默认规则
+    1. 颜色大于指定优选颜色的,无论是否套装都不计算在内
+    2. 颜色小于指定优选颜色的,无论是否套装都计算在内
+    '''
+    #GameWorld.DebugLog("处理优选部位掉落: classLV=%s,optColor=%s,optIsSuit=%s,optPlaceList=%s" % (classLV, optColor, optIsSuit, optPlaceList))
+    minGSPlace = None
+    minGS = None
+    equipPack = dropPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
+    for optPlace in optPlaceList:
+        ipyData = IpyGameDataPY.GetIpyGameData('EquipPlaceIndexMap', classLV, optPlace)
+        if not ipyData:
+            continue
+        equipIndex = ipyData.GetGridIndex()
+        curEquip = equipPack.GetAt(equipIndex)
+        if not curEquip or curEquip.IsEmpty():
+            #GameWorld.DebugLog("    没穿装备,直接默认返回该部位: optPlace=%s" % optPlace)
+            return optPlace
+        curColor = curEquip.GetItemColor()
+        curIsSuit = 1 if curEquip.GetSuiteID() else 0
+        if curColor > optColor:
+            # 超过优选指定颜色的不算,无论是否有套装
+            #GameWorld.DebugLog("    颜色超过优选颜色,不算该部位: optPlace=%s,curColor=%s,curIsSuit=%s" % (optPlace, curColor, curIsSuit))
+            continue
+        if curColor == optColor and curIsSuit >= optIsSuit:
+            # 与优选指定颜色相同,且满足是否套装的不算
+            #GameWorld.DebugLog("    颜色套装满足优选,不算该部位: optPlace=%s,curColor=%s,curIsSuit=%s" % (optPlace, curColor, curIsSuit))
+            continue
+        curGS = ItemCommon.GetEquipGearScore(curEquip)
+        if minGS == None or curGS < minGS:
+            minGS = curGS
+            minGSPlace = optPlace
+            
+    return minGSPlace
+
 def __GetNPCDropDoCountChange(doCount, doCountRate, doCountAdd):
     ## 获取掉落执行次数变更结果,可能增加 或 减少
     if doCountRate != ChConfig.Def_MaxRateValue:

--
Gitblit v1.8.0