#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#-------------------------------------------------------------------------------  
 | 
#  
 | 
##@package GameWorldLogic.FBProcess.GameLogic_CrossBattlefield  
 | 
#  
 | 
# @todo:¿ç·þÕ½³¡/¹ÅÉñÕ½³¡  
 | 
# @author hxp  
 | 
# @date 2022-01-06  
 | 
# @version 1.0  
 | 
#  
 | 
# ÏêϸÃèÊö: ¿ç·þÕ½³¡/¹ÅÉñÕ½³¡  
 | 
#  
 | 
#-------------------------------------------------------------------------------  
 | 
#"""Version = 2022-01-06 20:30"""  
 | 
#-------------------------------------------------------------------------------  
 | 
  
 | 
import FBCommon  
 | 
import GameWorld  
 | 
import NPCCommon  
 | 
import PyGameData  
 | 
import IPY_GameWorld  
 | 
import IpyGameDataPY  
 | 
import PlayerActivity  
 | 
import GameWorldProcess  
 | 
import NPCCustomRefresh  
 | 
import DataRecordPack  
 | 
import PlayerFuncTeam  
 | 
import PlayerControl  
 | 
import ShareDefine  
 | 
import SkillCommon  
 | 
import SkillShell  
 | 
import BuffSkill  
 | 
import ChConfig  
 | 
import AICommon  
 | 
import GameObj  
 | 
import GameMap  
 | 
import ChNPC  
 | 
  
 | 
import operator  
 | 
import random  
 | 
import time  
 | 
import copy  
 | 
import math  
 | 
  
 | 
#µ±Ç°¸±±¾µØÍ¼µÄ״̬  
 | 
(  
 | 
FB_Step_Open, # µØÍ¼¿ªÆô  
 | 
FB_Step_Prepare, # µØÍ¼×¼±¸  
 | 
FB_Step_Fighting, # Õ½¶·ÖÐ  
 | 
FB_Step_LeaveTime, # ×ÔÓÉʱ¼ä  
 | 
FB_Step_Over, # ¸±±¾¹Ø±Õ  
 | 
) = range(5)  
 | 
  
 | 
(  
 | 
Time_Prepare, # ¸±±¾×¼±¸Ê±¼ä 0  
 | 
Time_Fight, # ¸±±¾Õ½¶·Ê±¼ä 1  
 | 
Time_Leave, # ¸±±¾À뿪ʱ¼ä 2  
 | 
) = range(3)  
 | 
  
 | 
FightRefreshInterval = 5000 # Õ½¶·½×¶Îˢд¦Àí¼ä¸ô£¬ºÁÃë  
 | 
  
 | 
GameFBData_BattleWorld = "BattleWorld"  
 | 
GameFBData_FactionInfo = "FactionInfo"  
 | 
GameFBData_PlayerInfo = "PlayerInfo"  
 | 
  
 | 
# Ê¼þ±àºÅ  
 | 
AllEventNumList = (  
 | 
EventNum_Aura, # Ê¼þ - »ý·Ö¹â»·  
 | 
EventNum_Boss, # Ê¼þ - Boss  
 | 
EventNum_Wall, # Ê¼þ - »ý·Öǽ  
 | 
) = range(1, 1 + 3)  
 | 
  
 | 
# µÃ·ÖÀàÐÍ  
 | 
(  
 | 
ScoreType_Default, # Ä¬ÈÏ  
 | 
ScoreType_KillPlayer, # »÷É±Íæ¼Ò     1  
 | 
ScoreType_CollectCrystal, # Õ¼Áì×ÊÔ´½¨Öþ     2  
 | 
ScoreType_CollectFactionBuff, # ²É¼¯ÕóÓªbuff    3  
 | 
ScoreType_GuardKillPlayer, # ÊØÎÀ»÷É±Íæ¼Ò     4  
 | 
ScoreType_HurtBoss, # ¶ÔbossÔì³ÉÉ˺¦     5  
 | 
ScoreType_Aura, # »ý·Ö¹â»·     6  
 | 
ScoreType_Wall, # »ý·Öǽ     7  
 | 
ScoreType_KillGuard, # »÷É±ÊØÎÀ 8  
 | 
) = range(9)  
 | 
  
 | 
## Õ½³¡¹«¹²ÊÀ½ç¹ÜÀíÀà  
 | 
class BattleWorld():  
 | 
      
 | 
    def __init__(self):  
 | 
        self.startTime = int(time.time())  
 | 
        self.hmNum = 0  
 | 
        self.callOpenPlayerInfo = {} # ±¾³¡´Î¹ºÂòÕÙ¼¯µÄÍæ¼ÒÐÅÏ¢ {playerID:faction, ...}  
 | 
        self.superItemInfo = [] # ´ó½±ÐÅÏ¢ [ÎïÆ·ID,¸öÊý,ÊÇ·ñÅÄÆ·]  
 | 
        self.crystalFactionInfo = {} # Ë®¾§×ÊÔ´ËùÊôÕóÓªÐÅÏ¢ {npcID:ËùÊôÕóÓª, ...}  
 | 
        self.crystalAwardTick = {} # Ë®¾§×ÊÔ´¶¨Ê±½±Àøtick {npcID:tick, ...}  
 | 
          
 | 
        self.personBuffCount = 0 # Õ½³¡´æÔڵĸöÈËbuff¸öÊý  
 | 
        self.personBuffCalcTick = 0 # ¿ªÊ¼¼ÆËã¸öÈËbuff²¹³ä¸öÊýtick  
 | 
          
 | 
        self.factionBuffNPCInfo = [] # Õ½³¡´æÔÚµÄÕóÓªbuffNPCÐÅÏ¢£¬Ä¬ÈÏÖ»ÄÜ´æÔÚÒ»¸ö [npcID, posX, posY]  
 | 
        self.factionBuffCalcTick = 0 # ¿ªÊ¼¼ÆËãÕóÓªbuff²¹³ä¸öÊýtick  
 | 
        self.factionBuffIDOrderList = [] # ÕóÓªbuff˳ÐòË¢ÐÂÁÐ±í  
 | 
          
 | 
        self.eventInfoList = [] # ±¾³¡´ÎҪˢеÄʼþÁбí [[Ë¢ÐÂʱ¼äÃë, Ê¼þ±àºÅ], ...]  
 | 
        self.eventNum = 0 # µ±Ç°½øÐÐÖеÄʼþ±àºÅ  
 | 
        self.eventNPCID = 0 # µ±Ç°½øÐÐÖеÄʼþNPCID  
 | 
        self.eventNPCPos = [] # µ±Ç°½øÐÐÖеÄʼþNPC×ø±ê  
 | 
        self.eventStartTick = 0 # Ê¼þ¿ªÊ¼tick  
 | 
        self.eventEndTick = 0 # Ê¼þ½áÊøÊ±tick£¬Ä³Ð©Ê¼þÓУ¬²»Ò»¶¨ÓÐÖµ  
 | 
        self.eventNPCHP = 0 # Ê¼þNPCµ±Ç°Ê£ÓàѪÁ¿  
 | 
        self.lastEventEndTick = 0 # Éϸöʼþ½áÊøtick  
 | 
        self.lastWallCollOKTick = 0 # Éϴλý·Öǽ²É¼¯OKʱtick  
 | 
          
 | 
        self.RandSuperTask()  
 | 
        self.__randEventList()  
 | 
          
 | 
        self.crystalAtkedDict = {} # ±»¹¥»÷ÖеÄË®¾§  {npcID:±»¹¥»÷¼ÆÊý, ...}  
 | 
        self.worldHelpDict = {} # Î´Í¨ÖªµÄÊÀ½ç±ä¸üÐÅÏ¢  
 | 
        return  
 | 
      
 | 
    def getWorldAllHelpInfo(self, tick):  
 | 
        worldInfo = {"superItemInfo":self.superItemInfo, "crystalFactionInfo":self.crystalFactionInfo,  
 | 
                     "factionBuffNPCInfo":self.factionBuffNPCInfo, "crystalAtkedList":self.crystalAtkedDict.keys()}  
 | 
        worldInfo.update({"eventNPCID":self.eventNPCID, "eventNPCPos":self.eventNPCPos,  
 | 
                          "eventEndTick":max(0, self.eventEndTick - tick), "eventNPCHP":self.eventNPCHP})  
 | 
        return worldInfo  
 | 
      
 | 
    def updEventNPCHelp(self, tick):  
 | 
        self.worldHelpDict.update({"eventNPCID":self.eventNPCID, "eventNPCPos":self.eventNPCPos,  
 | 
                                   "eventEndTick":max(0, self.eventEndTick - tick), "eventNPCHP":self.eventNPCHP})  
 | 
        return  
 | 
      
 | 
    def updCrystalAtkedHelp(self, npcID, atkValue):  
 | 
        crystalAtkedList = self.crystalAtkedDict.keys()  
 | 
          
 | 
        self.crystalAtkedDict[npcID] = self.crystalAtkedDict.get(npcID, 0) + atkValue  
 | 
        if self.crystalAtkedDict[npcID] <= 0:  
 | 
            self.crystalAtkedDict.pop(npcID)  
 | 
              
 | 
        if self.crystalAtkedDict.keys() == crystalAtkedList:  
 | 
            return  
 | 
        self.worldHelpDict["crystalAtkedList"] = self.crystalAtkedDict.keys()  
 | 
        return True  
 | 
      
 | 
    def RandSuperTask(self):  
 | 
        # Ëæ»úÉú³É´ó½±ÈÎÎñ  
 | 
        fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
        superItemWeightList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldAwardSuper", 1)  
 | 
        self.superItemInfo = GameWorld.GetResultByWeightList(superItemWeightList, [])  
 | 
        GameWorld.Log("Ëæ»úÕ½³¡´ó½±: superItemInfo=%s" % str(self.superItemInfo), fbPropertyID)  
 | 
        return  
 | 
      
 | 
    def __randEventList(self):  
 | 
        # Ëæ»ú±¾³¡´Îʼþ˳ÐòÁÐ±í  
 | 
        if self.eventInfoList:  
 | 
            return  
 | 
          
 | 
        commEventTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldEvent", 2)  
 | 
        commEventNumList = [] # ³£¹æÊ¼þ - ²»°üº¬bossµÄËùÓÐʼþ  
 | 
        commEventNumList += AllEventNumList  
 | 
        commEventNumList.remove(EventNum_Boss)  
 | 
          
 | 
        if len(commEventTimeList) != len(commEventNumList):  
 | 
            GameWorld.ErrLog("Õ½³¡³£¹æÊ¼þË¢ÐÂʱ¼ä¸öÊýÅäÖôíÎó! commEventTimeList=%s,commEventNumList=%s"   
 | 
                             % (commEventTimeList, commEventNumList))  
 | 
            return  
 | 
        random.shuffle(commEventNumList)  
 | 
          
 | 
        for i, eventNum in enumerate(commEventNumList):  
 | 
            self.eventInfoList.append([commEventTimeList[i], eventNum])  
 | 
              
 | 
        eventBossStartTime = IpyGameDataPY.GetFuncCfg("CrossBattlefieldEvent", 3)  
 | 
        isOnlyCallHaveBoss = IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 5)  
 | 
          
 | 
        if isOnlyCallHaveBoss:  
 | 
            zoneID = FBCommon.GetCrossDynamicLineMapZoneID()  
 | 
            hmNum = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_CrossBattlefield)  
 | 
            hmCallTeamInfo = PyGameData.g_crossBattlefieldCallTeamInfo.get(zoneID, {})  
 | 
            callTeamInfo = hmCallTeamInfo.get(hmNum, {})  
 | 
            if callTeamInfo:  
 | 
                self.eventInfoList.append([eventBossStartTime, EventNum_Boss])  
 | 
        else:  
 | 
            self.eventInfoList.append([eventBossStartTime, EventNum_Boss])  
 | 
          
 | 
        self.eventInfoList.sort()  
 | 
          
 | 
        fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
        GameWorld.Log("Ëæ»úÕ½³¡Ê¼þË¢ÐÂʱ¼ä¼°±àºÅÁбí: eventInfoList=%s" % self.eventInfoList, fbPropertyID)  
 | 
        return  
 | 
      
 | 
    def setEventEnd(self, tick):  
 | 
        GameWorld.Log("Õ½³¡Ëæ»úʼþ½áÊø! eventNum=%s" % (self.eventNum), GameWorld.GetGameWorld().GetPropertyID())  
 | 
        self.eventNum = 0  
 | 
        self.eventNPCID = 0  
 | 
        self.eventNPCPos = []  
 | 
        self.eventNPCHP = 0  
 | 
        self.eventEndTick = 0  
 | 
        self.lastEventEndTick = tick # Éϸöʼþ½áÊøtick  
 | 
        self.updEventNPCHelp(tick)  
 | 
        return  
 | 
      
 | 
      
 | 
## Õ½³¡ÕóÓªÀà  
 | 
class BattleFaction():  
 | 
      
 | 
    def __init__(self, faction):  
 | 
        self.fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
        self.faction = faction  
 | 
        self.score = 0 # »ý·Ö  
 | 
        self.scoreSortTime = 0 # »ý·Ö±ä¸üÅÅÐòtimeÖµ£¬ÓÃÓÚͬ»ý·Öʱ£¬Ïȵ½ÅÅÃû¿¿Ç°  
 | 
          
 | 
        self.factionPlayerDict = {} # {playerID:BattlePlayer, ...}  
 | 
        self.battlePlayerSortList = [] # ÕóÓª»ý·ÖÅÅÃûÍæ¼ÒÁбí [BattlePlayer, ...]  
 | 
        self.scoreKingIDList = [] # Ç°xÃû»ý·ÖÍõIDÁбí [playerID, ...] £¬Ö»ËãÔÚÏߵģ¬ËùÒÔ²»Ò»¶¨ÊÇ»ý·ÖÅÅÃûǰxÃû  
 | 
          
 | 
        self.onlineFightPowerTotal = 0 # ÔÚÏßÈËÊý×ÜÕ½Á¦  
 | 
        self.onlinePlayerIDList = [] # ÔÚÏßÍæ¼ÒIDÁбí [playerID, ...]  
 | 
        self.homePlayerIDList = [] # ÔÚÓªµØ¼ÒÀïµÄÍæ¼ÒIDÁбí [playerID, ...]  
 | 
          
 | 
        self.factionBuffInfo = [] # ÕóÓªµ±Ç°»ñµÃµÄÕóÓªbuffÐÅÏ¢ [buff¼¼ÄÜID, ½áÊøÊ±¼ä´Á]  
 | 
        self.crystalScorePlusRate = 0 # ½¨Öþ»ñÈ¡×ÊÔ´ËÙ¶ÈÌáÉýÍò·ÖÂÊ  
 | 
        self.crystalScorePlusEndTick = 0 # ½¨Öþ»ñÈ¡×ÊÔ´ËÙ¶ÈÌáÉý½áÊøtick  
 | 
          
 | 
        self.hurtBossValue = 0 # ÕóÓª¶ÔbossµÄ×ÜÉ˺¦  
 | 
        self.hurtBossPlayerDict = {} # ÕóÓªÍæ¼Ò¶ÔbossµÄÉ˺¦ {playerID:hurtValue, ...}  
 | 
          
 | 
        self.superItemProgress = 0 # ÕóÓª´ó½±¿ª½±½ø¶È»ê  
 | 
        self.superItemPlayerID = 0 # ÕóÓª´ó½±Öн±ÕßÍæ¼ÒID  
 | 
        self.superItemPlayerName = "" # ÕóÓª´ó½±Öн±ÕßÍæ¼ÒÃû  
 | 
          
 | 
        self.robotObjIDList = [] # ±¾ÕóÓªµ±Ç°»úÆ÷ÈËʵÀýIDÁÐ±í  
 | 
          
 | 
        self.factionHelpDict = {} # Î´Í¨ÖªµÄÕóÓª±ä¸üÐÅÏ¢  
 | 
        return  
 | 
      
 | 
    def getFactionAllHelpInfo(self):  
 | 
        if self.factionBuffInfo and time.time() >= self.factionBuffInfo[1]:  
 | 
            self.factionBuffInfo = []  
 | 
        factionInfo = {"faction":self.faction, "score":self.score, "superItemPlayerName":self.superItemPlayerName,  
 | 
                       "superItemProgress":self.superItemProgress, "factionBuffInfo":self.factionBuffInfo}  
 | 
        factionInfo["hurtBossValue"] = self.hurtBossValue  
 | 
          
 | 
        sysCallBuyIDList = []  
 | 
        for playerID in self.factionPlayerDict.keys():  
 | 
            if playerID in PyGameData.g_crossBattlefieldSysCallBuyList:  
 | 
                sysCallBuyIDList.append(playerID)  
 | 
        factionInfo["sysCallBuyIDList"] = sysCallBuyIDList  
 | 
        return factionInfo  
 | 
      
 | 
    def addSuperItemProgress(self, addProgress):  
 | 
        if self.superItemPlayerID:  
 | 
            # ÕóÓª´ó½±ÒÑ¿ª½±£¬²»ÔÙÔö¼ÓÕóÓª´ó½±½ø¶È£¬µ«ÊÇÒÀÈ»»áÔö¼Ó¸öÈË´ó½±¹±Ï×  
 | 
            return  
 | 
        self.superItemProgress = max(0, self.superItemProgress + addProgress)  
 | 
        self.factionHelpDict["superItemProgress"] = self.superItemProgress  
 | 
        GameWorld.DebugLog("    Ôö¼ÓÕóÓª´ó½±½ø¶È: faction=%s,addProgress=%s,superItemProgress=%s"   
 | 
                           % (self.faction, addProgress, self.superItemProgress), self.fbPropertyID)  
 | 
          
 | 
        if self.superItemProgress < IpyGameDataPY.GetFuncCfg("CrossBattlefieldAwardSuper", 2):  
 | 
            return  
 | 
          
 | 
        worldObj = GetBattleWorld()  
 | 
        if not worldObj.superItemInfo:  
 | 
            return  
 | 
          
 | 
        # ±¾ÕóÓª´ó½±¿ª½±£¬½öÏÞÔÚÏßÍæ¼Ò  
 | 
        weightList = []  
 | 
        for playerID, battleObj in self.factionPlayerDict.items():  
 | 
            if playerID not in self.onlinePlayerIDList:  
 | 
                continue  
 | 
            if not battleObj.superItemContribution:  
 | 
                continue  
 | 
            weightList.append([battleObj.superItemContribution, playerID])  
 | 
        superItemPlayerID = GameWorld.GetResultByWeightList(weightList)  
 | 
        if not superItemPlayerID:  
 | 
            return  
 | 
        battleObj = GetBattlePlayerObj(superItemPlayerID)  
 | 
        self.superItemPlayerID = superItemPlayerID  
 | 
        self.superItemPlayerName = battleObj.name  
 | 
        self.factionHelpDict["superItemPlayerName"] = self.superItemPlayerName  
 | 
        battleObj.superItemContribution = 0 # ÖØÖù±Ï×  
 | 
        battleObj.playerHelpDict["superItemContribution"] = battleObj.superItemContribution  
 | 
        battleObj.superItemAwardCnt += 1  
 | 
          
 | 
        itemID, itemCount = worldObj.superItemInfo[0], worldObj.superItemInfo[1]  
 | 
        GameWorld.Log("ÕóÓª´ó½±¿ª½±: faction=%s,weightList=%s,superItemPlayerID=%s,itemID=%s,itemCount=%s"   
 | 
                      % (self.faction, weightList, superItemPlayerID, itemID, itemCount), self.fbPropertyID)  
 | 
        PlayerControl.FBNotify("CrossBattlefieldSuperItemPlayer", [battleObj.faction, battleObj.name, itemID, itemCount])  
 | 
        NotifyBattlefieldHelp()  
 | 
        return  
 | 
      
 | 
    def __checkPerScoreAddSuperItemProgress(self, befScore):  
 | 
        perScoreInfo = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldAwardSuper2", 4)  
 | 
        if not perScoreInfo or len(perScoreInfo) != 2:  
 | 
            return  
 | 
        superScorePer, addProgress = perScoreInfo  
 | 
        if not superScorePer or not addProgress:  
 | 
            return  
 | 
        befTimes = befScore / superScorePer  
 | 
        aftTimes = self.score / superScorePer  
 | 
        if aftTimes <= 0 or aftTimes == befTimes:  
 | 
            return  
 | 
        GameWorld.DebugLog("    ÕóӪÿ%s»ý·ÖÔö¼ÓÔÚÏßÕóÓªÍæ¼Ò´ó½±¹±Ï×! addProgress=%s" % (superScorePer, addProgress), self.fbPropertyID)  
 | 
        for playerID, battleObj in self.factionPlayerDict.items():  
 | 
            if playerID in self.onlinePlayerIDList:  
 | 
                battleObj.addSuperItemContribution(addProgress)  
 | 
        return  
 | 
      
 | 
    def addFactionScore(self, addValue, isCheckVictory=True):  
 | 
        ## Ôö¼ÓÕóÓª»ý·Ö  
 | 
        # @return: ÊÇ·ñ½áËãʤ¸º£¬Ä³Ð©Çé¿öϲ»ÄÜÔÚ¼Ó·ÖºóÖ±½ÓÑéÖ¤ÊÇ·ñ»ñʤ£¬ÓÉÓÚijЩ¹¦ÄÜ¿ÉÄÜͬʱÔö¼ÓË«·½ÕóÓª»ý·Ö£¬ËùÒÔÐèµÈ¶¼¼ÓÍêºó²Å´¦Àí½áËã  
 | 
        if not addValue:  
 | 
            return  
 | 
        befScore = self.score  
 | 
        self.score = max(0, self.score + addValue)  
 | 
        self.factionHelpDict["score"] = self.score  
 | 
        calcTime = 3471264000 #GameWorld.ChangeTimeStrToNum("2080-01-01 00:00:00")  
 | 
        self.scoreSortTime = max(0, calcTime - int(time.time()))  
 | 
        GameWorld.DebugLog("    Ôö¼ÓÕóÓª»ý·Ö: faction=%s,addValue=%s,updScore=%s" % (self.faction, addValue, self.score), self.fbPropertyID)  
 | 
          
 | 
        self.__checkPerScoreAddSuperItemProgress(befScore)  
 | 
          
 | 
        if not isCheckVictory:  
 | 
            return  
 | 
        return self.checkIsVictory()  
 | 
      
 | 
    def checkIsVictory(self):  
 | 
        battleOverScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreBase", 1)  
 | 
        if self.score < battleOverScore:  
 | 
            return  
 | 
          
 | 
        GameWorld.Log("ÕóÓª»ý·Ö´ïµ½»ñʤ»ý·Ö£¬»ñʤ£¡ faction=%s,score=%s" % (self.faction, self.score), self.fbPropertyID)  
 | 
        tick = GameWorld.GetGameWorld().GetTick()  
 | 
        DoOver(self.faction, tick)  
 | 
        return True  
 | 
      
 | 
