From 297de92ab4234a2ec6c84a0b93861a41bc71d1b3 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期一, 12 十一月 2018 17:07:58 +0800
Subject: [PATCH] 4631 【后端】【1.3.0】上古战场增加机器人投放、分线逻辑优化

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py                              |   14 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_EnterFB.py                 |   42 +++--
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_ElderBattlefield.py |  361 ++++++++++++++++++++++++++++++--------------
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py                                          |    4 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/NormalNPC_Attack_Player.py          |    9 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py                                            |    5 
 6 files changed, 297 insertions(+), 138 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/NormalNPC_Attack_Player.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/NormalNPC_Attack_Player.py
index e652130..647fb07 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/NormalNPC_Attack_Player.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/NormalNPC_Attack_Player.py
@@ -22,7 +22,7 @@
 import ChEquip
 import GameWorld
 import EventShell
-import SkillShell
+import FBLogic
 import GameObj
 import NPCCommon
 import ChNPC
@@ -113,11 +113,14 @@
     else:
         #通知玩家
         if curTagPlayer.GetMapID() != ChConfig.Def_FBMapID_XMZZ:
-            PlayerControl.NotifyCode(curTagPlayer, 'GeRen_chenxin_279029', [curNormalNPC.GetNPCID()])
+            if curNormalNPC.GetType() == ChConfig.ntRobot:
+                PlayerControl.NotifyCode(curTagPlayer, 'RobotKill_1', [curNormalNPC.GetObjID(), curNormalNPC.GetNPCID()])
+            else:
+                PlayerControl.NotifyCode(curTagPlayer, 'GeRen_chenxin_279029', [curNormalNPC.GetNPCID()])
         #玩家已经死亡
         playerControl = PlayerControl.PlayerControl(curTagPlayer)
         playerControl.SetDead()
-        
+        FBLogic.DoFBOnNPCKill_Player(curNormalNPC, curTagPlayer, tick)
         #触发玩家死亡事件
         EventShell.EventRespons_PlayerEvent(curTagPlayer, "player_dead")
     return True
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index be2b304..dca95dd 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -1798,7 +1798,7 @@
 Def_NoPlayerNeedProcessRefreshPointMap = [Def_FBMapID_SealDemon, Def_FBMapID_GodArea, Def_FBMapID_BossHome]
 
 # 可重复进的副本
-Def_NoLimitEnterCntMap = [Def_FBMapID_FamilyParty, Def_FBMapID_FamilyWar, Def_FBMapID_FamilyInvade]
+Def_NoLimitEnterCntMap = [Def_FBMapID_FamilyParty, Def_FBMapID_FamilyWar, Def_FBMapID_FamilyInvade, Def_FBMapID_ElderBattlefield]
 
 # 无玩家时不自动关闭的自伸缩副本
 Def_NoPlayerNotCloseAutoSizeMap = [Def_FBMapID_FamilyInvade, Def_FBMapID_FamilyBossMap]
@@ -4938,8 +4938,9 @@
 ntPet,
 ntTouchKill, #触碰后自杀类 17
 ntUndeath, #不死类型 18
+ntRobot, #上古战场机器人类型 19
 ntMax
