From 7333df76f1172b83238623969ae0b6f978801201 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 14 一月 2025 20:07:04 +0800 Subject: [PATCH] 10263 【越南】【英文】【BT】后端支持NPC仿真实玩家战斗和快速战斗(改为真实地图战斗;竞技场、跨服PK、跨服排位赛,测试地图100均已支持;) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_MirrorBattle.py | 183 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 150 insertions(+), 33 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_MirrorBattle.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_MirrorBattle.py index bb16b47..ef2477c 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_MirrorBattle.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_MirrorBattle.py @@ -15,22 +15,101 @@ #"""Version = 2024-10-17 15:00""" #------------------------------------------------------------------------------- -import GameWorld +import ChConfig +import ShareDefine import MirrorAttack +import PlayerControl +import IpyGameDataPY +import PlayerCrossRealmPK +import CrossRealmPlayer +import PlayerArena +import GameWorld import FBCommon -import GameObj -## 是否能够通过活动查询进入 -def OnEnterFBEvent(curPlayer, mapID, lineID, tick): - return True +def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick): + return MirrorAttack.OnGetMirrorBattlePos(mapID, lineId)[0] -## 客户端进入自定义场景 -def OnEnterCustomScene(curPlayer, mapID, lineID): +def DoEnterFB(curPlayer, tick): + playerID = curPlayer.GetPlayerID() + GameWorld.Log("---------------- 镜像战斗DoEnterFB ----------------", playerID) + MirrorAttack.OnMirrorBattleEnterMapInit(curPlayer, tick) return + +def DoExitFB(curPlayer, tick): + ##玩家退出副本 + MirrorAttack.DoExitFB(curPlayer, tick) + return + +def DoPlayerLeaveFB(curPlayer, tick): + ##玩家主动离开副本 + MirrorAttack.DoPlayerLeaveFB(curPlayer, tick) + return + +def CheckPlayersRelation_IsFriend(curPlayer, curTagPlayer): + return not CanAttackPlayer(curPlayer, curTagPlayer) + +def CanAttackPlayer(curPlayer, curTagPlayer): + battle = MirrorAttack.GetMirrorBattle(curPlayer) + if not battle: + return + + if battle.batState != ChConfig.Def_MirrorBatState_Fight: + return + + if curTagPlayer: + if curPlayer.GetFaction() == curTagPlayer.GetFaction(): + return + + return True ##处理副本中杀死玩家逻辑 def DoFBOnKill_Player(atkobj, defender, tick): GameWorld.DebugLog("镜像切磋击杀玩家: defID=%s" % (defender.GetID()), atkobj.GetID()) + return True + +def OnMirrorBattleRequest(curPlayer, mapID, funcLineID, factionPlayerList): + ## 镜像战斗请求 + + if mapID == ChConfig.Def_FBMapID_CrossRealmPK: + return __CheckRequest_CrossRealmPK(curPlayer, mapID, funcLineID) + + if mapID == ChConfig.Def_FBMapID_CrossChampionship: + return __CheckRequest_CrossChampionship(curPlayer, mapID, funcLineID) + + return True + +def __CheckRequest_CrossRealmPK(curPlayer, mapID, funcLineID): + if not CrossRealmPlayer.IsCrossServerOpen(): + PlayerControl.NotifyCode(curPlayer, "CrossMatching18") + return + if not PlayerCrossRealmPK.CheckCanMatch(curPlayer): + return + if not PlayerCrossRealmPK.CheckHavePKCount(curPlayer): + return + return True + +def __CheckRequest_CrossChampionship(curPlayer, mapID, funcLineID): + + playerID = curPlayer.GetPlayerID() + if not CrossRealmPlayer.IsCrossServerOpen(): + PlayerControl.NotifyCode(curPlayer, "CrossMatching18") + return + + stateError = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossChampionshipStateError) + if stateError: + GameWorld.ErrLog("跨服排位状态已经异常无法进入! stateError=%s" % stateError, playerID) + return + + state = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossChampionshipState) + if state not in ShareDefine.CrossChampionshipEnterStateInfo: + GameWorld.ErrLog("当前状态非跨服排位战斗状态无法进入: state=%s" % state, playerID) + return + groupMark = ShareDefine.CrossChampionshipEnterStateInfo[state] + reqGroupMark = funcLineID % 100 + if reqGroupMark != groupMark: + GameWorld.ErrLog("当前状态与跨服排位战斗分组不一致无法进入: funcLineID=%s,reqGroupMark=%s != %s" % (funcLineID, reqGroupMark, groupMark), playerID) + return + return True def OnMirrorBattleOver(battleID): @@ -39,35 +118,73 @@ battle = MirrorAttack.GetMirrorBattleByID(battleID) if not battle: return - isLogout = battle.isLogout - mapID = battle.mapID funcLineID = battle.funcLineID - winFaction = battle.winFaction - curPlayerID = battle.requestID # 副本所属玩家ID,该玩家不一定参与实际战斗 - curIsWin = 0 - GameWorld.DebugLog("镜像战斗结算: mapID=%s,funcLineID=%s,winFaction=%s,isLogout=%s" % (mapID, funcLineID, winFaction, isLogout), battleID) - - playerMgr = GameWorld.GetMapCopyPlayerManager() - for playerID, faction in battle.playerFactionDict.items(): - curPlayer = playerMgr.FindPlayerByID(playerID) - if not curPlayer: - continue - realPlayerID = curPlayer.GetRealPlayerID() - isWin = (faction == winFaction) - GameWorld.DebugLog("剩余血量: %s/%s,playerID=%s,realPlayerID=%s,faction=%s,isWin=%s" - % (GameObj.GetHP(curPlayer), GameObj.GetMaxHP(curPlayer), playerID, realPlayerID, faction, isWin), battleID) - if isWin and faction == 1: - curIsWin = 1 - - if not curPlayerID: - return - - curPlayer = playerMgr.FindPlayerByID(curPlayerID) + isWin = battle.isWin + curPlayerID = battle.playerID # 副本所属玩家ID,该玩家不一定参与实际战斗 + tagPlayerID = battle.GetTagPlayerID() + curPlayer = GameWorld.GetMapCopyPlayerManager().FindPlayerByID(curPlayerID) if not curPlayer: return - # 结算奖励,通知结果 + + if mapID == ChConfig.Def_FBMapID_ArenaBattle: + arenaPlayerID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ArenaBattleTagID) + if tagPlayerID == arenaPlayerID: + PlayerArena.SendGameServer_ArenaBattleOver(curPlayer, isWin) + else: + GameWorld.DebugLog("非竞技场对手不结算! tagPlayerID=%s,arenaPlayerID=%s" % (tagPlayerID, arenaPlayerID), curPlayerID) + return + + if mapID == ChConfig.Def_FBMapID_CrossRealmPK: + PlayerCrossRealmPK.SendPKOver(curPlayer, tagPlayerID, isWin) + return + + if mapID == ChConfig.Def_FBMapID_CrossChampionship: + __MirrorBattleOver_CrossChampionship(curPlayer, battle) + return + giveItemList = [] - overDict = {"isWin":curIsWin, FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(giveItemList)} - FBCommon.NotifyFBOver(curPlayer, mapID, funcLineID, isWin, overDict) + overDict = {"isWin":isWin, FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(giveItemList)} + FBCommon.NotifyFBOver(curPlayer, mapID, funcLineID, isWin, overDict) return + +def __MirrorBattleOver_CrossChampionship(curPlayer, battle): + playerID = curPlayer.GetPlayerID() + mapID = battle.mapID + funcLineID = battle.funcLineID + isWin = battle.isWin + tagPlayerID = battle.GetTagPlayerID() + curHPPer, tagHPPer = battle.CalcHPPer() + remainTimePer = battle.CalcRemainTimePer() + + baseScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossChamMirrorPK", 2) + baseScore = 0 + if baseScoreList and len(baseScoreList) == 2: + baseScore = baseScoreList[0] if isWin else baseScoreList[1] + hpScore = int(eval(IpyGameDataPY.GetFuncCompileCfg("CrossChamMirrorPK", 3))) + GameWorld.DebugLog(" hpScore=%s,curHPPer=%s,tagHPPer=%s" % (hpScore, curHPPer, tagHPPer), playerID) + + timeScore = int(eval(IpyGameDataPY.GetFuncCompileCfg("CrossChamMirrorPK", 4))) + GameWorld.DebugLog(" timeScore=%s,remainTimePer=%s%%" % (timeScore, remainTimePer), playerID) + + addScore = baseScore + hpScore + timeScore + GameWorld.DebugLog(" addScore=%s,baseScore=%s" % (addScore, baseScore), playerID) + + pkCountMax = IpyGameDataPY.GetFuncCfg("CrossChamMirrorPK", 1) + playerID = curPlayer.GetPlayerID() + dataMsg = { + "playerID":playerID, + "tagPlayerID":tagPlayerID, + "funcLineID":funcLineID, + "isWin":isWin, + "addScore":addScore, + "baseScore":baseScore, + "hpScore":hpScore, + "timeScore":timeScore, + "pkCountMax":pkCountMax, + } + GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipPKOver, dataMsg) + overDict = {"isWin":isWin, "tagPlayerID":tagPlayerID, "addScore":addScore, "baseScore":baseScore, "hpScore":hpScore, "timeScore":timeScore} + FBCommon.NotifyFBOver(curPlayer, mapID, funcLineID, isWin, overDict) + return + -- Gitblit v1.8.0