def checkBattleOver(tick):  
 | 
    ## ¼ì²é½áË㣬¸ù¾ÝË«·½×îÖÕ»ý·ÖÅжϻñʤ·½  
 | 
      
 | 
    jFactionObj = GetBattleFactionObj(ShareDefine.CampType_Justice)  
 | 
    eFactionObj = GetBattleFactionObj(ShareDefine.CampType_Evil)  
 | 
    battleOverScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreBase", 1)  
 | 
    if jFactionObj.score < battleOverScore and eFactionObj.score < battleOverScore:  
 | 
        # ¶¼Î´»ñʤ  
 | 
        return  
 | 
      
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
      
 | 
    winFactionObj = jFactionObj  
 | 
    # Ò»°ãÇé¿öË«·½»ý·Ö²»Ò»Ñù£¬È¡ÅÅÐòºóµÄ×î¸ß·Ö¼´Îª»ñʤÕóÓª  
 | 
    if jFactionObj.score != eFactionObj.score:  
 | 
        sortList = [[jFactionObj.score, jFactionObj], [eFactionObj.score, eFactionObj]]  
 | 
        sortList.sort(reverse=True)  
 | 
        _, winFactionObj = sortList[0]  
 | 
        winFaction = winFactionObj.faction  
 | 
        GameWorld.Log("Ë«·½ÕóÓª»ý·Ö²»Í¬£¬¸ß·ÖÒ»·½»ñʤ! winFaction=%s,jScore=%s,eScore=%s"   
 | 
                      % (winFaction, jFactionObj.score, eFactionObj.score), fbPropertyID)  
 | 
          
 | 
    # »ý·ÖÏàͬµÄÇé¿ö£¬Ëæ»úÒ»·½»ñʤ  
 | 
    else:  
 | 
        winFaction = random.choice([ShareDefine.CampType_Justice, ShareDefine.CampType_Evil])  
 | 
        winFactionObj = GetBattleFactionObj(winFaction)  
 | 
        winFactionObj.score += 100 # Ëæ»ú»ñʤ·½¶îÍâÔö¼Ó»ý·Ö  
 | 
        GameWorld.Log("Ë«·½ÕóÓª»ý·ÖÏàͬ£¬Ëæ»úÒ»·½»ñʤ! winFaction=%s,jScore=%s,eScore=%s"   
 | 
                      % (winFaction, jFactionObj.score, eFactionObj.score), fbPropertyID)  
 | 
          
 | 
    return winFactionObj.checkIsVictory()  
 | 
  
 | 
## Õ½³¡Íæ¼ÒÀà  
 | 
class BattlePlayer():  
 | 
      
 | 
    def __init__(self, playerID):  
 | 
        self.playerID = playerID  
 | 
        self.name = ""  
 | 
        self.faction = 0  
 | 
        self.factionObj = None  
 | 
        self.accID = ""  
 | 
        self.job = 1  
 | 
        self.realmLV = 0  
 | 
        self.fightPower = 0  
 | 
          
 | 
        self.highScoreToday = 0 # ±¾ÈÕ×î¸ß»ý·Ö  
 | 
        self.highScoreWeekTotal = 0 # ±¾ÖÜÿÈÕ×î¸ß·ÖÀÛ¼Æ  
 | 
        self.enterCountWeek = 0 # ±¾ÖÜÀۼƽøÈë´ÎÊý  
 | 
        self.onlineCalcTick = 0 # ÔÚÏßͳ¼Ætick  
 | 
        self.onlineTimes = 0 # »î¶¯ÀÛ¼ÆÔÚÏßʱ³¤£¬ºÁÃë  
 | 
        self.restoreHPTick = 0 # ÓªµØ»ØÑªtick  
 | 
        self.itemRebornCount = 0 # Ê¹ÓÃÌØÊâµÀ¾ßԵظ´»î´ÎÊý  
 | 
          
 | 
        self.score = 0 # »ý·Ö  
 | 
        self.scoreSortTime = 0 # »ý·Ö±ä¸üÅÅÐòtimeÖµ£¬ÓÃÓÚͬ»ý·Öʱ£¬Ïȵ½ÅÅÃû¿¿Ç°  
 | 
        self.killCount = 0 # »÷ɱÊý  
 | 
        self.continueKillCount = 0 # Á¬É±Êý  
 | 
        self.ckillCntInfo = {} # ³É¾ÍÁ¬É±Êý´ÎÊý {Á¬É±Êý:´ÎÊý, ...}  
 | 
        self.killPlayerAddScoreTimes = 0 # »÷É±Íæ¼Ò»ñµÃ»ý·Ö±¶Öµ  
 | 
        self.killPlayerScoreAwardEndTick = 0 # »÷É±Íæ¼Ò¶à±¶»ý·Ö¸£Àû½áÊøtick  
 | 
        self.killBossCnt = 0 # ±¾ÕóÓª¹éÊô»÷°Üboss  
 | 
        self.killScoreKing = 0 # ±¾³¡´ÎÊÇ·ñÓл÷°Ü»ý·ÖÍõ£¬µ¥³¡½ö¼ÆËãÒ»´Î  
 | 
        self.killGuardCnt = 0 # »÷É±ÊØÎÀ´ÎÊý  
 | 
        self.auraScore = 0 # Ôڹ⻷ÖÐÀۼƻñµÃ»ý·Ö  
 | 
        self.superItemAwardCnt = 0 # »ñµÃ´ó½±´ÎÊý  
 | 
        self.factionBuffCollCnt = 0 # ²É¼¯ÕóÓªbuff´ÎÊý  
 | 
        self.personBuffCollCnt = 0 # ¸öÈËbuff´ÎÊý  
 | 
        self.crystalCollCnt = 0 # ²É¼¯Ë®¾§×ÊÔ´´ÎÊý  
 | 
        self.wallCollCnt = 0 # ²É¼¯»ý·Öǽ´ÎÊý  
 | 
        self.superItemContribution = 0 # ´ó½±½ø¶È¹±Ï×Öµ£¬Ò²ÊÇ´ó½±»ñ½±È¨ÖØ  
 | 
          
 | 
        self.playerHelpDict = {} # Î´Í¨ÖªµÄÍæ¼Ò±ä¸üÐÅÏ¢  
 | 
        return  
 | 
      
 | 
    def getFactionObj(self):  
 | 
        if not self.factionObj and self.faction:  
 | 
            self.factionObj = GetBattleFactionObj(self.faction)  
 | 
        return self.factionObj  
 | 
      
 | 
    def getPlayerAllHelpInfo(self):  
 | 
        helpInfo = {"score":self.score, "superItemContribution":self.superItemContribution, "itemRebornCount":self.itemRebornCount,  
 | 
                    "killCount":self.killCount, "continueKillCount":self.continueKillCount}  
 | 
        return helpInfo  
 | 
      
 | 
    def addPlayerScore(self, curPlayer, addValue, scoreType=ScoreType_Default, scoreTimes=1, isCheckVictory=True):  
 | 
        if not addValue:  
 | 
            return  
 | 
        addValue *= scoreTimes  
 | 
        befScore = self.score  
 | 
        self.score = max(0, self.score + addValue)  
 | 
        calcTime = 3471264000 #GameWorld.ChangeTimeStrToNum("2080-01-01 00:00:00")  
 | 
        self.scoreSortTime = max(0, calcTime - int(time.time()))  
 | 
        GameWorld.DebugLog("    Ôö¼ÓÍæ¼Ò»ý·Ö: playerID=%s,scoreType=%s,addValue=%s,±¶Öµ=%s,updScore=%s"   
 | 
                           % (self.playerID, scoreType, addValue, scoreTimes, self.score), self.playerID)  
 | 
          
 | 
        if scoreType == ScoreType_Aura and addValue > 0:  
 | 
            self.auraScore += addValue  
 | 
              
 | 
        self.playerHelpDict.update({"score":self.score, "addScore":[addValue, scoreType, scoreTimes]})  
 | 
          
 | 
        superScorePer = IpyGameDataPY.GetFuncCfg("CrossBattlefieldAwardSuper2", 1)  
 | 
        if superScorePer:  
 | 
            befTimes = befScore / superScorePer  
 | 
            aftTimes = self.score / superScorePer  
 | 
            if aftTimes > 0 and aftTimes != befTimes:  
 | 
                addIndex = aftTimes - 1  
 | 
                addProgressList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldAwardSuper2", 3)  
 | 
                addProgress = addProgressList[addIndex] if len(addProgressList) > addIndex else addProgressList[-1]  
 | 
                GameWorld.DebugLog("    Íæ¼Òÿ%s»ý·ÖÔö¼Ó´ó½±¹±Ï×! addProgress=%s,superItemContribution=%s"   
 | 
                                   % (superScorePer, addProgress, self.superItemContribution), self.playerID)  
 | 
                self.addSuperItemContribution(addProgress)  
 | 
                  
 | 
        # ¸öÈËÔö¼Ó»ý·Öͬ²½Ôö¼ÓËùÊôÕóÓª»ý·Ö      
 | 
        factionObj = self.getFactionObj()  
 | 
        if factionObj:  
 | 
            factionObj.addFactionScore(addValue, isCheckVictory)  
 | 
        return  
 | 
      
 | 
    def addKillCount(self, addCount):  
 | 
        befContKillCount = self.continueKillCount  
 | 
        self.killCount = max(0, self.killCount + addCount)  
 | 
        self.continueKillCount = max(0, self.continueKillCount + addCount) # Í¬²½Ôö¼ÓÁ¬É±  
 | 
        self.playerHelpDict.update({"killCount":self.killCount, "continueKillCount":self.continueKillCount})  
 | 
          
 | 
        superContKillPer = IpyGameDataPY.GetFuncCfg("CrossBattlefieldAwardSuper2", 2)  
 | 
        if superContKillPer:  
 | 
            befTimes = befContKillCount / superContKillPer  
 | 
            aftTimes = self.continueKillCount / superContKillPer  
 | 
            if aftTimes > 0 and aftTimes != befTimes:  
 | 
                addIndex = aftTimes - 1  
 | 
                addProgressList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldAwardSuper2", 3)  
 | 
                addProgress = addProgressList[addIndex] if len(addProgressList) > addIndex else addProgressList[-1]  
 | 
                GameWorld.DebugLog("    Íæ¼Òÿ%sÁ¬É±Ôö¼Ó´ó½±¹±Ï×! addProgress=%s,superItemContribution=%s"   
 | 
                                   % (superContKillPer, addProgress, self.superItemContribution), self.playerID)  
 | 
                self.addSuperItemContribution(addProgress)  
 | 
                  
 | 
        # Á¬É±Êý³É¾Í¼ÆÊý  
 | 
        ckillCntList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldSuccess", 1)  
 | 
        for ckillCnt in ckillCntList:  
 | 
            # ÐèÕû³ý²Å¼ÆÊý1  
 | 
            if self.continueKillCount and self.continueKillCount % ckillCnt == 0:  
 | 
                self.ckillCntInfo[ckillCnt] = self.ckillCntInfo.get(ckillCnt, 0) + 1  
 | 
        return  
 | 
      
 | 
    def addSuperItemContribution(self, addProgress):  
 | 
        self.superItemContribution = max(0, self.superItemContribution + addProgress)  
 | 
        self.playerHelpDict["superItemContribution"] = self.superItemContribution  
 | 
        GameWorld.DebugLog("    ¸üÐÂÍæ¼Ò´ó½±¹±Ï×: playerID=%s,addProgress=%s,superItemContribution=%s" % (self.playerID, addProgress, self.superItemContribution), self.playerID)  
 | 
        factionObj = self.getFactionObj()  
 | 
        if factionObj:  
 | 
            factionObj.addSuperItemProgress(addProgress)  
 | 
        return  
 | 
      
 | 
def GetBattleWorld():  
 | 
    worldObj = FBCommon.GetGameFBData(GameFBData_BattleWorld)  
 | 
    if not worldObj:  
 | 
        worldObj = BattleWorld()  
 | 
        FBCommon.SetGameFBData(GameFBData_BattleWorld, worldObj)  
 | 
    return worldObj  
 | 
  
 | 
def GetBattleFactionObj(faction):  
 | 
    factionObj = None  
 | 
    factionInfoDict = FBCommon.GetGameFBData(GameFBData_FactionInfo)  
 | 
    if factionInfoDict == None:  
 | 
        factionInfoDict = {}  
 | 
    if faction in factionInfoDict:  
 | 
        factionObj = factionInfoDict[faction]  
 | 
    else:          
 | 
        factionObj = BattleFaction(faction)  
 | 
        factionInfoDict[faction] = factionObj  
 | 
    return factionObj  
 | 
  
 | 
def GetBattlePlayerObj(playerID):  
 | 
    playerObj = None  
 | 
    playerInfoDict = FBCommon.GetGameFBData(GameFBData_PlayerInfo)  
 | 
    if playerInfoDict == None:  
 | 
        playerInfoDict = {}  
 | 
    if playerID in playerInfoDict:  
 | 
        playerObj = playerInfoDict[playerID]  
 | 
    else:          
 | 
        playerObj = BattlePlayer(playerID)  
 | 
        playerInfoDict[playerID] = playerObj  
 | 
    return playerObj  
 | 
  
 | 
def GetBFStepTime(): return IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFB", 1) # ½×¶Îʱ¼ä  
 | 
def GetCrystalNPCIDList(): # Ë®¾§×ÊÔ´NPCIDÁÐ±í  
 | 
    crystalNPCIDPosDict = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldCrystal", 1, {})  
 | 
    return [int(npcID) for npcID in crystalNPCIDPosDict.keys()]  
 | 
def GetGuardNPCIDList(): return IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldGuard", 1) # ÊØÎÀNPCIDÁÐ±í  
 | 
def GetPersonBuffIDList(): return IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldPersonBuff", 1) # ¸öÈËbuffIDÁÐ±í  
 | 
def GetFactionBuffIDList(): return IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFactionBuff", 1) # ÕóÓªbuffIDÁÐ±í  
 | 
def GetRobotNPCIDList(): return IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldRobot", 1) # »úÆ÷ÈËNPCIDÁÐ±í  
 | 
  
 | 
def OnOpenFB(tick):  
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    FBCommon.SetGameFBData(GameFBData_BattleWorld, None)  
 | 
    FBCommon.SetGameFBData(GameFBData_FactionInfo, {})  
 | 
    FBCommon.SetGameFBData(GameFBData_PlayerInfo, {})  
 | 
      
 | 
    worldObj = GetBattleWorld()  
 | 
    GetBattleFactionObj(ShareDefine.CampType_Justice)  
 | 
    GetBattleFactionObj(ShareDefine.CampType_Evil)  
 | 
      
 | 
    FBCommon.SetFBStep(FB_Step_Prepare, tick)  
 | 
      
 | 
    zoneID = FBCommon.GetCrossDynamicLineMapZoneID()  
 | 
    hmNum = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_CrossBattlefield)  
 | 
    hmCallTeamInfo = PyGameData.g_crossBattlefieldCallTeamInfo.get(zoneID, {})  
 | 
    callTeamInfo = hmCallTeamInfo.get(hmNum, {})  
 | 
    for playerID, callTeam in callTeamInfo.items():  
 | 
        worldObj.callOpenPlayerInfo[playerID] = callTeam["factionID"]  
 | 
    GameWorld.Log("¿ªÆôÕ½³¡¸±±¾: hmNum=%s,callOpenPlayerInfo=%s" % (hmNum, worldObj.callOpenPlayerInfo), fbPropertyID)  
 | 
    worldObj.hmNum = hmNum  
 | 
      
 | 
    # Ë¢Ë®¾§  
 | 
    crystalNPCIDPosDict = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldCrystal", 1, {})  
 | 
    for npcID, posInfo in crystalNPCIDPosDict.items():  
 | 
        NPCCommon.SummonMapNpc(int(npcID), posInfo[0], posInfo[1])  
 | 
          
 | 
    # Ë¢ÊØÎÀ  
 | 
    rebornGurad()  
 | 
    return  
 | 
  
 | 