-) = range(20)
+) = range(21)
 
 
 (Def_SkillFuncType_Common, #0为通用技能
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
index bb1d347..aff2794 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
@@ -355,6 +355,16 @@
     
     return
 
+def DoFBOnNPCKill_Player(curNPC, curPlayer, tick):
+    ## 副本内NPC杀人
+    do_FBLogic_ID = __GetFBLogic_MapID(GameWorld.GetMap().GetMapID())
+    
+    callFunc = GameWorld.GetExecFunc(FBProcess, "GameLogic_%s.%s" % (do_FBLogic_ID, "DoFBOnNPCKill_Player"))
+    
+    if callFunc:
+        #GameWorld.Log("副本逻辑不可使用   GameLogic_%d"%(mapID))
+        return  callFunc(curNPC, curPlayer, tick)
+    return
 #---------------------------------------------------------------------
 ## 任务专用,触发事件(副本内攻击人)
 #  @param curPlayer 攻击者
@@ -1897,14 +1907,14 @@
 #  @param mapID 玩家
 #  @param tick 当前时间
 #  @return None-未找到,线路id - 0~N
-def GetFBLineMaxPlayerCount(mapID):
+def GetFBLineMaxPlayerCount(mapID, lineID):
     
     do_FBLogic_ID = __GetFBLogic_MapID(mapID)
     
     callFunc = GameWorld.GetExecFunc(FBProcess, "GameLogic_%s.%s" % (do_FBLogic_ID, "GetFBLineMaxPlayerCount"))
     
     if callFunc:
-        return callFunc()
+        return callFunc(lineID)
     
     return 0
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_ElderBattlefield.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_ElderBattlefield.py
index d9c5a46..9ca4291 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_ElderBattlefield.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_ElderBattlefield.py
@@ -34,6 +34,7 @@
 import NPCCustomRefresh
 import SkillShell
 import EventReport
+import SkillCommon
 
 import random
 import time
@@ -41,44 +42,53 @@
 #------------------------------------------------------------------------------
 #
 
-
 # 副本玩家字典key
-FBPlayerDict_Score = 'FBPD_Score%s'   # 玩家当前积分
-FBPlayerDict_KillCnt = 'FBPD_KillCnt'   # 玩家当前杀敌数
-FBPD_LastCheckTick = 'FBPD_LastCheckTick'   # 检查刷怪时间
-FBPlayerDict_ContKillCntEx = 'FBPD_ContKillCntEx'   # 玩家当前总连杀数
-FBPlayerDict_TotalExp = 'FBPlayerDict_TotalExp%s'   # 获得的总经验
-FBPlayerDict_TotalExpPoint = 'FBPlayerDict_TotalExpPoint%s'   # 获得的总经验点
-FBPlayerDict_EnemyID = 'FBPD_EnemyID'   # 玩家最近一个仇敌ID
-Map_ElderBattlefield_StartTick = "Map_ElderBattlefield_StartTick"     # 副本开始时间
-Map_ElderBattlefield_TopPlayer = "Map_ElderBattlefield_TopPlayer"     # 积分王
-
+FBPlayerDict_Score = 'FBPD_Score%s'  # 玩家当前积分
+FBPlayerDict_KillCnt = 'FBPD_KillCnt'  # 玩家当前杀敌数
+FBPD_LastCheckTick = 'FBPD_LastCheckTick'  # 检查刷buff时间
+FBPD_LastCheckTick1 = 'FBPD_LastCheckTick1'  # 检查刷机器人时间
+FBPlayerDict_ContKillCntEx = 'FBPD_ContKillCntEx'  # 玩家当前总连杀数
+FBPlayerDict_TotalExp = 'FBPlayerDict_TotalExp%s'  # 获得的总经验
+FBPlayerDict_TotalExpPoint = 'FBPlayerDict_TotalExpPoint%s'  # 获得的总经验点
+FBPlayerDict_EnemyID = 'FBPD_EnemyID'  # 玩家最近一个仇敌ID
+FBPlayerDict_RebornBuffLV = 'RebornBuffLV'  # 玩家当前复活BUFFLV
+Map_ElderBattlefield_StartTick = "Map_ElderBattlefield_StartTick"  # 副本开始时间
+Map_ElderBattlefield_TopPlayer = "Map_ElderBattlefield_TopPlayer"  # 积分王
 
 #
+(
+Def_PlayerCnt,  # 真人数量
+Def_RobotCnt,  # 机器人最大数量
+Def_TotalCnt,  # 真人+机器人总和
+) = range(3)
 
 #当前副本地图的状态
 (
-FB_Step_Open, # 副本开启
-FB_Step_Fighting, # 副本进行中
-FB_Step_Over, # 副本结束
+FB_Step_Open,  # 副本开启
+FB_Step_Fighting,  # 副本进行中
+FB_Step_Over,  # 副本结束
 ) = range(3)
+
+def OnLogin(curPlayer):
+    OnElderBattlefieldFBResult(curPlayer, True)
+    return
 
 def OnElderBattlefieldStateChange(state, tick):
     #活动状态变更
-    mapID = GameWorld.GetMap().GetMapID()
-    if mapID != ChConfig.Def_FBMapID_ElderBattlefield:
-        return
+#    mapID = GameWorld.GetMap().GetMapID()
+#    if mapID != ChConfig.Def_FBMapID_ElderBattlefield:
+#        return
     GameWorld.DebugLog('    上古战场活动状态变更 state=%s' % state)
 
     if state == 1:
         GameWorld.GetGameWorld().SetGameWorldDict(Map_ElderBattlefield_StartTick, tick)
         GameWorld.GetGameWorld().SetGameWorldDict(Map_ElderBattlefield_TopPlayer, 0)
 
-#    else:
-#        GiveJoinPrize()
-#        FBCommon.DoLogic_FBKickAllPlayer()
-#        GameWorldProcess.CloseFB(tick)
+    else:
+        GiveJoinPrize()
+
     return
+
 
 ##开启副本
 # @param tick 时间戳
@@ -115,6 +125,7 @@
 
     return True
 
+
 ##是否可以进入
 # @param ask 请求结构体
 # @param tick 时间戳
@@ -124,6 +135,7 @@
     
     #可进入
     return IPY_GameWorld.cmeAccept
+
 
 ##玩家进入副本
 # @param curPlayer 玩家实例
@@ -146,16 +158,15 @@
     
     if not FBCommon.GetHadDelTicket(curPlayer):
         FBCommon.SetHadDelTicket(curPlayer)
-        FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_ElderBattlefield)
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_ElderBattlefieldStage, 0)
-        GameWorld.GetGameWorld().SetGameWorldDict(FBPlayerDict_Score % playerID, 0)
-        GameWorld.GetGameWorld().SetGameWorldDict(FBPlayerDict_TotalExp % playerID, 0)
-        GameWorld.GetGameWorld().SetGameWorldDict(FBPlayerDict_TotalExpPoint % playerID, 0)
-        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_ElderBattlefield, 0, ChConfig.CME_Log_Start)
+        if FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_ElderBattlefield):
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_ElderBattlefieldStage, 0)
+            GameWorld.GetGameWorld().SetGameWorldDict(FBPlayerDict_Score % playerID, 0)
+            GameWorld.GetGameWorld().SetGameWorldDict(FBPlayerDict_TotalExp % playerID, 0)
+            GameWorld.GetGameWorld().SetGameWorldDict(FBPlayerDict_TotalExpPoint % playerID, 0)
+            EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_ElderBattlefield, 0, ChConfig.CME_Log_Start)
     
     DoFBHelp(curPlayer, tick)
     return
