| | |
| | | return
|
| | | return ipyDrop
|
| | |
|
| | | def GetNPCDropInfoTJG(dropPlayer, mapID, npcID, killCount):
|
| | | '''脱机挂杀怪掉落专用函数
|
| | | 只算: 1.饼图装备掉落 + 2.指定物品ID掉落 + 3.金币掉落
|
| | | '''
|
| | | ipyDrop = GetNPCDropIpyData(npcID)
|
| | | if not ipyDrop:
|
| | | return
|
| | | |
| | | realmNPCIpyData = None
|
| | | realmMapIDList = IpyGameDataPY.GetFuncEvalCfg("RealmDifficulty", 1)
|
| | | realmDifficulty = PlayerControl.GetRealmDifficulty(dropPlayer)
|
| | | if mapID in realmMapIDList and realmDifficulty:
|
| | | realmLV = PlayerControl.GetDifficultyRealmLV(realmDifficulty)
|
| | | realmNPCIpyData = IpyGameDataPY.GetIpyGameDataNotLog("NPCRealmStrengthen", npcID, realmLV)
|
| | | #if realmNPCIpyData:
|
| | | # maxDropLV = realmNPCIpyData.GetMaxDrapLV()
|
| | | |
| | | #脱机暂不限制最大等级掉落
|
| | | #playerLV = dropPlayer.GetLV()
|
| | | #maxDropLV = ipyDrop.GetMaxDropLV()
|
| | | #if maxDropLV and playerLV > maxDropLV:
|
| | | # GameWorld.DebugLog("超过最大可掉落等级,不掉落物品!npcID=%s,playerLV(%s) > maxDropLV(%s)" % (npcID, playerLV, maxDropLV))
|
| | | # return
|
| | | |
| | | playerID = dropPlayer.GetPlayerID()
|
| | | npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)
|
| | | if not npcData:
|
| | | return
|
| | | |
| | | dropIDList = [] # 掉落的ID列表
|
| | | itemJobList = [dropPlayer.GetJob()] if ipyDrop.GetIsDropJobSelf() else IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # 掉落装备职业列表
|
| | | |
| | | equipDropRatePlus = PlayerControl.GetDropEquipPer(dropPlayer)
|
| | | equipDropDoCountPlus = PlayerControl.GetDropEquipDoCount(dropPlayer)
|
| | | |
| | | dropRatePlusValue = ipyDrop.GetCanDropRatePlus()
|
| | | if not dropRatePlusValue & pow(2, 0):
|
| | | equipDropRatePlus = 0
|
| | | |
| | | if not dropRatePlusValue & pow(2, 1):
|
| | | equipDropDoCountPlus = 0
|
| | | |
| | | doCountAdd = 0
|
| | | doCountRate = ChConfig.Def_MaxRateValue
|
| | | |
| | | GameWorld.DebugLog("脱机挂杀怪掉落: npcID=%s,killCount=%s,itemJobList=%s,dropRatePlusValue=%s,equipDropRatePlus=%s,equipDropDoCountPlus=%s" |
| | | % (npcID, killCount, itemJobList, dropRatePlusValue, equipDropRatePlus, equipDropDoCountPlus), playerID)
|
| | | |
| | | dropEquipInfoList = [] # [(阶,颜色, 件数), ...]
|
| | | # 1.装备只算饼图概率
|
| | | pieRateDoCnt = ipyDrop.GetPieRateDoCnt()
|
| | | if pieRateDoCnt and ipyDrop.GetPieRateDrop():
|
| | | pieRateDoCnt = __GetNPCDropDoCountChange(pieRateDoCnt, doCountRate + equipDropDoCountPlus, doCountAdd)
|
| | | pieRateDoCnt *= killCount
|
| | | pieRateDropList = ipyDrop.GetPieRateDrop() # [(概率,0),(概率,(阶,颜色)),...]
|
| | | if equipDropRatePlus:
|
| | | dropRateList = GameWorld.GetPlusPieList(pieRateDropList, equipDropRatePlus)
|
| | | GameWorld.DebugLog(" 装备配置饼图: %s,equipDropRatePlus=%s" % (pieRateDropList, equipDropRatePlus), playerID)
|
| | | else:
|
| | | dropRateList = pieRateDropList
|
| | | preRate = 0
|
| | | maxRate = dropRateList[-1][0]
|
| | | GameWorld.DebugLog(" 装备掉落饼图: %s,maxRate=%s" % (dropRateList, maxRate), playerID)
|
| | | for rateInfo in dropRateList:
|
| | | rate, equipInfo = rateInfo
|
| | | curRate = rate - preRate
|
| | | if not curRate:
|
| | | break
|
| | | preRate = rate
|
| | | if not equipInfo:
|
| | | continue
|
| | | classLV, color = equipInfo
|
| | | totalRate = curRate * pieRateDoCnt # 总概率
|
| | | dropCount = totalRate / maxRate # 可掉落件数
|
| | | rateEx = totalRate % maxRate # 剩余概率
|
| | | if GameWorld.CanHappen(rateEx, maxRate):
|
| | | dropCount += 1
|
| | | GameWorld.DebugLog(" 装备掉率: curRate=%s,totalRate=%s,rateEx=%s,dropCount=%s,classLV=%s,color=%s" |
| | | % (curRate, totalRate, rateEx, dropCount, classLV, color), playerID)
|
| | | if not dropCount:
|
| | | continue
|
| | | dropEquipInfoList.append([classLV, color, dropCount])
|
| | | GameWorld.DebugLog(" 装备掉落结果: killCount=%s,[阶,颜色,件数]=%s" % (killCount, dropEquipInfoList), playerID)
|
| | | |
| | | colorSuitRateDict = ipyDrop.GetEquipColorSuitInfo() # 装备颜色对应套装概率 {颜色:套装概率, ...}
|
| | | colorSuitPlaceKeyInfoDict = ipyDrop.GetEquipPartKeyRateInfo() # 装备部位集合信息 {(颜色,是否套装):部位集合key, ...}
|
| | | dropEquipIDDict = {}
|
| | | for classLV, color, dropCount in dropEquipInfoList:
|
| | | if realmNPCIpyData:
|
| | | classLV = realmNPCIpyData.GetEquipClassLV()
|
| | | GameWorld.DebugLog(" 脱机掉落对应难度境界装备: classLV=%s" % classLV, playerID)
|
| | | suitCountDict = {} # {套装:件数, ...}
|
| | | if color in colorSuitRateDict:
|
| | | suitRate = colorSuitRateDict[color]
|
| | | for _ in xrange(dropCount):
|
| | | isSuit = GameWorld.CanHappen(suitRate, maxRate=Def_NPCMaxDropRate)
|
| | | suitCountDict[isSuit] = suitCountDict.get(isSuit, 0) + 1
|
| | | else:
|
| | | suitCountDict[0] = dropCount
|
| | | |
| | | for isSuit, curDropCount in suitCountDict.items():
|
| | | colorSuitKey = (color, isSuit)
|
| | | if colorSuitKey not in colorSuitPlaceKeyInfoDict:
|
| | | GameWorld.ErrLog("未配置颜色是否套装对应部位集合key! npcID=%s,color=%s,isSuit=%s" % (npcID, color, isSuit))
|
| | | continue
|
| | | placeKey = colorSuitPlaceKeyInfoDict[colorSuitKey]
|
| | | placeList = GetEquipPlaceByPlaceKey(placeKey)
|
| | | if not placeList:
|
| | | GameWorld.ErrLog("部位集合key不存在!npcID=%s,placeKey=%s" % (npcID, placeKey))
|
| | | continue
|
| | | randEquipIDList = __GetEquipIDList(npcID, classLV, color, isSuit, placeList, itemJobList)
|
| | | if not randEquipIDList:
|
| | | continue
|
| | | for _ in xrange(curDropCount):
|
| | | randItemID = random.choice(randEquipIDList)
|
| | | dropIDList.append(randItemID)
|
| | | dropEquipIDDict[randItemID] = [color, placeKey]
|
| | | GameWorld.DebugLog(" 掉落装备: npcID=%s,itemID=%s,classLV=%s,color=%s,isSuit=%s,placeKey=%s,itemJobList=%s,randEquipIDList=%s" |
| | | % (npcID, randItemID, classLV, color, isSuit, placeKey, itemJobList, randEquipIDList), playerID)
|
| | | |
| | | # 2. 指定物品ID库
|
| | | itemIDDropRateDict = ipyDrop.GetItemIDDropRate() # {物品ID:概率, ...}
|
| | | itemIDDropMaxCntDict = ipyDrop.GetItemIDMaxDropCount() # {物品ID:最大掉落个数,...}
|
| | | for itemID, dropRate in itemIDDropRateDict.items():
|
| | | |
| | | if not dropRate:
|
| | | continue
|
| | | |
| | | doCnt = itemIDDropMaxCntDict.get(itemID, 1) # 默认1个
|
| | | doCnt = __GetNPCDropDoCountChange(doCnt, doCountRate, doCountAdd)
|
| | | doCnt *= killCount
|
| | | |
| | | totalRate = dropRate * doCnt
|
| | | dropCount = totalRate / Def_NPCMaxDropRate # 可掉落件数
|
| | | rateEx = totalRate % Def_NPCMaxDropRate # 剩余概率
|
| | | if GameWorld.CanHappen(rateEx, Def_NPCMaxDropRate):
|
| | | dropCount += 1
|
| | | dropIDList += [itemID] * dropCount
|
| | | GameWorld.DebugLog(" 指定物品掉落: itemID=%s,dropRate=%s,doCnt=%s,totalRate=%s,dropCount=%s" |
| | | % (itemID, dropRate, doCnt, totalRate, dropCount), playerID)
|
| | | |
| | | # 检查掉落互斥ID组
|
| | | dropIDList = __RemoveMutexDropID(dropIDList, IpyGameDataPY.GetFuncCfg("MutexDrop", 1))
|
| | | |
| | | # 掉落金币
|
| | | dropMoneyDoCnt = ipyDrop.GetDropMoneyDoCnt()
|
| | | dropMoneyRate = ipyDrop.GetDropMoneyRate()
|
| | | moneyTotalRate = dropMoneyRate * dropMoneyDoCnt * killCount
|
| | | dropMoneyCnt = moneyTotalRate / ChConfig.Def_NPCMapDropRate
|
| | | if GameWorld.CanHappen(moneyTotalRate % ChConfig.Def_NPCMapDropRate, ChConfig.Def_NPCMapDropRate):
|
| | | dropMoneyCnt += 1
|
| | | dropMoney = 0
|
| | | if dropMoneyCnt:
|
| | | dropMoney = __GetDropMoneyValue(dropPlayer, ipyDrop, realmNPCIpyData) * dropMoneyCnt
|
| | | GameWorld.DebugLog(" 金币掉率: dropMoneyRate=%s,moneyTotalRate=%s,dropMoneyCnt=%s,dropMoney=%s" |
| | | % (dropMoneyRate, moneyTotalRate, dropMoneyCnt, dropMoney), playerID)
|
| | | dropIDCountDict = {}
|
| | | for dropID in dropIDList:
|
| | | dropIDCountDict[dropID] = dropIDCountDict.get(dropID, 0) + 1
|
| | | |
| | | # 集字掉落
|
| | | dropWordsCountDict = PlayerActCollectWords.OnGetDropWordsItemDict(dropPlayer, npcData, killCount)
|
| | | for dropID, dropCount in dropWordsCountDict.items():
|
| | | dropIDCountDict[dropID] = dropIDCountDict.get(dropID, 0) + dropCount
|
| | | |
| | | # 垃圾分类
|
| | | giveGarbageItemList = PlayerActGarbageSorting.AddActGarbageTaskProgress(dropPlayer, ChConfig.Def_GarbageTask_KillNPC, killCount, isTJG=True)
|
| | | for dropID, dropCount, _ in giveGarbageItemList:
|
| | | dropIDCountDict[dropID] = dropIDCountDict.get(dropID, 0) + dropCount
|
| | | |
| | | auctionIDList = []
|
| | | if ipyDrop.GetAucionItemCanSell():
|
| | | for dropID in dropIDCountDict.keys():
|
| | | if IpyGameDataPY.GetIpyGameDataNotLog("AuctionItem", dropID):
|
| | | auctionIDList.append(dropID)
|
| | | |
| | | if dropIDCountDict:
|
| | | GameWorld.DebugLog(" 最终掉落: npcID=%s,killCount=%s,dropIDCountDict=%s,auctionIDList=%s,dropMoney=%s" |
| | | % (npcID, killCount, dropIDCountDict, auctionIDList, dropMoney), playerID)
|
| | | return dropIDCountDict, auctionIDList, dropMoney
|
| | |
|
| | | def GetNPCDropInfo(dropPlayer, mapID, npcID, ownerPlayerList=[], ipyDrop=None, isSingle=True, isKillCountDrop=True, curGrade=0):
|
| | | '''获取NPC掉落信息, 击杀及扫荡通用,调用该函数获得掉落信息,然后再看掉落地板上还是直接放入背包
|
| | | @param dropPlayer: 用于判断调用相关用的玩家示例,该玩家并不一定是击杀者,只是按一定规则设定的掉落判断依据的玩家
|