| | |
| | | import random
|
| | | import math
|
| | | import time
|
| | | import copy
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | OnNPCDie = None
|
| | |
| | | GameWorld.ErrLog("获取NPC掉落配置错误!表不存在该NPCID=%s" % npcID, playerID)
|
| | | return
|
| | |
|
| | | tianxuanState = False # 是否有天玄额外掉落状态
|
| | | tianxuanBuff = SkillCommon.FindBuffByID(dropPlayer, ChConfig.Def_SkillID_TianxuanBuff)[0]
|
| | | curGrade = curGrade if curGrade else GameWorld.GetGameFB().GetGameFBDictByKey(ChConfig.Def_FB_Grade)
|
| | |
|
| | | dropIDList = [] # 掉落的ID列表
|
| | |
| | | dropEquipInfoList += __GetNPCIndepRateEquipDrop(mapID, ipyDrop, indepRateDoCnt, equipDropRatePlus, curGrade)
|
| | | #GameWorld.DebugLog("阶,颜色 key,dropEquipInfoList=%s" % (dropEquipInfoList))
|
| | |
|
| | | # 天玄丹 |
| | | tianxuanEquipRateList = ipyDrop.GetTianxuanEquipRateList()
|
| | | if tianxuanBuff and tianxuanEquipRateList:
|
| | | tianxuanState = True
|
| | | dropInfo = GameWorld.GetResultByRandomList(tianxuanEquipRateList)
|
| | | if dropInfo:
|
| | | dropEquipInfoList.append(dropInfo)
|
| | | |
| | | # 3. 第x次击杀, 归属者公共附加掉落,所有归属者都增加击杀次数;
|
| | | tagClassLV, tagColor, tagIsSuit, tagPlaceKey = 0, 0, 0, 0
|
| | | killCountDropEquipPub = ipyDrop.GetKillCountDropEquipPub() # 第x次击杀附加必掉装备 {次数:[阶,颜色,是否套装,部位集合key], ...}
|
| | |
| | | if npcID in fbGradeColorSuitRateDict:
|
| | | gradeColorSuitRateDict = fbGradeColorSuitRateDict[npcID]
|
| | |
|
| | | equipColorDropLimitDay = IpyGameDataPY.GetFuncEvalCfg("ItemDropCountLimit", 1, {}) # 每日个人掉落装备个数限制 {品质:每日掉落个数, ...}
|
| | | colorDropCntDict = {} # 装备颜色已经掉落数 {颜色:数量, ...}
|
| | | colorMaxDropCntDict = ipyDrop.GetEquipColorMaxDropCount() # {颜色:上限数量,...}
|
| | | colorSuitRateDict = ipyDrop.GetEquipColorSuitInfo() # 装备颜色对应套装概率 {颜色:套装概率, ...}
|
| | |
| | | if realmNPCIpyData:
|
| | | classLV = realmNPCIpyData.GetEquipClassLV()
|
| | | GameWorld.DebugLog("掉落对应难度境界装备: classLV=%s" % classLV, playerID)
|
| | | |
| | | colorCountToday = 0
|
| | | if color in equipColorDropLimitDay:
|
| | | colorCountMax = equipColorDropLimitDay[color]
|
| | | colorCountToday = dropPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DropColorToday % color)
|
| | | if colorCountToday >= colorCountMax:
|
| | | GameWorld.DebugLog("已超过该颜色装备今日最大掉落数,不掉!color=%s,colorCountMax=%s" % (color, colorCountMax), playerID)
|
| | | continue
|
| | |
|
| | | if color in colorMaxDropCntDict:
|
| | | maxCount = colorMaxDropCntDict[color]
|
| | |
| | | randEquipIDList = __GetEquipIDList(npcID, classLV, color, isSuit, placeList, jobList)
|
| | | if not randEquipIDList:
|
| | | continue
|
| | | if color in equipColorDropLimitDay:
|
| | | colorCountToday += 1
|
| | | PlayerControl.NomalDictSetProperty(dropPlayer, ChConfig.Def_PDict_DropColorToday % color, colorCountToday)
|
| | | if color in colorMaxDropCntDict:
|
| | | colorDropCntDict[color] = dropCount + 1
|
| | | if isSuit and len(jobList) > 1:
|
| | |
| | | dropIDList.append(randItemID)
|
| | | GameWorld.DebugLog("掉落装备: npcID=%s,itemID=%s,classLV=%s,color=%s,isSuit=%s,placeKey=%s,jobList=%s,randEquipIDList=%s"
|
| | | % (npcID, randItemID, classLV, color, isSuit, placeKey, jobList, randEquipIDList), playerID)
|
| | | if colorCountToday:
|
| | | GameWorld.DebugLog(" 更新掉落特殊品质装备今日次数: color=%s,colorCountToday=%s" % (color, colorCountToday), playerID)
|
| | |
|
| | | # 4. 指定物品ID库
|
| | | dropIDList += __GetAppointDropItemIDList(dropPlayer, npcID, ipyDrop, doCountRate, doCountAdd)
|
| | | if tianxuanBuff and (ipyDrop.GetTianxuanItemKeyRate() or ipyDrop.GetTianxuanItemIDRate()):
|
| | | tianxuanState = True
|
| | |
|
| | | # 5. 私有掉落
|
| | | if isSingle:
|
| | |
| | | GameWorld.DebugLog(" auctionIDList=%s" % (auctionIDList), playerID)
|
| | | elif ChConfig.IsGameBoss(npcData):
|
| | | GameWorld.ErrLog("Boss没有掉落物品,NPCID=%s" % (npcID), dropPlayer.GetPlayerID())
|
| | | |
| | | if tianxuanState:
|
| | | GameWorld.DebugLog(" 去除天玄丹buff", playerID)
|
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | BuffSkill.DelBuffBySkillID(dropPlayer, ChConfig.Def_SkillID_TianxuanBuff, tick)
|
| | | |
| | | return dropIDList, auctionIDList, dropMoneyCnt, moneyValue
|
| | |
|
| | | def __GetRandDropSuitEquipID(curPlayer, randEquipIDList):
|
| | |
| | |
|
| | | return dropIDList
|
| | |
|
| | | def __GetAppointDropItemIDList(curPlayer, npcID, ipyDrop, doCountRate, doCountAdd):
|
| | | def __GetAppointDropItemIDList(curPlayer, npcID, ipyDrop, doCountRate, doCountAdd, tianxuanBuff):
|
| | | ## 指定物品ID掉落
|
| | |
|
| | | dropItemIDList = []
|
| | |
|
| | | itemDropLimitDayInfo = IpyGameDataPY.GetFuncEvalCfg("ItemDropCountLimit", 2, {}) # 每日个人掉落物品个数限制 {物品ID:每日掉落上限, ...}
|
| | | # 1. 职业物品ID集合
|
| | | job = curPlayer.GetJob()
|
| | | JobItemDropSets = IpyGameDataPY.GetFuncCfg("JobItemDropSets", 1) # {物品ID集合key:[职业顺序物品ID列表], ...}
|
| | |
| | |
|
| | | # 1.2 随机掉落一个
|
| | | ItemKeyDropRateDict = ipyDrop.GetItemKeyDropRate() # {物品ID集合key:概率, ...}, 随机掉一个,优先级低
|
| | | tianxuanItemKeyRateDict = ipyDrop.GetTianxuanItemKeyRate() # 天玄丹指定ID集合Key概率{物品ID集合key:概率, ...}
|
| | | if tianxuanBuff and tianxuanItemKeyRateDict:
|
| | | ItemKeyDropRateDict = copy.deepcopy(ItemKeyDropRateDict)
|
| | | ItemKeyDropRateDict.update(tianxuanItemKeyRateDict)
|
| | | |
| | | if ItemKeyDropRateDict:
|
| | | GameWorld.DebugLog("ItemKeyDropRateDict:%s" % ItemKeyDropRateDict)
|
| | | for itemKey, dropRate in ItemKeyDropRateDict.items():
|
| | | # 在只掉本职业里的不处理
|
| | | if itemKey in ItemKeyDropRateJobDict:
|
| | |
| | | continue
|
| | | if not randItemID:
|
| | | continue
|
| | | if __dropIDCountLimitToday(curPlayer, randItemID, itemDropLimitDayInfo):
|
| | | continue
|
| | | dropItemIDList.append(randItemID)
|
| | | #GameWorld.DebugLog("掉落随机指定物品ID: itemKey=%s,randItemID=%s" % (itemKey, randItemID))
|
| | |
|
| | | # 2. 指定掉落ID处理, 受全局设定影响
|
| | | itemIDDropRateDict = ipyDrop.GetItemIDDropRate() # {物品ID:概率, ...}
|
| | | itemIDDropMaxCntDict = ipyDrop.GetItemIDMaxDropCount() # {物品ID:最大掉落个数,...}
|
| | | |
| | | tianxuanItemIDRate = ipyDrop.GetTianxuanItemIDRate() # 天玄丹指定ID概率 {物品ID:概率, ...}
|
| | | if tianxuanBuff and tianxuanItemIDRate:
|
| | | itemIDDropRateDict = copy.deepcopy(itemIDDropRateDict)
|
| | | itemIDDropRateDict.update(tianxuanItemIDRate)
|
| | | |
| | | # 全局材料掉落控制
|
| | | globalDropCDDict = IpyGameDataPY.GetFuncCfg("GlobalDropCD", 1) # {物品ID:分钟, ...}
|
| | | globalDropRateDict = IpyGameDataPY.GetFuncCfg("NPCGlobalDropRate", 1) # {物品ID:[[npcID列表], "概率公式"], ...}
|
| | | gw = GameWorld.GetGameWorld()
|
| | |
|
| | | if itemIDDropRateDict:
|
| | | GameWorld.DebugLog("itemIDDropRateDict=%s" % itemIDDropRateDict)
|
| | | |
| | | for itemID, dropRate in itemIDDropRateDict.items():
|
| | |
|
| | | if not dropRate:
|
| | |
| | | #GameWorld.DebugLog(" 指定判断: itemID=%s, dropRate=%s, doCnt=%s" % (itemID, dropRate, doCnt))
|
| | | for _ in xrange(doCnt):
|
| | | if not GameWorld.CanHappen(dropRate, maxRate=Def_NPCMaxDropRate):
|
| | | continue
|
| | | |
| | | if __dropIDCountLimitToday(curPlayer, itemID, itemDropLimitDayInfo):
|
| | | continue
|
| | |
|
| | | dropItemIDList.append(itemID)
|
| | |
| | | GameWorld.Log("全服击杀次数必掉随机物品: randItemID=%s,randItemCount=%s" % (randItemID, randItemCount))
|
| | |
|
| | | return dropItemIDList
|
| | |
|
| | | def __dropIDCountLimitToday(curPlayer, itemID, itemDropLimitDayInfo):
|
| | | ## 处理今日掉落物品ID个数限制
|
| | | # @return: 是否限制
|
| | | if itemID not in itemDropLimitDayInfo:
|
| | | return False
|
| | | dropCountTodayMax = itemDropLimitDayInfo[itemID]
|
| | | if not dropCountTodayMax:
|
| | | return False
|
| | | dropCountToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DropCountToday % itemID)
|
| | | if dropCountToday >= dropCountTodayMax:
|
| | | GameWorld.DebugLog(" 物品ID今日掉落次数已达上限: itemID=%s,dropCountToday=%s" % (itemID, dropCountToday), curPlayer.GetPlayerID())
|
| | | return True
|
| | | dropCountToday += 1
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DropCountToday % itemID, dropCountToday)
|
| | | GameWorld.DebugLog(" 更新物品ID今日掉落次数: itemID=%s,dropCountToday=%s" % (itemID, dropCountToday), curPlayer.GetPlayerID())
|
| | | return False
|
| | |
|
| | | def __GetEquipIDList(findID, classLV, color, isSuit, placeList, itemJobList, findType="NPC"):
|
| | | #存一个满足要求的所有的物品的列表 然后从当中随机选一个
|
| | |
| | | NetPackCommon.SendFakePack(curPlayer, npcIDCollInfo)
|
| | | return
|
| | |
|
| | | def PlayerOnDay(curPlayer):
|
| | | #采集次数重置
|
| | | CollNPCTimeOnDay(curPlayer)
|
| | | itemDropLimitDayInfo = IpyGameDataPY.GetFuncEvalCfg("ItemDropCountLimit", 2, {})
|
| | | for itemID in itemDropLimitDayInfo.keys():
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DropCountToday % itemID):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DropCountToday % itemID, 0)
|
| | | for color in range(20):
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DropColorToday % color):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DropColorToday % color, 0)
|
| | | return
|
| | |
|
| | | def CollNPCTimeOnDay(curPlayer):
|
| | | ## 采集NPCOnDay处理
|
| | | DoResetCollectNPCTimeByType(curPlayer, [1])
|