-
 
 
 ##副本玩家进入点, 玩家分散在半径3格范围
@@ -168,6 +179,7 @@
 def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
     return random.choice(ipyEnterPosInfo)
 
+
 ## 获取层随机坐标点
 def __GetRandPos():
     ipyEnterPosInfo = FBCommon.GetFBLineEnterPosInfo(ChConfig.Def_FBMapID_ElderBattlefield, 0)
@@ -175,6 +187,7 @@
     dist = 3 if len(enterPos) <= 2 else enterPos[2]
     posPoint = GameMap.GetEmptyPlaceInArea(enterPos[0], enterPos[1], dist)
     return posPoint.GetPosX(), posPoint.GetPosY()
+
 
 ##玩家退出副本
 # @param curPlayer 玩家实例
@@ -184,21 +197,30 @@
     buffIDList = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldBuff')
     for buffID in buffIDList:
         BuffSkill.DelBuffBySkillID(curPlayer, buffID, tick)
+    
+    
     return
+
 
 ##玩家主动离开副本.
 # @param curPlayer 玩家实例
 # @param tick 时间戳
 # @return 返回值无意义
 def DoPlayerLeaveFB(curPlayer, tick):
-    OnElderBattlefieldFBResult(curPlayer)
+
     return
 
 
 ##玩家切换地图
 def DoPlayerChangeMapLogic(curPlayer):
-    OnElderBattlefieldFBResult(curPlayer)
+    #副本的连杀,仇敌,死亡BUFF重置,积分不重置
+    
+    playerID = curPlayer.GetID()
+    gameFB = GameWorld.GetGameFB()
+    gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_ContKillCntEx, 0)
+    gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_EnemyID, 0)
     return
+
 
 ##副本总逻辑计时器
 # @param tick 时间戳
@@ -212,13 +234,25 @@
             FBCommon.SetFBStep(FB_Step_Fighting, tick)
     elif fbStep == FB_Step_Fighting:
         if not FBCommon.GetFBFuncOpenState(ChConfig.Def_FBMapID_ElderBattlefield):
-            GiveJoinPrize()
+            #GiveJoinPrize()
+            #积分王
+            topPlayerID = GameWorld.GetGameWorld().GetGameWorldDictByKey(Map_ElderBattlefield_TopPlayer)
+            if topPlayerID:
+                topAwardList = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldTopAward')
+                if topAwardList:
+                    PlayerControl.SendMailByKey("ElderBattlefieldTopMail", [topPlayerID], topAwardList) 
+                    PlayerControl.WorldNotify(0, 'ElderBattlefieldBest', [PyGameData.g_sgzztopPlayerName, topAwardList[0][0]])
+                GameWorld.GetGameWorld().SetGameWorldDict(Map_ElderBattlefield_TopPlayer, 0)
+            
+            
             FBCommon.SetFBStep(FB_Step_Over, tick)
             FBCommon.DoLogic_FBKickAllPlayer()
             GameWorldProcess.CloseFB(tick)
         else:
             __CheckRefreshBuffNPC(tick)
+            __RefreshRobot(tick)
     return
+
 
 def __CheckRefreshBuffNPC(tick):
     #检查buffnpc刷怪
@@ -229,13 +263,13 @@
         return
     gameFB.SetGameFBDict(FBPD_LastCheckTick, tick)
     
-    allRmark = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldBuff',3)
-    maxCnt = IpyGameDataPY.GetFuncCfg('ElderBattlefieldBuff',4)
+    allRmark = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldBuff', 3)
+    maxCnt = IpyGameDataPY.GetFuncCfg('ElderBattlefieldBuff', 4)
 
-    rmarkList = [] #可刷怪的标识点
+    rmarkList = []  #可刷怪的标识点
     npcCnt = 0
     gameNPC = GameWorld.GetNPCManager()
-    for i in range(0, gameNPC.GetCustomNPCRefreshCount()):
+    for i in xrange(gameNPC.GetCustomNPCRefreshCount()):
         npcRefresh = gameNPC.GetCustomNPCRefreshAt(i)
         rmark = npcRefresh.GetRefreshMark()
         if rmark not in allRmark:
@@ -243,17 +277,75 @@
         npcCnt += npcRefresh.GetCount()
         if not npcRefresh.GetCount():
             rmarkList.append(rmark)
-        
     
-    needAddCnt = maxCnt- npcCnt
+    needAddCnt = maxCnt - npcCnt
     if not needAddCnt:
         return
     random.shuffle(rmarkList)
