| | |
| | | #!/usr/bin/python
|
| | | # -*- coding: GBK -*-
|
| | |
|
| | | ##@package PlayerMirror
|
| | | # 创建玩家镜像, 考虑地图人满问题,py可以做个预判,可调整地图配置的人数上限
|
| | |
|
| | | #-------------------------------------------------------------------------------
|
| | | #
|
| | | ##@package GM.Commands.PlayerMirror
|
| | | #
|
| | | # @todo:创建玩家镜像进行战斗
|
| | | # @author hxp
|
| | | # @date 2024-10-17
|
| | | # @version 1.0
|
| | | #
|
| | | # 详细描述: 创建玩家镜像, 考虑地图人满问题,py可以做个预判,可调整地图配置的人数上限
|
| | | #
|
| | | #-------------------------------------------------------------------------------
|
| | | #"""Version = 2024-10-17 15:00"""
|
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import GameWorld
|
| | | import PlayerEventCounter
|
| | | import ChPlayer
|
| | | import GameServerRefresh
|
| | | import MirrorAttack
|
| | | import PlayerViewCacheTube
|
| | | import PlayerFB
|
| | | import ChConfig
|
| | |
|
| | | ## GM命令执行入口
|
| | | # @param curPlayer 当前玩家
|
| | | # @param playerList 参数列表 [玩家ID]
|
| | | # @param paramList 参数列表 [玩家ID]
|
| | | # @return None
|
| | | # @remarks 函数详细说明.
|
| | | def OnExec(curPlayer, playerList):
|
| | | playerID = 0
|
| | | if len(playerList) != 0:
|
| | | playerID = playerList[0]
|
| | | |
| | | if playerID != 0:
|
| | | #向GameServer请求其他玩家数据
|
| | | #开始查询
|
| | | curPlayer.GameServer_QueryPlayerByID(ChConfig.queryType_MirrorPlayer, playerID, 'PlayerMirror', '', 0)
|
| | | def OnExec(curPlayer, paramList):
|
| | | if not paramList:
|
| | | GameWorld.DebugAnswer(curPlayer, "-------------------%s" % GameWorld.GetCurrentDataTimeStr())
|
| | | GameWorld.DebugAnswer(curPlayer, "创建战斗: PlayerMirror c 是否后台 [目标ID ID2 ...]")
|
| | | GameWorld.DebugAnswer(curPlayer, "开始战斗: PlayerMirror s")
|
| | | GameWorld.DebugAnswer(curPlayer, "跳过战斗: PlayerMirror q")
|
| | | GameWorld.DebugAnswer(curPlayer, "退出战斗: PlayerMirror e")
|
| | | GameWorld.DebugAnswer(curPlayer, "更新镜像: PlayerMirror 5")
|
| | | GameWorld.DebugAnswer(curPlayer, "是否后台:0-玩家自身参与战斗")
|
| | | GameWorld.DebugAnswer(curPlayer, "是否后台:1-玩家无感知,系统直接出结果")
|
| | | GameWorld.DebugAnswer(curPlayer, "目标ID:无-自己;>0-其他玩家ID支持跨服玩家ID")
|
| | | GameWorld.DebugAnswer(curPlayer, "目标ID多个时为多对多战斗")
|
| | | GameWorld.DebugAnswer(curPlayer, "多对多阵营分配均分AABBB即玩家和AA对BBB")
|
| | | return
|
| | |
|
| | | playerData = curPlayer.GetPackData()
|
| | | # playerData为base64后的数据
|
| | | mirrorPlayer = GameWorld.GetGameWorld().CreateMirrorPlayer(playerData, curPlayer.GetPosX(), curPlayer.GetPosY())
|
| | |
|
| | | #是否镜像玩家 判断 mirrorPlayer.GetRealPlayerID()是否为0
|
| | | if mirrorPlayer:
|
| | | GameWorld.Log("mirrorPlayer.GetRealPlayerID %s"%mirrorPlayer.GetRealPlayerID())
|
| | | index = mirrorPlayer.GetIndex()
|
| | | mapID = ChConfig.Def_FBMapID_MirrorBattle
|
| | | lineID = 0
|
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | value1 = paramList[0]
|
| | | if value1 == "c":
|
| | | isSysbg = paramList[1] if len(paramList) > 1 else 0
|
| | | if not isSysbg:
|
| | | if not PlayerFB.DoEnterCustomScene(curPlayer, mapID, lineID, tick):
|
| | | GameWorld.DebugAnswer(curPlayer, "进入自定义PK创景失败:%s" % mapID)
|
| | | return
|
| | | |
| | | mirrorIDList = paramList[2:]
|
| | | if not mirrorIDList:
|
| | | mirrorIDList.append(playerID)
|
| | | |
| | | factionIDListA, factionIDListB = [playerID], []
|
| | | while mirrorIDList:
|
| | | # 后面为对手
|
| | | factionIDListB.append(mirrorIDList.pop(-1))
|
| | | # 前面为队友
|
| | | if mirrorIDList:
|
| | | factionIDListA.append(mirrorIDList.pop(0))
|
| | | |
| | | posX, posY = curPlayer.GetPosX(), curPlayer.GetPosY()
|
| | | battlePlayerList = []
|
| | | for i, batPlayerID in enumerate(factionIDListA):
|
| | | battlePlayerList.append({"playerID":batPlayerID, "faction":1, "posX":posX, "posY":posY + i * 5})
|
| | | for i, batPlayerID in enumerate(factionIDListB):
|
| | | battlePlayerList.append({"playerID":batPlayerID, "faction":2, "posX":posX + 5, "posY":posY + i * 5})
|
| | | |
| | | GameWorld.DebugAnswer(curPlayer, "创建镜像: %s VS %s" % (factionIDListA, factionIDListB))
|
| | | requestID = playerID
|
| | | MirrorAttack.OnRequestCreateMirrorBattle(mapID, lineID, requestID, battlePlayerList, isSysbg, curPlayer)
|
| | | |
| | | elif value1 == "s":
|
| | | battle = MirrorAttack.GetMirrorBattle(curPlayer)
|
| | | if battle:
|
| | | MirrorAttack.OnMirrorBattleStart(battle.battleID)
|
| | | |
| | | elif value1 == "q":
|
| | | battle = MirrorAttack.GetMirrorBattle(curPlayer)
|
| | | if battle:
|
| | | MirrorAttack.DoMirrorBattleQuick(battle.battleID)
|
| | | |
| | | elif value1 == "e":
|
| | | PlayerFB.DoExitCustomScene(curPlayer)
|
| | | |
| | | elif value1 == 5:
|
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | ChPlayer.PlayerLogin(index, tick)
|
| | | PlayerEventCounter.GameServer_InitOK(index, tick)
|
| | | ChPlayer.LoadMapOK(index, tick)
|
| | | GameServerRefresh.GameSever_PlayerInitOK(index, tick) |
| | | PlayerViewCacheTube.UpdateGameServerPlayerCache(curPlayer, tick, forcePackData=True)
|
| | | GameWorld.DebugAnswer(curPlayer, "已更新最新镜像缓存!")
|
| | | |
| | | return
|