def rebornGurad():  
 | 
    # ¸´»îÊØÎÀ  
 | 
    isOnlyCallHaveGuard = IpyGameDataPY.GetFuncCfg("CrossBattlefieldGuard", 5)  
 | 
    guardFactionList = []  
 | 
    if isOnlyCallHaveGuard:  
 | 
        zoneID = FBCommon.GetCrossDynamicLineMapZoneID()  
 | 
        hmNum = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_CrossBattlefield)  
 | 
        hmCallTeamInfo = PyGameData.g_crossBattlefieldCallTeamInfo.get(zoneID, {})  
 | 
        callTeamInfo = hmCallTeamInfo.get(hmNum, {})  
 | 
        for playerID, callTeam in callTeamInfo.items():  
 | 
            guardFactionList.append([callTeam["factionID"], playerID])  
 | 
    else:  
 | 
        guardFactionList = [[ShareDefine.CampType_Justice, 0], [ShareDefine.CampType_Evil, 0]]  
 | 
          
 | 
    rebornNPCIDList = []  
 | 
    guardNPCIDList = GetGuardNPCIDList()  
 | 
    guardNPCPosList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldGuard", 2)  
 | 
    for faction, playerID in guardFactionList:  
 | 
        if not faction or faction > len(guardNPCIDList) or faction > len(guardNPCPosList):  
 | 
            continue  
 | 
        npcID = guardNPCIDList[faction - 1]  
 | 
        if GameWorld.FindNPCByNPCID(npcID):  
 | 
            GameWorld.DebugLog("ÊØÎÀÒÑ´æÔÚ£¬²»Öظ´¸´»î! npcID=%s" % npcID)  
 | 
            continue  
 | 
        posInfo = guardNPCPosList[faction - 1]  
 | 
        NPCCommon.SummonMapNpc(npcID, posInfo[0], posInfo[1], playerID=playerID)  
 | 
        rebornNPCIDList.append(npcID)  
 | 
    return rebornNPCIDList  
 | 
  
 | 
def OnCloseFB(tick):  
 | 
    GameWorld.GetGameWorld().SetPropertyID(0)  
 | 
    FBCommon.SetGameFBData(GameFBData_BattleWorld, None)  
 | 
    FBCommon.SetGameFBData(GameFBData_FactionInfo, None)  
 | 
    FBCommon.SetGameFBData(GameFBData_PlayerInfo, None)  
 | 
    FBCommon.ClearFBNPC()  
 | 
    return  
 | 
  
 | 
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):  
 | 
    if GameWorld.IsCrossServer():  
 | 
        return True  
 | 
      
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    hmNum = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_CrossBattlefield)  
 | 
    for zoneID, hmCallTeamInfo in PyGameData.g_crossBattlefieldCallTeamInfo.items():  
 | 
        callTeamInfo = hmCallTeamInfo.get(hmNum, {})  
 | 
        for buyPlayerID, callTeam in callTeamInfo.items():  
 | 
            if playerID in callTeam["callPlayerIDList"]:  
 | 
                GameWorld.DebugLog("    ÔÚÕ½³¡ÕÙ¼¯¶ÓÎéÀÃâ·Ñ½øÈë! zoneID=%s,hmNum=%s,buyPlayerID=%s,callPlayerIDList=%s"   
 | 
                                   % (zoneID, hmNum, buyPlayerID, callTeam["callPlayerIDList"]), playerID)  
 | 
                return True  
 | 
              
 | 
    remainCnt = PlayerActivity.GetDailyActionrRemainCnt(curPlayer, ShareDefine.DailyActionID_CrossBattlefield)  
 | 
    GameWorld.DebugLog("    Õ½³¡Ê£Óà¿É½øÈë´ÎÊý! hmNum=%s,remainCnt=%s" % (hmNum, remainCnt), playerID)  
 | 
    return remainCnt > 0  
 | 
  
 | 
def OnChangeMapAsk(ask, tick):  
 | 
    return IPY_GameWorld.cmeAccept  
 | 
  
 | 
##¸±±¾Íæ¼Ò½øÈëµã, Íæ¼Ò·ÖÉ¢ÔÚ°ë¾¶3¸ñ·¶Î§  
 | 
def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):  
 | 
    randPosX, randPosY, minDist, maxDist = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFB", 2)  
 | 
    posPoint = GameMap.GetEmptyPlaceInAreaEx(randPosX, randPosY, minDist, maxDist)  
 | 
    return posPoint.GetPosX(), posPoint.GetPosY()  
 | 
  
 | 
def DoEnterFB(curPlayer, tick):      
 | 
    gameFB = GameWorld.GetGameFB()  
 | 
    fbStep = gameFB.GetFBStep()  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
      
 | 
    if fbStep not in [FB_Step_Prepare, FB_Step_Fighting]:  
 | 
        GameWorld.Log("DoEnterFB... fbPropertyID=%s,fbStep=%s PlayerLeaveFB" % (fbPropertyID, fbStep), playerID)  
 | 
        PlayerControl.PlayerLeaveFB(curPlayer)  
 | 
        return  
 | 
      
 | 
    curPlayer.SetFamilyID(0)  
 | 
    fightPower = PlayerControl.GetFightPower(curPlayer)  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    battleObj.job = curPlayer.GetJob()  
 | 
    battleObj.accID = curPlayer.GetAccID()  
 | 
    battleObj.name = curPlayer.GetPlayerName()  
 | 
    battleObj.realmLV = curPlayer.GetOfficialRank()  
 | 
    battleObj.fightPower = fightPower  
 | 
    battleObj.highScoreToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Battlefield_HighScoreToday)  
 | 
    battleObj.highScoreWeekTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Battlefield_HighScoreTotalWeek)  
 | 
    battleObj.enterCountWeek = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Battlefield_EnterCountWeek)  
 | 
      
 | 
    GameWorld.Log("DoEnterFB... fbPropertyID=%s,fbStep=%s,faction=%s" % (fbPropertyID, fbStep, battleObj.faction), playerID)  
 | 
      
 | 
    if fbStep == FB_Step_Prepare:  
 | 
        notify_tick = GetBFStepTime()[Time_Prepare] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())  
 | 
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttWaitStart, 0, max(notify_tick, 0), True)  
 | 
          
 | 
    elif fbStep == FB_Step_Fighting:  
 | 
        notify_tick = GetBFStepTime()[Time_Fight] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())  
 | 
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True)  
 | 
        allotPlayerFaction(playerID, fightPower, curPlayer, fbStep, tick)  
 | 
          
 | 
    NotifyBattlefieldHelp(True, curPlayer)  
 | 
    return  
 | 
  
 | 
def IsSysCallBuyPlayer(playerID):  
 | 
    ## ÊÇ·ñϵͳ³¡´Î¹ºÂòÕÙ¼¯µÄÍæ¼Ò  
 | 
    return playerID in PyGameData.g_crossBattlefieldSysCallBuyList  
 | 
  
 | 
def OnPlayerSysCallBuy(curPlayer):  
 | 
    faction = curPlayer.GetFaction()  
 | 
    PlayerControl.FBNotify("CrossBattlefieldSysCallBuy", [faction, curPlayer.GetPlayerName()])  
 | 
    NotifyBattlefieldHelp(True, curPlayer)  
 | 
    return  
 | 
  
 | 
def NotifyBattlefieldHelp(isAllInfo=False, curPlayer=None, helpEx=None):  
 | 
    ## ¹ã²¥Õ½³¡°ïÖúÐÅÏ¢£¬Õë¶ÔËùÓÐÍæ¼Ò  
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    lineID = gameWorld.GetLineID()  
 | 
      
 | 
    worldInfoKey = "worldInfo"  
 | 
    factionInfoKey = "factionInfo_%s"  
 | 
    playerInfoKey = "playerInfo"  
 | 
      
 | 
    worldObj = GetBattleWorld()  
 | 
      
 | 
    helpDict = {}  
 | 
    factionObjList = []  
 | 
      
 | 
    # Í¨ÖªÍêÕûÄÚÈÝ  
 | 
    if isAllInfo:  
 | 
        tick = GameWorld.GetGameWorld().GetTick()  
 | 
        helpDict[worldInfoKey] = worldObj.getWorldAllHelpInfo(tick)  
 | 
        for faction in [ShareDefine.CampType_Justice, ShareDefine.CampType_Evil]:  
 | 
            factionObj = GetBattleFactionObj(faction)  
 | 
            helpDict[factionInfoKey % faction] = factionObj.getFactionAllHelpInfo()  
 | 
        helpDict[FBCommon.Help_robotJob] = PyGameData.g_fbRobotJobDict.get(lineID, {})  
 | 
          
 | 
    # Í¨ÖªÎ´Í¨ÖªÄÚÈÝ  
 | 
    else:  
 | 
        if worldObj.worldHelpDict:  
 | 
            helpDict[worldInfoKey] = worldObj.worldHelpDict  
 | 
              
 | 
        for faction in [ShareDefine.CampType_Justice, ShareDefine.CampType_Evil]:  
 | 
            factionObj = GetBattleFactionObj(faction)  
 | 
            if factionObj.factionHelpDict:  
 | 
                factionObj.factionHelpDict["faction"] = faction  
 | 
                helpDict[factionInfoKey % faction] = factionObj.factionHelpDict  
 | 
                factionObjList.append(factionObj)  
 | 
                  
 | 
        if helpEx:  
 | 
            helpDict.update(helpEx)  
 | 
              
 | 
    if curPlayer:  
 | 
        playerID = curPlayer.GetPlayerID()  
 | 
        battleObj = GetBattlePlayerObj(playerID)  
 | 
        if isAllInfo:  
 | 
            helpDict[playerInfoKey] = battleObj.getPlayerAllHelpInfo()  
 | 
        elif battleObj.playerHelpDict:  
 | 
            helpDict[playerInfoKey] = battleObj.playerHelpDict  
 | 
        if helpDict:   
 | 
            FBCommon.Notify_FBHelp(curPlayer, helpDict)  
 | 
        battleObj.playerHelpDict = {}  
 | 
    else:  
 | 
        playerManager = GameWorld.GetMapCopyPlayerManager()  
 | 
        for index in xrange(playerManager.GetPlayerCount()):  
 | 
            player = playerManager.GetPlayerByIndex(index)  
 | 
            if not player:  
 | 
                continue  
 | 
            helpDict.pop(playerInfoKey, None)  
 | 
            playerID = player.GetPlayerID()  
 | 
            battleObj = GetBattlePlayerObj(playerID)  
 | 
            if isAllInfo:  
 | 
                helpDict[playerInfoKey] = battleObj.getPlayerAllHelpInfo()  
 | 
            elif battleObj.playerHelpDict:  
 | 
                helpDict[playerInfoKey] = battleObj.playerHelpDict  
 | 
            if helpDict:  
 | 
                FBCommon.Notify_FBHelp(player, helpDict)  
 | 
            battleObj.playerHelpDict = {}  
 | 
              
 | 
    # ÖØÖÃδ֪ͨµÄ  
 | 
    if not curPlayer:  
 | 
        worldObj.worldHelpDict = {}  
 | 
        for factionObj in factionObjList:  
 | 
            factionObj.factionHelpDict = {}  
 | 
    return  
 | 
  
 | 
def OnRandomRobotJob(curNPC, lineRobotJobDict):  
 | 
    ## Ëæ»ú»úÆ÷ÈËÖ°Òµ  
 | 
    NotifyBattlefieldHelp(helpEx={FBCommon.Help_robotJob:lineRobotJobDict})  
 | 
    return  
 | 
  
 | 
##»ñµÃ¸±±¾°ïÖúÐÅÏ¢, ÓÃÓÚ֪ͨÕóÓª±È·ÖÌõ  
 | 
def DoFBHelp(curPlayer, tick):  
 | 
    return  
 | 
  
 | 
##Íæ¼ÒÍ˳ö¸±±¾  
 | 
def DoExitFB(curPlayer, tick):  
 | 
    gameFB = GameWorld.GetGameFB()  
 | 
    fbStep = gameFB.GetFBStep()  
 | 
    if fbStep != FB_Step_Fighting:  
 | 
        return  
 | 
      
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    faction = curPlayer.GetFaction()  
 | 
    fightPower = PlayerControl.GetFightPower(curPlayer)  
 | 
      
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    GameWorld.Log("DoExitFB... playerID=%s,faction=%s,fightPower=%s,fbStep=%s"   
 | 
                  % (playerID, faction, fightPower, fbStep), fbPropertyID)  
 | 
      
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    battleObj.onlineCalcTick = 0  
 | 
      
 | 
    if not faction:  
 | 
        return  
 | 
      
 | 
    factionObj = GetBattleFactionObj(faction)  
 | 
    factionObj.onlineFightPowerTotal = max(0, factionObj.onlineFightPowerTotal - fightPower)  
 | 
    if playerID in factionObj.onlinePlayerIDList:  
 | 
        factionObj.onlinePlayerIDList.remove(playerID)  
 | 
          
 | 
    GameWorld.Log("    faction=%s,onlineFightPowerTotal=%s,onlinePlayerIDList=%s"   
 | 
                  % (faction, factionObj.onlineFightPowerTotal, factionObj.onlinePlayerIDList), fbPropertyID)  
 | 
    return  
 | 
  
 | 
##Íæ¼ÒÖ÷¶¯À뿪¸±±¾.  
 | 
def DoPlayerLeaveFB(curPlayer, tick):  
 | 
    return  
 | 
  
 | 
##¸±±¾×ÜÂß¼¼ÆÊ±Æ÷  
 | 
# @param tick Ê±¼ä´Á  
 | 
# @return ÎÞÒâÒå  
 | 
# @remarks ¸±±¾×ÜÂß¼¼ÆÊ±Æ÷  
 | 
def OnProcess(tick):  
 | 
    fbStep = GameWorld.GetGameFB().GetFBStep()  
 | 
      
 | 
    # ¸±±¾×¼±¸  
 | 
    if fbStep == FB_Step_Prepare:  
 | 
        __DoLogic_FB_Prepare(fbStep, tick)  
 | 
          
 | 
    # ¸±±¾½øÐÐÖÐ  
 | 
    elif fbStep == FB_Step_Fighting:  
 | 
        __DoLogic_FB_Fighting(tick)  
 | 
          
 | 
    # ¸±±¾½áÊø  
 | 
    elif fbStep == FB_Step_LeaveTime:  
 | 
        __DoLogic_FB_Leave(tick)  
 | 
          
 | 
    return  
 | 
  
 | 
def __DoLogic_FB_Prepare(fbStep, tick):  
 | 
      
 | 
    remaindTick = GetBFStepTime()[Time_Prepare] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())  
 | 
    if remaindTick > 0:  
 | 
        return  
 | 
      
 | 
    FBCommon.SetFBStep(FB_Step_Fighting, tick)  
 | 
      
 | 
    playerInfoDict = {}  
 | 
    playerInfoList = []  
 | 
    fightTime = GetBFStepTime()[Time_Fight] * 1000  
 | 
    playerManager = GameWorld.GetMapCopyPlayerManager()  
 | 
    for index in xrange(playerManager.GetPlayerCount()):  
 | 
        curPlayer = playerManager.GetPlayerByIndex(index)  
 | 
        playerID = curPlayer.GetPlayerID()  
 | 
        if not playerID:  
 | 
            continue  
 | 
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, fightTime, True)  
 | 
          
 | 
        fightPower = PlayerControl.GetFightPower(curPlayer)  
 | 
          
 | 
        playerInfo = {"playerID":playerID, "fightPower":fightPower, "curPlayer":curPlayer}  
 | 
        playerInfoList.append(playerInfo)  
 | 
        playerInfoDict[playerID] = playerInfo  
 | 
          
 | 
#    ##--------- É½Õ¯·ÖÅä²âÊÔ´úÂë --------------  
 | 
#    for i in xrange(15):  
 | 
#        playerID = i + 1  
 | 
#        fightPower = random.randint(100000, 10000000000)  
 | 
#        playerInfoList.append({"playerID":playerID, "fightPower":fightPower, "curPlayer":None})  
 | 
#    ##--------- É½Õ¯·ÖÅä²âÊÔ´úÂë --------------  
 | 
      
 | 
    # °´Õ½Á¦´ÓµÍµ½¸ßÉýÐòÅÅÐò  
 | 
    playerInfoList.sort(key=operator.itemgetter("fightPower"))  
 | 
      
 | 
    # ÏÈ·ÖÅäÕÙ¼¯¶ÓÎé  
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    zoneID = FBCommon.GetCrossDynamicLineMapZoneID()  
 | 
    hmNum = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_CrossBattlefield)  
 | 
    hmCallTeamInfo = PyGameData.g_crossBattlefieldCallTeamInfo.get(zoneID, {})  
 | 
    callTeamInfo = hmCallTeamInfo.get(hmNum, {})  
 | 
      
 | 
    GameWorld.Log("×¼±¸¿ªÊ¼Õ½¶·£¬·ÖÅäÕóÓª: zoneID=%s,hmNum=%s,callTeamInfo=%s,playerCountTotal=%s" % (zoneID, hmNum, callTeamInfo, len(playerInfoList)), fbPropertyID)  
 | 
    callPlayerIDList = []  
 | 
    for callTeam in callTeamInfo.values():  
 | 
        for playerID in callTeam["callPlayerIDList"]:  
 | 
            callPlayerIDList.append(playerID)  
 | 
            if playerID not in playerInfoDict:  
 | 
                continue  
 | 
            playerInfo = playerInfoDict[playerID]  
 | 
            playerID = playerInfo["playerID"]  
 | 
            fightPower = playerInfo["fightPower"]  
 | 
            curPlayer = playerInfo["curPlayer"]  
 | 
            allotPlayerFaction(playerID, fightPower, curPlayer, fbStep, tick)  
 | 
              
 | 
    for playerInfo in playerInfoList:  
 | 
        playerID = playerInfo["playerID"]  
 | 
        fightPower = playerInfo["fightPower"]  
 | 
        curPlayer = playerInfo["curPlayer"]  
 | 
        if playerID in callPlayerIDList:  
 | 
            continue  
 | 
        allotPlayerFaction(playerID, fightPower, curPlayer, fbStep, tick)  
 | 
          
 | 
    NotifyBattlefieldHelp(True)  
 | 
    PlayerControl.FBNotify("CrossBattlefieldStartFighting")  
 | 
    return  
 | 
  
 | 