-    npcID = IpyGameDataPY.GetFuncCfg('ElderBattlefieldBuff',2)
+    npcID = IpyGameDataPY.GetFuncCfg('ElderBattlefieldBuff', 2)
     for rMark in rmarkList[:needAddCnt]:
         NPCCustomRefresh.SetNPCRefresh(rMark, [(npcID, 1)], 1, 1)
-    NPCCustomRefresh.ProcessAllNPCRefresh(tick) # 立即出发一次标识点刷新
+    NPCCustomRefresh.ProcessAllNPCRefresh(tick)  # 立即出发一次标识点刷新
     
+    return
+
+
+def __RefreshRobot(tick):
+    ##刷新机器人
+    gameFB = GameWorld.GetGameFB()
+    lastCheckTick = gameFB.GetGameFBDictByKey(FBPD_LastCheckTick1)
+    if lastCheckTick and tick - lastCheckTick < 2000:
+        return
+    gameFB.SetGameFBDict(FBPD_LastCheckTick1, tick)
+    fblineid = GameWorld.GetGameWorld().GetLineID()
+    g_elderBattleRobotDieList = PyGameData.g_elderBattleRobotDieDict.get(fblineid, [])
+    robotCfgDict = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldCfg', 3, {})
+    lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
+    if lineID not in robotCfgDict:
+        return
+    rmarkList = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldRobot', 5)
+    curNPCCnt = 0
+    robotCntDict = {}
+    gameNPC = GameWorld.GetNPCManager()
+    for i in xrange(gameNPC.GetCustomNPCRefreshCount()):
+        npcRefresh = gameNPC.GetCustomNPCRefreshAt(i)
+        rmark = npcRefresh.GetRefreshMark()
+        if rmark not in rmarkList:
+            continue
+        cnt = npcRefresh.GetCount()
+        robotCntDict[rmark] = cnt
+        curNPCCnt += cnt
+    
+    robotCfg = robotCfgDict[lineID]
+    curPlayerCnt = GameWorld.GetMapCopyPlayerManager().GetPlayerCount()
+    maxRobotCnt = min(robotCfg[Def_TotalCnt] - curPlayerCnt, robotCfg[Def_RobotCnt])
+    extraCnt = maxRobotCnt - curNPCCnt - len(g_elderBattleRobotDieList)
+    rebornTime = IpyGameDataPY.GetFuncCfg('ElderBattlefieldRobot')
+    rebornCnt = 0
+    for dieTick in g_elderBattleRobotDieList:
+        if tick - dieTick < rebornTime * 1000:
+            break
+        rebornCnt += 1
+    PyGameData.g_elderBattleRobotDieDict[fblineid] = g_elderBattleRobotDieList[rebornCnt:]
+    refreshCnt = rebornCnt + extraCnt
+    #GameWorld.DebugLog('    刷新机器人 rebornCnt=%s,extraCnt=%s,refreshCnt=%s,robotCntDict=%s'%(rebornCnt, extraCnt,refreshCnt,robotCntDict))
+    if refreshCnt > 0:
+        npcID = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldRobot', 2, {}).get(lineID, 0)
+        if not npcID:
+            return
+        
+        random.shuffle(rmarkList)
+        hasRefreshCnt = 0
+        for i, rMark in enumerate(rmarkList):
+            if hasRefreshCnt >=refreshCnt:
+                break
+            curCnt = robotCntDict.get(rMark, 0)
+            cnt = 1 if i < len(rmarkList)-1 else refreshCnt-hasRefreshCnt
+            hasRefreshCnt += cnt
+            curMaxCnt = curCnt+cnt
+            NPCCustomRefresh.SetNPCRefresh(rMark, [(npcID, cnt)], curMaxCnt, cnt)
+        NPCCustomRefresh.ProcessAllNPCRefresh(tick)
+        
     return
 
 
@@ -262,29 +354,21 @@
 # @return 无意义
 # @remarks 战斗逻辑
 def GiveJoinPrize():
-    copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
-    for i in xrange(copyMapPlayerManager.GetPlayerCount()):
-        
-        curPlayer = copyMapPlayerManager.GetPlayerByIndex(i)
-        
-        if curPlayer == None or curPlayer.IsEmpty():
+    playerManager = GameWorld.GetPlayerManager()
+    for i in xrange(playerManager.GetPlayerCount()):
+        curPlayer = playerManager.GetPlayerByIndex(i)
+        if curPlayer == None or not curPlayer.GetInitOK():
             continue
         OnElderBattlefieldFBResult(curPlayer)
         
-    #积分王
-    topPlayerID = GameWorld.GetGameWorld().GetGameWorldDictByKey(Map_ElderBattlefield_TopPlayer)
-    if topPlayerID:
-        topAwardList = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldTopAward')
-        if topAwardList:
-            PlayerControl.SendMailByKey("ElderBattlefieldTopMail", [topPlayerID], topAwardList) 
-            PlayerControl.WorldNotify(0, 'ElderBattlefieldBest', [PyGameData.g_sgzztopPlayerName, topAwardList[0][0]])
-        GameWorld.GetGameWorld().SetGameWorldDict(Map_ElderBattlefield_TopPlayer, 0)
+    
     return
 
