From d2a7a62fce1fcbf25633c620e06f9c40d1d1bbde Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 17 一月 2025 12:05:07 +0800
Subject: [PATCH] 1111 【越南】【英语】【BT】【砍树】增加击杀boss任务事件

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py |  354 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 248 insertions(+), 106 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py
index a0734dc..08e1c29 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py
@@ -38,20 +38,29 @@
 import PlayerUniversalGameRec
 import PlayerCompensation
 import IpyGameDataPY
-import MergePlayer
 import PyGameDataStruct
+import CrossRealmPlayer
 import PyDataManager
 import PlayerControl
+import CrossRealmMsg
 import CommFunc
 import PyGameData
-import PlayerGeTui
 import IPY_GameServer
+import PlayerTeam
+import CrossBoss
+import PlayerFB
 
 import time
 
-
-
+''' boss首杀
+ShareDefine.Def_UniversalGameRecType_BossFirstKill
+value1:bossID
+StrValue2:killedTimeStr
+StrValue3:playerName,playerName,...
 '''
+
+
+''' boss击杀信息
 ShareDefine.Def_UniversalGameRecType_BossInfo
 value1:bossID
 value2:killedTime
@@ -102,12 +111,13 @@
     if bossID <= 0:
         return
     
-    # 设置不存活,击杀玩家名
-    killPlayerName = msgList[1]
-    hurtValue = msgList[2]
-    isAddKillCnt = msgList[3]
-    isNotify = msgList[4] if len(msgList) > 4 else True
-    mapID = msgList[5] if len(msgList) > 5 else None
+    bossID, killPlayerName, hurtValue, isNotify, mapID, realMapID, copyMapID, killerIDList = msgList
+    mapID = PlayerFB.GetRecordMapID(mapID)
+    if GameWorld.IsCrossServer():
+        CrossBoss.DoCrossBossOnKilled(bossID, killPlayerName, mapID, realMapID, copyMapID, killerIDList)
+        return
+    
+    isAddKillCnt = False
     
     isMapNeedShunt = IsMapNeedBossShunt(mapID)
     isAlive = __GetIsAlive(bossID)
@@ -138,6 +148,9 @@
     horsePetRobBossIDList = IpyGameDataPY.GetFuncEvalCfg("FairyGrabBossID", 1)
     if bossID in horsePetRobBossIDList:
         OnFamilyKillHorsePetRobBoss(killPlayerName)
+        
+    # boss首杀
+    OnBossFirstKill(bossID, killerIDList)
     return
 
 def __UpdateBossRefreshList(bossID, killedTime=0, refreshTime=0):
@@ -157,11 +170,14 @@
     ## 世界boss状态变更
     if len(msgList) <= 0:
         return
-
-    bossID = msgList[0]
-    isAlive = msgList[1]
-    mapID = msgList[2] if len(msgList) > 2 else None
-    lineID = msgList[3] if len(msgList) > 3 else None
+    
+    bossID, isAlive, mapID, realMapID, copyMapID = msgList
+    mapID = PlayerFB.GetRecordMapID(mapID)
+    if GameWorld.IsCrossServer():
+        CrossBoss.DoCrossBossStateChange(bossID, isAlive, mapID, realMapID, copyMapID)
+        return
+    
+    lineID = copyMapID
     GameWorld.Log("世界boss状态变更: mapID=%s,lineID=%s,bossID=%s,state=%s,tick=%s" % (mapID, lineID, bossID, isAlive, tick))
     
     if bossID <= 0:
@@ -213,7 +229,7 @@
     recTypeListData = __GetBossPrizeRecData()
     # 查找是否已有记录
     bossRec = None
-    for index in range(recTypeListData.Count()):
+    for index in xrange(recTypeListData.Count()):
         universalRecData = recTypeListData.At(index)
         if universalRecData.GetValue1() == bossID:
             bossRec = universalRecData
@@ -306,6 +322,32 @@
 #        
 #    return
 
+#// A9 04 查询boss信息 #tagCGQueryBossInfo
+#
+#
+#struct    tagCGQueryBossInfo
+#{
+#    tagHead        Head;
+#    BYTE        Count;    //数量
+#    DWORD        BossIDList[Count];    //boosid
+#};
+def OnQueryBossInfo(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    bossIDList = clientData.BossIDList
+    if not bossIDList:
+        Sync_BossInfo(curPlayer)
+        CrossBoss.Sync_CrossBossInfo(curPlayer)
+        return
+    bossID = bossIDList[0]
+    ipyData = IpyGameDataPY.GetIpyGameData('BOSSInfo', bossID)
+    if not ipyData:
+        return
+    mapID = ipyData.GetMapID()
+    if mapID in ChConfig.Def_CrossMapIDList:
+        CrossBoss.Sync_CrossBossInfo(curPlayer, bossIDList)
+    else:
+        Sync_BossInfo(curPlayer, bossIDList)
+    return
 
 
 ## 同步boss相关信息
@@ -319,12 +361,18 @@
     recTypeListData = __GetBossPrizeRecData()
     bossInfo.BossInfoList = []
     #GameWorld.DebugLog("Sync_BossInfo...count=%s,curTime=%s" % (recTypeListData.Count(), curTime))
-    for index in range(recTypeListData.Count()):
+    for index in xrange(recTypeListData.Count()):
         universalRecData = recTypeListData.At(index)
         bossID = universalRecData.GetValue1()
         if not bossID:
             continue
         if syncBOSSIDList and bossID not in syncBOSSIDList:
+            continue
+        ipyData = IpyGameDataPY.GetIpyGameData('BOSSInfo', bossID)
+        if not ipyData:
+            continue
+        mapID = ipyData.GetMapID()
+        if mapID in ChConfig.Def_CrossMapIDList:
             continue
         bossInfoObj = ChPyNetSendPack.tagBossInfoObj()
         bossInfoObj.BossID = bossID
@@ -342,11 +390,14 @@
 #                           % (bossInfoObj.BossID, bossInfoObj.IsAlive, bossInfoObj.KillRecord, 
 #                              killedTime, bossInfoObj.RefreshSecond))
         
+    if not bossInfo.BossInfoList:
+        return
+    
     bossInfo.BossCnt = len(bossInfo.BossInfoList)
     if not curPlayer:
         # 全服广播在线玩家
         playerManager = GameWorld.GetPlayerManager()
-        for i in range(0, playerManager.GetActivePlayerCount()):
+        for i in xrange(playerManager.GetActivePlayerCount()):
             curPlayer = playerManager.GetActivePlayerAt(i)
             if curPlayer == None or not curPlayer.GetInitOK():
                 continue
@@ -366,6 +417,9 @@
     if not GameWorld.SetWorldDictKey(ChConfig.TYPE_WorldBossProcessTick, tick):
         #间隔未到 
         return
+    if GameWorld.IsCrossServer():
+        CrossBoss.DoCheckCrossBossReborn(tick)
+        return
     curTime = int(time.time())
     DoCheckWorldBossShuntInfo(curTime, tick)
     BossRebornWorldNotify(curTime)
@@ -373,7 +427,13 @@
         for i in xrange(IpyGameDataPY.IPY_Data().GetBOSSInfoCount()):
             ipyData = IpyGameDataPY.IPY_Data().GetBOSSInfoByIndex(i)
             bossID = ipyData.GetNPCID()
+            mapID = ipyData.GetMapID()
+            if mapID in ChConfig.Def_CrossMapIDList:
+                continue
             bossPrizeRec = __GetBossRecDataByID(bossID)
+            refreshTimeStr = ipyData.GetRefreshTime()
+            if not refreshTimeStr or refreshTimeStr == "0":
+                continue
             killedTime = bossPrizeRec.GetValue2()
             refreshTime = __GetBossRefreshTime(bossID)
             PyGameData.g_sortBOSSRefreshList.append([bossID, killedTime, refreshTime])
@@ -395,7 +455,6 @@
             break
         
         #此处只处理复活的
-        PlayerGeTui.GeTuiBossReborn(bossID)
         __SetIsAlive(bossID, 1)
         syncBOSSIDList.append(bossID)
         
@@ -406,28 +465,6 @@
     if syncBOSSIDList:
         Sync_BossInfo(None, syncBOSSIDList)
     return
-
-
-#BOSS个推提前倒计时通知处理,   复活由DoCheckWorldBossReborn处理
-def ProcessBossGeTui(tick):
-    if not GameWorld.SetWorldDictKey(ChConfig.TYPE_WorldBossGeTuiTick, tick):
-        #间隔未到 
-        return
-    
-    curTime = int(time.time())
-    for bossInfo in PyGameData.g_sortBOSSRefreshList:
-        bossID, killedTime, refreshTime = bossInfo
-        isAlive = __GetIsAlive(bossID)
-        if isAlive:
-            #GameWorld.DebugLog("    bossID=%s,未被击杀!" % bossID)
-            continue
-        rebornSecond = max(0, refreshTime - (curTime - killedTime))
-        if not rebornSecond:
-            #不处理复活BOSS
-            continue
-        
-        PlayerGeTui.GeTuiBoss(bossID, rebornSecond)
-
 
 def GetBossIsAliveOrCanReborn(bossID):
     ##BOSS是否活着或者可重生
@@ -446,18 +483,21 @@
     for i in xrange(IpyGameDataPY.IPY_Data().GetBOSSInfoCount()):
         ipyData = IpyGameDataPY.IPY_Data().GetBOSSInfoByIndex(i)
         bossID = ipyData.GetNPCID()
+        mapID = ipyData.GetMapID()
+        if mapID in ChConfig.Def_CrossMapIDList:
+            continue
         isAlive = __GetIsAlive(bossID)
         if not isAlive:
             continue
-        mapID = ipyData.GetMapID()
-        if mapID != ChConfig.Def_FBMapID_SealDemon:
-            GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_GameWorldBossReborn % bossID, 1)
+        #if mapID not in ChConfig.WorldBossFBMapIDList:
+        GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_GameWorldBossReborn % bossID, 1)
     return
 
 ## 玩家登录通知
 #  @param curPlayer
 #  @return None
 def OnPlayerLogin(curPlayer):
+    CrossBoss.OnPlayerLogin(curPlayer)
     Sync_BossInfo(curPlayer)
     PyDataManager.GetBossAttentionManager().NotifyBossAttentionInfo(curPlayer)
     if IsMapNeedBossShunt(0):
@@ -467,22 +507,20 @@
     state = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_OperationActionState % ShareDefine.OperationActionName_BossReborn)
     if state:
         Sync_BossRebornPoint(curPlayer)
-    Sync_DogzNPCRefreshTime(curPlayer)
     return
 
 ## 地图启动ok通知
 #  @param None
 #  @return None
 def OnMapServerInitOK():
+    if GameWorld.IsCrossServer():
+        CrossBoss.OnCrossMapServerInitOK()
+        return
     SendMapServerBossKilledCnt()
     __SendMapServerAliveBoss()
     if IsMapNeedBossShunt(0):
         GameWorld.SendCommMapServerMsg(ShareDefine.Def_Notify_WorldKey_BossShuntPlayer, PyGameData.g_bossShuntPlayerInfo)
         GameWorld.SendCommMapServerMsg(ShareDefine.Def_Notify_WorldKey_BossShuntLineState, PyGameData.g_bossShuntLineState)
-    #通知一个参数
-    bossID = IpyGameDataPY.GetFuncCfg('DogzFBRefreshCfg', 2)
-    onlineCnt = __GetBossOnlineHeroCnt(bossID)[0]
-    GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_BossOnlineHeroCnt % bossID, onlineCnt)
     
     #仙盟击杀骑宠boss数
     if PyGameData.g_familyKillHorsePetRobBossCntDict:
@@ -492,16 +530,37 @@
 
 ##--------------------------------------------------------------------------------------------------
 
+def CrossServerMsg_DropGoodItem(msgList, tick):
+    ## 收到跨服服务器同步的掉落好物品信息
+    playerID = msgList[0]
+    curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
+    if curPlayer:
+        msgList[1] = curPlayer.GetName() # 本服玩家在线,修改为本服玩家的名字展示
+    OnKillBossDropGoodItem(msgList, tick)
+    return
+
 def OnKillBossDropGoodItem(msgList, tick):
     # playerName, mapID, npcID, itemID, userData
-    if len(msgList) != 7:
+    if len(msgList) != 10:
         return
-    playerID, killerName, mapID, npcID, itemID, userData, weightValue = msgList
-    GameWorld.DebugLog("击杀Boss掉落好物品: mapID=%s,npcID=%s,killerName=%s,itemID=%s, userData=%s, weightValue=%s" 
-                       % (mapID, npcID, killerName, itemID, userData, weightValue))
+    playerID, killerName, mapID, lineID, npcID, itemID, userData, weightValue, serverGroupID, playerLV = msgList
+    GameWorld.DebugLog("击杀Boss掉落好物品: mapID=%s,npcID=%s,killerName=%s,itemID=%s, userData=%s, weightValue=%s, serverGroupID=%s" 
+                       % (mapID, npcID, killerName, itemID, userData, weightValue, serverGroupID))
     maxRecordCnt = IpyGameDataPY.GetFuncCfg('DropRecordNum')
     if not maxRecordCnt:
         return
+    
+    if GameWorld.IsCrossServer():
+        # 同步到玩家对应子服
+        if not serverGroupID:
+            return
+        zoneIpyData = CrossRealmPlayer.GetCrossZoneIpyDataByServerGroupID(mapID, serverGroupID)
+        if not zoneIpyData:
+            return
+        serverGroupIDList = zoneIpyData.GetServerGroupIDList()
+        CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_DropGoodItem, msgList, serverGroupIDList)
+        return
+    
     recType = ShareDefine.Def_UniversalGameRecType_BossDropGoodItemInfo
     universalRecMgr = GameWorld.GetUniversalRecMgr()
     recordList = universalRecMgr.GetTypeList(recType)
@@ -529,8 +588,11 @@
             if commonList and commonList[0][0] != -1:
                 recordList.Delete(commonList[0][0])
         
-    PlayerUniversalGameRec.MapServer_UniversalGameRec(None, recType, [mapID, npcID, itemID, playerID, weightValue],
-                                                      [killerName, "", userData])
+    PlayerUniversalGameRec.MapServer_UniversalGameRec(None, recType, [mapID*100+lineID, npcID, itemID, playerID, weightValue],
+                                                      [killerName, '%s|%s'%(serverGroupID, playerLV), userData])
+    
+    msgList = [killerName, playerID, mapID, npcID, itemID, userData, serverGroupID, playerLV, lineID]
+    PlayerControl.WorldNotify(0, 'DropRecord' , msgList)
     return
 
 
@@ -542,11 +604,16 @@
     if not GameWorld.SetWorldDictKey(ChConfig.TYPE_WorldBossOnlineCntTick, tick):
         #间隔未到 
         return
+    if GameWorld.IsCrossServer():
+        return
     GameWorld.DebugLog('世界boss在线人数统计')
     bossRebornDict = {}
     for i in xrange(IpyGameDataPY.IPY_Data().GetBOSSInfoCount()):
         ipyData = IpyGameDataPY.IPY_Data().GetBOSSInfoByIndex(i)
         bossID = ipyData.GetNPCID()
+        mapID = ipyData.GetMapID()
+        if mapID in ChConfig.Def_CrossMapIDList:
+            continue
         refreshTimeStr = ipyData.GetRefreshTime()
         if 'onlineCnt' in refreshTimeStr:
             bossRebornDict[bossID] = ipyData.GetLVLimit()
@@ -566,15 +633,6 @@
             if lvLimit[0] <= findLV <= lvLimit[1]:
                 playerCntDict[bossid] = playerCntDict.get(bossid, 0) + 1
     GameWorld.DebugLog('    boss等级信息对应本服在线人数 %s' % playerCntDict)
-    
-    # 此处需要统计累加当前在跨服服务器的玩家
-    mergeServerOnlinePlayerDict = MergePlayer.GetMergeServerOnlinePlayerInfo()
-    for playerInfo in mergeServerOnlinePlayerDict.values():
-        findLV = playerInfo[MergePlayer.Def_MSOLPlayer_LV]
-        for bossid, lvLimit in bossRebornDict.items():
-            if lvLimit[0] <= findLV <= lvLimit[1]:
-                playerCntDict[bossid] = playerCntDict.get(bossid, 0) + 1
-    GameWorld.DebugLog('    boss等级信息对应本服及跨服在线人数 %s' % playerCntDict)
     
     for bossid, curOnlineCnt in playerCntDict.items():
         SetBossOnlineHeroCnt(bossid, curOnlineCnt)
@@ -601,8 +659,6 @@
     
     newNum = newOnlieCnt * 100 + unUpdataCnt
     PlayerDBGSEvent.SetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_GameWorldBossOnlineCnt % bossid, newNum)
-    if bossid == IpyGameDataPY.GetFuncCfg('DogzFBRefreshCfg', 2):
-        GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_BossOnlineHeroCnt % bossid, newOnlieCnt)
     GameWorld.DebugLog("设置计算boss刷新时间用的在线人数 Change:bossid=%s, beforeOnlineCnt = %s, newOnlieCnt = %s, unUpdataCnt=%s" % (bossid, beforeOnlineCnt, newOnlieCnt, unUpdataCnt))
     return
 
@@ -614,7 +670,7 @@
 
 def SetBossRefreshTime(bossid, killedTime):
     '''设置boss刷新时间'''
-    ipyData = IpyGameDataPY.GetIpyGameData('BOSSInfo', bossid)
+    ipyData = IpyGameDataPY.GetIpyGameDataNotLog('BOSSInfo', bossid)
     if not ipyData:
         return
     onlineCnt = __GetBossOnlineHeroCnt(bossid)[0]
@@ -665,6 +721,7 @@
     def GetBossAttentionDict(self):
         return self.bossAttentionDict
 
+    # RecordData改json记录 bossid存为字符串
     def UpdateBossAttention(self, playerid, bossid, isAdd):
         if playerid in self.bossAttentionDict:
             bossAttentionData = self.bossAttentionDict[playerid]
@@ -706,7 +763,7 @@
         packData.BossList = []
         for bossid, addState in bttentionDict.items():
             bossInfo = ChPyNetSendPack.tagGCBossAttention()
-            bossInfo.BossID=bossid
+            bossInfo.BossID=int(bossid)
             bossInfo.AddState=addState
             packData.BossList.append(bossInfo)
         
@@ -723,7 +780,7 @@
             cnt += 1
             savaData += attentionData.getBuffer()
                 
-        GameWorld.Log("SaveBossAttention cnt :%s" % cnt)
+        GameWorld.Log("SaveBossAttention cnt :%s len=%s" % (cnt, len(savaData)))
         return CommFunc.WriteDWORD(cntData, cnt) + savaData
     
     # 从数据库载入数据
@@ -738,10 +795,7 @@
             data.clear()
             pos += data.readData(datas, pos, dataslen)
             playerID = data.PlayerID
-            if type(eval(data.RecordData)) != list:
-                self.bossAttentionDict[playerID] = data
-            else:
-                data.clear()
+            self.bossAttentionDict[playerID] = data
             
         return pos
 
@@ -907,6 +961,11 @@
         NetPackCommon.SendFakePack(curPlayer, bossShuntLineInfo)
     return
 
+def BossRebornOnDayEx():
+    ## boss复活过天
+    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornCnt, 0)
+    Sync_BossRebornPoint()
+    return
 
 def AddBossRebornPoint(addPoint):
     ## 增加boss复活点
@@ -922,13 +981,18 @@
     if not totalPoint:
         GameWorld.Log(' 增加boss复活点 没有总点数!!!!')
         return
+    rebornCnt = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornCnt)
+    maxRebornCnt = IpyGameDataPY.GetFuncCfg('BossRebornTotalPoint', 3)
+    if maxRebornCnt and rebornCnt >= maxRebornCnt:
+        GameWorld.DebugLog(' boss复活已达到最大次数! maxRebornCnt=%s' % maxRebornCnt)
+        return
+    
     curPoint = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornPoint)
     
     updPoint = (curPoint+addPoint)%totalPoint
     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornPoint, updPoint)
     if curPoint+addPoint >= totalPoint:
         #重生boss
-        rebornCnt = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornCnt)
         PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornCnt, rebornCnt+1)
         
         killBossCntLimitDict = IpyGameDataPY.GetFuncEvalCfg('KillBossCntLimit', 1, {})
@@ -954,6 +1018,8 @@
         PyGameData.g_sortBOSSRefreshList.sort(key=lambda asd:max(0, asd[2] - (curTime - asd[1])))
         GameWorld.Log(' boss复活活动 重生boss bossIDList=%s'%bossIDList)
         g_lastBossRebornTime = curTime
+        
+        GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_ActionBossRebornSign % ShareDefine.OperationActionName_BossReborn, int(time.time()))
     else:
         #广播
         needNotifyPointPerList = IpyGameDataPY.GetFuncEvalCfg('BossRebornNotify')
@@ -1024,40 +1090,9 @@
         totalPoint = SetBossRebornNeedPoint()
     packData.TotalPoint = totalPoint
     packData.RebornCnt = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornCnt)
+    packData.TotalRebornCnt = IpyGameDataPY.GetFuncCfg('BossRebornTotalPoint', 3)
     playerManager = GameWorld.GetPlayerManager()
     if not curPlayer:
-        for i in xrange(playerManager.GetActivePlayerCount()):
-            curPlayer = playerManager.GetActivePlayerAt(i)
-            if curPlayer == None or not curPlayer.GetInitOK():
-                continue
-            if PlayerControl.GetIsTJG(curPlayer):
-                continue
-            NetPackCommon.SendFakePack(curPlayer, packData)
-    else:
-        if PlayerControl.GetIsTJG(curPlayer):
-            return
-        NetPackCommon.SendFakePack(curPlayer, packData)
-    return
-
-def Sync_DogzNPCRefreshTime(curPlayer=None):
-    #同步神兽副本NPC刷新时间
-    refreshTimeDict = PyGameData.g_dogzNPCRefreshTimeDict
-
-    if not refreshTimeDict:
-        return
-    curTime = int(time.time())
-    packData = ChPyNetSendPack.tagGCDogzNPCRefreshTime()
-    packData.InfoList=[]
-    for npcid, timeinfo in refreshTimeDict.items():
-        lastRefreshTime, nextNeedTime = timeinfo
-        remainTime = max(0, nextNeedTime - curTime + lastRefreshTime)
-        timeInfo = ChPyNetSendPack.tagDogzTimeInfoObj()
-        timeInfo.NPCID = npcid
-        timeInfo.RefreshSecond = remainTime
-        packData.InfoList.append(timeInfo)
-    packData.Cnt = len(packData.InfoList)
-    if not curPlayer:
-        playerManager = GameWorld.GetPlayerManager()
         for i in xrange(playerManager.GetActivePlayerCount()):
             curPlayer = playerManager.GetActivePlayerAt(i)
             if curPlayer == None or not curPlayer.GetInitOK():
@@ -1220,3 +1255,110 @@
     PlayerControl.FamilyNotify(curFamily.GetID(), "FairyGrabBossHelp", [curPlayer.GetName(), npcID])
     return
 
+## -------------------------------------- boss 首杀 ------------------------------------------------
+def __GetBossFirstKillRecDataList():
+    ## 获取boss首杀记录信息列表
+    return GameWorld.GetUniversalRecMgr() .GetTypeList(ShareDefine.Def_UniversalGameRecType_BossFirstKill)
+
+def __GetBossFirstKillRecDataByID(bossID):
+    ## 获取boss首杀记录信息数据
+    
+    recTypeListData = __GetBossFirstKillRecDataList()
+    # 查找是否已有记录
+    bossFirstKillRec = None
+    for index in xrange(recTypeListData.Count()):
+        universalRecData = recTypeListData.At(index)
+        if universalRecData.GetValue1() == bossID:
+            bossFirstKillRec = universalRecData
+            break
+        
+    if bossFirstKillRec == None:
+        #还未记录,则添加一个记录对象
+        bossFirstKillRec = recTypeListData.AddRec()        
+        bossFirstKillRec.SetValue1(bossID)
+        
+    return bossFirstKillRec
+
+def OnBossFirstKill(bossID, killerIDList):
+    ## 处理boss首杀逻辑
+    
+    maxOSDay = IpyGameDataPY.GetFuncCfg("OSCBossFirstKill", 1)
+    openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1
+    if openServerDay > maxOSDay:
+        GameWorld.DebugLog("超过开服天(%s), 不开放首杀活动!" % maxOSDay)
+        return
+    
+    if not bossID or not killerIDList:
+        return
+    
+    ipyData = IpyGameDataPY.GetIpyGameDataNotLog("BOSSFirstKill", bossID)
+    if not ipyData:
+        return
+    
+    fkRecData = __GetBossFirstKillRecDataByID(bossID)
+    if not fkRecData:
+        return
+    
+    firstKillTimeStr = fkRecData.GetStrValue2()
+    if firstKillTimeStr:
+        GameWorld.DebugLog("已经首杀过了! bossID=%s, %s" % (bossID, firstKillTimeStr))
+        return
+    
+    killPlayerList = []
+    playerMgr = GameWorld.GetPlayerManager()
+    for playerID in killerIDList:
+        player = playerMgr.FindPlayerByID(playerID)
+        if not player:
+            continue
+        teamMemLV = PlayerTeam.__GetPlayerTeamLV(player)
+        killPlayerList.append([teamMemLV, player.GetName()])
+    if not killPlayerList:
+        return
+    
+    killPlayerList.sort(reverse=True)
+    fkPlayerNameList = [nameInfo[1] for nameInfo in killPlayerList]
+    
+    fkRecData.SetStrValue2(GameWorld.GetCurrentDataTimeStr())
+    fkRecData.SetStrValue3(",".join(fkPlayerNameList))
+    
+    # 首杀奖励邮件
+    PlayerCompensation.SendMailByKey("BossFirstKillMail", killerIDList, ipyData.GetServerFirstKillPlayerAward(), [bossID])
+    
+    ## 主动广播全服玩家
+    PlayerUniversalGameRec.SendUniversalGameRecSingle(None, fkRecData)
+    return
+
+
+#// A9 01 获取Boss首杀奖励 #tagCGGetBossFirstKillAward
+#
+#struct    tagCGGetBossFirstKillAward
+#{
+#    tagHead    Head;
+#    DWORD    NPCID;
+#    BYTE    AwardType;    // 0-首杀红包奖励;1-个人首杀奖励
+#};
+def OnGetBossFirstKillAward(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    bossID = clientData.NPCID
+    awardType = clientData.AwardType
+    
+    ipyData = IpyGameDataPY.GetIpyGameDataNotLog("BOSSFirstKill", bossID)
+    if not ipyData:
+        return
+    
+    if awardType == 0:
+        fkRecData = __GetBossFirstKillRecDataByID(bossID)
+        if not fkRecData:
+            return
+        
+        firstKillTimeStr = fkRecData.GetStrValue2()
+        if not firstKillTimeStr:
+            GameWorld.DebugLog("Boss还未首杀,不能领取boss首杀公共红包奖励! bossID=%s" % (bossID), curPlayer.GetPlayerID())
+            return
+        
+    msgInfo = str([bossID, awardType])
+    curPlayer.MapServer_QueryPlayerResult(0, 0, "BossFirstKill", msgInfo, len(msgInfo))
+    return
+
+## ------------------------------------------------------------------------------------------------
+

--
Gitblit v1.8.0