| | |
| | | fbStep = gameFB.GetFBStep()
|
| | | GameWorld.Log("DoEnterFB fbRoomID=%s,playerVSRoomID=%s,fbStep=%s" % (roomID, playerVSRoomID, fbStep), playerID)
|
| | |
|
| | | gameFB.SetGameFBDict(GameFBDict_PlayerLeaveTick % playerID, 0)
|
| | |
|
| | | if gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerID):
|
| | | GameWorld.Log(" 玩家离线保护时间内上线!", playerID)
|
| | | gameFB.SetGameFBDict(GameFBDict_PlayerLeaveTick % playerID, 0)
|
| | | playerManager = GameWorld.GetMapCopyPlayerManager()
|
| | | for index in xrange(playerManager.GetPlayerCount()):
|
| | | player = playerManager.GetPlayerByIndex(index)
|
| | | if player and player.GetPlayerID() != curPlayer.GetPlayerID():
|
| | | player.Sync_TimeTick(ChConfig.tttPlayerLeave, 0, 0, True)
|
| | | |
| | | fbRoundNum = gameFB.GetGameFBDictByKey(FB_RoundNum)
|
| | | playerRoundNum = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_RoundNum)
|
| | | if playerRoundNum and fbRoundNum and playerRoundNum != fbRoundNum:
|
| | |
| | | if fbStep >= FB_State_Leave or not roomID or not playerVSRoomID or roomID != playerVSRoomID:
|
| | | PlayerControl.PlayerLeaveFB(curPlayer)
|
| | | return
|
| | | PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default * 3)
|
| | |
|
| | | PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default * 2)
|
| | | # 非战斗阶段,通知动态障碍点
|
| | | if fbStep < FB_State_Fight:
|
| | | FBCommon.SyncDynamicBarrierState(IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 2), 1, curPlayer) # 准备期间有动态障碍点
|
| | |
| | | gameFB.SetPlayerGameFBDict(playerID, FBPDict_ResetPosY, curPlayer.GetPosY())
|
| | | gameFB.SetPlayerGameFBDict(playerID, FBPDict_RoundNum, 1)
|
| | | FBCommon.SetFBStep(FB_State_Waiting, tick)
|
| | | GameWorld.Log(" 第一个进入,设置副本进入等待对手阶段!roomID=%s" % (roomID), playerID)
|
| | | __ResetPlayerState(gameFB, curPlayer, playerID, False)
|
| | | GameWorld.Log(" 第一个进入,阵营1,设置副本进入等待对手阶段!roomID=%s" % (roomID), playerID)
|
| | | __ResetPlayerState(gameFB, curPlayer, playerID)
|
| | | curPlayer.Sync_TimeTick(ChConfig.tttWaitPlayer, 0, fbTimeList[Def_Time_MaxWait] * 1000, True)
|
| | | sendMsg = str([roomID])
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "CrossPKRoomOpen", sendMsg, len(sendMsg))
|
| | |
| | | gameFB.SetPlayerGameFBDict(playerID, FBPDict_ResetPosX, curPlayer.GetPosX())
|
| | | gameFB.SetPlayerGameFBDict(playerID, FBPDict_ResetPosY, curPlayer.GetPosY())
|
| | | gameFB.SetPlayerGameFBDict(playerID, FBPDict_RoundNum, 1)
|
| | | GameWorld.Log(" 第二个进入的玩家!roomID=%s" % (roomID), playerID)
|
| | | __ResetPlayerState(gameFB, curPlayer, playerID, False)
|
| | | GameWorld.Log(" 第二个进入的玩家!阵营2,roomID=%s" % (roomID), playerID)
|
| | | __ResetPlayerState(gameFB, curPlayer, playerID)
|
| | |
|
| | | if GameWorld.GetMapCopyPlayerManager().GetPlayerCount() == 2:
|
| | | GameWorld.Log(" 两个人都在,设置副本进入战斗倒计时阶段!roomID=%s" % (roomID), playerID)
|
| | |
| | | curPlayer.Sync_TimeTick(ChConfig.tttTowerTake, 0, max(notify_tick, 0), True)
|
| | |
|
| | | FBCommon.Notify_FBHelp(curPlayer, __GetFBHelpInfo())
|
| | | PlayerControl.DelLimitSuperBuff(curPlayer, tick)
|
| | | PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
|
| | | return
|
| | |
|
| | | def __GetFBHelpInfo():
|
| | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | gameFB.SetGameFBDict(GameFBDict_PlayerLeaveTick % playerID, tick)
|
| | | GameWorld.Log("玩家战斗阶段下线!playerID=%s,waitPlayerID=%s" % (playerID, playerID))
|
| | | |
| | | ## 通知对方,对手掉线
|
| | | playerManager = GameWorld.GetMapCopyPlayerManager()
|
| | | for index in xrange(playerManager.GetPlayerCount()):
|
| | | player = playerManager.GetPlayerByIndex(index)
|
| | | if player and player.GetPlayerID() != curPlayer.GetPlayerID():
|
| | | fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
|
| | | player.Sync_TimeTick(ChConfig.tttPlayerLeave, 0, max(fbTimeList[Def_Time_Protect] * 1000, 0), True)
|
| | | |
| | | return
|
| | |
|
| | | ##玩家主动离开副本.
|
| | | def DoPlayerLeaveFB(curPlayer, tick):
|
| | | gameFB = GameWorld.GetGameFB()
|
| | | fbStep = gameFB.GetFBStep()
|
| | | |
| | | if fbStep <= FB_State_Waiting or fbStep >= FB_State_Leave:
|
| | | return
|
| | | |
| | | leavePlayerID = curPlayer.GetPlayerID()
|
| | | roomID = GameWorld.GetGameWorld().GetPropertyID()
|
| | | playerIDA = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 1)
|
| | | playerIDB = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 2)
|
| | | |
| | | loser, loserID = curPlayer, leavePlayerID
|
| | | winnerID = playerIDA if playerIDB == loserID else playerIDB
|
| | | winner = GameWorld.GetMapCopyPlayerManager().FindPlayerByID(winnerID)
|
| | | GameWorld.Log("玩家主动退出,直接算输! roomID=%s,leavePlayerID=%s,loserID=%s,winnerID=%s" % (roomID, leavePlayerID, loserID, winnerID))
|
| | | __DoFBPKAllOver(winner, winnerID, loser, loserID, Def_OverType_PlayerExit, tick)
|
| | | return
|
| | |
|
| | | ## 获得副本帮助信息
|
| | |
| | | 其他情况则在线玩家获胜,如果没有玩家在线,则最迟离线的获胜
|
| | | '''
|
| | | winner, winnerID, loser, loserID = None, 0, None, 0
|
| | | roomID = GameWorld.GetGameWorld().GetPropertyID()
|
| | | gameFB = GameWorld.GetGameFB()
|
| | | fbStep = gameFB.GetFBStep()
|
| | | copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
|
| | |
| | | # 时间到还没分出胜负, 根据以下规则决定胜负,这里用玩家ID处理,防止结算时都掉线了导致没有结果
|
| | | # 伤害输出 > 优先到达时间 > 剩余HP > 最大HP > playerID
|
| | |
|
| | | GameWorld.Log("两个人都在线,根据超时规则判断胜负玩家! roomID=%s" % (roomID))
|
| | | playerInfoList = []
|
| | | for playerID in [playerIDA, playerIDB]:
|
| | | player = copyMapPlayerManager.FindPlayerByID(playerID)
|
| | | # 还是离线时间的,走掉线逻辑,越晚掉线的赢;需要加这个逻辑主要是因为当玩家没有触发完整登录流程导致玩家在线但是没有触发DoEnter
|
| | | playerLeaveTick = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerID)
|
| | | if playerLeaveTick:
|
| | | pvpDamage, sortTick, curHP, curMaxHP = 0, 0, 0, 0
|
| | | playerInfoList.append([pvpDamage, sortTick, curHP, curMaxHP, playerLeaveTick, playerID, player])
|
| | | GameWorld.Log("PK超时: playerLeaveTick=%s" % (playerLeaveTick), playerID)
|
| | | continue
|
| | | pvpDamage = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_PVPDamage)
|
| | | pvpDamTick = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_PVPDamUpdTick)
|
| | | sortTick = tick - pvpDamTick
|
| | | curHP = 0 if not player else player.GetHP()
|
| | | curMaxHP = 0 if not player else player.GetMaxHP()
|
| | | playerInfoList.append([pvpDamage, sortTick, curHP, curMaxHP, playerID, player])
|
| | | GameWorld.Log("PK超时: pvpDamge=%s,pvpDamTick=%s,tick=%s,sortTick=%s,HP=%s/%s" |
| | | % (pvpDamage, pvpDamTick, tick, sortTick, curHP, curMaxHP), playerID)
|
| | | playerInfoList.append([pvpDamage, sortTick, curHP, curMaxHP, playerLeaveTick, playerID, player])
|
| | | GameWorld.Log("PK超时: pvpDamge=%s,pvpDamTick=%s,tick=%s,sortTick=%s,HP=%s/%s,playerLeaveTick=%s" |
| | | % (pvpDamage, pvpDamTick, tick, sortTick, curHP, curMaxHP, playerLeaveTick), playerID)
|
| | |
|
| | | playerInfoList.sort(reverse=True)
|
| | | GameWorld.Log("PK超时, 进入结算!playerInfoList=%s" % str(playerInfoList))
|
| | |
| | | player = copyMapPlayerManager.GetPlayerByIndex(i)
|
| | | if player == None or player.IsEmpty():
|
| | | continue
|
| | | playerID = player.GetPlayerID()
|
| | | if playerID not in [playerIDA, playerIDB]:
|
| | | GameWorld.ErrLog("副本中玩家不在进入的玩家ID里,不处理! roomID=%s,playerID=%s" % (roomID, playerID))
|
| | | continue
|
| | | winner = player
|
| | | winnerID = player.GetPlayerID()
|
| | | GameWorld.Log("超时结算,玩家在线,直接获胜: roomID=%s,winnerID=%s" % (roomID, winnerID))
|
| | | break
|
| | |
|
| | | if not winner:
|
| | | playerLeaveTickA = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerIDA)
|
| | | playerLeaveTickB = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerIDB)
|
| | | GameWorld.Log("超时结算,没有玩家在线,后离线的获胜: playerLeaveTickA=%s,playerLeaveTickB=%s" % (playerLeaveTickA, playerLeaveTickB))
|
| | | # 离线tick较大的就是比较晚离线的
|
| | | if playerLeaveTickA > playerLeaveTickB:
|
| | | winnerID = playerIDA
|
| | |
| | | prepareTime = fbTimeList[Def_Time_MapPrepare] * 1000
|
| | | helpDict["prepareTime"] = prepareTime
|
| | |
|
| | | roundNum = gameFB.GetGameFBDictByKey(FB_RoundNum)
|
| | | winnerID = gameFB.GetGameFBDictByKey(FB_RoundWinPlayerID % roundNum)
|
| | | |
| | | nextRoundNum = gameFB.GetGameFBDictByKey(FB_RoundNum) + 1
|
| | | gameFB.SetGameFBDict(FB_RoundNum, nextRoundNum)
|
| | |
|
| | | isWinnerResetState = False
|
| | | copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
|
| | | for i in xrange(copyMapPlayerManager.GetPlayerCount()):
|
| | | player = copyMapPlayerManager.GetPlayerByIndex(i)
|
| | |
| | |
|
| | | if player.GetPlayerAction() == IPY_GameWorld.paDie or player.GetHP() <= 0:
|
| | | GameWorld.DebugLog("复活玩家...", player.GetPlayerID())
|
| | | ChPlayer.PlayerRebornByType(player, ChConfig.rebornType_System, tick)
|
| | | ChPlayer.PlayerRebornByType(player, ChConfig.rebornType_System, tick, isAddSuperBuff=False)
|
| | | __ResetPlayerState(gameFB, player, playerID)
|
| | | elif winnerID and playerID != winnerID:
|
| | | GameWorld.DebugLog("平局,输的玩家回满血!", playerID)
|
| | | __ResetPlayerState(gameFB, player, playerID) |
| | | else:
|
| | | if isWinnerResetState:
|
| | | __ResetPlayerState(gameFB, player, playerID)
|
| | | __ResetPlayerState(gameFB, player, playerID, False)
|
| | |
|
| | | FBCommon.Notify_FBHelp(player, helpDict)
|
| | |
|
| | |
| | | GameWorld.Log("回合结束: roomID=%s,roundNum=%s,winnerID=%s,loserID=%s,updWinCnt=%s" % (roomID, roundNum, winnerID, loserID, updWinCnt))
|
| | | isOver = (updWinCnt >= IpyGameDataPY.GetFuncCfg("CrossRealmPKFB", 3))
|
| | | if not isOver:
|
| | | if winner:
|
| | | clearDeBuff = False
|
| | | # 胜利者马上清除负面buff,防止死亡导致回合表现异常,如中毒
|
| | | for buffType in [IPY_GameWorld.bfDeBuff, IPY_GameWorld.bfProcessDeBuff, IPY_GameWorld.bfActionBuff]:
|
| | | buffTuple = SkillCommon.GetBuffManagerByBuffType(winner, buffType)
|
| | | if buffTuple:
|
| | | buffState = buffTuple[0]
|
| | | buffCount = buffState.GetBuffCount()
|
| | | if buffCount:
|
| | | clearDeBuff = True
|
| | | buffState.Clear()
|
| | | GameWorld.DebugLog("胜者马上清除 buffType=%s,buffCount=%s" % (buffType, buffCount), winner.GetPlayerID())
|
| | | |
| | | if clearDeBuff:
|
| | | PlayerControl.PlayerControl(winner).RefreshAllState()
|
| | | |
| | | FBCommon.SetFBStep(FB_State_Reborn, tick)
|
| | | return
|
| | |
|
| | |
| | | __DoFBPKAllOver(winner, winnerID, loser, loserID, overType, tick)
|
| | | return
|
| | |
|
| | | def __ResetPlayerState(gameFB, player, playerID, resetPos=True):
|
| | | if resetPos:
|
| | | posX = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_ResetPosX)
|
| | | posY = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_ResetPosY)
|
| | | player.ResetPos(posX, posY)
|
| | | |
| | | def __ResetPlayerState(gameFB, player, playerID, resetAttr=True):
|
| | | posX = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_ResetPosX)
|
| | | posY = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_ResetPosY)
|
| | | player.ResetPos(posX, posY)
|
| | | |
| | | if not resetAttr:
|
| | | return
|
| | | |
| | | if player.GetHP() != player.GetMaxHP():
|
| | | player.SetHP(player.GetMaxHP())
|
| | |
|
| | |
| | | SkillCommon.ResetAllSkillCD(player)
|
| | | return
|
| | |
|
| | | ## 跨服PK结束处理
|
| | | ## 跨服PK结束处理,注意 winner、loser 参数可能为None
|
| | | def __DoFBPKAllOver(winner, winnerID, loser, loserID, overType, tick):
|
| | | gameFB = GameWorld.GetGameFB()
|
| | |
|