-def OnElderBattlefieldFBResult(curPlayer):
+
+def OnElderBattlefieldFBResult(curPlayer, isLogin=False):
     # 玩家处理上古战场结算信息
-    GameWorld.DebugLog('    玩家处理上古战场结算信息 %s' % curPlayer.GetPlayerID())
-    lineID = 0 #GameWorld.GetGameWorld().GetPropertyID() -1
+    GameWorld.DebugLog('    玩家处理上古战场结算信息 , isLogin=%s' % isLogin, curPlayer.GetPlayerID())
+    lineID = 0  #GameWorld.GetGameWorld().GetPropertyID() -1
     fbRewardDict = FBCommon.GetFBLineReward(ChConfig.Def_FBMapID_ElderBattlefield, lineID)
     
     curStage = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ElderBattlefieldStage, 0)
@@ -298,20 +382,20 @@
         rewardItemList.append([itemID, itemCnt, 1])
     for itemID, itemCnt in succAwardDict.items():
         rewardItemList.append([itemID, itemCnt, 1])
-        
     needSpace = len(rewardItemList)
     emptySpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
-    if emptySpace < needSpace:
+    mapID = GameWorld.GetMap().GetMapID()
+    if mapID != ChConfig.Def_FBMapID_ElderBattlefield or isLogin or emptySpace < needSpace:
         PlayerControl.SendMailByKey("ElderBattlefieldMail", [curPlayer.GetPlayerID()], rewardItemList)
     else:
         for itemID, itemCnt, isBind in rewardItemList:
             ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, isBind, [IPY_GameWorld.rptItem], event=["ElderBattlefield", False, {}])
-    overDict = {FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(itemList), FBCommon.Over_succItemInfo:FBCommon.GetJsonItemList(succAwardDict.items())}
-    FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_ElderBattlefield, lineID, 1, overDict)
+    
+        overDict = {FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(itemList), FBCommon.Over_succItemInfo:FBCommon.GetJsonItemList(succAwardDict.items())}
+        FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_ElderBattlefield, lineID, 1, overDict)
     #结算过,重置阶段
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_ElderBattlefieldStage, 0)
     return
-
 
 
 def __AddElderBattlefieldPlayerScore(curPlayer, gameFB, addValue):
@@ -367,6 +451,7 @@
 
 #---------------------------------------------------------------------
 
+
 ##获得副本帮助信息, 用于通知阵营比分条
 # @param curPlayer 玩家实例
 # @param tick 时间戳
@@ -392,11 +477,15 @@
     helpDict['topScore'] = topScore if topPlayerID else 0
     helpDict['topPlayerID'] = topPlayerID
     #helpDict[FBCommon.Help_lineID] = GameWorld.GetGameWorld().GetLineID()
-    helpDict['enemyID'] =  GameWorld.GetGameFB().GetPlayerGameFBDictByKey(playerID, FBPlayerDict_EnemyID)
+    helpDict['enemyID'] = GameWorld.GetGameFB().GetPlayerGameFBDictByKey(playerID, FBPlayerDict_EnemyID)
     GameWorld.DebugLog("DoFBHelp %s" % helpDict, playerID)
     FBCommon.Notify_FBHelp(curPlayer, helpDict)
     return
 
+def DoFBOnNPCKill_Player(curNPC, curPlayer, tick):
+    if curNPC.GetNPCID() in IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldRobot', 2, {}).values():
+        DoFBOnKill_Player(curNPC, curPlayer, tick)
+    return
 
 ##处理副本中杀死玩家逻辑
 # @param curPlayer 玩家实例
@@ -404,58 +493,66 @@
 # @param tick 时间戳
 # @return 布尔值
 # @remarks 处理副本中杀死玩家逻辑
-def DoFBOnKill_Player(curPlayer, defender, tick):
+def DoFBOnKill_Player(atkobj, defender, tick):
     gameFB = GameWorld.GetGameFB()
-    playerID = curPlayer.GetPlayerID()
-    GameWorld.DebugLog("DoFBOnKill_Player", playerID)
+    atkIsPlayer = atkobj.GetGameObjType() == IPY_GameWorld.gotPlayer
+    addScore = 0
+    if atkIsPlayer:
+        playerID = atkobj.GetPlayerID()
+        GameWorld.DebugLog("DoFBOnKill_Player", playerID)
     