def allotPlayerFaction(playerID, fightPower, curPlayer, allotStep, tick):  
 | 
    ## ·ÖÅäÍæ¼ÒÕóÓª  
 | 
      
 | 
    zoneID = FBCommon.GetCrossDynamicLineMapZoneID()  
 | 
    hmNum = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_CrossBattlefield)  
 | 
    hmCallTeamInfo = PyGameData.g_crossBattlefieldCallTeamInfo.get(zoneID, {})  
 | 
    callTeamInfo = hmCallTeamInfo.get(hmNum, {})  
 | 
      
 | 
    callFaction = None  
 | 
    for callTeam in callTeamInfo.values():  
 | 
        if playerID in callTeam["callPlayerIDList"]:  
 | 
            callFaction = callTeam["factionID"]  
 | 
            break  
 | 
              
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    faction = battleObj.faction  
 | 
    isAllot = not faction # ÊÇ·ñ·ÖÅ䣬ÎÞÕóӪʱΪ True  
 | 
    if callFaction:  
 | 
        faction = callFaction # ÕÙ¼¯ÕóӪΪ¹Ì¶¨ÕóÓª  
 | 
          
 | 
    # ¶ÓÎéͬÕóÓª  
 | 
    teamID = PlayerFuncTeam.GetPlayerTeamID(playerID, ChConfig.Def_FBMapID_CrossBattlefield)  
 | 
    if not faction and teamID:  
 | 
        memIDList = PlayerFuncTeam.GetMemberIDList(teamID)  
 | 
        for memID in memIDList:  
 | 
            memBattleObj = GetBattlePlayerObj(memID)  
 | 
            if memBattleObj.faction:  
 | 
                faction = memBattleObj.faction  
 | 
                GameWorld.Log("Óë¶ÓÓÑͬһÕóÓª! playerID=%s,teamID=%s,faction=%s,memIDList=%s" % (playerID, teamID, faction, memIDList), fbPropertyID)  
 | 
                break  
 | 
              
 | 
    if not faction:  
 | 
        jFactionObj = GetBattleFactionObj(ShareDefine.CampType_Justice)  
 | 
        eFactionObj = GetBattleFactionObj(ShareDefine.CampType_Evil)  
 | 
        jPlayerCount = len(jFactionObj.factionPlayerDict)  
 | 
        ePlayerCount = len(eFactionObj.factionPlayerDict)  
 | 
        # ÈËÊýÏàÍ¬Ê±Ëæ»ú£¬·ñÔòÍùÈËÊýÉٵķÖÅä  
 | 
        if jPlayerCount == ePlayerCount:  
 | 
            faction = random.choice([ShareDefine.CampType_Justice, ShareDefine.CampType_Evil])  
 | 
        elif jPlayerCount < ePlayerCount:  
 | 
            faction = ShareDefine.CampType_Justice  
 | 
        else:  
 | 
            faction = ShareDefine.CampType_Evil  
 | 
              
 | 
    battleObj.faction = faction  
 | 
    battleObj.onlineCalcTick = tick  
 | 
      
 | 
    factionObj = GetBattleFactionObj(faction)  
 | 
    battleObj.factionObj = factionObj  
 | 
      
 | 
    if playerID not in factionObj.factionPlayerDict:  
 | 
        factionObj.factionPlayerDict[playerID] = battleObj  
 | 
          
 | 
    # ÔÚÏ߲ŻáÌí¼Ó£¬ËùÒÔ´¦ÀíÔÚÏßÏà¹Ø  
 | 
    factionObj.onlineFightPowerTotal += fightPower  
 | 
    if playerID not in factionObj.onlinePlayerIDList:  
 | 
        factionObj.onlinePlayerIDList.append(playerID)  
 | 
          
 | 
    GameWorld.Log("    ·ÖÅäÕóÓª: allotStep=%s,callFaction=%s,faction=%s,playerID=%s,fightPower=%s,onlineFightPowerTotal=%s,onlinePlayerIDList=%s,isAllot=%s"   
 | 
                  % (allotStep, callFaction, faction, playerID, fightPower, factionObj.onlineFightPowerTotal, factionObj.onlinePlayerIDList, isAllot), fbPropertyID)  
 | 
      
 | 
    # ·ÖÅä½×¶ÎÊÇ×¼±¸½×¶ÎµÄ  
 | 
    if allotStep == FB_Step_Prepare:  
 | 
        initScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreBase", 2)  
 | 
        battleObj.addPlayerScore(curPlayer, initScore)  
 | 
          
 | 
    if curPlayer:  
 | 
        curPlayer.SetFaction(faction)  
 | 
        #if isAllot:  
 | 
        __RandFactionRebornArea(curPlayer, False)  
 | 
              
 | 
    return  
 | 
  
 | 
def OnCanFBReborn(curPlayer, rebornType):  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    if rebornType == ChConfig.rebornType_Health:  
 | 
        GameWorld.ErrLog("²»ÔÊÐíÏûºÄ»õ±ÒԵؽ¡¿µ¸´»î! ", playerID)  
 | 
        return False  
 | 
      
 | 
    if rebornType == ChConfig.rebornType_UseItem:  
 | 
        battleObj = GetBattlePlayerObj(playerID)  
 | 
        if battleObj.itemRebornCount >= IpyGameDataPY.GetFuncCfg("CrossBattlefieldReborn", 2):  
 | 
            PlayerControl.NotifyCode(curPlayer, "CrossBattlefieldItemRebornLimit")  
 | 
            return False  
 | 
          
 | 
    return True  
 | 
  
 | 
## Íæ¼Ò¸´»îºó´¦Àí  
 | 
def OnPlayerRebornOver(curPlayer, rebornType):  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
      
 | 
    if rebornType == ChConfig.rebornType_UseItem:  
 | 
        battleObj.itemRebornCount += 1  
 | 
        battleObj.playerHelpDict["itemRebornCount"] = battleObj.itemRebornCount  
 | 
        GameWorld.DebugLog("¸üÐÂʹÓõÀ¾ß¸´»î´ÎÊý£¡ itemRebornCount=%s, ÇÒ²»ÖжÏÁ¬É±=%s"   
 | 
                           % (battleObj.itemRebornCount, battleObj.continueKillCount), playerID)  
 | 
    else:  
 | 
        GameWorld.DebugLog("·ÇԵظ´»î£¬ÖжÏÁ¬É±£¡  %s" % battleObj.continueKillCount, playerID)  
 | 
        battleObj.continueKillCount = 0 # ·ÇԵظ´»îµÄÖжÏÁ¬É±Êý  
 | 
        battleObj.playerHelpDict["continueKillCount"] = battleObj.continueKillCount  
 | 
          
 | 
    NotifyBattlefieldHelp(False, curPlayer)  
 | 
    return  
 | 
  
 | 
def OnPlayerReborn():  
 | 
    ## ÊÇ·ñ¸±±¾¸´»î  
 | 
    return True  
 | 
  
 | 
## ÖØÖø±±¾¸´»îÍæ¼Ò×ø±êµã  
 | 
def OnResetFBRebornPlacePos(curPlayer, rebornPlace, tick):  
 | 
    __RandFactionRebornArea(curPlayer)  
 | 
    return  
 | 
  
 | 
def __RandFactionRebornArea(curPlayer, includeCrystal=True):  
 | 
    ## Ëæ»úÕóÓª¸´»îµã£º ÓªµØ + ÒÑÕ¼ÁìµÄ×ÊÔ´µã  Ëæ»ú  
 | 
    faction = curPlayer.GetFaction()        
 | 
    posInfo = getRandFactionRebornPos(faction, includeCrystal)  
 | 
    if posInfo:  
 | 
        posX, posY = posInfo  
 | 
    else:  
 | 
        posX, posY = curPlayer.GetPosX(), curPlayer.GetPosY()  
 | 
    curPlayer.ResetPos(posX, posY)  
 | 
    return  
 | 
  
 | 
def getRandFactionRebornPos(faction, includeCrystal=True):  
 | 
    rebornPosList = []      
 | 
    factionSafeAreaRandPosList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFB", 3)  
 | 
    if faction and faction <= len(factionSafeAreaRandPosList):  
 | 
        safePosX, safePosY, _ = factionSafeAreaRandPosList[faction - 1]  
 | 
        rebornPosList.append([safePosX, safePosY, 0, 3])  
 | 
          
 | 
    # °üº¬Õ¼ÁìµÄË®¾§  
 | 
    if includeCrystal:  
 | 
        crystalNPCIDPosDict = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldCrystal", 1, {})  
 | 
        worldObj = GetBattleWorld()  
 | 
        for npcID, ownerFaction in worldObj.crystalFactionInfo.items():  
 | 
            if ownerFaction != faction:  
 | 
                continue  
 | 
            if str(npcID) not in crystalNPCIDPosDict:  
 | 
                continue  
 | 
            posInfo = crystalNPCIDPosDict[str(npcID)]  
 | 
            rebornPosList.append([posInfo[0], posInfo[1], 3, 6])  
 | 
          
 | 
    if not rebornPosList:  
 | 
        return  
 | 
    randPosX, randPosY, minDist, maxDist = random.choice(rebornPosList)  
 | 
    posPoint = GameMap.GetEmptyPlaceInAreaEx(randPosX, randPosY, minDist, maxDist)  
 | 
    return posPoint.GetPosX(), posPoint.GetPosY()  
 | 
  
 | 
#def GetFBRobotRandomMovePos(curNPC):  
 | 
#    ## »ñÈ¡¸±±¾ÖлúÆ÷ÈËËæ»úÒÆ¶¯×ø±êµã  
 | 
#      
 | 
#    randPosList = []  
 | 
#      
 | 
#    crystalNPCIDPosDict = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldCrystal", 1, {})  
 | 
#    for posX, posY in crystalNPCIDPosDict.values():  
 | 
#        randPosList.append([posX, posY])  
 | 
#          
 | 
#    factionBuffPosList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFactionBuff", 2)  
 | 
#    for posList in factionBuffPosList:  
 | 
#        for posX, posY in posList:  
 | 
#            randPosList.append([posX, posY])  
 | 
#              
 | 
#    return random.choice(randPosList)  
 | 
  
 | 
def __DoLogic_FB_Fighting(tick):  
 | 
      
 | 
    passTick = tick - GameWorld.GetGameFB().GetFBStepTick()  
 | 
    remaindTick = GetBFStepTime()[Time_Fight] * 1000 - passTick  
 | 
    if remaindTick > 0:  
 | 
        passSeconds = passTick / 1000  
 | 
        __refreshFactionHome(tick)  
 | 
        __RefreshPersonBuff(tick, passSeconds)  
 | 
        __RefreshFactionBuff(tick, passSeconds)  
 | 
        __RefreshBattlefieldEvent(tick, passSeconds)  
 | 
          
 | 
        gameFB = GameWorld.GetGameFB()  
 | 
        lastTick = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_NotifyFBHelpTick)  
 | 
        if tick - lastTick >= FightRefreshInterval:  
 | 
            gameFB.SetGameFBDict(ChConfig.Def_FB_NotifyFBHelpTick, tick)  
 | 
            refreshCrossBattlefield(tick)  
 | 
            NotifyBattlefieldHelp()  
 | 
        return  
 | 
      
 | 
    jFactionObj = GetBattleFactionObj(ShareDefine.CampType_Justice)  
 | 
    eFactionObj = GetBattleFactionObj(ShareDefine.CampType_Evil)  
 | 
    jFactionScore = jFactionObj.score  
 | 
    eFactionScore = eFactionObj.score  
 | 
      
 | 
    winnerFaction = ShareDefine.CampType_Justice if jFactionScore >= eFactionScore else ShareDefine.CampType_Evil  
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    GameWorld.Log("¸±±¾Ê±¼äµ½£¬»ý·Ö¸ßµÄÕóÓª»ñʤ£¡ winnerFaction=%s,jFactionScore=%s,eFactionScore=%s"   
 | 
                  % (winnerFaction, jFactionScore, eFactionScore), fbPropertyID)  
 | 
    DoOver(winnerFaction, tick)  
 | 
    return  
 | 
  
 | 
def __refreshFactionHome(tick):  
 | 
    # Ë¢ÐÂÕóÓªÓªµØÏà¹Ø£¬Èç»ØÑªµÈ  
 | 
      
 | 
    restoreHPPerBySecond = IpyGameDataPY.GetFuncCfg("CrossBattlefieldFB", 4) # Ã¿Ãë»ØÑª°Ù·Ö±È  
 | 
    factionSafeAreaRandPosList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFB", 3) # ÓªµØ×ø±ê  
 | 
      
 | 
    copyMapMgr = GameWorld.GetMapCopyPlayerManager()  
 | 
    for faction in [ShareDefine.CampType_Justice, ShareDefine.CampType_Evil]:  
 | 
        factionObj = GetBattleFactionObj(faction)  
 | 
        if not factionObj.homePlayerIDList:  
 | 
            continue  
 | 
          
 | 
        for playerID in factionObj.homePlayerIDList[::-1]:  
 | 
            curPlayer = copyMapMgr.FindPlayerByID(playerID)  
 | 
            if not curPlayer:  
 | 
                continue  
 | 
                          
 | 
            batObj = GetBattlePlayerObj(playerID)  
 | 
            safePosX, safePosY, safeRadius = factionSafeAreaRandPosList[faction - 1]  
 | 
            if GameWorld.GetDist(curPlayer.GetPosX(), curPlayer.GetPosY(), safePosX, safePosY) > safeRadius:  
 | 
                factionObj.homePlayerIDList.remove(playerID)  
 | 
                batObj.restoreHPTick = 0  
 | 
                continue  
 | 
              
 | 
            # ÓªµØ»ØÑª  
 | 
            restoreSeconds = (tick - batObj.restoreHPTick) / 1000.0 if batObj.restoreHPTick else 1 # Ê״α£µ×1Ãë  
 | 
            if restoreSeconds < 1:  
 | 
                continue  
 | 
            maxHP = GameObj.GetMaxHP(curPlayer)  
 | 
            if GameObj.GetHP(curPlayer) < maxHP:  
 | 
                restoreHP = int(maxHP * restoreHPPerBySecond / 100.0 * round(restoreSeconds, 1))  
 | 
                #GameWorld.DebugLog("restoreHPPerBySecond=%s,restoreSeconds=%s,maxHP=%s,restoreHP=%s"   
 | 
                #                   % (restoreHPPerBySecond, restoreSeconds, maxHP, restoreHP), playerID)  
 | 
                SkillCommon.SkillAddHP(curPlayer, 0, restoreHP)  
 | 
            batObj.restoreHPTick = tick  
 | 
              
 | 
    return  
 | 
  
 | 
def __RefreshPersonBuff(tick, passSeconds):  
 | 
    ## Ë¢Ð¸öÈËbuff  
 | 
    startRefreshSeconds, refreshCD = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldPersonBuff", 3)  
 | 
    if passSeconds < startRefreshSeconds:  
 | 
        return  
 | 
      
 | 
    buffCountMax = IpyGameDataPY.GetFuncCfg("CrossBattlefieldPersonBuff", 4)  
 | 
    worldObj = GetBattleWorld()  
 | 
    if worldObj.personBuffCount >= buffCountMax:  
 | 
        return  
 | 
      
 | 
    if (tick - worldObj.personBuffCalcTick) < (refreshCD * 1000):  
 | 
        return  
 | 
      
 | 
    buffIDList = GetPersonBuffIDList()  
 | 
    if not buffIDList:  
 | 
        return  
 | 
          
 | 
    posList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldPersonBuff", 2)  
 | 
    posInfo = __GetRandPos(posList)  
 | 
    if not posInfo:  
 | 
        return  
 | 
      
 | 
    randBuffNPCID = random.choice(buffIDList)  
 | 
    if not NPCCommon.SummonMapNpc(randBuffNPCID, posInfo[0], posInfo[1]):  
 | 
        return  
 | 
          
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    worldObj.personBuffCount = worldObj.personBuffCount + 1  
 | 
    if worldObj.personBuffCount >= buffCountMax:  
 | 
        worldObj.personBuffCalcTick = 0  
 | 
    else:  
 | 
        worldObj.personBuffCalcTick = tick  
 | 
          
 | 
    GameWorld.DebugLog("ˢиöÈËbuff: randBuffNPCID=%s,personBuffCount=%s" % (randBuffNPCID, worldObj.personBuffCount), fbPropertyID)  
 | 
    return  
 | 
  
 | 
def __RefreshFactionBuff(tick, passSeconds):  
 | 
    ## Ë¢ÐÂÕóÓªbuff  
 | 
    startRefreshSeconds, refreshCD = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFactionBuff", 3)  
 | 
    if passSeconds < startRefreshSeconds:  
 | 
        return  
 | 
      
 | 
    worldObj = GetBattleWorld()  
 | 
    if worldObj.factionBuffNPCInfo:  
 | 
        return  
 | 
      
 | 
    if (tick - worldObj.factionBuffCalcTick) < (refreshCD * 1000):  
 | 
        return  
 | 
      
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    if not worldObj.factionBuffIDOrderList:  
 | 
        buffIDList = GetFactionBuffIDList()  
 | 
        if not buffIDList:  
 | 
            return  
 | 
        worldObj.factionBuffIDOrderList = copy.deepcopy(buffIDList)  
 | 
        random.shuffle(worldObj.factionBuffIDOrderList) # Ã¿ÂÖÖØÐ´òÂÒ˳Ðò  
 | 
        GameWorld.DebugLog("Õ½³¡ÕóÓªbuff˳ÐòÁбí: %s" % worldObj.factionBuffIDOrderList, fbPropertyID)  
 | 
          
 | 
    if not worldObj.factionBuffIDOrderList:  
 | 
        return  
 | 
      
 | 
    jFactionObj = GetBattleFactionObj(ShareDefine.CampType_Justice)  
 | 
    eFactionObj = GetBattleFactionObj(ShareDefine.CampType_Evil)  
 | 
    # Ê¹ÓöԷ½ÕóÓªµÄ»ý·Ö×÷Ϊ±¾ÕóÓªÈ¨ÖØ£¬ ·ÖÊýÔ½µÍµÄÕóÓªËæ»úµ½¿¿½ü×Ô¼ºÕóÓªµÄλÖõÄÈ¨ÖØÔ½¸ß£¬È¨ÖØÖÁÉÙ10  
 | 
    nearFactionWeightList = [[max(10, jFactionObj.score), ShareDefine.CampType_Evil],  
 | 
                             [max(10, eFactionObj.score), ShareDefine.CampType_Justice]]  
 | 
    nearFaction = GameWorld.GetResultByWeightList(nearFactionWeightList, ShareDefine.CampType_Evil)  
 | 
      
 | 
    allPosList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFactionBuff", 2)  
 | 
    if nearFaction > len(allPosList):  
 | 
        return  
 | 
      
 | 
    posList = allPosList[nearFaction - 1]  
 | 
    posInfo = __GetRandPos(posList)  
 | 
    if not posInfo:  
 | 
        return  
 | 
    posX, posY = posInfo[0], posInfo[1]  
 | 
      
 | 
    randBuffNPCID = worldObj.factionBuffIDOrderList.pop(0)  
 | 
    if not NPCCommon.SummonMapNpc(randBuffNPCID, posX, posY):  
 | 
        return  
 | 
      
 | 
    worldObj.factionBuffNPCInfo = [randBuffNPCID, posX, posY]  
 | 
    worldObj.worldHelpDict["factionBuffNPCInfo"] = worldObj.factionBuffNPCInfo  
 | 
    GameWorld.DebugLog("Ë¢ÐÂÕóÓªbuff: randBuffNPCID=%s,nearFaction=%s,nearFactionWeightList=%s"   
 | 
                       % (randBuffNPCID, nearFaction, nearFactionWeightList), fbPropertyID)  
 | 
    PlayerControl.FBNotify("CrossBattlefieldBuff_%s" % randBuffNPCID, [randBuffNPCID])  
 | 
    NotifyBattlefieldHelp()  
 | 
    return  
 | 
  
 | 
