From 92422444e4113c2b525a74b5b3cc29ec0c9e309d Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 14 五月 2019 14:42:53 +0800 Subject: [PATCH] 6778 【后端】【2.0】任务接口开发(灵根品级相关) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py | 295 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 235 insertions(+), 60 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 fd34538..30c0148 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py @@ -50,6 +50,7 @@ import PlayerBossReborn import PlayerFairyCeremony import PlayerNewFairyCeremony +import GameLogic_CrossGrassland import PlayerWeekParty import PlayerActLogin import FamilyRobBoss @@ -94,8 +95,6 @@ #初始化处理间隔 curNPC.SetIsNeedProcess(False) - #设定致命一击伤害百分比 - curNPC.SetSuperHit(ChConfig.Def_SuperHitPercent) #初始化这个NPC的时钟 curNPC.SetTickTypeCount(ChConfig.TYPE_NPC_Tick_Count) return @@ -1223,7 +1222,7 @@ itemData = GameWorld.GetGameData().GetItemByTypeID(itemID) if not itemData: continue - itemJob = itemData.GetJobLimit() / 100 + itemJob = itemData.GetJobLimit() if itemJob and itemJob != curPlayer.GetJob(): # 非本职业可用,不掉落 GameWorld.DebugLog("全服击杀次数必掉,非本职业可用,不掉落! itemID=%s" % itemID) @@ -1237,7 +1236,7 @@ itemData = GameWorld.GetGameData().GetItemByTypeID(rItemID) if not itemData: continue - itemJob = itemData.GetJobLimit() / 100 + itemJob = itemData.GetJobLimit() if itemJob and itemJob != curPlayer.GetJob(): # 非本职业可用,不掉落 GameWorld.DebugLog("全服击杀次数必掉随机,非本职业可用,不掉落! rItemID=%s" % rItemID) @@ -1276,7 +1275,7 @@ if itemData.GetItemColor() != color: continue suiteID = itemData.GetSuiteID() - itemJob = itemData.GetJobLimit() / 100 + itemJob = itemData.GetJobLimit() itemPlace = itemData.GetEquipPlace() itemID = itemData.GetItemTypeID() if itemPlace not in filterItemIDDict: @@ -1402,7 +1401,7 @@ if not itemData: GameWorld.ErrLog("掉落物品ID不存在, dropItemID=%s" % dropItemID) continue - itemJob = itemData.GetJobLimit() / 100 + itemJob = itemData.GetJobLimit() if isJobLimit and itemJob and itemJob != curPlayer.GetJob(): # 非本职业可用,不掉落 #GameWorld.DebugLog("非本职业可用,不掉落! dropItemID=%s" % dropItemID) @@ -1941,6 +1940,67 @@ return +#// B4 0C 召唤私有专属木桩怪 #tagCMSummonPriWoodPile +# +#struct tagCMSummonPriWoodPile +#{ +# tagHead Head; +# DWORD NPCID; +# BYTE Count; //默认1个,最多5个 +#}; +def OnSummonPriWoodPile(index, clientData, tick): + curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) + npcID = clientData.NPCID + count = clientData.Count + SummonPriWoodPile(curPlayer, npcID, count) + return + +def SummonPriWoodPile(curPlayer, npcID, count): + ''' 召唤私有专属木桩怪 + ''' + + maxCount = 5 + nowCount = 0 + # 只允许存在一个私有木桩 + indexList = range(curPlayer.GetSummonCount()) + for index in indexList[::-1]: + summonNPC = curPlayer.GetSummonNPCAt(index) + if not summonNPC: + continue + npcType = summonNPC.GetType() + if npcType not in [ChConfig.ntPriWoodPilePVE, ChConfig.ntPriWoodPilePVP]: + continue + if nowCount >= maxCount or summonNPC.GetNPCID() != npcID: + SetDeadEx(summonNPC) + else: + nowCount += 1 + + summonCount = min(count, maxCount - nowCount) + #GameWorld.DebugLog("召唤: count=%s,maxCount=%s,nowCount=%s,summonCount=%s" + # % (count, maxCount, nowCount, summonCount)) + if summonCount <= 0: + return + + for _ in xrange(summonCount): + summonNPC = curPlayer.SummonNewNPC() + + #设置召唤兽基础信息 + summonNPC.SetNPCTypeID(npcID) + #初始化 + InitNPC(summonNPC) + + #玩家召唤兽列表添加召唤兽,召唤兽添加主人 + summonNPC.SetOwner(curPlayer) + summonNPC.SetDict(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID, curPlayer.GetPlayerID()) + + #将召唤兽召唤出来 + #玩家周围随机出生点 + #技能召唤坐标 ChConfig.Def_SummonAppearDist + summonPos = GameMap.GetEmptyPlaceInArea(curPlayer.GetPosX(), curPlayer.GetPosY(), 3) + summonNPC.Reborn(summonPos.GetPosX(), summonPos.GetPosY()) + + return + ## 设置npc死亡及自身处理(请不要将游戏逻辑加在此函数中) # @param curNPC:npc实例 # @return @@ -1995,31 +2055,34 @@ return def GameServer_KillGameWorldBoss(bossID, killPlayerName, hurtValue, isNotify=True, killerIDList=[]): - dataMapID = GameWorld.GetGameWorld().GetMapID() + mapID = GameWorld.GetGameWorld().GetMapID() realMapID = GameWorld.GetGameWorld().GetRealMapID() copyMapID = GameWorld.GetGameWorld().GetCopyMapID() - killMsg = str([bossID, killPlayerName, hurtValue, isNotify, realMapID, dataMapID, copyMapID, killerIDList]) + killMsg = str([bossID, killPlayerName, hurtValue, isNotify, mapID, realMapID, copyMapID, killerIDList]) GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'KillGameWorldBoss', killMsg, len(killMsg)) - GameWorld.DebugLog("Boss被击杀: bossID=%s,dataMapID=%s,realMapID=%s,copyMapID=%s,killerIDList=%s" % (bossID, dataMapID, realMapID, copyMapID, killerIDList)) + GameWorld.DebugLog("Boss被击杀: bossID=%s,mapID=%s,realMapID=%s,copyMapID=%s,killerIDList=%s" % (bossID, mapID, realMapID, copyMapID, killerIDList)) return def GameServe_GameWorldBossState(bossID, isAlive): - dataMapID = GameWorld.GetGameWorld().GetMapID() + mapID = GameWorld.GetGameWorld().GetMapID() realMapID = GameWorld.GetGameWorld().GetRealMapID() copyMapID = GameWorld.GetGameWorld().GetCopyMapID() - stateMsg = str([bossID, isAlive, dataMapID, realMapID, copyMapID]) + stateMsg = str([bossID, isAlive, mapID, realMapID, copyMapID]) GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'GameWorldBossState', '%s' % stateMsg, len(stateMsg)) - GameWorld.DebugLog("Boss状态变更: bossID=%s,isAlive=%s,dataMapID=%s,realMapID=%s,copyMapID=%s" - % (bossID, isAlive, dataMapID, realMapID, copyMapID)) + GameWorld.DebugLog("Boss状态变更: bossID=%s,isAlive=%s,mapID=%s,realMapID=%s,copyMapID=%s" + % (bossID, isAlive, mapID, realMapID, copyMapID)) if not isAlive: - if dataMapID in ChConfig.Def_CrossZoneMapTableName: - tableName = ChConfig.Def_CrossZoneMapTableName[dataMapID] + if mapID in ChConfig.Def_CrossZoneMapTableName: + tableName = ChConfig.Def_CrossZoneMapTableName[mapID] realMapID = GameWorld.GetGameWorld().GetRealMapID() copyMapID = GameWorld.GetGameWorld().GetCopyMapID() - zoneIpyData = IpyGameDataPY.GetIpyGameData(tableName, realMapID, dataMapID, copyMapID) + zoneIpyData = IpyGameDataPY.GetIpyGameData(tableName, realMapID, mapID, copyMapID) if not zoneIpyData: return zoneID = zoneIpyData.GetZoneID() + GameWorld.GetGameWorld().SetGameWorldDict(ShareDefine.Def_Notify_WorldKey_GameWorldBossRebornCross % (zoneID, bossID), 0) + elif mapID in ChConfig.Def_CrossDynamicLineMap: + zoneID = FBCommon.GetCrossDynamicLineMapZoneID() GameWorld.GetGameWorld().SetGameWorldDict(ShareDefine.Def_Notify_WorldKey_GameWorldBossRebornCross % (zoneID, bossID), 0) else: GameWorld.GetGameWorld().SetGameWorldDict(ShareDefine.Def_Notify_WorldKey_GameWorldBossReborn % bossID, 0) @@ -3553,14 +3616,13 @@ def DoHPPerLogic(self, dropType, ownerID): curNPC = self.__Instance curNPCID = curNPC.GetNPCID() - hpPerLogicNPCIDList = ReadChConfig.GetEvalChConfig('HPPerLogicNPCIDList') - if curNPCID not in hpPerLogicNPCIDList: + + hpPerLogicNPCIDDict = IpyGameDataPY.GetFuncEvalCfg('BossHPInformation', 1, {}) + hpPerLogicList = GameWorld.GetDictValueByKey(hpPerLogicNPCIDDict, curNPCID) + if not hpPerLogicList: return - - hpPerLogicDict = ReadChConfig.GetEvalChConfig('HPPerLogic_%s' % curNPCID) - - hpPerList = sorted(hpPerLogicDict.keys(), reverse=True) - + hpPerList, sysMark = hpPerLogicList + hpPerList = sorted(hpPerList, reverse=True) nowHPPer = GameObj.GetHP(curNPC) * 100 / GameObj.GetMaxHP(curNPC) # 当前百分比 hpPerLogicMark = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_HPPerLogicMark) logicHPPerList = hpPerList[hpPerLogicMark:] @@ -3573,16 +3635,12 @@ #GameWorld.DebugLog("DoHPPerLogic npcID=%s,hpPerLogicDict=%s,nowHPPer=%s,hpPerLogicMark=%s,logicHPPerList=%s" # % (curNPCID, str(hpPerLogicDict), nowHPPer, hpPerLogicMark, str(logicHPPerList))) - isNotify, dropItemTemplate, addPrestigeFormat = hpPerLogicDict[hpPer] - if isNotify: - PlayerControl.WorldNotify(0, "FB_liubo_0", [GameWorld.GetMap().GetMapID(), curNPCID, hpPer]) + + PlayerControl.WorldNotify(0, sysMark, [curNPCID, hpPer]) # if dropItemTemplate > 0: # self.__DropItemByTemplate(dropItemTemplate, dropType, ownerID) # PlayerControl.WorldNotify(0, "GeRen_admin_481766", [GameWorld.GetMap().GetMapID(), curNPCID, curNPCID]) - - if addPrestigeFormat != '': - self.__GiveNearbyPlayerPrestige(addPrestigeFormat, ChConfig.Def_Matrix_Six) hpPerLogicMark += 1 #GameWorld.DebugLog("DoHPPerLogic update hpPerLogicMark=%s" % (hpPerLogicMark)) @@ -3707,7 +3765,6 @@ ############################################ #初始化状态 curNPC.SetSpeed(curNPC.GetOrgSpeed()) - curNPC.SetSuperHit(ChConfig.Def_SuperHitPercent) curNPC.SetAtkInterval(curNPC.GetBaseAtkInterval()) # #先清空异常 @@ -3893,11 +3950,11 @@ #杀死NPC, 触发任务 self.__EventKillNpc() - #mapID = GameWorld.GetMap().GetMapID() + mapID = GameWorld.GetMap().GetMapID() killerName = "" if not self.__Killer else self.__Killer.GetPlayerName() # 记录boss击杀信息的NPC bossIpyData = IpyGameDataPY.GetIpyGameDataListNotLog('BOSSInfo', npcID) - if bossIpyData: + if bossIpyData and mapID not in [ChConfig.Def_FBMapID_ZhuXianBoss, ChConfig.Def_FBMapID_SealDemon]: if GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_Family: killerName = FamilyRobBoss.FamilyOwnerBossOnKilled(curNPC, self.__OwnerHurtID) #KillerJob = 0 if not self.__Killer else self.__Killer.GetJob() @@ -4101,10 +4158,10 @@ mapID = GameWorld.GetMap().GetMapID() mapID = FBCommon.GetRecordMapID(mapID) isGameBoss = ChConfig.IsGameBoss(curNPC) + if mapID in [ChConfig.Def_FBMapID_MunekadoTrial, ChConfig.Def_FBMapID_DemonKing]: + return if isGameBoss: GameWorld.Log("NPC开始掉落: npcID=%s,dropPlayerID=%s" % (npcID, dropPlayer.GetPlayerID()), dropPlayer.GetPlayerID()) - if mapID == ChConfig.Def_FBMapID_MunekadoTrial: - return ipyDrop = GetNPCDropIpyData(npcID) if not ipyDrop: if isGameBoss: @@ -5109,7 +5166,7 @@ tagObj = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer) elif dropOwnerType == ChConfig.DropOwnerType_Family: - ownerInfo = FamilyRobBoss.RefreshFamilyOwnerNPCHurt(curNPC, tick, refreshInterval) + ownerInfo = FamilyRobBoss.RefreshFamilyOwnerNPCHurt(self, curNPC, tick, refreshInterval) if ownerInfo: tagObj, ownerFamilyID = ownerInfo ownerType, ownerID = ChConfig.Def_NPCHurtTypeFamily, ownerFamilyID @@ -5174,7 +5231,7 @@ GameWorld.DebugLog("竞争归属玩家不在boss范围里,移除归属!playerID=%s" % ownerID) return - GameWorld.DebugLog("竞争归属玩家归属正常!playerID=%s" % ownerID) + #GameWorld.DebugLog("竞争归属玩家归属正常!playerID=%s" % ownerID) return owner def __GetMaxHurtTeamPlayer(self, teamID, isDead): @@ -5486,21 +5543,6 @@ return max(value / pow(10, nlen), 1) -Def_CollNPCCfg_Len = 10 -( -Def_CollNPCCfg_CanTogether, # 是否允许同时采集 -Def_CollNPCCfg_SysMsgMark, # 不可同时采集提示 -Def_CollNPCCfg_CostItemInfo, # 采集消耗物品信息 -Def_CollNPCCfg_PrepareTime, # 采集时间毫秒 -Def_CollNPCCfg_ExpFormat, # 获得经验公式 -Def_CollNPCCfg_MoneyFormat, # 获得金币公式 -Def_CollNPCCfg_ZhenQi, # 获得的真气/魔魂 -Def_CollNPCCfg_GiveItemModeID, # 获得的物品信息模板编号 -Def_CollNPCCfg_NotCostItemNotify, # 消耗品不足提示 -Def_CollNPCCfg_LimitSysMsgMark, #采集上限提示 -) = range(Def_CollNPCCfg_Len) - - def CheckCanCollectByNPCID(curPlayer, npcID, collectNPCIpyData): # 根据NPCID判断是否可以采集 @@ -5538,7 +5580,11 @@ npcID = curNPC.GetNPCID() collectNPCIpyData = IpyGameDataPY.GetIpyGameData("CollectNPC", npcID) if not collectNPCIpyData: - GameWorld.DebugLog("非特定采集NPC...") + #GameWorld.DebugLog("非特定采集NPC...") + return False + + if collectNPCIpyData.GetIsMissionCollectNPC(): + #GameWorld.DebugLog("任务采集物暂不处理") return False if not CheckCanCollectByNPCID(curPlayer, npcID, collectNPCIpyData): @@ -5641,6 +5687,10 @@ GameWorld.DebugLog(" 非特定采集NPC...npcID=%s" % npcID) return + if collectNPCIpyData.GetIsMissionCollectNPC(): + #GameWorld.DebugLog("任务采集物暂不处理") + return + PlayerState.DoCollectingLostHP(curPlayer, collectNPCIpyData, tick, True) if GameWorld.IsCrossServer(): @@ -5666,33 +5716,106 @@ DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData) return +#// A2 34 自定义场景中获取采集奖励 #tagCMGetCustomSceneCollectAward +# +#struct tagCMGetCustomSceneCollectAward +#{ +# tagHead Head; +# DWORD NPCID; //采集的NPCID +#}; +def OnGetCustomSceneCollectAward(index, clientData, tick): + curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) + npcID = clientData.NPCID + if not curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene): + GameWorld.DebugLog("非自定义场景中,无法获取定义采集奖励!") + return + collectNPCIpyData = IpyGameDataPY.GetIpyGameData("CollectNPC", npcID) + if collectNPCIpyData: + DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData) + return + def DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData, collectCnt=1): GameWorld.DebugLog("给采集奖励: npcID=%s,collectCnt=%s" % (npcID, collectCnt)) if collectCnt <= 0: return + + if collectNPCIpyData.GetIsMissionCollectNPC(): + #GameWorld.DebugLog("任务采集物暂不处理") + return + isMaxTime = False # 是否达到了采集最大次数 limitMaxTime = collectNPCIpyData.GetMaxCollectCount() if limitMaxTime > 0: todayCollTime = GetTodayCollectCount(curPlayer, npcID) canCollectCnt = max(0, limitMaxTime - todayCollTime) collectCnt = min(collectCnt, canCollectCnt) if collectCnt <= 0: - GameWorld.DebugLog(" 该NPC已达到最大采集次数: todayCollTime=%s,limitMaxTime=%s" % (todayCollTime, limitMaxTime)) + GameWorld.DebugLog(" 该NPC已达到最大采集次数: npcID=%s,todayCollTime=%s,limitMaxTime=%s" % (npcID, todayCollTime, limitMaxTime)) return - updCollTime = todayCollTime + collectCnt + curCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID) + updCollTime = curCollTime + collectCnt PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, updCollTime) SyncCollNPCTime(curPlayer, [npcID]) - GameWorld.DebugLog(" 增加当日采集次数: todayCollTime=%s,updCollTime=%s" % (todayCollTime, updCollTime)) - - giveItemList = collectNPCIpyData.GetCollectAward() - if giveItemList: - itemID, itemCount, isAuctionItem = giveItemList - ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem]) + GameWorld.DebugLog(" 增加采集次数: npcID=%s,todayCollTime=%s,curCollTime=%s,updCollTime=%s" % (npcID, todayCollTime, curCollTime, updCollTime)) + isMaxTime = todayCollTime + collectCnt >= limitMaxTime + + awardItemList = [] + collectAwardCfg = collectNPCIpyData.GetCollectAward() + collectAppointAwardCfg = collectNPCIpyData.GetCollectAppointAward() + if collectAppointAwardCfg: + collTotalTime = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTimeTotal % npcID) + 1, ChConfig.Def_UpperLimit_DWord) + if collTotalTime in collectAppointAwardCfg: + awardItemList.append(collectAppointAwardCfg[collTotalTime]) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTimeTotal % npcID, collTotalTime) + GameWorld.DebugLog(" 采集次数定制奖励: collTotalTime=%s,awardItemList=%s" % (collTotalTime, awardItemList)) + + if not awardItemList: + alchemyDiffLV = collectNPCIpyData.GetAlchemyDiffLV() + giveItemWeightList = [] + if alchemyDiffLV: + curAlchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV) + for itemInfo in collectAwardCfg: + itemID = itemInfo[1][0] + itemData = GameWorld.GetGameData().GetItemByTypeID(itemID) + if not itemData: + continue + if ItemCommon.GetItemClassLV(itemData) > curAlchemyLV + alchemyDiffLV: + continue + giveItemWeightList.append(itemInfo) + else: + giveItemWeightList = collectAwardCfg + + GameWorld.DebugLog(" 常规采集物品权重列表: alchemyDiffLV=%s,collectAwardCfg=%s,giveItemWeightList=%s" % (alchemyDiffLV, collectAwardCfg, giveItemWeightList)) + giveItemInfo = GameWorld.GetResultByWeightList(giveItemWeightList) + if giveItemInfo: + awardItemList.append(giveItemInfo) + + GameWorld.DebugLog(" 最终采集奖励: awardItemList=%s" % awardItemList) + if awardItemList: + for itemID, itemCount, isAuctionItem in awardItemList: + ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem]) + if collectNPCIpyData.GetNotifyCollectResult(): + awardPack = ChPyNetSendPack.tagMCCollectAwardItemInfo() + awardPack.CollectNPCID = npcID + for itemID, itemCount, isAuctionItem in awardItemList: + awardItem = ChPyNetSendPack.tagMCCollectAwardItem() + awardItem.ItemID = itemID + awardItem.Count = itemCount + awardItem.IsAuctionItem = isAuctionItem + awardPack.AwardItemList.append(awardItem) + awardPack.Count = len(awardPack.AwardItemList) + NetPackCommon.SendFakePack(curPlayer, awardPack) + else: + GameWorld.ErrLog("采集物品没有奖励!npcID=%s" % (npcID)) #采集成就 PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Collect, collectCnt, [npcID]) #SyncCollectionItemInfo(curPlayer, addExp, addMoney, addZhenQi, giveItemInfoList, npcID) + + if isMaxTime: + GameLogic_CrossGrassland.DoCheckUpdateGrasslandEnd(curPlayer) + return ## 采集结果同步 @@ -5739,11 +5862,20 @@ def CollNPCTimeOnDay(curPlayer): ## 采集NPCOnDay处理 + DoResetCollectNPCTimeByType(curPlayer, [1]) + return + +def DoResetCollectNPCTimeByType(curPlayer, resetTypeList=[]): + '''重置采集物采集次数 + 重置类型: 0-不重置,1-每日5点,12-灵草园重置,14-仙草园重置 + ''' resetNPCIDList = [] ipyDataMgr = IpyGameDataPY.IPY_Data() for index in xrange(ipyDataMgr.GetCollectNPCCount()): ipyData = ipyDataMgr.GetCollectNPCByIndex(index) npcID = ipyData.GetNPCID() + if resetTypeList and ipyData.GetCollectResetType() not in resetTypeList: + continue if not ipyData.GetMaxCollectCount(): continue if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID): @@ -5752,6 +5884,7 @@ resetNPCIDList.append(npcID) if resetNPCIDList: + #GameWorld.DebugLog("重置采集次数: resetTypeList=%s,resetNPCIDList=%s" % (resetTypeList, resetNPCIDList), curPlayer.GetPlayerID()) SyncCollNPCTime(curPlayer, resetNPCIDList) return @@ -6044,3 +6177,45 @@ sendPack.Value = speed curNPC.NotifyAll(sendPack.GetBuffer(), sendPack.GetLength()) return + +def UpdateNPCAttackCount(curPlayer, npcID, attackCount, maxCount=0): + ## 更新玩家攻击NPC次数 + GameWorld.DebugLog("更新玩家攻击NPC次数: npcID=%s,attackCount=%s,maxCount=%s" % (npcID, attackCount, maxCount)) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NPCAttackCount % npcID, attackCount) + + if GameWorld.IsCrossServer(): + serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer) + msgInfo = {"PlayerID":curPlayer.GetPlayerID(), "NPCID":npcID, "AttackCount":attackCount, "MaxCount":maxCount} + GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_NPCAttackCount, msgInfo, [serverGroupID]) + else: + SyncNPCAttackCount(curPlayer, [npcID]) + if attackCount and attackCount >= maxCount: + GameLogic_CrossGrassland.DoCheckUpdateGrasslandEnd(curPlayer) + return + +def CrossServerMsg_NPCAttackCount(curPlayer, msgData): + ## 收到跨服服务器同步的攻击NPC次数 + npcID = msgData["NPCID"] + attackCount = msgData["AttackCount"] + maxCount = msgData["MaxCount"] + UpdateNPCAttackCount(curPlayer, npcID, attackCount, maxCount) + return + +def SyncNPCAttackCount(curPlayer, npcIDList): + ## 同步NPC攻击次数 + if not npcIDList: + return + + clientPack = ChPyNetSendPack.tagMCNPCAttackCountInfo() + for npcID in npcIDList: + attackCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NPCAttackCount % npcID) + atkCountObj = ChPyNetSendPack.tagMCNPCAttackCount() + atkCountObj.NPCID = npcID + atkCountObj.AttackCount = attackCount + clientPack.NPCAttackCountList.append(atkCountObj) + clientPack.Count = len(clientPack.NPCAttackCountList) + NetPackCommon.SendFakePack(curPlayer, clientPack) + return + + + \ No newline at end of file -- Gitblit v1.8.0