#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package GameWorldLogic.FBProcess.GameLogic_ZhuXianBoss # # @todo:ÖïÏÉboss # @author xdh # @date 2019-01-18 # @version 1.0 # # ÏêϸÃèÊö: ÖïÏÉboss # #------------------------------------------------------------------------------- #"""Version = 2019-01-18 14:30""" #------------------------------------------------------------------------------- import FBCommon import GameWorld import IPY_GameWorld import GameWorldProcess import IpyGameDataPY import ChConfig import PyGameData import PlayerControl import NPCCommon import ItemCommon import ChPyNetSendPack import ShareDefine import PlayerSuccess import PlayerActivity import NetPackCommon import ItemControler import EventReport FBDict_StartTick = 'FBDict_StartTick%s' #¿ªÊ¼Ê±¼ä FBDict_Speed = 'FBDict_Speed%s' #µôѪËÙ¶È /s FBDict_RemainHP = 'FBDict_RemainHP%s' #Ê£Óàʱ¼ä FBPlayerDict_EncourageLV = 'FBPlayerDict_EncourageLV' # ¹ÄÎèµÈ¼¶ FBDict_IsOver = 'FBDict_IsOver' #ÊÇ·ñÒѽáËã, ½áËãʱµÄtick FBDict_IsReduceing = 'FBDict_IsReduceing%s' #ÊÇ·ñµôѪÖÐ FBPlayerDict_Rank = "FBPlayerDict_Rank" # Íæ¼ÒÅÅÃû FBDict_BossTotalHP = 'FBDict_BossTotalHP%s' #BOSSѪÁ¿ g_heroHurtDict = {} #{playerID:hurt} def OnFBPlayerOnLogin(curPlayer): NotifyZXHelpCnt(curPlayer) return def OnFBPlayerOnDay(curPlayer): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ZhuXianBossHelpCnt, IpyGameDataPY.GetFuncCfg('ZhuXianBossCntCfg', 3)) NotifyZXHelpCnt(curPlayer) return def NotifyZXHelpCnt(curPlayer): ##֪ͨЭÖú´ÎÊý packData = ChPyNetSendPack.tagMCZhuXianBossCnt() packData.Cnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhuXianBossHelpCnt) NetPackCommon.SendFakePack(curPlayer, packData) return ## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë # @param curPlayer Íæ¼ÒʵÀý # @param mapID µØÍ¼ID # @param lineID Ïß·id # @param tick ʱ¼ä´Á # @return ²¼¶ûÖµ def OnEnterFBEvent(curPlayer, mapID, lineID, tick): #¾³½çÒªÇó¡¢ÖïÏÉ×ÜÆÀ·Ö¡¢Íæ¼ÒµÈ¼¶¡¢¹éÊô´ÎÊý²»Îª0»òÓÐͬÃËÍæ¼ÒÔÚ¸±±¾ÀïЭÖú´ÎÊý²»Îª0 ipyData = IpyGameDataPY.GetIpyGameData('ZhuXianBoss', lineID) if not ipyData: return if curPlayer.GetOfficialRank() < ipyData.GetRealmLV(): return #ÖïÏÉ×ÜÆÀ·Ö if ItemCommon.GetZhuXianEquipTotalGS(curPlayer) < ipyData.GetZhuXianScore(): return enterCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_EnterFbCntDay % ChConfig.Def_FBMapID_ZhuXianBoss) if enterCnt >= FBCommon.GetEnterFBMaxCnt(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss): if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhuXianBossHelpCnt): return if not curPlayer.GetFamilyID(): GameWorld.DebugLog(" ÓйéÊô´ÎÊýΪµ«Ã»ÓнøÏÉÃË!", curPlayer.GetPlayerID()) return return True def GetHasSameFamilyMerber(curFamilyID, playerManager): ##¸±±¾ÀïÊÇ·ñÓÐͬÃ˳ÉÔ± GameWorld.Log('¼ì²é¸±±¾ÀïÊÇ·ñÓÐͬÃ˳ÉÔ± curFamilyID=%s'%curFamilyID) if not curFamilyID: return for index in range(0 , playerManager.GetPlayerCount()): player = playerManager.GetPlayerByIndex(index) if not player.GetPlayerID(): continue if player.GetFamilyID() == curFamilyID: return True return ##¸±±¾Íæ¼Ò½øÈëµã # @param curPlayer Íæ¼ÒʵÀý # @param mapID µØÍ¼ID # @param lineId ·ÖÏßID # @param ipyEnterPosInfo ¹¦ÄÜÏß·IPYÅäÖÃ×ø±êÐÅÏ¢ # @param tick ʱ¼ä´Á # @return posX, posY, Ëæ»ú°ë¾¶(¿ÉÑ¡) def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick): return ipyEnterPosInfo ### ²éѯµØÍ¼ÊÇ·ñ¿ªÆô ## @param tick ʱ¼ä´Á ## @return ²¼¶ûÖµ #def OnCanOpen(tick): # return True ##²éѯÊÇ·ñ¿ÉÒÔ½øÈëµØÍ¼ # @param ask:ÇëÇó½á¹¹Ìå(IPY_BMChangeMapAsk) # @param tick:ʱ¼ä´Á # @return IPY_GameWorld.cme ö¾Ù def OnChangeMapAsk(ask, tick): return IPY_GameWorld.cmeAccept ##¿ªÆô¸±±¾ # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÎÞÒâÒå # @remarks ¿ªÆô¸±±¾ def OnOpenFB(tick): lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 bossID = CurFBLineBOSSID(lineID) if not bossID: return key = ShareDefine.Def_Notify_WorldKey_GameWorldBossReborn % bossID GameWorld.GetGameWorld().SetGameWorldDict(key, 1) GameWorld.DebugLog(' Ë¢BOSSbossID=%s' % bossID) ipyData = IpyGameDataPY.GetIpyGameData('ZhuXianBoss', lineID) GameWorld.GetGameWorld().SetGameWorldDict(FBDict_BossTotalHP%lineID, ipyData.GetKillTime() * 1000) return ## ½ø¸±±¾ # @param curPlayer # @param tick # @return None def DoEnterFB(curPlayer, tick): global g_heroHurtDict playerID = curPlayer.GetPlayerID() lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 playerCnt = GameWorld.GetGameWorld().GetMapCopyPlayerManager().GetPlayerCount() GameWorld.DebugLog("DoEnterFB...playerCnt=%s,lineID=%s" % (playerCnt, lineID), playerID) if lineID < 0: PlayerControl.PlayerLeaveFB(curPlayer) return hadDelTicket = FBCommon.GetHadDelTicket(curPlayer) if not hadDelTicket: FBCommon.SetHadDelTicket(curPlayer) PyGameData.g_fbPickUpItemDict.pop(playerID, 0) g_heroHurtDict.pop(playerID, 0) # if playerCnt == 1: # posX, posY = IpyGameDataPY.GetFuncEvalCfg('ZhuXianBossFirstPos') # GameWorld.ResetPlayerPos(curPlayer, posX, posY) EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, 0, ChConfig.CME_Log_Start) UpdateHurtInfo(curPlayer, 0, True) UpdateHPReduceSpeed(tick) gameFB = GameWorld.GetGameFB() # ÉϹÄÎèbuff encourageLV = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_EncourageLV) if encourageLV > 0: FBCommon.AddFbEncourageBuff(curPlayer, FBPlayerDict_EncourageLV, tick) else: FBCommon.SendFBEncourageInfo(curPlayer, encourageLV) #DoFBHelp(curPlayer, tick) return ##¹Ø±Õ¸±±¾ # @param tick ʱ¼ä´Á # @return ÎÞÒâÒå # @remarks def OnCloseFB(tick): gameWorld = GameWorld.GetGameWorld() lineID = gameWorld.GetPropertyID() - 1 gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, 0) gameWorld.SetGameWorldDict(FBDict_Speed % lineID, 0) gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, 0) gameWorld.SetPropertyID(0) return ##Íæ¼ÒÍ˳ö¸±±¾ # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ÎÞÒâÒå def DoExitFB(curPlayer, tick): gameWorld = GameWorld.GetGameWorld() # Çå³ý¹ÄÎèbuff FBCommon.ClearEncourageBuff(curPlayer, tick) #×îºóÒ»ÈË if gameWorld.GetMapCopyPlayerManager().GetPlayerCount() == 1: lineID = gameWorld.GetPropertyID() - 1 PyGameData.g_ZhuXianBossPlayerHurtDict[lineID] = {} gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, 0) GameWorld.GetGameFB().ClearGameFBDict() GameWorldProcess.CloseFB(tick) return UpdateHPReduceSpeed(tick, True) return ##Íæ¼ÒÖ÷¶¯À뿪¸±±¾. # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÎÞÒâÒå def DoPlayerLeaveFB(curPlayer, tick): FBCommon.SetHadDelTicket(curPlayer, 0) #Ö÷¶¯Í˳öµÄÈ¥µôÅÅÐаñÐÅÏ¢ lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 playerHurtDict = PyGameData.g_ZhuXianBossPlayerHurtDict.get(lineID, {}) playerHurtDict.pop(curPlayer.GetPlayerID(), 0) PyGameData.g_ZhuXianBossPlayerHurtDict[lineID] = playerHurtDict if not playerHurtDict: #°ñÉÏûÈË£¬Í£Ö¹µôѪ StopReduceHP(lineID, tick) return ##Íæ¼ÒÇл»µØÍ¼ def DoPlayerChangeMapLogic(curPlayer): FBCommon.SetHadDelTicket(curPlayer, 0) return ## ÊÇ·ñ¸±±¾¸´»î # @param None # @return ÊÇ·ñ¸±±¾¸´»î def OnPlayerReborn(): return True ## »ñµÃ¸±±¾°ïÖúÐÅÏ¢ # @param curPlayer µ±Ç°Íæ¼Ò£¨±»Í¨Öª¶ÔÏó£© # @param tick µ±Ç°Ê±¼ä # @return None def DoFBHelp(curPlayer, tick): #É˺¦ÅÅÐÐÐÅÏ¢ if GameWorld.GetGameFB().GetGameFBDictByKey(FBDict_IsOver): return hurtInfo = [] lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 playerHurtList = PyGameData.g_ZhuXianBossPlayerHurtDict.get(lineID, {}).items() syncHurtList = playerHurtList[:5] syncHurtList.sort(key=lambda asd:asd[1][1], reverse=True) for i, info in enumerate(syncHurtList, 1): playerName, hurt = info[1][:2] hurtDict = {} hurtDict["rank"] = i hurtDict["playerName"] = playerName hurtDict["hurt"] = hurt % ChConfig.Def_PerPointValue hurtDict["hurtEx"] = hurt / ChConfig.Def_PerPointValue hurtInfo.append(hurtDict) # myRank = __GetSelfHurtRank(curPlayer) # if myRank and myRank > 5: # hurtDict = {} # hurtDict["rank"] = myRank # info = playerHurtList[myRank - 1] # playerName, hurt = info[1][:2] # hurtDict["playerName"] = playerName # hurtDict["hurt"] = hurt % ChConfig.Def_PerPointValue # hurtDict["hurtEx"] = hurt / ChConfig.Def_PerPointValue # hurtInfo.append(hurtDict) curSpeed = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_Speed % lineID) isReduceing = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_IsReduceing % lineID) remainHP = GetBossRemainHP(lineID, tick) totalHP = __GetBossTotalHP(lineID) hpReduceSpeed = curSpeed * 10000 / totalHP if totalHP else 0 remainHPPer = min(100, remainHP * 100 / totalHP) if totalHP else 0 myHurt = g_heroHurtDict.get(curPlayer.GetID(), 0) fbHelpDict = {FBCommon.Help_lineID:lineID, "hurtInfo":hurtInfo, 'hpReduceSpeed':hpReduceSpeed, 'remainHPPer':remainHPPer, 'isReduceing':isReduceing,'myHurt':myHurt % ChConfig.Def_PerPointValue, 'myHurtEx':myHurt / ChConfig.Def_PerPointValue } GameWorld.DebugLog("DoFBHelp: %s" % fbHelpDict, curPlayer.GetPlayerID()) FBCommon.Notify_FBHelp(curPlayer, fbHelpDict) return def __GetSelfHurtRank(curPlayer): #»ñÈ¡×Ô¼ºµÄÅÅÃû playerName = curPlayer.GetName() lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 playerHurtList = __GetSortHurtList(lineID) myRank = 0 for i, info in enumerate(playerHurtList): if playerName == info[1][0]: myRank = i + 1 break return myRank ## ¸±±¾ÐÐΪ # @param curPlayer Íæ¼Ò # @param actionType ÐÐΪÀàÐÍ # @param actionInfo ÐÐΪÐÅÏ¢ # @param tick µ±Ç°Ê±¼ä # @return None def DoFBAction(curPlayer, actionType, actionInfo, tick): if actionType == 0: FBCommon.FbEncourageBuff(curPlayer, FBPlayerDict_EncourageLV, actionInfo, tick) return ## Íæ¼Ò¶ÔNPCÔì³ÉÉ˺¦ # @param curPlayer µ±Ç°Íæ¼Ò # @param curNPC # @param hurtHP # @return None def DoFB_Player_HurtNPC(curPlayer, curNPC, hurtHP): UpdateHurtInfo(curPlayer, hurtHP) return # def UpdateHurtInfo(curPlayer, hurtHP, isAdd=False): global g_heroHurtDict playerID = curPlayer.GetPlayerID() g_heroHurtDict[playerID] = g_heroHurtDict.get(playerID, 0) + hurtHP enterCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_EnterFbCntDay % ChConfig.Def_FBMapID_ZhuXianBoss) if enterCnt >= FBCommon.GetEnterFBMaxCnt(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss): #û¹éÊôµÄ²»½øÉ˺¦°ñ return lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 playerName = curPlayer.GetName() familyID = curPlayer.GetFamilyID() playerHurtDict = PyGameData.g_ZhuXianBossPlayerHurtDict.get(lineID, {}) if playerID not in playerHurtDict: if not isAdd: return playerHurtDict[playerID] = [playerName, hurtHP, familyID] else: playerHurtDict[playerID][1] += hurtHP PyGameData.g_ZhuXianBossPlayerHurtDict[lineID] = playerHurtDict #ÓÐÈËÉϰñ¿ªÊ¼µôѪ StartReduceHP(lineID, GameWorld.GetGameWorld().GetTick()) return ##---¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷--- # @param tick:ʱ¼ä´Á # @return ÎÞÒâÒå # @remarks ¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷ def OnProcess(tick): gameFB = GameWorld.GetGameFB() overTick = gameFB.GetGameFBDictByKey(FBDict_IsOver) # ½áËã20ÃëºóÇ¿ÖÆ¹Ø±Õ¸±±¾, ·ÀÖ¹Íæ¼Ò²»¼ñ¶«Î÷µ¼Ö²»½áË㣬ǿ¹ØºóµØ°åÉϵĶ«Î÷»áÓʼþ·¢·Å¸øÍæ¼Ò if overTick and tick - overTick >= ChConfig.Def_FBPickupItemTime: GameWorld.Log("Ç¿ÖÆÌß³öÍæ¼Ò¹Ø±Õ¸±±¾: overTick=%s,tick=%s" % (overTick, tick)) FBCommon.DoLogic_FBKickAllPlayer() return lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 if lineID <0: return gameWorld = GameWorld.GetGameWorld() startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID) if not startTick or overTick: return FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 5000) __CheckBossHP(tick) return def __GetSortHurtList(lineID): playerHurtDict = PyGameData.g_ZhuXianBossPlayerHurtDict.get(lineID, {}) playerHurtList = sorted(playerHurtDict.iteritems(), key=lambda asd:asd[1][1], reverse=True) return playerHurtList def GetFirstOwnerName(lineID): ##»ñÈ¡¹éÊôÕßÃû×Ö playerHurtList = __GetSortHurtList(lineID) if not playerHurtList: return '' return playerHurtList[0][1][0] def __DoLogicZhuXianBossOver(isPass, tick, dropPosX, dropPosY): #½áËã gameFB = GameWorld.GetGameFB() mapID = GameWorld.GetMap().GetMapID() lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 leaveTick = FBCommon.GetFBLineStepTime(mapID, lineID) * 1000 playerHurtList = __GetSortHurtList(lineID) if not playerHurtList: GameWorld.Log(' __DoLogicZhuXianBossOver£¬ É˺¦°ñÉÏûÓÐÈË£¡£¡lineID=%s'%lineID) return firsthurtInfo = playerHurtList[0] firstPlayerID = firsthurtInfo[0] firstPlayerFamilyID = firsthurtInfo[1][2] playerManager = GameWorld.GetMapCopyPlayerManager()#GameWorld.GetPlayerManager() firstPlayer = playerManager.FindPlayerByID(firstPlayerID) if firstPlayer: gameFB.SetPlayerGameFBDict(firstPlayerID, FBPlayerDict_Rank, 1) if not dropPosX or not dropPosY: dropPosX, dropPosY = firstPlayer.GetPosX(), firstPlayer.GetPosY() prizeItemList = GiveZhuXianBossAward(firstPlayer, lineID, dropItemMapInfo=[dropPosX, dropPosY, True]) if not prizeItemList: # ûÓеôÂäʱֱ½Ó֪ͨ½áË㣬·ÀÖ¹¿¨¸±±¾ firstPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True) overDict = {FBCommon.Over_rank:1, FBCommon.Over_itemInfo:prizeItemList} FBCommon.NotifyFBOver(firstPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, lineID, isPass, overDict) else: firstPlayer.Sync_TimeTick(ChConfig.tttPickupItem, 0, ChConfig.Def_FBPickupItemTime, True) else: leaveServerTick = PlayerControl.GetPlayerLeaveServerTick(firstPlayerID) if leaveServerTick and tick - leaveServerTick < ChConfig.Def_PlayerOfflineProtectTime: #ÀëÏß³¬¹ý3·ÖÖӵIJ»¸ø½±Àø msgStr = str([ShareDefine.Def_UniversalGameRecType_ZhuXianBossRecord, [firstPlayerID, lineID], [], 0, 0]) playerManager.GameServer_QueryPlayerResult(0, 0, 0, 'AddUniversalGameRec', msgStr, len(msgStr)) helpItemList = FBCommon.GetFBLineReward(mapID, lineID) if helpItemList: #ͬÃËЭÖú½±Àø needSpace = len(helpItemList) jsonItemList = FBCommon.GetJsonItemList(helpItemList) for index in range(0 , playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(index) curPlayerID = curPlayer.GetPlayerID() if not curPlayerID: continue if curPlayerID == firstPlayerID: continue if curPlayer.GetFamilyID() != firstPlayerFamilyID: continue remainCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhuXianBossHelpCnt) if not remainCnt: continue PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ZhuXianBossHelpCnt, remainCnt-1) NotifyZXHelpCnt(curPlayer) curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True) overDict = {FBCommon.Over_rank:0, FBCommon.Over_itemInfo:jsonItemList} FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, lineID, isPass, overDict) packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace) if needSpace > packSpace: PlayerControl.SendMailByKey('ZXBossHelperReward', [curPlayerID], helpItemList) else: for itemID, itemCount, isBind in helpItemList: ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem]) return def GiveZhuXianBossAward(curPlayer, lineID, isMail=False, dropItemMapInfo=[]): ##¸ø¹éÊôÕß½±Àø addCnt = 1 equipList = [] prizeItemDict ={} bossID = CurFBLineBOSSID(lineID) jsonItemList, totalExp, totalMoney = NPCCommon.GiveKillNPCDropPrize(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, {bossID:addCnt}, mailTypeKey="ZXBossBelongerReward", isMail=isMail, dropItemMapInfo=dropItemMapInfo) for jsonItem in jsonItemList: if 'UserData' in jsonItem: equipList.append(jsonItem) else: itemID, itemCnt = jsonItem['ItemID'], jsonItem.get('Count',1) prizeItemDict[itemID] = prizeItemDict.get(itemID,0)+itemCnt GameWorld.DebugLog("ÖïÏÉboss½áËã½±Àø: lineID=%s,bossID=%s,totalExp=%s,totalMoney=%s,jsonItemList=%s" % (lineID, bossID, totalExp, totalMoney, jsonItemList), curPlayer.GetPlayerID()) prizeItemList = equipList + FBCommon.GetJsonItemList(prizeItemDict.items()) #PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_ZhuXianBoss, addCnt) #»÷É±ÌØ¶¨NPC³É¾Í PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillSpecificNPC, addCnt, [bossID]) FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, addCnt) # ÿÈջ PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_ZhuXianBoss, addCnt) return prizeItemList def OnPickUpItem(curPlayer, curItem, tick): mapItemType = curItem.GetType() if mapItemType == ChConfig.Def_ItemType_Money: return playerID = curPlayer.GetID() isEquip = ItemCommon.CheckItemIsEquip(curItem) jsonItem = ItemCommon.GetJsonItem(curItem) if playerID in PyGameData.g_fbPickUpItemDict: if isEquip: PyGameData.g_fbPickUpItemDict[playerID].append(jsonItem) else: isIn = False for itemInfo in PyGameData.g_fbPickUpItemDict[playerID]: if itemInfo["ItemID"] == jsonItem["ItemID"] and itemInfo.get("IsBind") == jsonItem.get("IsBind"): itemInfo["Count"] = itemInfo.get("Count", 1)+ jsonItem.get("Count", 1) isIn = True break if not isIn: PyGameData.g_fbPickUpItemDict[playerID].append(jsonItem) else: PyGameData.g_fbPickUpItemDict[playerID] = [jsonItem] playerItemCount = 0 mapItemManager = GameWorld.GetMapItemManager() for index in xrange(mapItemManager.GetMapItemCount()): mapItem = mapItemManager.GetMapItemByIndex(index) if not mapItem or mapItem.IsEmpty(): continue # »¹ÓÐÊôÓÚ×Ô¼ºµÄ¶«Î÷û¼ñ²»Í¨Öª½áÊø if mapItem.GetOwnerID() == curPlayer.GetPlayerID(): playerItemCount += 1 isItemAllPickUp = (playerItemCount <= 1) if not isItemAllPickUp: return isPass = 1 lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 leaveTick = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_ZhuXianBoss, lineID) * 1000 gameFB = GameWorld.GetGameFB() rank = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_Rank) jsonItemList = PyGameData.g_fbPickUpItemDict.get(playerID, []) curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True) overDict = {FBCommon.Over_rank:rank, FBCommon.Over_itemInfo:jsonItemList} FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, lineID, isPass, overDict) return def __CheckBossHP(tick): gameFB = GameWorld.GetGameFB() isOver = gameFB.GetGameFBDictByKey(FBDict_IsOver) lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 if not isOver and GetBossRemainHP(lineID, tick) == 0: bossID = CurFBLineBOSSID(lineID) curBoss = GameWorld.FindNPCByNPCID(bossID) dropPosX, dropPosY = 0, 0 if curBoss: dropPosX, dropPosY = curBoss.GetPosX(), curBoss.GetPosY() #½áÊø ÉèÖÃBOSSËÀÍö FBCommon.ClearFBNPC() FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0) GameWorld.DebugLog('½áÊø ÉèÖÃBOSSËÀÍö lineID=%s' % lineID) playerHurtList = __GetSortHurtList(lineID) if playerHurtList: killerName, hurtValue = playerHurtList[0][1][:2] NPCCommon.GameServer_KillGameWorldBoss(bossID, killerName, hurtValue) NPCCommon.GameServe_GameWorldBossState(bossID, 0) __DoLogicZhuXianBossOver(1, tick, dropPosX, dropPosY) gameFB.SetGameFBDict(FBDict_IsOver, tick) return def UpdateHPReduceSpeed(tick, isExit=False): gameWorld = GameWorld.GetGameWorld() playerCnt = gameWorld.GetMapCopyPlayerManager().GetPlayerCount() playerCnt = playerCnt - 1 if isExit else playerCnt if playerCnt <=0: return lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 if lineID < 0: return curSpeed = int(min(1 + 0.08 * (playerCnt - 1), 1.8) * 1000) gameWorld.SetGameWorldDict(FBDict_Speed % lineID, curSpeed) if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing%lineID): return startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID) remainHP = gameWorld.GetGameWorldDictByKey(FBDict_RemainHP % lineID) lastSpeed = gameWorld.GetGameWorldDictByKey(FBDict_Speed % lineID) if not startTick: startTick = tick lastSpeed = curSpeed remainHP = __GetBossTotalHP(lineID) remainHP = max(0, int((remainHP - (tick - startTick) / 1000.0 * lastSpeed))) gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, tick) gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, remainHP) GameWorld.DebugLog(' curSpeed=%s, remainHP=%s, passTime=%s, lastSpeed=%s' % (curSpeed, remainHP, tick - startTick, lastSpeed)) FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0) return def StopReduceHP(lineID, tick): ##ÔÝÍ£BOSSѪÁ¿¼õÉÙ gameWorld = GameWorld.GetGameWorld() if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing%lineID): return remainHP = GetBossRemainHP(lineID, tick) if not remainHP: return gameWorld.SetGameWorldDict(FBDict_IsReduceing % lineID, 0) gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, remainHP) return def StartReduceHP(lineID, tick): ##¿ªÊ¼BOSSµôѪ gameWorld = GameWorld.GetGameWorld() if gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing%lineID): return gameWorld.SetGameWorldDict(FBDict_IsReduceing % lineID, 1) startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID) if not startTick: gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, __GetBossTotalHP(lineID)) gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, tick) return def __GetBossTotalHP(lineID):return GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_BossTotalHP%lineID) def GetBossRemainHP(lineID, tick): gameWorld = GameWorld.GetGameWorld() startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID) lastSpeed = gameWorld.GetGameWorldDictByKey(FBDict_Speed % lineID) remainHP = gameWorld.GetGameWorldDictByKey(FBDict_RemainHP % lineID) if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing%lineID): return remainHP if not startTick: startTick = tick remainHP = __GetBossTotalHP(lineID) else: remainHP = max(0, int((remainHP - (tick - startTick) / 1000.0 * lastSpeed))) return remainHP def GetBossRemainHPPer(lineID, tick): remainHP = GetBossRemainHP(lineID, tick) totalHP = __GetBossTotalHP(lineID) if not totalHP: return 0 return remainHP * 100 / totalHP def CurFBLineBOSSID(lineID= -1): #¸Ã·ÖÏßË¢µÄBOSSID if lineID == -1: lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 if lineID == -1: return 0 ipyData = IpyGameDataPY.GetIpyGameData('ZhuXianBoss', lineID) if not ipyData: return 0 bossID = ipyData.GetNPCID() return bossID ##Íæ¼ÒËÀÍö. # @param curPlayer:ËÀÍöµÄÍæ¼Ò # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÎÞÒâÒå # @remarks Íæ¼ÒÖ÷¶¯À뿪¸±±¾. def DoPlayerDead(curPlayer): return ## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼­ÓÉÍâ²ã¾ö¶¨ # @param attacker ¹¥»÷·½ # @param defender ·ÀÊØ·½ # @return bool def CheckCanAttackTagObjInFB(attacker, defender): atkObjType = attacker.GetGameObjType() defObjType = defender.GetGameObjType() if atkObjType == IPY_GameWorld.gotPlayer and defObjType == IPY_GameWorld.gotNPC: gameWorld = GameWorld.GetGameWorld() lineID = gameWorld.GetPropertyID() - 1 if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing%lineID): PlayerControl.NotifyCode(attacker, 'TryEnterJadeDynastyBossError_7') return False return True