def __GetRandPos(posList):  
 | 
    if not posList:  
 | 
        return  
 | 
    random.shuffle(posList)  
 | 
    gameMap = GameWorld.GetMap()  
 | 
    for posX, posY in posList:  
 | 
        if gameMap.CanMove(posX, posY) != True:  
 | 
            continue  
 | 
        #¼ì²éÓÐûÓÐÍæ¼ÒÔÚÕâÒ»µãÉÏ  
 | 
        mapObj = gameMap.GetPosObj(posX, posY)  
 | 
        if not mapObj:  
 | 
            continue  
 | 
        if mapObj.GetObjCount() != 0:  
 | 
            #ÓÐÍæ¼ÒÔڴ˵ãÉÏ  
 | 
            #GameWorld.DebugLog("ÓÐʵÀýÔÚ´Ë×ø±êÉÏ: posX=%s, posY=%s, GetObjCount=%s"   
 | 
            #                   % (posX, posY, mapObj.GetObjCount()), GameWorld.GetGameWorld().GetPropertyID())  
 | 
            continue  
 | 
        return posX, posY  
 | 
      
 | 
    return  
 | 
  
 | 
def __RefreshBattlefieldEvent(tick, passSeconds):  
 | 
    ## Ë¢ÐÂÕ½³¡Ëæ»úʼþ  
 | 
      
 | 
    worldObj = GetBattleWorld()  
 | 
      
 | 
    if worldObj.eventStartTick > worldObj.lastEventEndTick:  
 | 
        #GameWorld.DebugLog("µ±Ç°Ê¼þ½øÐÐÖÐδ½áÊø!")  
 | 
        if worldObj.eventNum == EventNum_Aura:  
 | 
            if tick <= worldObj.eventEndTick:  
 | 
                return  
 | 
              
 | 
            auraNPCID = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreAura", 1)  
 | 
            auraNPC = GameWorld.FindNPCByNPCID(auraNPCID)  
 | 
            if auraNPC:  
 | 
                NPCCommon.SetDeadEx(auraNPC)  
 | 
                  
 | 
            worldObj.setEventEnd(tick)  
 | 
            NotifyBattlefieldHelp()  
 | 
              
 | 
        return  
 | 
      
 | 
    if not worldObj.eventInfoList:  
 | 
        return  
 | 
      
 | 
    nextEventTime, nextEventNum = worldObj.eventInfoList[0] # Ä¬ÈÏÈ¡µÚÒ»¸ö¾ÍÐУ¬¸±±¾¿ªÊ¼Ê±ÒÑËæ»úºÃ  
 | 
    if passSeconds < nextEventTime:  
 | 
        # Ê¼þʱ¼äδµ½  
 | 
        return  
 | 
      
 | 
    eventRefresCD = IpyGameDataPY.GetFuncCfg("CrossBattlefieldEvent", 4) * 1000  
 | 
    if worldObj.lastEventEndTick and eventRefresCD and (tick - worldObj.lastEventEndTick) < eventRefresCD:  
 | 
        #GameWorld.DebugLog("ʼþË¢ÐÂCDÖÐ!")  
 | 
        return  
 | 
      
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    jFactionObj = GetBattleFactionObj(ShareDefine.CampType_Justice)  
 | 
    eFactionObj = GetBattleFactionObj(ShareDefine.CampType_Evil)  
 | 
          
 | 
    nearFaction = 0  
 | 
    if nextEventNum == EventNum_Boss:  
 | 
        callFactioList = worldObj.callOpenPlayerInfo.values()  
 | 
        callFactioList = worldObj.callOpenPlayerInfo.values()  
 | 
        if len(callFactioList) == 1:  
 | 
            nearFaction = callFactioList[0]  
 | 
            GameWorld.Log("Õ½³¡bossʼþ£¬½öÒ»·½ÕÙ¼¯£¬¹Ì¶¨Ë¢ÐÂÔÚ¿¿½ü¸ÃÕóÓªµÄλÖÃ: nearFaction=%s, callOpenPlayerInfo=%s"   
 | 
                          % (nearFaction, worldObj.callOpenPlayerInfo), fbPropertyID)  
 | 
        else:  
 | 
            GameWorld.Log("Õ½³¡bossʼþ£¬×ß³£¹æÂß¼ÅжϿ¿½üÕóӪλÖÃ! callOpenPlayerInfo=%s" % worldObj.callOpenPlayerInfo, fbPropertyID)  
 | 
              
 | 
    # Ê¹ÓöԷ½ÕóÓªµÄ»ý·Ö×÷Ϊ±¾ÕóÓªÈ¨ÖØ£¬ ·ÖÊýÔ½µÍµÄÕóÓªËæ»úµ½¿¿½ü×Ô¼ºÕóÓªµÄλÖõÄÈ¨ÖØÔ½¸ß£¬È¨ÖØÖÁÉÙ10  
 | 
    if nearFaction:  
 | 
        # ÒѾ¾ö¶¨ÁËʼþ¿¿½üµÄÕóÓª£¬²»ÓÃÔÙ´¦Àí  
 | 
        pass  
 | 
    elif jFactionObj.score < eFactionObj.score:  
 | 
        nearFaction = ShareDefine.CampType_Justice  
 | 
    elif jFactionObj.score > eFactionObj.score:  
 | 
        nearFaction = ShareDefine.CampType_Evil  
 | 
    else:  
 | 
        nearFaction = random.choice([ShareDefine.CampType_Justice, ShareDefine.CampType_Evil])  
 | 
          
 | 
    if nextEventNum == EventNum_Aura:  
 | 
        refreshNPCID = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreAura", 1)  
 | 
    elif nextEventNum == EventNum_Boss:  
 | 
        refreshNPCID = IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 1)  
 | 
    elif nextEventNum == EventNum_Wall:  
 | 
        refreshNPCID = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreWall", 1)  
 | 
    else:  
 | 
        return  
 | 
      
 | 
    refreshMark = 0  
 | 
    if refreshNPCID:  
 | 
        eventRefreshMarkList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldEvent", 1)  
 | 
        if nearFaction > len(eventRefreshMarkList):  
 | 
            return  
 | 
        refreshMark = eventRefreshMarkList[nearFaction - 1]  
 | 
          
 | 
    worldObj.eventInfoList.pop(0)  
 | 
    eventNum = nextEventNum  
 | 
    GameWorld.Log("¿ªÊ¼Õ½³¡Ê¼þ: eventNum=%s,refreshNPCID=%s,nearFaction=%s,refreshMark=%s"   
 | 
                  % (eventNum, refreshNPCID, nearFaction, refreshMark), fbPropertyID)  
 | 
      
 | 
    worldObj.eventNum = eventNum  
 | 
    worldObj.eventNPCID = refreshNPCID  
 | 
    worldObj.eventStartTick = tick  
 | 
    if eventNum == EventNum_Aura:  
 | 
        worldObj.eventEndTick = tick + IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreAura", 2) * 1000  
 | 
    else:  
 | 
        worldObj.eventEndTick = 0  
 | 
          
 | 
    if refreshNPCID and refreshMark:  
 | 
        NPCCustomRefresh.SetNPCRefresh(refreshMark, [refreshNPCID])  
 | 
          
 | 
    # °ïÖúÐÅÏ¢·ÅÔÚNPCË¢³öÀ´ºó֪ͨ£¬ÒòΪÐèÒª×ø±êÐÅÏ¢  
 | 
    return  
 | 
  
 | 
def DoFBRebornNPC(curNPC, tick):  
 | 
    ##¸±±¾ÓÐNPCÕÙ³ö  
 | 
      
 | 
    npcID = curNPC.GetNPCID()  
 | 
    worldObj = GetBattleWorld()  
 | 
      
 | 
    if npcID == worldObj.eventNPCID:  
 | 
        fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
        eventNum = worldObj.eventNum  
 | 
        worldObj.eventNPCHP = GameObj.GetHP(curNPC)  
 | 
        worldObj.eventNPCPos = [curNPC.GetPosX(), curNPC.GetPosY()]  
 | 
        GameWorld.Log("Õ½³¡Ê¼þNPCË¢ÐÂ: eventNum=%s,npcID=%s,eventNPCPos=%s,eventNPCHP=%s"   
 | 
                      % (worldObj.eventNum, npcID, worldObj.eventNPCPos, worldObj.eventNPCHP), fbPropertyID)  
 | 
          
 | 
        if eventNum == EventNum_Aura:  
 | 
            PlayerControl.FBNotify("CrossBattlefieldEventAura", [npcID])  
 | 
        elif eventNum == EventNum_Boss:  
 | 
            factionScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 3)  
 | 
            PlayerControl.FBNotify("CrossBattlefieldEventBoss", [npcID, factionScore])  
 | 
        elif eventNum == EventNum_Wall:  
 | 
            wallScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreWall", 3)  
 | 
            PlayerControl.FBNotify("CrossBattlefieldEventWall", [npcID, wallScore, worldObj.eventNPCHP])  
 | 
              
 | 
        worldObj.updEventNPCHelp(tick)  
 | 
        NotifyBattlefieldHelp()  
 | 
          
 | 
    return  
 | 
  
 | 
def DoBeAttackOver(attacker, defender, curSkill, tick):  
 | 
    atkObjType = attacker.GetGameObjType()  
 | 
    defObjType = defender.GetGameObjType()  
 | 
      
 | 
    if atkObjType == IPY_GameWorld.gotNPC and defObjType == IPY_GameWorld.gotPlayer:  
 | 
        curNPC, curPlayer = attacker, defender  
 | 
        npcID = curNPC.GetNPCID()  
 | 
        if npcID == IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreAura", 1):  
 | 
            __DoAuraNPCAddPlayerScore(curNPC, curPlayer)  
 | 
              
 | 
    return  
 | 
  
 | 
def __DoAuraNPCAddPlayerScore(curNPC, curPlayer):  
 | 
    ## »ý·Ö¹â»·¸øÍæ¼ÒÔö¼Ó»ý·Ö  
 | 
    #npcID = curNPC.GetNPCID()  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    auraScoreRange = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldScoreAura", 3)  
 | 
    if len(auraScoreRange) != 2:  
 | 
        return  
 | 
    addValue = random.randint(auraScoreRange[0], auraScoreRange[1])  
 | 
    #GameWorld.DebugLog("»ý·Ö¹â»·¸øÍæ¼Ò¼Ó»ý·Ö: addValue=%s,auraScoreRange=%s" % (addValue, auraScoreRange), playerID)  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    battleObj.addPlayerScore(curPlayer, addValue, ScoreType_Aura)  
 | 
    NotifyBattlefieldHelp(False, curPlayer)  
 | 
    return  
 | 
  
 | 
def __DoLogic_FB_Leave(tick):  
 | 
    remaindTick = GetBFStepTime()[Time_Leave] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())  
 | 
    if remaindTick > 0:  
 | 
        return  
 | 
      
 | 
    FBCommon.DoLogic_FBKickAllPlayer()  
 | 
    GameWorldProcess.CloseFB(tick)  
 | 
    FBCommon.SetFBStep(FB_Step_Over, tick)  
 | 
    return  
 | 
  
 | 
##´¦Àí¸±±¾ÖÐɱËÀÍæ¼ÒÂß¼  
 | 
def DoFBOnKill_Player(curPlayer, defender, tick):  
 | 
    onBattleObjKillOtherBattleObj(curPlayer, defender, tick)  
 | 
    return True  
 | 
  
 | 
def onBattleObjKillOtherBattleObj(atkObj, defObj, tick):  
 | 
    ## Õ½¶·ÊµÀý »÷ɱ ÆäËûÕóÓªÕ½¶·ÊµÀý£¬Õ½¶·ÊµÀý°üº¬£¨ÕæÊµÍæ¼Ò¡¢Õ½¶·»úÆ÷ÈË£©  
 | 
    if not atkObj or not defObj:  
 | 
        return  
 | 
      
 | 
    atkID = atkObj.GetID()  
 | 
    defID = defObj.GetID()  
 | 
    atkObjType = atkObj.GetGameObjType()  
 | 
    defObjType = defObj.GetGameObjType()  
 | 
      
 | 
    if atkObjType == defObjType and atkID == defID:  
 | 
        return  
 | 
      
 | 
    if atkObjType == IPY_GameWorld.gotPlayer:  
 | 
        atkName = atkObj.GetName()  
 | 
        atkFaction = atkObj.GetFaction()  
 | 
    elif atkObjType == IPY_GameWorld.gotNPC:  
 | 
        atkFaction = NPCCommon.GetFaction(atkObj)  
 | 
        atkName = atkObj.GetName()  
 | 
        atkName = atkName.decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())  
 | 
    else:  
 | 
        return  
 | 
          
 | 
    if defObjType == IPY_GameWorld.gotPlayer:  
 | 
        defFaction = defObj.GetFaction()  
 | 
    elif defObjType == IPY_GameWorld.gotNPC:  
 | 
        defFaction = NPCCommon.GetFaction(defObj)  
 | 
    else:  
 | 
        return  
 | 
      
 | 
    if not atkFaction or not defFaction or atkFaction == defFaction:  
 | 
        return  
 | 
      
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    baseKillScore = 0 # »ù´¡»÷ɱ·Ö  
 | 
    fbFightSeconds = (tick - GameWorld.GetGameFB().GetFBStepTick()) / 1000  
 | 
    killPlayerScoreTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldScoreBase", 3)  
 | 
    for fbFightTimes, killScore in killPlayerScoreTimeList:  
 | 
        if fbFightSeconds <= (fbFightTimes * 60):  
 | 
            baseKillScore = killScore  
 | 
            GameWorld.DebugLog("»ù´¡»÷ɱ·Ö: baseKillScore=%s, %s·ÖÖÓÄÚ" % (baseKillScore, fbFightTimes), fbPropertyID)  
 | 
            break  
 | 
          
 | 
    worldObj = GetBattleWorld()  
 | 
      
 | 
    # 1. ´¦ÀíÍæ¼Ò¸öÈË»ý·Ö  
 | 
    if atkObjType == IPY_GameWorld.gotPlayer:  
 | 
        playerID = atkID  
 | 
        playerScore = 0  
 | 
        playerScore += baseKillScore  
 | 
          
 | 
        GameWorld.DebugLog("Íæ¼Ò»÷ɱ¶ÔÊÖ! playerID=%s,atkFaction=%s,defObjType=%s,defID=%s"   
 | 
                           % (playerID, atkFaction, defObjType, defID), fbPropertyID)  
 | 
          
 | 
        if playerID in worldObj.callOpenPlayerInfo or IsSysCallBuyPlayer(playerID):  
 | 
            callPlayerKillScoreEx = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreBase", 4)  
 | 
            playerScore += callPlayerKillScoreEx  
 | 
            GameWorld.DebugLog("    ÕÙ¼¯È˶îÍâ»÷ɱ·Ö: callPlayerKillScoreEx=%s" % callPlayerKillScoreEx, fbPropertyID)  
 | 
              
 | 
        atkBattleObj = GetBattlePlayerObj(playerID)  
 | 
        scoreTimes = 1 # »ý·Ö±¶Öµ  
 | 
        if atkBattleObj.killPlayerAddScoreTimes and tick <= atkBattleObj.killPlayerScoreAwardEndTick:  
 | 
            scoreTimes = atkBattleObj.killPlayerAddScoreTimes  
 | 
        else:  
 | 
            atkBattleObj.killPlayerAddScoreTimes = 0  
 | 
            atkBattleObj.killPlayerScoreAwardEndTick = 0  
 | 
        atkBattleObj.addKillCount(1)  
 | 
        atkBattleObj.addPlayerScore(atkObj, playerScore, ScoreType_KillPlayer, scoreTimes)  
 | 
          
 | 
    else:  
 | 
        GameWorld.DebugLog("»úÆ÷ÈË»÷ɱ¶ÔÊÖ! atkID=%s,atkFaction=%s,defObjType=%s,defID=%s"   
 | 
                           % (atkID, atkFaction, defObjType, defID), fbPropertyID)  
 | 
        # »úÆ÷È˲»¼ÆËã¸öÈË»ý·Ö  
 | 
          
 | 
    # 2. ´¦ÀíÕóÓª»ý·Ö  
 | 
    factionScore = 0  
 | 
    atkFactionObj = GetBattleFactionObj(atkFaction)  
 | 
    defFactionObj = GetBattleFactionObj(defFaction)  
 | 
      
 | 
    if atkObjType == IPY_GameWorld.gotNPC:  
 | 
        factionScore += baseKillScore # »úÆ÷ÈËûÓиöÈË·Ö£¬ËùÒÔ»÷ɱ»ù´¡·ÖÖ±½ÓËãµ½ÕóÓªÉÏ  
 | 
              
 | 
    # »÷ɱ»ý·ÖÍõ£¬ÕóÓª»ý·Ö¶îÍâÔö¼Ó  
 | 
    if defObjType == IPY_GameWorld.gotPlayer:  
 | 
        for index, kingID in enumerate(defFactionObj.scoreKingIDList):  
 | 
            if kingID == defID:  
 | 
                killScoreKingScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldScoreKing", 3)  
 | 
                kingScore = killScoreKingScoreList[index] if index < len(killScoreKingScoreList) else 0  
 | 
                factionScore += kingScore  
 | 
                GameWorld.DebugLog("    ¶Ô·½ÊÇ»ý·ÖÍõ£¬ÕóÓª¶îÍâ»ñµÃ»ý·Ö£º  index=%s,kingScore=%s" % (index, kingScore), fbPropertyID)  
 | 
                  
 | 
                killScoreKingNotifyList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldScoreKing", 4)  
 | 
                if index < len(killScoreKingNotifyList) and atkObjType == IPY_GameWorld.gotPlayer:  
 | 
                    msgMark = killScoreKingNotifyList[index]  
 | 
                    lineID = GameWorld.GetGameWorld().GetLineID()  
 | 
                    defMapID = GameWorld.GetMap().GetMapID()  
 | 
                    defPosX = defObj.GetPosX()  
 | 
                    defPosY = defObj.GetPosY()  
 | 
                    PlayerControl.FBNotify(msgMark, [atkFaction, atkName, defFaction, defObj.GetPlayerName(), kingScore, defMapID, defPosX, defPosY, lineID])  
 | 
                      
 | 
                # Íæ¼Ò»÷°Ü»ý·ÖÍõ  
 | 
                if atkObjType == IPY_GameWorld.gotPlayer and index == 0:  
 | 
                    atkBattleObj.killScoreKing = 1  
 | 
                break  
 | 
    else:  
 | 
        pass  
 | 
          
 | 
    #factionScore += ... # ÆäËû¼Ó·Ö  
 | 
    atkFactionObj.addFactionScore(factionScore)  
 | 
      
 | 
    if atkObjType == IPY_GameWorld.gotPlayer:  
 | 
        NotifyBattlefieldHelp(False, atkObj) # »÷ɱµÄÔÝֻʵʱ֪ͨ×Ô¼º  
 | 
          
 | 
    # Íæ¼Ò±»»÷ɱ£¬µôÂä¸öÈËbuff  
 | 
    if defObjType == IPY_GameWorld.gotPlayer:  
 | 
        DoDropPersonBuffOnKilled(atkObj, defObj, tick)  
 | 
          
 | 
    return  
 | 
  
 | 
