From 143c55479cbb2f77883ca8a87c7f42c2ddcb8673 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 03 十二月 2024 15:31:51 +0800 Subject: [PATCH] 4999 【bt】【英文】【越南】优化灵宠战斗(主人不攻击时,灵宠达到攻击间隔也会主动攻击可攻击的目标;灵宠攻击目标增加可攻击视野内主动怪,攻击顺序为:主人攻击目标 > 攻击主人的目标 > 视野内主动怪) --- ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py | 158 +++++++++++++++++++--------------------------------- 1 files changed, 58 insertions(+), 100 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py index f700782..9a0007d 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py @@ -21,7 +21,6 @@ import ReadChConfig import ChConfig import PlayerControl -import PlayerViewCache import PlayerCompensation import ChPyNetSendPack import PlayerDBGSEvent @@ -91,6 +90,21 @@ zoneTypeName = ChConfig.Def_CrossZoneTypeName.get(mapID, "CrossZoneComm") ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition(zoneTypeName, {"CrossZoneName":crossZoneName}, True) return ipyDataList + +def GetServerCommCrossZoneID(serverGroupID): + ## 获取跨服常规分区 + zoneTypeName = "CrossZoneComm" + crossZoneName = GameWorld.GetCrossZoneName() + ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition(zoneTypeName, {"CrossZoneName":crossZoneName}, True) + if not ipyDataList: + return 0 + for ipyData in ipyDataList: + serverGroupIDList = ipyData.GetServerGroupIDList() + for serverGroupIDInfo in serverGroupIDList: + if (isinstance(serverGroupIDInfo, tuple) and serverGroupIDInfo[0] <= serverGroupID <= serverGroupIDInfo[1]) \ + or (isinstance(serverGroupIDInfo, int) and serverGroupIDInfo == serverGroupID): + return ipyData.GetZoneID() + return 0 def GetServerCrossZoneMapIpyData(zoneID, mapID): ## 获取本服对应跨服玩法分区地图信息 - 仅适用于固定地图及虚拟分线的跨服玩法 @@ -196,6 +210,8 @@ def SendCrossRealmReg(curPlayer, registerMap, mapID=0, dataMapID=0, copyMapID=0, posX=0, posY=0, lineID=0): # 发送跨服账号注册上传数据 + # @param mapID: 真实场景地图ID + # @param dataMapID: 真实场景地图ID对应场景数据地图ID # 设置上传数据的活动类型 curPlayer.SetDict(ChConfig.Def_PlayerKey_CrossRegisterMap, registerMap) @@ -268,104 +284,6 @@ PlayerControl.SetCrossMapID(curPlayer, 0) return -#// C0 02 查看跨服玩家信息 #tagCGViewCrossPlayerInfo -# -#struct tagCGViewCrossPlayerInfo -#{ -# tagHead Head; -# DWORD PlayerID; // 跨服玩家ID -# BYTE EquipClassLV; //大于0为查看指定境界阶装备信息, 0为查看默认信息 -#}; -def OnViewCrossPlayerInfo(index, clientData, tick): - if GameWorld.IsCrossServer(): - return - - curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) - playerID = curPlayer.GetPlayerID() - tagPlayerID = clientData.PlayerID - equipClassLV = clientData.EquipClassLV - curCache = PlayerViewCache.FindViewCache(tagPlayerID) - ## 本服有,直接回客户端 - if curCache: - GameWorld.DebugLog("查看跨服玩家,是本服玩家,直接回复!tagPlayerID=%s" % (tagPlayerID), playerID) - PlayerViewCache.Sync_PlayerCache(curPlayer, curCache, equipClassLV) - return - - if tagPlayerID in PyGameData.g_crossPlayerViewCache: - validChaheTime = 10 * 60 * 1000 - cacheInfo, updTick = PyGameData.g_crossPlayerViewCache[tagPlayerID] - if tick - updTick <= validChaheTime: - GameWorld.DebugLog("查看跨服玩家数据同步CD中,直接用缓存数据回复!tagPlayerID=%s" % (tagPlayerID), playerID) - SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo) - return - - for crossPlayerID, cacheInfoList in PyGameData.g_crossPlayerViewCache.items(): - if tick - cacheInfoList[1] > validChaheTime: - PyGameData.g_crossPlayerViewCache.pop(crossPlayerID) - - # 发送跨服服务器查询 - dataMsg = {"tagPlayerID":tagPlayerID, "playerID":playerID, "equipClassLV":equipClassLV} - CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ViewPlayerCache, dataMsg) - return - -def ClientServerMsg_ViewPlayerCache(serverGroupID, msgData): - tagPlayerID = msgData["tagPlayerID"] - playerID = msgData["playerID"] - equipClassLV = msgData["equipClassLV"] - - GameWorld.Log("收到子服查看跨服玩家信息: serverGroupID=%s,playerID=%s,tagPlayerID=%s" % (serverGroupID, playerID, tagPlayerID)) - - cacheInfo = {} - curCache = PlayerViewCache.FindViewCache(tagPlayerID) - if curCache: - cacheInfo = {"PropData":curCache.PropData, "PlusData":curCache.PlusData} - for classLV in xrange(1, 15 + 1): - attrName = "ItemData%s" % classLV - if hasattr(curCache, attrName): - cacheInfo[attrName] = getattr(curCache, attrName) - - viewPlayerCacheRet = [playerID, tagPlayerID, equipClassLV, cacheInfo] - CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ViewPlayerCacheRet, viewPlayerCacheRet, [serverGroupID]) - return - -def CrossServerMsg_ViewPlayerCacheRet(msgData, tick): - - playerID, tagPlayerID, equipClassLV, cacheInfo = msgData - GameWorld.Log("收到跨服服务器回复的查看玩家信息: playerID=%s,tagPlayerID=%s" % (playerID, tagPlayerID)) - - PyGameData.g_crossPlayerViewCache[tagPlayerID] = [cacheInfo, tick] # 更新信息 - - curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) - if curPlayer: - SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo) - - return - -def SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo): - if not cacheInfo: - PlayerControl.NotifyCode(curPlayer, "ViewPlayer_OffLine") - return - - if equipClassLV: - itemData = cacheInfo.get("ItemData%s" % equipClassLV, "") - sendPack = ChPyNetSendPack.tagSCPlayerEquipCacheResult() - sendPack.PlayerID = tagPlayerID - sendPack.EquipClassLV = equipClassLV - sendPack.ItemData = itemData - sendPack.ItemDataSize = len(sendPack.ItemData) - NetPackCommon.SendFakePack(curPlayer, sendPack) - return - - #回包客户端 - sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult() - sendPack.PlayerID = tagPlayerID - sendPack.PropData = cacheInfo.get("PropData", "") - sendPack.PropDataSize = len(sendPack.PropData) - sendPack.PlusData = cacheInfo.get("PlusData", "") - sendPack.PlusDataSize = len(sendPack.PlusData) - NetPackCommon.SendFakePack(curPlayer, sendPack) - return - def CrossServerMsg_PutInItem(itemInfo): ## 跨服获得物品 @@ -428,6 +346,46 @@ PyGameData.g_crossSetPlayerAttr = {} return +def OnPlayerLogin(curPlayer): + if not IsCrossServerOpen(): + return + + Sync_CrossZoneInfo(curPlayer) + LoginDoUnNotifyCrossMsg(curPlayer) + return + +def MapServer_QueryCrossPlayerResult(playerID, callName, msgInfo, offlineExitCross=False): + ## 同步地图跨服玩家处理信息,玩家可能不在线,缓存后等玩家上线处理,暂不考虑存档问题,服务器维护后未处理的命令将失效 + + curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) + if curPlayer and curPlayer.GetInitOK(): + msgInfo = str(msgInfo) + curPlayer.MapServer_QueryPlayerResult(0, 0, callName, msgInfo, len(msgInfo)) + return curPlayer + else: + # 缓存起来,等上线后处理 + if playerID not in PyGameData.g_unNotifyPlayerCrossMsgDict: + PyGameData.g_unNotifyPlayerCrossMsgDict[playerID] = [] + msgList = PyGameData.g_unNotifyPlayerCrossMsgDict[playerID] + msgList.append([callName, msgInfo]) + GameWorld.Log("玩家不在线,添加未通知的跨服命令: %s, msgInfo=%s" % (callName, msgInfo), playerID) + if offlineExitCross: + DoOfflinePlayerExitCrossServer(playerID) + return +def LoginDoUnNotifyCrossMsg(curPlayer): + playerID = curPlayer.GetPlayerID() + msgList = PyGameData.g_unNotifyPlayerCrossMsgDict.pop(playerID, []) + if not msgList: + return + for callName, msgInfo in msgList: + GameWorld.Log("上线处理未通知的跨服命令: %s, msgInfo=%s" % (callName, msgInfo), playerID) + msgInfo = str(msgInfo) + curPlayer.MapServer_QueryPlayerResult(0, 0, callName, msgInfo, len(msgInfo)) + return - \ No newline at end of file +def Sync_CrossZoneInfo(curPlayer): + clientPack = ChPyNetSendPack.tagGCCrossZoneInfo() + clientPack.CommZoneID = GetServerCommCrossZoneID(GameWorld.GetServerGroupID()) + NetPackCommon.SendFakePack(curPlayer, clientPack) + return -- Gitblit v1.8.0