From b60fd3b8a91432c1491f0c017fc90735dd28ebcf Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期五, 11 一月 2019 20:34:44 +0800 Subject: [PATCH] 5722 【后端】【1.5】跨服BOSS开发(宝箱怪物刷新、跨服地图NPC个数查询支持) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py | 149 ++++++++++++++++++++++--------------------------- 1 files changed, 66 insertions(+), 83 deletions(-) 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 5334251..7229e00 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py @@ -5275,21 +5275,9 @@ # 采集次数判断 limitMaxTime, todayCollTime = 0, 0 - npcFuncType = curNPC.GetFunctionType() - npcFuncCollectCntLimitDict = ReadChConfig.GetEvalChConfig('CollectNPCFuncTimeLimit') - if npcFuncType in npcFuncCollectCntLimitDict: - vipLV = curPlayer.GetVIPLv() - limitMaxTime = eval(npcFuncCollectCntLimitDict[npcFuncType]) - todayBuyTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcBuyTime % npcFuncType) - todayCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcCollTime % npcFuncType) - limitMaxTime += todayBuyTime - GameWorld.DebugLog(" vipLV=%s,maxTime=%s,todayTime=%s,todayBuyTime=%s" % (vipLV, limitMaxTime, todayCollTime, todayBuyTime)) - - npcIDCollectCntLimitDict = ReadChConfig.GetEvalChConfig("CollectNPCIDTimeLimit") - if npcID in npcIDCollectCntLimitDict: - limitMaxTime = npcIDCollectCntLimitDict[npcID][0] - todayCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID) - GameWorld.DebugLog(" maxTime=%s,todayTime=%s" % (limitMaxTime, todayCollTime)) + collLimitInfo = GetCollTimeLimitInfo(curPlayer, npcID) + if collLimitInfo: + limitMaxTime, todayCollTime = collLimitInfo if limitMaxTime > 0 and todayCollTime >= limitMaxTime: @@ -5338,6 +5326,19 @@ AttackCommon.AddHurtValue(curNPC, curPlayer.GetPlayerID(), ChConfig.Def_NPCHurtTypePlayer, 1) return +def GetCollTimeLimitInfo(curPlayer, npcID): + ## 获取采集次数限制信息 + npcIDCollectCntLimitDict = ReadChConfig.GetEvalChConfig("CollectNPCIDTimeLimit") + for npcIDTuple in npcIDCollectCntLimitDict.keys(): + if npcID not in npcIDTuple: + continue + limitMaxTime = npcIDCollectCntLimitDict[npcIDTuple][0] + todayCollTime = 0 + for collNPCID in npcIDTuple: + todayCollTime += curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % collNPCID) + GameWorld.DebugLog(" limitMaxTime=%s,todayCollTime=%s" % (limitMaxTime, todayCollTime)) + return limitMaxTime, todayCollTime + return ## 设置玩家采集该NPC # @param curPlayer:玩家实例 @@ -5422,11 +5423,11 @@ openCnt = clientData.OpenCnt isAutoBuy = clientData.IsAutoBuy isOnlyGold = clientData.IsOnlyGold - npcIDCollectCntLimitDict = ReadChConfig.GetEvalChConfig("CollectNPCIDTimeLimit") - if npcID not in npcIDCollectCntLimitDict: + curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) + collLimitInfo = GetCollTimeLimitInfo(curPlayer, npcID) + if not collLimitInfo: GameWorld.DebugLog("该NPC不是自定义采集NPC箱子, 不可开启! npcID=%s" % npcID) return - curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) GameWorld.DebugLog("OnOpenCollNPCBox...npcID=%s,openCnt=%s,isAutoBuy=%s" % (npcID, openCnt, isAutoBuy)) DoGetCollectionNPCAwardLogic(curPlayer, npcID, isAutoBuy, openCnt, mapID, isOnlyGold) return @@ -5456,22 +5457,14 @@ curNPC = GameWorld.GetGameData().FindNPCDataByID(npcID) if not curNPC: return True - - # 根据NPC功能号 - npcFuncType = curNPC.GetFunctionType() - npcFuncCollectCntLimitDict = ReadChConfig.GetEvalChConfig('CollectNPCFuncTimeLimit') + limitMaxTime = 0 # 0表示不限制次数 todayCollTime = 0 - if npcFuncType in npcFuncCollectCntLimitDict: - vipLV = curPlayer.GetVIPLv() - todayCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcCollTime % npcFuncType) - limitMaxTime = eval(npcFuncCollectCntLimitDict[npcFuncType]) # 根据NPCID - npcIDCollectCntLimitDict = ReadChConfig.GetEvalChConfig("CollectNPCIDTimeLimit") - if npcID in npcIDCollectCntLimitDict: - limitMaxTime = npcIDCollectCntLimitDict[npcID][0] - todayCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID) + collLimitInfo = GetCollTimeLimitInfo(curPlayer, npcID) + if collLimitInfo: + limitMaxTime, todayCollTime = collLimitInfo if limitMaxTime > 0: canCollectCnt = max(0, limitMaxTime - todayCollTime) @@ -5573,20 +5566,13 @@ % (unCostCnt, itemGold, reduceGold), curPlayer.GetPlayerID()) # 增加当日采集次数 - if limitMaxTime > 0: + if collLimitInfo: updCollTime = todayCollTime + successCnt - npcFuncType = curNPC.GetFunctionType() - npcFuncCollectCntLimitDict = ReadChConfig.GetEvalChConfig('CollectNPCFuncTimeLimit') - if npcFuncType in npcFuncCollectCntLimitDict: - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcCollTime % npcFuncType, updCollTime) - SyncCollNPCTime(curPlayer, [npcFuncType]) - - if npcID in npcIDCollectCntLimitDict: - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, updCollTime) - SyncCollNPCTime(curPlayer, npcIDList=[npcID]) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, updCollTime) + SyncCollNPCTime(curPlayer, npcIDList=[npcID]) GameWorld.DebugLog(" 增加当日采集次数: todayCollTime=%s,updCollTime=%s" % (todayCollTime, updCollTime)) - #采集成就 - PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Collect, successCnt, [npcID]) + #采集成就 + PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Collect, successCnt, [npcID]) SyncCollectionItemInfo(curPlayer, addExp, addMoney, addZhenQi, giveItemInfoList, npcID) #DataRecordPack.DR_CollectNPCOK(curPlayer, npcID, addMoney, addExp, addZhenQi, giveItemInfoList) return True @@ -5763,24 +5749,11 @@ # @param funcType:功能号,默认为0,即同步配表中全部 # @return None def SyncCollNPCTime(curPlayer, funcTypeList=[], npcIDList=[]): - if not funcTypeList: - npcFuncCollectCntLimitDict = ReadChConfig.GetEvalChConfig('CollectNPCFuncTimeLimit') - funcTypeList = npcFuncCollectCntLimitDict.keys() - if not npcIDList: collectNPCIDTimeLimit = ReadChConfig.GetEvalChConfig('CollectNPCIDTimeLimit') - npcIDList = collectNPCIDTimeLimit.keys() - -# if funcTypeList: -# collection = ChPyNetSendPack.tagMCFuncNPCCollectionCnt() -# for fType in funcTypeList: -# todayCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcCollTime % fType) -# collection.Clear() -# collection.FuncType = fType -# collection.CollectionCnt = todayCollTime -# collection.BuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcBuyTime % fType) -# NetPackCommon.SendFakePack(curPlayer, collection) - + for npcIDTuple in collectNPCIDTimeLimit.keys(): + npcIDList += list(npcIDTuple) + if npcIDList: npcIDCollInfo = ChPyNetSendPack.tagMCNPCIDCollectionCntInfo() npcIDCollInfo.Clear() @@ -5800,18 +5773,13 @@ # @param curPlayer:玩家实例 # @return None def CollNPCTimeOnDay(curPlayer, funcTypeList=[]): - npcFuncCollectCntLimitDict = ReadChConfig.GetEvalChConfig('CollectNPCFuncTimeLimit') - funcTypeList = npcFuncCollectCntLimitDict.keys() if not funcTypeList else funcTypeList - for funcType in funcTypeList: - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcCollTime % funcType, 0) - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcBuyTime % funcType, 0) - collectNPCIDTimeLimit = ReadChConfig.GetEvalChConfig('CollectNPCIDTimeLimit') - for npcID, collCntInfo in collectNPCIDTimeLimit.items(): + for npcIDTuple, collCntInfo in collectNPCIDTimeLimit.items(): isResetOnDay = collCntInfo[1] if not isResetOnDay: continue - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, 0) + for npcID in npcIDTuple: + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, 0) SyncCollNPCTime(curPlayer) return @@ -5899,28 +5867,43 @@ # @param queryNPCIDList:查询的NPCID列表 # @param tick # @return {NPCID:cnt} -def GetNPCCntInfo(queryNPCIDList, tick): +def GetNPCCntInfo(queryNPCIDList, tick, copyMapID=None): npcCntDict = {} - if not queryNPCIDList: - return npcCntDict + #if not queryNPCIDList: + # return npcCntDict gameNPCManager = GameWorld.GetNPCManager() GameWorld.DebugLog("GetNPCCntInfo...queryNPCIDList=%s" % (str(queryNPCIDList))) - - for index in xrange(gameNPCManager.GetNPCCount()): - curNPC = gameNPCManager.GetNPCByIndex(index) - curID = curNPC.GetID() - if curID == 0: - continue - - curNPCID = curNPC.GetNPCID() - - if curNPCID not in queryNPCIDList: - continue - if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or not curNPC.IsAlive(): - continue - npcCntDict[curNPCID] = npcCntDict.get(curNPCID, 0) + 1 + + if isinstance(copyMapID, int): + for index in xrange(gameNPCManager.GetNPCCountByGWIndex(copyMapID)): + curNPC = gameNPCManager.GetNPCByIndexByGWIndex(copyMapID, index) + curID = curNPC.GetID() + if curID == 0: + continue + + curNPCID = curNPC.GetNPCID() + + if queryNPCIDList and curNPCID not in queryNPCIDList: + continue + if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or not curNPC.IsAlive(): + continue + npcCntDict[curNPCID] = npcCntDict.get(curNPCID, 0) + 1 + else: + for index in xrange(gameNPCManager.GetNPCCount()): + curNPC = gameNPCManager.GetNPCByIndex(index) + curID = curNPC.GetID() + if curID == 0: + continue + + curNPCID = curNPC.GetNPCID() + + if queryNPCIDList and curNPCID not in queryNPCIDList: + continue + if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or not curNPC.IsAlive(): + continue + npcCntDict[curNPCID] = npcCntDict.get(curNPCID, 0) + 1 GameWorld.DebugLog(" npcCntDict=%s" % (str(npcCntDict))) return npcCntDict -- Gitblit v1.8.0