def DoFB_NPCDead(curNPC):  
 | 
      
 | 
    gameFB = GameWorld.GetGameFB()  
 | 
    if gameFB.GetFBStep() != FB_Step_Fighting:  
 | 
        return  
 | 
      
 | 
    faction = NPCCommon.GetFaction(curNPC)  
 | 
    if not faction:  
 | 
        return  
 | 
    if curNPC.GetType() == ChConfig.ntRobot:  
 | 
        objID = curNPC.GetID()  
 | 
        factionObj = GetBattleFactionObj(faction)  
 | 
        if objID in factionObj.robotObjIDList:  
 | 
            factionObj.robotObjIDList.remove(objID)  
 | 
            GameWorld.DebugLog("»úÆ÷È˱»»÷ɱ£¬ÕóÓª»úÆ÷ÈËIDÒÆ³ý£º faction=%s,objID=%s,robotObjIDList=%s"   
 | 
                               % (faction, objID, factionObj.robotObjIDList), GameWorld.GetGameWorld().GetPropertyID())  
 | 
    return  
 | 
  
 | 
def refreshCrossBattlefield(tick, checkVictory=True):  
 | 
    ## Ë¢ÐÂÕ½³¡Ïà¹Ø  
 | 
      
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    # ¶¨Ê±Õ¼Áì×ÊÔ´»ý·Ö½±Àø  
 | 
    awardScorePerSecondDict = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldCrystal", 3)  
 | 
    worldObj = GetBattleWorld()  
 | 
    for npcID, ownerFaction in worldObj.crystalFactionInfo.items():  
 | 
        if npcID not in awardScorePerSecondDict:  
 | 
            continue  
 | 
        awardScorePerSecond = awardScorePerSecondDict[npcID]  
 | 
        lastAwardTick = worldObj.crystalAwardTick.get(npcID, tick)  
 | 
        awardSeconds = (tick - lastAwardTick) / 1000.0  
 | 
        awardFactionScore = int(awardScorePerSecond * round(awardSeconds))  
 | 
        worldObj.crystalAwardTick[npcID] = tick  
 | 
        if awardFactionScore <= 0:  
 | 
            continue  
 | 
        factionObj = GetBattleFactionObj(ownerFaction)  
 | 
        if factionObj.crystalScorePlusRate and tick <= factionObj.crystalScorePlusEndTick:  
 | 
            awardFactionScore = int(awardFactionScore * (1 + int(factionObj.crystalScorePlusRate / 10000.0)))  
 | 
        else:  
 | 
            factionObj.crystalScorePlusRate = 0  
 | 
            factionObj.crystalScorePlusEndTick = 0  
 | 
        GameWorld.DebugLog("¶¨Ê±×ÊÔ´»ý·Ö: npcID=%s,ownerFaction=%s,awardScorePerSecond=%s,awardSeconds=%s,awardFactionScore=%s"   
 | 
                           % (npcID, ownerFaction, awardScorePerSecond, awardSeconds, awardFactionScore), fbPropertyID)  
 | 
        factionObj.addFactionScore(awardFactionScore, False)  
 | 
          
 | 
    # ²ÎÓëÍæ¼Ò´¦Àí  
 | 
    scoreKingScoreMin = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreKing", 1)  
 | 
    scoreKingBuffIDList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldScoreKing", 2)  
 | 
    scoreKingCount = len(scoreKingBuffIDList)  
 | 
      
 | 
    factionSafeAreaRandPosList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldFB", 3) # ÓªµØ×ø±ê  
 | 
    robotNPCIDList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldRobot", 1)  
 | 
    battleObjBaseCount = IpyGameDataPY.GetFuncCfg("CrossBattlefieldRobot", 2) # ÕóÓª±£µ×Õ½¶·ÈËÔ±Êý£¬ÔÚÏß+»úÆ÷ÈË  
 | 
      
 | 
    copyMapMgr = GameWorld.GetMapCopyPlayerManager()  
 | 
    copyPlayerCount = copyMapMgr.GetPlayerCount()  
 | 
    for faction in [ShareDefine.CampType_Justice, ShareDefine.CampType_Evil]:  
 | 
        factionObj = GetBattleFactionObj(faction)  
 | 
          
 | 
        # »úÆ÷ÈË£¬ÓÐÕæÊµÍæ¼Òʱ²Å´¦ÀíË¢³ö»úÆ÷ÈË  
 | 
        if copyPlayerCount and len(factionObj.onlinePlayerIDList) + len(factionObj.robotObjIDList) < battleObjBaseCount and faction <= len(robotNPCIDList):  
 | 
            robotNPCID = robotNPCIDList[faction - 1]  
 | 
            posInfo = getRandFactionRebornPos(faction)  
 | 
            if posInfo:  
 | 
                robotNPC = NPCCommon.SummonMapNpc(robotNPCID, posInfo[0], posInfo[1])  
 | 
                if robotNPC:  
 | 
                    robotNPC.SetIsNeedProcess(True)  
 | 
                    robotID = robotNPC.GetID()  
 | 
                    if robotID not in factionObj.robotObjIDList:  
 | 
                        factionObj.robotObjIDList.append(robotID)  
 | 
                        GameWorld.DebugLog("ÐÂÔöÕóÓª»úÆ÷ÈË: faction=%s,robotNPCID=%s,robotID=%s,posInfo=%s,robotObjIDList=%s"   
 | 
                                           % (faction, robotNPCID, robotID, posInfo, factionObj.robotObjIDList), fbPropertyID)  
 | 
                      
 | 
        befKingIDList = factionObj.scoreKingIDList  
 | 
          
 | 
        factionObj.battlePlayerSortList = factionObj.factionPlayerDict.values()  
 | 
        factionObj.battlePlayerSortList.sort(key=operator.attrgetter("score", "scoreSortTime"), reverse=True)  
 | 
          
 | 
        safePosX, safePosY, safeRadius = factionSafeAreaRandPosList[faction - 1]  
 | 
          
 | 
        aftKingIDList = []  
 | 
        aftKingObjList = []  
 | 
        for batObj in factionObj.battlePlayerSortList:  
 | 
            playerID = batObj.playerID  
 | 
            curPlayer = copyMapMgr.FindPlayerByID(playerID)  
 | 
            if not curPlayer:  
 | 
                continue  
 | 
              
 | 
            # ÀۼƲÎÓëÕ½¶·Ê±³¤  
 | 
            if batObj.onlineCalcTick:  
 | 
                batObj.onlineTimes += max(0, tick - batObj.onlineCalcTick)  
 | 
                batObj.onlineCalcTick = tick  
 | 
                  
 | 
            # »ØÓªµØ  
 | 
            if GameWorld.GetDist(curPlayer.GetPosX(), curPlayer.GetPosY(), safePosX, safePosY) <= safeRadius:  
 | 
                if playerID not in factionObj.homePlayerIDList:  
 | 
                    factionObj.homePlayerIDList.append(playerID)  
 | 
                  
 | 
            # ÓÐ×ʸñµÄ»ý·ÖÍõÁÐ±í  
 | 
            if batObj.score >= scoreKingScoreMin and len(aftKingIDList) < scoreKingCount:  
 | 
                aftKingIDList.append(playerID)  
 | 
                aftKingObjList.append([curPlayer, batObj])  
 | 
                  
 | 
        if befKingIDList == aftKingIDList:  
 | 
            #GameWorld.DebugLog("    ÕóÓª»ý·ÖÍõ²»±ä: faction=%s,befKingIDList=%s,aftKingIDList=%s" % (faction, befKingIDList, aftKingIDList), fbPropertyID)  
 | 
            continue  
 | 
          
 | 
        GameWorld.DebugLog("    ÕóÓª»ý·ÖÍõ±ä¸ü: faction=%s,befKingIDList=%s,aftKingIDList=%s" % (faction, befKingIDList, aftKingIDList), fbPropertyID)  
 | 
          
 | 
        # ¸üÐÂbuff  
 | 
        for index, objInfo in enumerate(aftKingObjList):  
 | 
            curPlayer, batObj = objInfo  
 | 
              
 | 
            playerID = curPlayer.GetPlayerID()  
 | 
              
 | 
            addBuffID = scoreKingBuffIDList[index] if index < len(scoreKingBuffIDList) else 0  
 | 
              
 | 
            if playerID in befKingIDList:  
 | 
                befIndex = befKingIDList.index(playerID)  
 | 
                if index == befIndex:  
 | 
                    GameWorld.DebugLog("        »ý·ÖÍõÃû´Î²»±ä£¬²»ÐèÒª±ä¸übuff! index=%s,playerID=%s" % (index, playerID), fbPropertyID)  
 | 
                    continue  
 | 
                delBuffID = scoreKingBuffIDList[befIndex] if befIndex < len(scoreKingBuffIDList) else 0  
 | 
                if delBuffID:  
 | 
                    GameWorld.DebugLog("        »ý·ÖÍõÃû´Î±ä¸ü! É¾³ý¾Ébuff! befIndex=%s,delBuffID=%s,playerID=%s" % (befIndex, delBuffID, playerID), fbPropertyID)  
 | 
                    BuffSkill.DelBuffBySkillID(curPlayer, delBuffID, tick)  
 | 
                      
 | 
            if addBuffID:  
 | 
                GameWorld.DebugLog("        »ý·ÖÍõÃû´Î±ä¸ü! Ìí¼ÓÐÂbuff! index=%s,addBuffID=%s,playerID=%s" % (index, addBuffID, playerID), fbPropertyID)  
 | 
                SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, addBuffID, tick)  
 | 
                  
 | 
        for befIndex, playerID in enumerate(befKingIDList):  
 | 
            if playerID in aftKingIDList:  
 | 
                continue  
 | 
            curPlayer = copyMapMgr.FindPlayerByID(playerID)  
 | 
            if not curPlayer:  
 | 
                continue  
 | 
            delBuffID = scoreKingBuffIDList[befIndex] if befIndex < len(scoreKingBuffIDList) else 0  
 | 
            if delBuffID:  
 | 
                GameWorld.DebugLog("        »ý·ÖÍõ±»¼·µô! É¾³ý¾Ébuff! befIndex=%s,delBuffID=%s,playerID=%s" % (befIndex, delBuffID, playerID), fbPropertyID)  
 | 
                BuffSkill.DelBuffBySkillID(curPlayer, delBuffID, tick)  
 | 
                  
 | 
        factionObj.scoreKingIDList = aftKingIDList  
 | 
      
 | 
    if not checkVictory:  
 | 
        return  
 | 
      
 | 
    checkBattleOver(tick)  
 | 
    return  
 | 
  
 | 
def DoOver(winnerFaction, tick):  
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    zoneID = FBCommon.GetCrossDynamicLineMapZoneID()  
 | 
    funcLineID = FBCommon.GetCrossDynamicLineMapFuncLineID()  
 | 
      
 | 
    gameFB = GameWorld.GetGameFB()  
 | 
    fbStep = gameFB.GetFBStep()  
 | 
    if fbStep > FB_Step_Fighting:  
 | 
        GameWorld.ErrLog("¿ç·þÕ½³¡´¥·¢Öظ´½áË㣬²»´¦Àí£¡ zoneID=%s,funcLineID=%s,winnerFaction=%s" % (zoneID, funcLineID, winnerFaction), fbPropertyID)  
 | 
        return  
 | 
    GameWorld.Log("¿ç·þÕ½³¡½áË㣡 zoneID=%s,funcLineID=%s,winnerFaction=%s" % (zoneID, funcLineID, winnerFaction), fbPropertyID)  
 | 
      
 | 
    refreshCrossBattlefield(tick, False) # ½áËãǰǿˢһ´Î  
 | 
    NotifyBattlefieldHelp(True)  
 | 
      
 | 
    #awardOnlineTimes = IpyGameDataPY.GetFuncCfg("CrossBattlefieldAward", 1) # ½áËã½±ÀøÐè²ÎÓë»î¶¯Ê±³¤£¬ÃëÖÓ  
 | 
    winnerOrderAwardDict = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldAward", 2, {})  
 | 
    winnerOrderIntAwardDict = {int(k):v for k, v in winnerOrderAwardDict.items()}  
 | 
    syncRankCount = max(winnerOrderIntAwardDict) if winnerOrderIntAwardDict else 20  
 | 
      
 | 
    worldObj = GetBattleWorld()  
 | 
    leaveTime = GetBFStepTime()[Time_Leave] * 1000  
 | 
    copyMapMgr = GameWorld.GetMapCopyPlayerManager()  
 | 
      
 | 
    superItemPlayerIDList = []  
 | 
    superWeight = []  
 | 
    for index in xrange(copyMapMgr.GetPlayerCount()):  
 | 
        curPlayer = copyMapMgr.GetPlayerByIndex(index)  
 | 
        playerID = curPlayer.GetPlayerID()  
 | 
        if not playerID:  
 | 
            continue  
 | 
        battleObj = GetBattlePlayerObj(playerID)  
 | 
        if not battleObj.superItemContribution:  
 | 
            continue  
 | 
        superWeight.append([battleObj.superItemContribution, playerID])  
 | 
    # ÕâÊÇ×îÖÕ½áËã¶îÍâÔÙ¿ªÒ»´ÎµÄ´ó½±£¬½öÏÞ½áËãʱÔÚÏßµÄËùÓÐÍæ¼Ò  
 | 
    finalSuperItemPlayerName = ""  
 | 
    finalSuperItemPlayerID = GameWorld.GetResultByWeightList(superWeight, 0)  
 | 
    GameWorld.Log("×îÖÕ½áËã¶îÍâËæ»ú´ó½±ÔÚÏßÍæ¼Ò! superItemInfo=%s,finalSuperItemPlayerID=%s,superWeight=%s"   
 | 
                  % (worldObj.superItemInfo, finalSuperItemPlayerID, superWeight), fbPropertyID)  
 | 
    if finalSuperItemPlayerID:  
 | 
        superPlayerObj = GetBattlePlayerObj(finalSuperItemPlayerID)  
 | 
        superPlayerObj.superItemAwardCnt += 1  
 | 
        finalSuperItemPlayerName = superPlayerObj.name  
 | 
        superItemPlayerIDList.append(finalSuperItemPlayerID)  
 | 
          
 | 
    hmNum = worldObj.hmNum  
 | 
    hmCallTeamInfo = PyGameData.g_crossBattlefieldCallTeamInfo.get(zoneID, {})  
 | 
    callTeamInfo = hmCallTeamInfo.get(hmNum, {})  
 | 
    allCallPlayerIDList = []  
 | 
    for callTeam in callTeamInfo.values():  
 | 
        allCallPlayerIDList.extend(callTeam["callPlayerIDList"])  
 | 
    GameWorld.Log("zoneID=%s,hmNum=%s,allCallPlayerIDList=%s" % (zoneID, hmNum, allCallPlayerIDList), fbPropertyID)  
 | 
      
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    drDict = {"mapID":GameWorld.GetMap().GetMapID(), "realMapID":gameWorld.GetRealMapID(), "copyMapID":gameWorld.GetCopyMapID(),  
 | 
              "zoneID":zoneID, "funcLineID":funcLineID, "fbPropertyID":fbPropertyID, "hmNum":hmNum,  
 | 
              "superItemInfo":worldObj.superItemInfo, "finalSuperItemPlayerID":finalSuperItemPlayerID,  
 | 
              "crystalFactionInfo":worldObj.crystalFactionInfo, "callTeamInfo":callTeamInfo,  
 | 
              "winnerFaction":winnerFaction, "fightTimeTotal":(int(time.time()) - worldObj.startTime)}  
 | 
    factionInfoList = []  
 | 
    for faction in [ShareDefine.CampType_Justice, ShareDefine.CampType_Evil]:  
 | 
        factionObj = GetBattleFactionObj(faction)  
 | 
        rankPlayerList = []  
 | 
        for battleObj in factionObj.battlePlayerSortList[:syncRankCount]:  
 | 
            rankPlayerList.append({"name":battleObj.name, "job":battleObj.job, "score":battleObj.score,  
 | 
                                   "killCount":battleObj.killCount, "crystalCollCnt":battleObj.crystalCollCnt})  
 | 
              
 | 
        callPlayerName = ""  
 | 
        for callPlayerID, callFaction in worldObj.callOpenPlayerInfo.items():  
 | 
            if callFaction == faction:  
 | 
                callBattleObj = GetBattlePlayerObj(callPlayerID)  
 | 
                callPlayerName = callBattleObj.name  
 | 
                break  
 | 
              
 | 
        factionInfoList.append({"faction":faction, "rankPlayerList":rankPlayerList, "callPlayerName":callPlayerName,  
 | 
                                "superItemPlayerName":factionObj.superItemPlayerName})  
 | 
          
 | 
    costTime = int((tick - GameWorld.GetGameFB().GetFBStepTick()) / 1000.0)  
 | 
    overDict = {"winnerFaction":winnerFaction, "factionInfoList":factionInfoList, FBCommon.Over_costTime:costTime,  
 | 
                "finalSuperItemPlayerName":finalSuperItemPlayerName}  
 | 
      
 | 
    scoreKingID, scoreKingName = 0, "" # ±¾³¡»ý·ÖÍõ£º »ñʤ·½ÔÚÏßµÚÒ»Ãû»ý·Ö  
 | 
    battlePlayerList = []  
 | 
    for faction in [ShareDefine.CampType_Justice, ShareDefine.CampType_Evil]:  
 | 
        factionObj = GetBattleFactionObj(faction)  
 | 
        factionScore = factionObj.score  
 | 
        isWinner = 1 if faction == winnerFaction else 0  
 | 
        scoreKingIDList = factionObj.scoreKingIDList  
 | 
        factionSuperItemPlayerID = factionObj.superItemPlayerID  
 | 
        GameWorld.Log("½áËãÕóÓª£¡ faction=%s,factionScore=%s,isWinner=%s,playerCount=%s,onlineFightPowerTotal=%s,onlinePlayerIDList=%s,scoreKingIDList=%s,factionSuperItemPlayerID=%s"   
 | 
                      % (faction, factionScore, isWinner, len(factionObj.battlePlayerSortList), factionObj.onlineFightPowerTotal, factionObj.onlinePlayerIDList, scoreKingIDList, factionSuperItemPlayerID), fbPropertyID)  
 | 
        if factionSuperItemPlayerID:  
 | 
            superItemPlayerIDList.append(factionSuperItemPlayerID)  
 | 
        if isWinner and scoreKingIDList:  
 | 
            scoreKingID = scoreKingIDList[0]  
 | 
            scoreKingObj = GetBattlePlayerObj(scoreKingID)  
 | 
            scoreKingName = scoreKingObj.name  
 | 
              
 | 
        drPlayerList = []  
 | 
        for rank, battleObj in enumerate(factionObj.battlePlayerSortList, 1):  
 | 
            playerID = battleObj.playerID  
 | 
            score = battleObj.score  
 | 
            job = battleObj.job  
 | 
            realmLV = battleObj.realmLV  
 | 
            name = battleObj.name  
 | 
            highScoreToday = battleObj.highScoreToday  
 | 
            highScoreWeekTotal = battleObj.highScoreWeekTotal  
 | 
            enterCountWeek = battleObj.enterCountWeek  
 | 
            onlineTimes = battleObj.onlineTimes / 1000  
 | 
              
 | 
            GameWorld.Log("     rank=%s,playerID=%s,score=%s,fightPower=%s,onlineTimes=%s,accID=%s"   
 | 
                          % (rank, playerID, score, battleObj.fightPower, onlineTimes, battleObj.accID), fbPropertyID)  
 | 
              
 | 
            #·þÎñ¶ËÔݲ»×ö²ÎÓëʱ³¤½±ÀøÏÞÖÆ  
 | 
            #if onlineTimes < awardOnlineTimes:  
 | 
            #    GameWorld.Log("    »î¶¯Ê±³¤²»×㣬²»¸ø½±Àø! faction=%s,playerID=%s,isWinner=%s" % (faction, playerID, isWinner), fbPropertyID)  
 | 
            #    continue  
 | 
              
 | 
            isCallOpen = 1 if playerID in worldObj.callOpenPlayerInfo else 0 # ÊÇ·ñÕÙ¼¯½øÈëµÄ  
 | 
            isCalled = 1 if (playerID in allCallPlayerIDList and not isCallOpen) else 0 # ÊÇ·ñ±»ÕÙ¼¯µÄ  
 | 
            teamID = PlayerFuncTeam.GetPlayerTeamID(playerID, ChConfig.Def_FBMapID_CrossBattlefield)  
 | 
            killCnt, ckillCntInfo, killBossCnt, killScoreKing, killGuardCnt, auraScore, superItemAwardCnt, \  
 | 
                factionBuffCollCnt, personBuffCollCnt, crystalCollCnt, wallCollCnt = \  
 | 
                battleObj.killCount, battleObj.ckillCntInfo, battleObj.killBossCnt, battleObj.killScoreKing, battleObj.killGuardCnt, \  
 | 
                battleObj.auraScore, battleObj.superItemAwardCnt, battleObj.factionBuffCollCnt, battleObj.personBuffCollCnt, \  
 | 
                battleObj.crystalCollCnt, battleObj.wallCollCnt  
 | 
                  
 | 
            playerInfo = [playerID, job, realmLV, name,  
 | 
                          isWinner, faction, rank, score, highScoreToday, highScoreWeekTotal, enterCountWeek, teamID,  
 | 
                          isCallOpen, isCalled, killCnt, ckillCntInfo, killBossCnt, killScoreKing, killGuardCnt, auraScore, superItemAwardCnt,  
 | 
                          factionBuffCollCnt, personBuffCollCnt, crystalCollCnt, wallCollCnt]  
 | 
            battlePlayerList.append(playerInfo)  
 | 
              
 | 
            drPlayerList.append({"playerID":playerID, "accID":battleObj.accID, "fightPower":battleObj.fightPower,  
 | 
                                 "score":score, "auraScore":auraScore, "wallCollCnt":wallCollCnt, "teamID":teamID,  
 | 
                                 "superItemAwardCnt":superItemAwardCnt, "superItemContribution":battleObj.superItemContribution})  
 | 
              
 | 
            player = copyMapMgr.FindPlayerByID(playerID)  
 | 
            if not player:  
 | 
                continue  
 | 
            player.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTime, True)  
 | 
              
 | 
            lineID = 0  
 | 
            overDict.update({FBCommon.Over_rank:rank, "score":score, "highScoreToday":highScoreToday, "onlineTimes":onlineTimes, "faction":faction})  
 | 
            FBCommon.NotifyFBOver(player, ChConfig.Def_FBMapID_CrossBattlefield, lineID, isWinner, overDict)  
 | 
              
 | 
        drFactionInfo = {"faction":faction, "score":factionObj.score, "hurtBossPlayerDict":factionObj.hurtBossPlayerDict,  
 | 
                         "superItemProgress":factionObj.superItemProgress, "superItemPlayerID":factionObj.superItemPlayerID,  
 | 
                         "drPlayerList":drPlayerList}  
 | 
        drDict["faction_%s" % faction] = drFactionInfo  
 | 
          
 | 
    GameWorld.Log("±¾³¡×îÖÕ½áËã»ý·ÖÍõ: scoreKingID=%s" % scoreKingID, fbPropertyID)  
 | 
              
 | 
    # Í¬²½GameServer ±ÈÈü½á¹û  
 | 
    superItemInfo = worldObj.superItemInfo  
 | 
    msgInfo = str([hmNum, fbPropertyID, zoneID, funcLineID, winnerFaction, superItemInfo, finalSuperItemPlayerID, finalSuperItemPlayerName, superItemPlayerIDList, scoreKingID, scoreKingName, battlePlayerList])  
 | 
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "CrossBattlefieldOver", msgInfo, len(msgInfo))  
 | 
      
 | 
    # ¼Ç¼Á÷Ïò  
 | 
    DataRecordPack.SendEventPack("CrossBattlefieldOver", drDict)  
 | 
      
 | 
    FBCommon.SetFBStep(FB_Step_LeaveTime, tick)  
 | 
      
 | 
    # Í¬²½¸Ã·ÖÏß½áËãÁË£¬·ÀÖ¹ÔÙ·ÖÁ÷µ½¸Ã·ÖÏß  
 | 
    GameWorldProcess.GameServer_DynamicLineMapStateChange(gameWorld, 3)  
 | 
    return  
 | 
  
 | 
