|  |  |  | 
|---|
|  |  |  | import ChPyNetSendPack | 
|---|
|  |  |  | import ShareDefine | 
|---|
|  |  |  | import PlayerSuccess | 
|---|
|  |  |  | import PlayerActivity | 
|---|
|  |  |  | import GameObj | 
|---|
|  |  |  | import NetPackCommon | 
|---|
|  |  |  | import ItemControler | 
|---|
|  |  |  | import PlayerActLogin | 
|---|
|  |  |  | 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血量 | 
|---|
|  |  |  | FBDict_LastHurtTick = 'FBDict_LastHurtTick'  #上次伤害时间 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | g_heroHurtDict = {} #{playerID:hurt} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ## 进副本 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | UpdateHurtInfo(curPlayer, 0, True) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | UpdateHPReduceSpeed(tick) | 
|---|
|  |  |  | gameFB = GameWorld.GetGameFB() | 
|---|
|  |  |  | # 上鼓舞buff | 
|---|
|  |  |  | encourageLV = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_EncourageLV) | 
|---|
|  |  |  | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | FBCommon.SendFBEncourageInfo(curPlayer, encourageLV) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #DoFBHelp(curPlayer, tick) | 
|---|
|  |  |  | DoFBHelp(curPlayer, 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 | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | playerHurtDict = PyGameData.g_ZhuXianBossPlayerHurtDict.get(lineID, {}) | 
|---|
|  |  |  | playerHurtDict.pop(curPlayer.GetPlayerID(), 0) | 
|---|
|  |  |  | PyGameData.g_ZhuXianBossPlayerHurtDict[lineID] = playerHurtDict | 
|---|
|  |  |  | if not playerHurtDict: #榜上没人,停止掉血 | 
|---|
|  |  |  | StopReduceHP(lineID, tick) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ##玩家切换地图 | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(1000000, remainHP * 1000000 / 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, | 
|---|
|  |  |  | fbHelpDict = {FBCommon.Help_lineID:lineID, "hurtInfo":hurtInfo, | 
|---|
|  |  |  | 'myHurt':myHurt % ChConfig.Def_PerPointValue, | 
|---|
|  |  |  | 'myHurtEx':myHurt / ChConfig.Def_PerPointValue | 
|---|
|  |  |  | } | 
|---|
|  |  |  | GameWorld.DebugLog("DoFBHelp: %s" % fbHelpDict, curPlayer.GetPlayerID()) | 
|---|
|  |  |  | 
|---|
|  |  |  | #  @return None | 
|---|
|  |  |  | def DoFB_Player_HurtNPC(curPlayer, curNPC, hurtHP): | 
|---|
|  |  |  | UpdateHurtInfo(curPlayer, hurtHP) | 
|---|
|  |  |  | GameWorld.GetGameFB().SetGameFBDict(FBDict_LastHurtTick, GameWorld.GetGameWorld().GetTick()) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | # | 
|---|
|  |  |  | def UpdateHurtInfo(curPlayer, hurtHP, isAdd=False): | 
|---|
|  |  |  | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | playerHurtDict[playerID][1] += hurtHP | 
|---|
|  |  |  | PyGameData.g_ZhuXianBossPlayerHurtDict[lineID] = playerHurtDict | 
|---|
|  |  |  | #有人上榜开始掉血 | 
|---|
|  |  |  | StartReduceHP(lineID, GameWorld.GetGameWorld().GetTick()) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ##---副本总逻辑计时器--- | 
|---|
|  |  |  | 
|---|
|  |  |  | lineID = GameWorld.GetGameWorld().GetPropertyID() - 1 | 
|---|
|  |  |  | if lineID <0: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | gameWorld = GameWorld.GetGameWorld() | 
|---|
|  |  |  | startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID) | 
|---|
|  |  |  | if not startTick or overTick: | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if overTick: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | lastHurtTick = gameFB.GetGameFBDictByKey(FBDict_LastHurtTick) | 
|---|
|  |  |  | if lastHurtTick and tick - lastHurtTick >= 2000: | 
|---|
|  |  |  | StopReduceHP(lineID, tick) | 
|---|
|  |  |  | GameWorld.GetGameFB().SetGameFBDict(FBDict_LastHurtTick, 0) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 5000) | 
|---|
|  |  |  | __CheckBossHP(tick) | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, lineID, isPass, overDict) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def DoFB_Npc_KillNPC(attacker, curNPC, tick): | 
|---|
|  |  |  | __FBNPCOnKilled(curNPC, tick) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | def DoFB_Player_KillNPC(curPlayer, curNPC, tick): | 
|---|
|  |  |  | __FBNPCOnKilled(curNPC, tick) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def __CheckBossHP(tick): | 
|---|
|  |  |  | gameFB = GameWorld.GetGameFB() | 
|---|
|  |  |  | isOver = gameFB.GetGameFBDictByKey(FBDict_IsOver) | 
|---|
|  |  |  | ## 执行副本杀怪逻辑 | 
|---|
|  |  |  | def __FBNPCOnKilled(curNPC, tick): | 
|---|
|  |  |  | 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() | 
|---|
|  |  |  | if curNPC.GetNPCID() != bossID: | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | dropPosX, dropPosY = curNPC.GetPosX(), curNPC.GetPosY() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #结束 设置BOSS死亡 | 
|---|
|  |  |  | FBCommon.ClearFBNPC() | 
|---|
|  |  |  | FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0) | 
|---|
|  |  |  | GameWorld.DebugLog('结束 设置BOSS死亡 lineID=%s' % lineID) | 
|---|
|  |  |  | playerHurtList = __GetSortHurtList(lineID) | 
|---|
|  |  |  | 
|---|
|  |  |  | NPCCommon.GameServe_GameWorldBossState(bossID, 0) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | __DoLogicZhuXianBossOver(1, tick, dropPosX, dropPosY) | 
|---|
|  |  |  | gameFB.SetGameFBDict(FBDict_IsOver, tick) | 
|---|
|  |  |  | GameWorld.GetGameFB().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) | 
|---|
|  |  |  | FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0) | 
|---|
|  |  |  | 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 GetBossRemainHPPer(copyMapID, funcLineID, tick): | 
|---|
|  |  |  | bossID = CurFBLineBOSSID(funcLineID) | 
|---|
|  |  |  | curBoss = GameWorld.FindNPCByNPCIDEx(copyMapID, bossID) | 
|---|
|  |  |  | if not curBoss: | 
|---|
|  |  |  | return 100 | 
|---|
|  |  |  | return GameObj.GetHP(curBoss) * 100 / GameObj.GetMaxHP(curBoss) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def CurFBLineBOSSID(lineID= -1): | 
|---|
|  |  |  | #该分线刷的BOSSID | 
|---|