-    # 击杀方处理
-    killCnt = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_KillCnt) + 1 # 击杀数
-    gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_KillCnt, killCnt)
-    contKillCntEx = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_ContKillCntEx) + 1 # 连杀数
-    gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_ContKillCntEx, contKillCntEx)
-    #连杀广播
-    ckillSysList = IpyGameDataPY.GetFuncCfg('ElderBattlefieldSys', 1)
-    baseCnt = IpyGameDataPY.GetFuncCfg('ElderBattlefieldSys', 2)
-    perCnt = IpyGameDataPY.GetFuncCfg('ElderBattlefieldSys', 3)
-    if contKillCntEx >= baseCnt and contKillCntEx % perCnt == 0:
-        sysIndex = min((contKillCntEx - baseCnt) / perCnt, len(ckillSysList)-1)
-        PlayerControl.FBNotify(ckillSysList[sysIndex], [curPlayer.GetName(), contKillCntEx])
-        PlayerControl.NotifyCode(curPlayer, 'AncientBattlefield_10', [contKillCntEx])
-    if contKillCntEx == 5:
-        PlayerControl.NotifyCode(curPlayer, 'AncientBattlefield_10', [5])
+        # 击杀方处理
+        killCnt = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_KillCnt) + 1  # 击杀数
+        gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_KillCnt, killCnt)
+        contKillCntEx = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_ContKillCntEx) + 1  # 连杀数
+        gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_ContKillCntEx, contKillCntEx)
+        #连杀广播
+        ckillSysList = IpyGameDataPY.GetFuncCfg('ElderBattlefieldSys', 1)
+        baseCnt = IpyGameDataPY.GetFuncCfg('ElderBattlefieldSys', 2)
+        perCnt = IpyGameDataPY.GetFuncCfg('ElderBattlefieldSys', 3)
+        if contKillCntEx >= baseCnt and contKillCntEx % perCnt == 0:
+            sysIndex = min((contKillCntEx - baseCnt) / perCnt, len(ckillSysList) - 1)
+            PlayerControl.FBNotify(ckillSysList[sysIndex], [atkobj.GetName(), contKillCntEx])
+            PlayerControl.NotifyCode(atkobj, 'AncientBattlefield_10', [contKillCntEx])
+        if contKillCntEx == 5:
+            PlayerControl.NotifyCode(atkobj, 'AncientBattlefield_10', [5])
   
-    # 击杀方成就
-    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_ElderBattlefieldKill, 1)
-    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_ElderBattlefieldConKill, 1, [contKillCntEx])
-    
+        # 击杀方成就
+        PlayerSuccess.DoAddSuccessProgress(atkobj, ShareDefine.SuccType_ElderBattlefieldKill, 1)
+        PlayerSuccess.DoAddSuccessProgress(atkobj, ShareDefine.SuccType_ElderBattlefieldConKill, 1, [contKillCntEx])
+        
+        addScore = IpyGameDataPY.GetFuncCfg('ElderBattlefieldCfg', 2)
         
     # 被杀方处理
-    tagPlayerID = defender.GetPlayerID()
-    defContKillCntEx = gameFB.GetPlayerGameFBDictByKey(tagPlayerID, FBPlayerDict_ContKillCntEx)
-    if defContKillCntEx >=baseCnt:
-        PlayerControl.FBNotify('AncientBattlefield_7', [curPlayer.GetName(), defender.GetName(),defContKillCntEx])
-    
-    gameFB.SetPlayerGameFBDict(tagPlayerID, FBPlayerDict_ContKillCntEx, 0)
-    
-    
-    addScore = IpyGameDataPY.GetFuncCfg('ElderBattlefieldCfg', 2)
-    
-    #记录仇人
-    gameFB.SetPlayerGameFBDict(tagPlayerID, FBPlayerDict_EnemyID, playerID)
-    if tagPlayerID == gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_EnemyID):
-        #击杀仇人广播
-        PlayerControl.NotifyCode(curPlayer, 'AncientBattlefield_8')
-        gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_EnemyID, 0)
-        addScore += IpyGameDataPY.GetFuncCfg('ElderBattlefieldPoint', 2)
-    if tagPlayerID == GameWorld.GetGameWorld().GetGameWorldDictByKey(Map_ElderBattlefield_TopPlayer):
-        addScore += IpyGameDataPY.GetFuncCfg('ElderBattlefieldPoint', 1)
-    updScore = __AddElderBattlefieldPlayerScore(curPlayer, gameFB, addScore)
-    GameWorld.DebugLog("击杀玩家: 击杀=%s,连杀=%s,tagPlayerID=%s,updScore=%s" 
-                       % (killCnt, contKillCntEx, tagPlayerID, updScore), playerID)
-    
-    DoFBHelp(curPlayer, tick)
-    DoFBHelp(defender, tick)
+    tagPlayerID = 0
+    if defender.GetGameObjType() == IPY_GameWorld.gotPlayer:
+        tagPlayerID = defender.GetPlayerID()
+        defContKillCntEx = gameFB.GetPlayerGameFBDictByKey(tagPlayerID, FBPlayerDict_ContKillCntEx)
+        if defContKillCntEx >= baseCnt:
+            if atkIsPlayer:
+                PlayerControl.FBNotify('AncientBattlefield_7', [atkobj.GetName(), defender.GetName(), defContKillCntEx])
+            else:
+                PlayerControl.FBNotify('AncientBattlefield_robot', [atkobj.GetNPCID(), atkobj.GetObjID(), defender.GetName(), defContKillCntEx])
+        gameFB.SetPlayerGameFBDict(tagPlayerID, FBPlayerDict_ContKillCntEx, 0)
+        #记录仇人
+        if atkIsPlayer:
+            
+            gameFB.SetPlayerGameFBDict(tagPlayerID, FBPlayerDict_EnemyID, playerID)
+            if tagPlayerID == gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_EnemyID):
+                #击杀仇人广播
+                PlayerControl.NotifyCode(atkobj, 'AncientBattlefield_8')
+                gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_EnemyID, 0)
+                addScore += IpyGameDataPY.GetFuncCfg('ElderBattlefieldPoint', 2)
+            if tagPlayerID == GameWorld.GetGameWorld().GetGameWorldDictByKey(Map_ElderBattlefield_TopPlayer):
+                addScore += IpyGameDataPY.GetFuncCfg('ElderBattlefieldPoint', 1)
+            
+    if atkIsPlayer:
+        updScore = __AddElderBattlefieldPlayerScore(atkobj, gameFB, addScore)
+        GameWorld.DebugLog("击杀玩家: 击杀=%s,连杀=%s,tagPlayerID=%s,updScore=%s" 
+                               % (killCnt, contKillCntEx, tagPlayerID, updScore), playerID)
+        DoFBHelp(atkobj, tick)
+    if defender.GetGameObjType() == IPY_GameWorld.gotPlayer:
+        DoFBHelp(defender, tick)
     return True
 
 