##ÊÇ·ñ¿ÉÒÔ¶áÆì  
 | 
def OnCanCollect(curPlayer, curNPC, tick):  
 | 
    gameFB = GameWorld.GetGameFB()  
 | 
    fbStep = gameFB.GetFBStep()  
 | 
      
 | 
    # ·ÇÕ½¶·½×¶Î²»¿É²É¼¯  
 | 
    if fbStep != FB_Step_Fighting:  
 | 
        PlayerControl.NotifyCode(curPlayer, "NotFightStepCanNotCollect")  
 | 
        return False  
 | 
      
 | 
    npcID = curNPC.GetNPCID()  
 | 
    GameWorld.DebugLog("OnCanCollect npcID=%s" % npcID, curPlayer.GetPlayerID())  
 | 
    if npcID in GetCrystalNPCIDList():  
 | 
        # ÒÑ»ñµÃÕ½ÆìµÄÕ½Ã˲»¿É²É¼¯  
 | 
        worldObj = GetBattleWorld()  
 | 
        ownerFaction = worldObj.crystalFactionInfo.get(npcID)  
 | 
        faction = curPlayer.GetFaction()  
 | 
        if ownerFaction == faction:  
 | 
            PlayerControl.NotifyCode(curPlayer, "CrossBattlefieldCollectOwnerLimit")  
 | 
            return False  
 | 
          
 | 
    # »ý·Öǽ  
 | 
    elif npcID == IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreWall", 1):  
 | 
        worldObj = GetBattleWorld()  
 | 
        collectCD = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreWall", 2) * 1000  
 | 
        passTick = tick - worldObj.lastWallCollOKTick  
 | 
        #GameWorld.DebugLog("lastWallCollOKTick=%s,tick=%s,passTick=%s,collectCD=%s" % (worldObj.lastWallCollOKTick, tick, passTick, collectCD))  
 | 
        if passTick <= collectCD:  
 | 
            waitSeconds = int(math.ceil((collectCD - passTick) / 1000.0))  
 | 
            PlayerControl.NotifyCode(curPlayer, "CrossBattlefieldWallTimeLimit", [waitSeconds])  
 | 
            return False  
 | 
          
 | 
    return True  
 | 
  
 | 
## ¿ªÊ¼²É¼¯  
 | 
def OnBeginCollect(curPlayer, curNPC):  
 | 
    npcID = curNPC.GetNPCID()  
 | 
    if npcID in GetCrystalNPCIDList():  
 | 
        worldObj = GetBattleWorld()  
 | 
        if worldObj.updCrystalAtkedHelp(npcID, 1):  
 | 
            NotifyBattlefieldHelp()  
 | 
    return  
 | 
  
 | 
## Í˳ö²É¼¯  
 | 
def OnExitCollect(curPlayer, curNPC):  
 | 
    if not curNPC or not hasattr(curNPC, "GetNPCID"):  
 | 
        return  
 | 
    npcID = curNPC.GetNPCID()  
 | 
    if npcID in GetCrystalNPCIDList():  
 | 
        worldObj = GetBattleWorld()  
 | 
        if worldObj.updCrystalAtkedHelp(npcID, -1):  
 | 
            NotifyBattlefieldHelp()  
 | 
    return  
 | 
  
 | 
def DoDropPersonBuffOnKilled(atkObj, defPlayer, tick):  
 | 
    dropPersonBuffNPCList = IpyGameDataPY.GetFuncEvalCfg("CrossBattlefieldDropPersonBuff", 1)  
 | 
    if not dropPersonBuffNPCList:  
 | 
        return  
 | 
      
 | 
    atkObjType = atkObj.GetGameObjType()  
 | 
    playerID = atkObj.GetPlayerID() if atkObjType == IPY_GameWorld.gotPlayer else 0  
 | 
      
 | 
    dropNPCIDList = []  
 | 
    for npcID in dropPersonBuffNPCList:  
 | 
        npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)  
 | 
        if not npcData:  
 | 
            continue  
 | 
        buffID = npcData.GetSkill1()  
 | 
        if not buffID:  
 | 
            continue  
 | 
        findBuff = SkillCommon.FindBuffByID(defPlayer, buffID)[0]  
 | 
        if not findBuff:  
 | 
            continue  
 | 
          
 | 
        if findBuff.GetLayer():  
 | 
            dropNPCIDList.extend([npcID] * findBuff.GetLayer())  
 | 
        else:  
 | 
            dropNPCIDList.append(npcID)  
 | 
              
 | 
    count = 0  
 | 
    defPosX, defPosY = defPlayer.GetPosX(), defPlayer.GetPosY()  
 | 
    while dropNPCIDList and count < 100:  
 | 
        count += 1  
 | 
        dropX, dropY = GameMap.GetNearbyPosByDis(defPosX, defPosY, 5)  
 | 
        if not dropX:  
 | 
            continue  
 | 
        npcID = dropNPCIDList.pop(0)  
 | 
        NPCCommon.SummonMapNpc(npcID, dropX, dropY, playerID=playerID)  
 | 
          
 | 
    return  
 | 
  
 | 
def OnCanMoveTouchNPC(curPlayer, curNPC, tick):  
 | 
    ## ¼ì²é¿É·ñ´¥ÅöNPCÂß¼  
 | 
    summonPlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID)  
 | 
    if not summonPlayerID:  
 | 
        return True  
 | 
    if summonPlayerID == curPlayer.GetPlayerID():  
 | 
        #GameWorld.DebugLog("OnCanMoveTouchNPC summonPlayerID=%s,owner=True" % summonPlayerID, curNPC.GetID())  
 | 
        return True  
 | 
    protectTick = IpyGameDataPY.GetFuncCfg("CrossBattlefieldDropPersonBuff", 2) * 1000  
 | 
    passTick = tick - curNPC.GetActionTick()  
 | 
    if passTick < protectTick:  
 | 
        #GameWorld.DebugLog("OnCanMoveTouchNPC in protect! passTick=%s < protectTick=%s" % (passTick, protectTick), curNPC.GetID())  
 | 
        return False  
 | 
    return True  
 | 
  
 | 
def OnMoveTouchNPC(curPlayer, curNPC, tick):  
 | 
    ## ´¥ÅöNPC´¦ÀíÂß¼  
 | 
    npcID = curNPC.GetNPCID()  
 | 
    GameWorld.DebugLog("OnMoveTouchNPC npcID=%s" % npcID, curPlayer.GetPlayerID())  
 | 
    # ¸öÈËbuff  
 | 
    if npcID in GetPersonBuffIDList():  
 | 
        __OnCollectOK_PersonBuff(curPlayer, curNPC, tick)  
 | 
    return  
 | 
  
 | 
##Íæ¼ÒÊÕ¼¯³É¹¦(Ëþ, Æì)  
 | 
def OnCollectOK(curPlayer, npcID, tick):  
 | 
    #GameWorld.DebugLog("OnCollectOK npcID=%s" % npcID, curPlayer.GetPlayerID())  
 | 
    tagObj = curPlayer.GetActionObj()  
 | 
    if not tagObj:  
 | 
        return  
 | 
    if tagObj.GetGameObjType() != IPY_GameWorld.gotNPC:  
 | 
        return  
 | 
      
 | 
    curNPC = GameWorld.GetNPCManager().GetNPCByIndex(tagObj.GetIndex())  
 | 
    AICommon.ClearPlayerPreparing(curNPC, curPlayer)  
 | 
    npcID = curNPC.GetNPCID()  
 | 
      
 | 
    # Ë®¾§  
 | 
    if npcID in GetCrystalNPCIDList():  
 | 
        __OnCollectOK_Crystal(curPlayer, curNPC, tick)  
 | 
          
 | 
    # ¸öÈËbuff  
 | 
    #elif npcID in GetPersonBuffIDList():  
 | 
    #    __OnCollectOK_PersonBuff(curPlayer, curNPC, tick)  
 | 
          
 | 
    # ÕóÓªbuff  
 | 
    elif npcID in GetFactionBuffIDList():  
 | 
        __OnCollectOK_FactionBuff(curPlayer, curNPC, tick)  
 | 
          
 | 
    # »ý·Öǽ  
 | 
    elif npcID == IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreWall", 1):  
 | 
        __OnCollectOK_EventWall(curPlayer, curNPC, tick)  
 | 
          
 | 
    return  
 | 
  
 | 
def __OnCollectOK_Crystal(curPlayer, curNPC, tick):  
 | 
    ## ²É¼¯Ë®¾§×ÊÔ´½¨Öþ  
 | 
    objID = curNPC.GetID()  
 | 
    npcID = curNPC.GetNPCID()  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    if not battleObj:  
 | 
        return  
 | 
    faction = battleObj.faction  
 | 
    worldObj = GetBattleWorld()  
 | 
    lastOwnerFaction = worldObj.crystalFactionInfo.get(npcID)  
 | 
      
 | 
    if lastOwnerFaction == faction:  
 | 
        return  
 | 
    # ¸üйéÊôÐÅÏ¢  
 | 
    worldObj.crystalFactionInfo[npcID] = faction  
 | 
    worldObj.crystalAwardTick[npcID] = tick  
 | 
    worldObj.worldHelpDict["crystalFactionInfo"] = worldObj.crystalFactionInfo  
 | 
      
 | 
    battleObj.crystalCollCnt += 1  
 | 
    GameWorld.Log("Íæ¼ÒÕ¼ÁìË®¾§: objID=%s,npcID=%s,lastOwnerFaction=%s,playerID=%s,faction=%s"   
 | 
                  % (objID, npcID, lastOwnerFaction, playerID, faction), fbPropertyID)  
 | 
    addScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldCrystal", 2)  
 | 
    battleObj.addPlayerScore(curPlayer, addScore, ScoreType_CollectCrystal)  
 | 
      
 | 
    # Õ¼Áì¹ã²¥¸ø×Ô¼ºÕóÓª¡¢¶Ô·½ÕóÓª ²»Í¬ÄÚÈÝ  
 | 
    PlayerControl.FBFactionNotify(curPlayer.GetFaction(), "CrossBattlefieldOccupiedSelf", [battleObj.name],  
 | 
                                  "CrossBattlefieldOccupiedOther", [battleObj.name])  
 | 
      
 | 
    NotifyBattlefieldHelp()  
 | 
    return  
 | 
  
 | 
def __OnCollectOK_PersonBuff(curPlayer, curNPC, tick):  
 | 
    npcID = curNPC.GetNPCID()  
 | 
    worldObj = GetBattleWorld()  
 | 
    if worldObj.personBuffCount > 0:  
 | 
        worldObj.personBuffCount = worldObj.personBuffCount - 1  
 | 
    if not worldObj.personBuffCalcTick:  
 | 
        worldObj.personBuffCalcTick = tick  
 | 
          
 | 
    # Ôö¼ÓbuffЧ¹û  
 | 
    addSkill = curNPC.GetSkillManager().GetSkillByIndex(0)  
 | 
    addSkillID = addSkill.GetSkillID() if addSkill else 0  
 | 
      
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    GameWorld.DebugLog("²É¼¯¸öÈËbuff: npcID=%s,addSkillID=%s,personBuffCount=%s"   
 | 
                       % (npcID, addSkillID, worldObj.personBuffCount), playerID)  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    battleObj.personBuffCollCnt += 1  
 | 
      
 | 
    if addSkill:  
 | 
        SkillShell.__DoLogic_AddBuff(curPlayer, curPlayer, addSkill, False, tick, addForce=True)  
 | 
          
 | 
    # ¹¥»÷·x±¶                            30908107  
 | 
    # »÷É±Íæ¼Ò»ý·Ö·x±¶        30908108  
 | 
    # Î޵Р                                       30908109  
 | 
    if npcID == 30908108:  
 | 
        buffSkill = GameWorld.GetGameData().GetSkillBySkillID(addSkillID)  
 | 
        if buffSkill:  
 | 
            buffTime = buffSkill.GetLastTime()  
 | 
            battleObj.killPlayerAddScoreTimes = buffSkill.GetEffect(0).GetEffectValue(0)  
 | 
            battleObj.killPlayerScoreAwardEndTick = tick + buffTime  
 | 
            GameWorld.DebugLog("»ñµÃ»÷É±Íæ¼Ò¶à±¶»ý·Ö¸£Àû: killPlayerAddScoreTimes=%s,buffTime=%s"   
 | 
                               % (battleObj.killPlayerAddScoreTimes, buffTime), playerID)  
 | 
              
 | 
    NPCCommon.SetDeadEx(curNPC)  
 | 
    return  
 | 
  
 | 
def __OnCollectOK_FactionBuff(curPlayer, curNPC, tick):  
 | 
    npcID = curNPC.GetNPCID()  
 | 
    worldObj = GetBattleWorld()  
 | 
    if worldObj.factionBuffNPCInfo and npcID == worldObj.factionBuffNPCInfo[0]:  
 | 
        worldObj.factionBuffNPCInfo = []  
 | 
        worldObj.worldHelpDict["factionBuffNPCInfo"] = []  
 | 
    worldObj.factionBuffCalcTick = tick  
 | 
      
 | 
    # Ôö¼ÓbuffЧ¹û  
 | 
    addSkill = curNPC.GetSkillManager().GetSkillByIndex(0)  
 | 
    addSkillID = addSkill.GetSkillID() if addSkill else 0  
 | 
    if not addSkillID:  
 | 
        return  
 | 
    buffSkill = GameWorld.GetGameData().GetSkillBySkillID(addSkillID)  
 | 
    if not buffSkill:  
 | 
        return  
 | 
      
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
      
 | 
    addScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldFactionBuff", 4)  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    battleObj.factionBuffCollCnt += 1  
 | 
    battleObj.addPlayerScore(curPlayer, addScore, ScoreType_CollectFactionBuff)  
 | 
      
 | 
    faction = battleObj.faction  
 | 
    tagFaction = ShareDefine.CampType_Justice if faction == ShareDefine.CampType_Evil else ShareDefine.CampType_Evil  
 | 
    factionObj = GetBattleFactionObj(faction)  
 | 
      
 | 
    # ºÚÒ¹½µÁÙ: µÐ¶ÔÍæ¼ÒÿxÃëµôѪy%£¬³ÖÐøxxÃë                        30908110  
 | 
    # ÌìµÀÍþѹ: µÐ¶ÔÍæ¼Ò¹¥»÷½µµÍx%£¬³ÖÐøxxÃë                           30908111  
 | 
    # ÆÕ¶ÈÖÚÉú: ÎÒ·½½¨Öþ»ñÈ¡×ÊÔ´ËÙ¶ÈÌáÉýx%£¬³ÖÐøxxÃë       30908112  
 | 
    # ¶´Ì츣µØ: ÎÒ·½Íæ¼ÒÿxÃë»ØÑªy%£¬³ÖÐøxxÃë                        30908113  
 | 
      
 | 
    gainBuffFaction = faction # »ñµÃbuffµÄÕóÓª  
 | 
    if npcID in [30908110, 30908111]:  
 | 
        gainBuffFaction = tagFaction  
 | 
          
 | 
    GameWorld.DebugLog("²É¼¯ÕóÓªbuff: npcID=%s,addSkillID=%s,faction=%s,tagFaction=%s,gainBuffFaction=%s"   
 | 
                       % (npcID, addSkillID, faction, tagFaction, gainBuffFaction), playerID)  
 | 
      
 | 
    paramList = [faction, battleObj.name, npcID, gainBuffFaction]  
 | 
    PlayerControl.FBNotify("CrossBattlefieldBuffOK_%s" % npcID, paramList)  
 | 
          
 | 
    gainBuffFactionObj = GetBattleFactionObj(gainBuffFaction)  
 | 
      
 | 
    doAddFactionPlayerBuff(curPlayer, gainBuffFactionObj, buffSkill, tick)  
 | 
      
 | 
    buffTime = buffSkill.GetLastTime()  
 | 
    endTime = int(time.time()) + int(buffTime / 1000)  
 | 
    gainBuffFactionObj.factionBuffInfo = [addSkillID, endTime]  
 | 
    gainBuffFactionObj.factionHelpDict["factionBuffInfo"] = gainBuffFactionObj.factionBuffInfo  
 | 
      
 | 
    if npcID == 30908112:  
 | 
        gainBuffFactionObj.crystalScorePlusRate = buffSkill.GetEffect(0).GetEffectValue(0)  
 | 
        gainBuffFactionObj.crystalScorePlusEndTick = tick + buffTime  
 | 
          
 | 
    # ²É¼¯ÕóÓªbuffʱÿ¸öÔÚÏßÕóÓªÍæ¼ÒÔö¼Ó¸öÈË¿ª½±¹±Ï×  
 | 
    addContribution = IpyGameDataPY.GetFuncCfg("CrossBattlefieldAwardSuper2", 5)  
 | 
    for battleObj in factionObj.factionPlayerDict.values():  
 | 
        if battleObj.playerID in factionObj.onlinePlayerIDList:  
 | 
            battleObj.addSuperItemContribution(addContribution)  
 | 
              
 | 
    NotifyBattlefieldHelp()  
 | 
    NPCCommon.SetDeadEx(curNPC)  
 | 
    return  
 | 
  
 | 
def doAddFactionPlayerBuff(curPlayer, factionObj, buffSkill, tick):  
 | 
    ## ¸øÄ³¸öÕóÓªÔÚÏßÍæ¼ÒÌí¼Óbuff  
 | 
    copyMapMgr = GameWorld.GetMapCopyPlayerManager()  
 | 
    for playerID in factionObj.onlinePlayerIDList:  
 | 
        player = copyMapMgr.FindPlayerByID(playerID)  
 | 
        if not player:  
 | 
            continue  
 | 
        SkillShell.__DoLogic_AddBuff(curPlayer, player, buffSkill, False, tick, addForce=True)  
 | 
          
 | 
    for robotID in factionObj.robotObjIDList:  
 | 
        robotNPC = GameWorld.GetObj(robotID, IPY_GameWorld.gotNPC)  
 | 
        if not robotNPC:  
 | 
            continue  
 | 
        SkillShell.__DoLogic_AddBuff(curPlayer, robotNPC, buffSkill, False, tick, addForce=True)  
 | 
          
 | 
    return  
 | 
  
 | 
def __OnCollectOK_EventWall(curPlayer, curNPC, tick):  
 | 
    ## ²É¼¯»ý·Öǽ  
 | 
    npcID = curNPC.GetNPCID()  
 | 
    ChNPC.OnCollectEnd(curPlayer, curNPC)  
 | 
    worldObj = GetBattleWorld()  
 | 
    worldObj.lastWallCollOKTick = tick  
 | 
    worldObj.eventNPCHP = GameObj.GetHP(curNPC)  
 | 
      
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    faction = curPlayer.GetFaction()  
 | 
      
 | 
    GameWorld.Log("Íæ¼Ò²É¼¯»ý·Öǽ: npcID=%s,faction=%s,eventNPCHP=%s,tick=%s" % (npcID, faction, worldObj.eventNPCHP, tick), playerID)  
 | 
    addPlayerScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreWall", 4)  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    battleObj.wallCollCnt += 1  
 | 
    battleObj.addPlayerScore(curPlayer, addPlayerScore, ScoreType_Wall)  
 | 
      
 | 
    factionObj = GetBattleFactionObj(faction)  
 | 
    addValue = IpyGameDataPY.GetFuncCfg("CrossBattlefieldScoreWall", 3)  
 | 
    factionObj.addFactionScore(addValue)  
 | 
    PlayerControl.FBNotify("CrossBattlefieldWallCollectOK", [faction, curPlayer.GetPlayerName(), npcID, addValue])  
 | 
    if worldObj.eventNPCHP <= 0:  
 | 
        worldObj.setEventEnd(tick)  
 | 
    else:  
 | 
        worldObj.worldHelpDict["eventNPCHP"] = worldObj.eventNPCHP  
 | 
    NotifyBattlefieldHelp()  
 | 
    return  
 | 
  
 | 
def DoFBOnNPCKill_Player(curNPC, curPlayer, tick):  
 | 
    ## Ö´Ðи±±¾NPC»÷É±Íæ¼Ò  
 | 
      
 | 
    npcID = curNPC.GetNPCID()  
 | 
    npcFaction = NPCCommon.GetFaction(curNPC)  
 | 
    if npcFaction:  
 | 
        if npcID in GetGuardNPCIDList():  
 | 
            __OnGuardKillOtherPlayer(curNPC, curPlayer, tick)  
 | 
        elif npcID in GetRobotNPCIDList():  
 | 
            onBattleObjKillOtherBattleObj(curNPC, curPlayer, tick)  
 | 
              
 | 
    else:  
 | 
        pass  
 | 
      
 | 
    return  
 | 
  
 | 
def DoFB_Player_KillNPC(curPlayer, curNPC, tick):  
 | 
    ## Ö´Ðи±±¾É±¹ÖÂß¼  
 | 
    npcID = curNPC.GetNPCID()  
 | 
    npcFaction = NPCCommon.GetFaction(curNPC)  
 | 
    GameWorld.DebugLog("DoFB_Player_KillNPC %s kill %s" % (curPlayer.GetID(), npcID))  
 | 
    if npcFaction:  
 | 
        if npcID in GetGuardNPCIDList():  
 | 
            __OnPlayerKillOtherFactionGurad(curPlayer, curNPC, tick)  
 | 
        elif npcID in GetRobotNPCIDList():  
 | 
            onBattleObjKillOtherBattleObj(curPlayer, curNPC, tick)  
 | 
              
 | 
    # boss  
 | 
    elif npcID == IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 1):  
 | 
        __OnPlayerKillEventBoss(curPlayer, curNPC, tick)  
 | 
          
 | 
    return  
 | 
  
 | 
def DoFB_Npc_KillNPC(attacker, curNPC, tick):  
 | 
    if attacker.GetType() == ChConfig.ntRobot and curNPC.GetType() == ChConfig.ntRobot:  
 | 
        onBattleObjKillOtherBattleObj(attacker, curNPC, tick)  
 | 
    return  
 | 
  
 | 
def __OnPlayerKillOtherFactionGurad(curPlayer, curNPC, tick):  
 | 
    ## Íæ¼Ò»÷ɱÆäËûÕóÓªÊØÎÀ  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    guardFaction = NPCCommon.GetFaction(curNPC)  
 | 
    tagFaction = curPlayer.GetFaction()  
 | 
    if guardFaction == tagFaction:  
 | 
        return  
 | 
    guardKillGuardScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldGuard2", 1)  
 | 
    battleObj = GetBattlePlayerObj(playerID)  
 | 
    battleObj.killGuardCnt += 1  
 | 
    battleObj.addPlayerScore(curPlayer, guardKillGuardScore, ScoreType_KillGuard)  
 | 
    PlayerControl.FBFactionNotify(curPlayer.GetFaction(), "CrossBattlefieldKillGuardSelf", [battleObj.name],  
 | 
                                  "CrossBattlefieldKillGuardOther", [battleObj.name])  
 | 
      
 | 
    factionObj = GetBattleFactionObj(battleObj.faction)  
 | 
    killGuardScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldGuard", 3)  
 | 
    factionObj.addFactionScore(killGuardScore)  
 | 
    return  
 | 
  
 | 
def __OnGuardKillOtherPlayer(curNPC, tagPlayer, tick):  
 | 
    ## ÊØÎÀ»÷É±Íæ¼Ò  
 | 
      
 | 
    npcID = curNPC.GetNPCID()  
 | 
    guardFaction = NPCCommon.GetFaction(curNPC)  
 | 
    tagFaction = tagPlayer.GetFaction()  
 | 
    tagPlayerID = tagPlayer.GetPlayerID()  
 | 
    ownerPlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID)  
 | 
    if not ownerPlayerID or guardFaction == tagFaction:  
 | 
        return  
 | 
      
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    copyMapMgr = GameWorld.GetMapCopyPlayerManager()  
 | 
    ownerPlayer = copyMapMgr.FindPlayerByID(ownerPlayerID)  
 | 
      
 | 
    guardKillPlayerScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldGuard", 4)  
 | 
    GameWorld.DebugLog("ÊØÎÀ»÷É±Íæ¼Ò: npcID=%s,guardFaction=%s,ownerPlayerID=%s,tagPlayerID=%s"   
 | 
                       % (npcID, guardFaction, ownerPlayerID, tagPlayerID), fbPropertyID)  
 | 
    battleObj = GetBattlePlayerObj(ownerPlayerID)  
 | 
    battleObj.addKillCount(1)  
 | 
    battleObj.addPlayerScore(ownerPlayer, guardKillPlayerScore, ScoreType_GuardKillPlayer)  
 | 
    if ownerPlayer:  
 | 
        NotifyBattlefieldHelp(False, ownerPlayer)  
 | 
    return  
 | 
  
 | 
def __OnPlayerKillEventBoss(curPlayer, curNPC, tick):  
 | 
    ## Íæ¼Ò»÷ɱʼþBoss  
 | 
      
 | 
    npcID = curNPC.GetNPCID()  
 | 
    killerPlayerID = curPlayer.GetPlayerID()  
 | 
    killerFaction = curPlayer.GetFaction()  
 | 
    fbPropertyID = GameWorld.GetGameWorld().GetPropertyID()  
 | 
    jFactionObj = GetBattleFactionObj(ShareDefine.CampType_Justice)  
 | 
    eFactionObj = GetBattleFactionObj(ShareDefine.CampType_Evil)  
 | 
    GameWorld.Log("»÷ɱÌìµÀÖ®ÑÛBoss: npcID=%s,killerPlayerID=%s,killerFaction=%s"   
 | 
                  % (npcID, killerPlayerID, killerFaction), fbPropertyID)  
 | 
    GameWorld.Log("    faction=%s,hurtBossValue=%s" % (jFactionObj.faction, jFactionObj.hurtBossValue), fbPropertyID)  
 | 
    GameWorld.Log("    faction=%s,hurtBossValue=%s" % (eFactionObj.faction, eFactionObj.hurtBossValue), fbPropertyID)  
 | 
    ownerFaction = None  
 | 
    if jFactionObj.hurtBossValue > eFactionObj.hurtBossValue:  
 | 
        ownerFaction = jFactionObj  
 | 
    elif jFactionObj.hurtBossValue < eFactionObj.hurtBossValue:  
 | 
        ownerFaction = eFactionObj  
 | 
    else:  
 | 
        # É˺¦Ïàͬʱ£¬¹éÊô×îºóÒ»»÷Íæ¼ÒËùÊôÕóÓª  
 | 
        ownerFaction = jFactionObj if killerFaction == jFactionObj.faction else eFactionObj  
 | 
        ownerFaction.hurtBossValue += 100 # Ëæ»ú¹éÊô·½¶îÍâÔö¼ÓÉ˺¦  
 | 
        ownerFaction.factionHelpDict["hurtBossValue"] = ownerFaction.hurtBossValue  
 | 
        GameWorld.Log("    É˺¦Ïàͬ£¬¹éÊô×îºóÒ»»÷Íæ¼ÒÕóÓª! ", fbPropertyID)  
 | 
    GameWorld.Log("    Boss¹éÊôÕóÓª: faction=%s" % ownerFaction.faction, fbPropertyID)  
 | 
    ownerFactionScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 3)      
 | 
    ownerFaction.addFactionScore(ownerFactionScore, False)  
 | 
      
 | 
    hurtPlayerScore = IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 2)  
 | 
    for factionObj in [jFactionObj, eFactionObj]:  
 | 
        for playerID in factionObj.hurtBossPlayerDict.keys():  
 | 
            battleObj = GetBattlePlayerObj(playerID)  
 | 
            if factionObj.faction == ownerFaction.faction:  
 | 
                battleObj.killBossCnt += 1  
 | 
            battleObj.addPlayerScore(curPlayer, hurtPlayerScore, ScoreType_HurtBoss, isCheckVictory=False)  
 | 
              
 | 
    PlayerControl.FBNotify("CrossBattlefieldBossKilled", [npcID, ownerFaction.faction, ownerFactionScore, hurtPlayerScore])  
 | 
      
 | 
    worldObj = GetBattleWorld()  
 | 
    worldObj.setEventEnd(tick)  
 | 
    if not checkBattleOver(tick):  
 | 
        NotifyBattlefieldHelp()  
 | 
    return  
 | 
  
 | 
def GetFBPlayerHurtNPCMultiValue(curPlayer, curNPC):  
 | 
    ## Íæ¼Ò¶ÔNPCÔì³ÉÉ˺¦±¶Öµ£¬Ä¬ÈÏ1  
 | 
      
 | 
    npcID = curNPC.GetNPCID()  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    worldObj = GetBattleWorld()  
 | 
      
 | 
    # ÕÙ¼¯¿ªÆôµÄÍæ¼Ò  ¶Ô BossµÄÉ˺¦±¶Öµ  
 | 
    if (playerID in worldObj.callOpenPlayerInfo or IsSysCallBuyPlayer(playerID)) \  
 | 
        and npcID == IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 1):  
 | 
        return IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 4)  
 | 
      
 | 
    return 1  
 | 
  
 | 
def DoFB_Player_HurtNPC(curPlayer, curNPC, hurtHP):  
 | 
    ## Íæ¼Ò¶ÔNPCÔì³ÉÉ˺¦  
 | 
      
 | 
    npcID = curNPC.GetNPCID()  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
      
 | 
    # Boss  
 | 
    if npcID == IpyGameDataPY.GetFuncCfg("CrossBattlefieldBoss", 1):  
 | 
        worldObj = GetBattleWorld()  
 | 
        worldObj.eventNPCHP = GameObj.GetHP(curNPC)  
 | 
          
 | 
        faction = curPlayer.GetFaction()  
 | 
        factionObj = GetBattleFactionObj(faction)  
 | 
          
 | 
        # ÀÛ¼ÓÉ˺¦  
 | 
        factionObj.hurtBossValue = factionObj.hurtBossValue + hurtHP  
 | 
        factionObj.factionHelpDict["hurtBossValue"] = factionObj.hurtBossValue  
 | 
        factionObj.hurtBossPlayerDict[playerID] = factionObj.hurtBossPlayerDict.get(playerID, 0) + hurtHP  
 | 
        GameWorld.DebugLog("Íæ¼Ò¹¥»÷boss: faction=%s,hurtHP=%s,factionHurtBossValue=%s,playerHurtBossValue=%s,npcHP=%s"   
 | 
                           % (faction, hurtHP, factionObj.hurtBossValue, factionObj.hurtBossPlayerDict[playerID], GameObj.GetHP(curNPC)), playerID)  
 | 
    return  
 | 
  
 | 
## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼ÓÉÍâ²ã¾ö¶¨  
 | 
def CheckCanAttackTagObjInFB(attacker, defender):  
 | 
    gameFB = GameWorld.GetGameFB()  
 | 
    if gameFB.GetFBStep() != FB_Step_Fighting:  
 | 
        return False  
 | 
      
 | 
    atkObjType = attacker.GetGameObjType()  
 | 
    defObjType = defender.GetGameObjType()  
 | 
    if atkObjType == IPY_GameWorld.gotNPC and defObjType == IPY_GameWorld.gotNPC:  
 | 
        if NPCCommon.GetFaction(attacker) == NPCCommon.GetFaction(defender):  
 | 
            return False  
 | 
        if attacker.GetType() == ChConfig.ntRobot and defender.GetType() == ChConfig.ntRobot:  
 | 
            #GameWorld.DebugLog("±¾¸±±¾»úÆ÷ÈËNPC¿ÉÒÔ»¥Ï๥»÷: atkNPCID=%s(%s),defNPCID=%s(%s)" % (attacker.GetNPCID(), attacker.GetName(), defender.GetNPCID(), defender.GetName()))  
 | 
            return True  
 | 
        #GameWorld.DebugLog("±¾¸±±¾NPC²»ÄÜ»¥Ï๥»÷: atkNPCID=%s(%s),defNPCID=%s(%s)" % (attacker.GetNPCID(), attacker.GetName(), defender.GetNPCID(), defender.GetName()))  
 | 
        return False  
 | 
      
 | 
    return True  
 | 
  
 | 
#def GetFBRobotCanAtkObjTypeIDList(curNPC):  
 | 
#    ## »ñÈ¡¸±±¾ÖлúÆ÷ÈË¿ÉÄܿɹ¥»÷µÄʵÀýÀàÐÍIDÁÐ±í  
 | 
#    ## @return: [[objType, objID], ...]  
 | 
#    faction = NPCCommon.GetFaction(curNPC)  
 | 
#    if not faction:  
 | 
#        return []  
 | 
#      
 | 
#    defFaction = ShareDefine.CampType_Justice if faction == ShareDefine.CampType_Evil else ShareDefine.CampType_Evil  
 | 
#    objTypeIDList = []  
 | 
#    defFactionObj = GetBattleFactionObj(defFaction)  
 | 
#    for playerID in defFactionObj.onlinePlayerIDList:  
 | 
#        objTypeIDList.append([IPY_GameWorld.gotPlayer, playerID])  
 | 
#          
 | 
#    for robotID in defFactionObj.robotObjIDList:  
 | 
#        objTypeIDList.append([IPY_GameWorld.gotNPC, robotID])  
 | 
#          
 | 
#    random.shuffle(objTypeIDList) # ´òÂÒ˳Ðò  
 | 
#    return objTypeIDList  
 | 
  
 | 
  
 | 
## Íæ¼Ò¹¥»÷Íæ¼ÒÊÇ·ñÓгͷ£  
 | 
def DoFBAttackHasPunish(atkPlayer, defPlayer):  
 | 
    return False  
 |