@@ -469,7 +566,9 @@
     fbStep = gameFB.GetFBStep()
 #    if fbStep != FB_State_Fight:
 #        return
-    
+    if curNPC.GetNPCID() in IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldRobot', 2, {}).values():
+        DoFBOnKill_Player(curPlayer, curNPC, tick)
+        __OnRobotDie(tick)
     npcid = curNPC.GetNPCID()
     killNPCScoreDict = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldCfg', 1)
     addScore = killNPCScoreDict.get(npcid)
@@ -477,6 +576,20 @@
         return
     __AddElderBattlefieldPlayerScore(curPlayer, gameFB, addScore)
     DoFBHelp(curPlayer, tick)
+    return
+
+def DoFB_Npc_KillNPC(attacker, curNPC, tick):
+    if curNPC.GetNPCID() in IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldRobot', 2, {}).values():
+        __OnRobotDie(tick)
+    return
+
+def __OnRobotDie(tick):
+    #记录机器人死亡时间
+    lineID = GameWorld.GetGameWorld().GetLineID()
+    if lineID in PyGameData.g_elderBattleRobotDieDict:
+        PyGameData.g_elderBattleRobotDieDict[lineID].append(tick)
+    else:
+        PyGameData.g_elderBattleRobotDieDict[lineID] = [tick]
     return
 
 def OnMoveTouchNPC(curPlayer, curNPC, tick):
@@ -505,6 +618,7 @@
 def CheckPlayersRelation_IsFriend(curPlayer, curTagPlayer):
     return not CanAttackPlayer(curPlayer, curTagPlayer)
 
+
 ##副本中,攻击队友逻辑
 # @param curPlayer 玩家实例
 # @param curTagPlayer 目标玩家实例
@@ -512,6 +626,7 @@
 # @remarks
 def DoCanAttackTeamer(curPlayer, curTagPlayer):
     return CanAttackPlayer(curPlayer, curTagPlayer)
+
 
 ##副本中,是否可攻击
 # @param curPlayer 玩家实例
@@ -534,12 +649,29 @@
 def OnPlayerReborn():
     return True
 
+
 ## 重置副本复活玩家坐标点
 # @param None
 # @return 无意义
 def OnResetFBRebornPlacePos(curPlayer, rebornPlace, tick):
     __SetPlayerRandomPos(curPlayer)
+    #复活加buff
+    playerID = curPlayer.GetID()
+    rebornBuffLV = GameWorld.GetGameFB().GetPlayerGameFBDictByKey(playerID, FBPlayerDict_RebornBuffLV)
+    if rebornBuffLV >= IpyGameDataPY.GetFuncCfg('ElderBattlefieldRobot', 4):
+        return
+    skillBuffID = IpyGameDataPY.GetFuncCfg('ElderBattlefieldRobot', 3) + rebornBuffLV
+    skillBuff = GameWorld.GetGameData().GetSkillBySkillID(skillBuffID)
+    if not skillBuff:
+        GameWorld.Log("上古复活加buff   找不到技能%s" % skillBuffID)
+        return
+    GameWorld.GetGameFB().SetPlayerGameFBDict(playerID, FBPlayerDict_RebornBuffLV, rebornBuffLV+1)
+    buffType = SkillCommon.GetBuffType(skillBuff)
+    BuffSkill.DoAddBuff(curPlayer, buffType, skillBuff, tick)
+    
+    
     return
+
 
 ## 设置玩家随机坐标点
 def __SetPlayerRandomPos(curPlayer):
@@ -551,10 +683,11 @@
 ## 获取副本线路最大玩家人数
 #  @param None
 #  @return 
-def GetFBLineMaxPlayerCount():
-    return IpyGameDataPY.GetFuncCfg('ElderBattlefieldCfg', 3)
-
+def GetFBLineMaxPlayerCount(lineID):
+    cfg = IpyGameDataPY.GetFuncEvalCfg('ElderBattlefieldCfg', 3, {}).get(lineID)
+    if not cfg:
+        return 20
+    return cfg[Def_PlayerCnt]
 
 ## -------------------------------------------------------------------------------------------------
-
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_EnterFB.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_EnterFB.py
index 4eaa6fd..8a9cca4 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_EnterFB.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_EnterFB.py
@@ -65,25 +65,37 @@
         resultLineID = -1  # 结果lineID
         
         gameWorldManager = GameWorld.GetGameWorld()
-        maxPlayerCount = FBLogic.GetFBLineMaxPlayerCount(tagMapID)
+        maxPlayerCount = FBLogic.GetFBLineMaxPlayerCount(tagMapID, tagMapLineID)
         
-        GameWorld.Log("    DoLogic()  tagMapID=%s,maxPlayerCount=%s" % (tagMapID, maxPlayerCount))
-        for index in range(gameWorldManager.GetGameWorldCount()):
+        GameWorld.Log("    DoLogic()  tagMapID=%s,tagMapLineID=%s,maxPlayerCount=%s" % (tagMapID, tagMapLineID,maxPlayerCount))
+        firstEmptyGameWorld = None
+        sameLineGameWorldList = []
+        for index in xrange(gameWorldManager.GetGameWorldCount()):
             gameWorld = IPY_GameWorld.IPY_GameWorld(index)
             playerManager = gameWorld.GetMapCopyPlayerManagerByFbIndex(index)
             propertyID = gameWorld.GetPropertyID()
-            GameWorld.Log("    DoLogic()  check gameworld index=%s,propertyID=%s,playerCount=%s" \
-                          % (index, propertyID, playerManager.GetPlayerCount()))
+            curPlayerCnt = playerManager.GetPlayerCount()
+#            GameWorld.Log("    DoLogic()  check gameworld index=%s,propertyID=%s,playerCount=%s" \
+#                          % (index, propertyID, curPlayerCnt))
+            if propertyID == 0 and not firstEmptyGameWorld:
+                firstEmptyGameWorld = gameWorld
             # 如果不是同一线路属性的,则跳过
             # 如果当前人数超过额定人数,则跳过
-            if propertyID == 0 or (propertyID == tagMapPropertyID \
-                                   and playerManager.GetPlayerCount() < maxPlayerCount):
-                gameWorld.SetPropertyID(tagMapPropertyID)
-                if propertyID == 0:
-                    gameWorld.SetFBFirstOpen(1) # 开启副本
-                resultLineID = gameWorld.GetLineID()
-                GameWorld.Log("    DoLogic()  check ok!resultLineID=%s" % (resultLineID))
-                break
+            if propertyID == tagMapPropertyID and curPlayerCnt < maxPlayerCount:
+                sameLineGameWorldList.append([gameWorld, curPlayerCnt])
+        findGameWorld = None
+        if sameLineGameWorldList:
+            sameLineGameWorldList.sort(key=lambda asd:asd[1])
+            findGameWorld = sameLineGameWorldList[0][0]
+        elif firstEmptyGameWorld:
+            findGameWorld = firstEmptyGameWorld
+        if findGameWorld:
+            if findGameWorld.GetPropertyID() == 0:
+                findGameWorld.SetFBFirstOpen(1) # 开启副本
+            findGameWorld.SetPropertyID(tagMapPropertyID)
+            resultLineID = findGameWorld.GetLineID()
+            GameWorld.Log("    DoLogic()  check ok!resultLineID=%s" % (resultLineID))
+            
             
 #===================================================================================================
 #    # 战盟家园
@@ -137,9 +149,7 @@
         resultLineID = -1  # 结果lineID
         
         gameWorldManager = GameWorld.GetGameWorld()
-        maxPlayerCount = FBLogic.GetFBLineMaxPlayerCount(tagMapID)
-        
-        GameWorld.Log("    DoLogic()  tagMapID=%s,maxPlayerCount=%s" % (tagMapID, maxPlayerCount))
+        GameWorld.Log("    DoLogic()  tagMapID=%s,tagMapLineID=%s" % (tagMapID, tagMapLineID))
         findGameWord = None
         for index in range(gameWorldManager.GetGameWorldCount()):
             gameWorld = IPY_GameWorld.IPY_GameWorld(index)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
index bf4ec9e..a374fd5 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
@@ -65,4 +65,6 @@
 
 g_npcKillerInfo = {} # NPC击杀者信息 {(lineID, objID, npcID):[killerDict, curTeam, hurtType, hurtID], ...}
 
-g_familyPartyInfo = {} #[ [[familyID, familyName, 答题数量]], top名字,top答题数量]
\ No newline at end of file
+g_familyPartyInfo = {} #[ [[familyID, familyName, 答题数量]], top名字,top答题数量]
+
+g_elderBattleRobotDieDict = {} #上古战场机器人死亡时间{lineid:[]}
\ No newline at end of file

--
Gitblit v1.8.0