ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py
@@ -36,6 +36,7 @@
import ChPyNetSendPack
import PlayerDBGSEvent
import PlayerUniversalGameRec
import PlayerCompensation
import IpyGameDataPY
import MergePlayer
import PyGameDataStruct
@@ -44,6 +45,8 @@
import CommFunc
import PyGameData
import PlayerGeTui
import IPY_GameServer
import time
@@ -176,6 +179,10 @@
        __SetIsAlive(bossID, isAlive)
        # 全服广播世界boss变更信息
        Sync_BossInfo(None, [bossID])
    # 仙盟归属boss的重置
    if isAlive and bossID in PyGameData.g_familyOwnerBossInfo:
        PyGameData.g_familyOwnerBossInfo.pop(bossID)
    return
@@ -472,6 +479,10 @@
    if IsMapNeedBossShunt(0):
        GameWorld.SendCommMapServerMsg(ShareDefine.Def_Notify_WorldKey_BossShuntPlayer, PyGameData.g_bossShuntPlayerInfo)
        GameWorld.SendCommMapServerMsg(ShareDefine.Def_Notify_WorldKey_BossShuntDeadLine, PyGameData.g_bossShuntDeadLine)
    #通知一个参数
    bossID = IpyGameDataPY.GetFuncCfg('DogzFBRefreshCfg', 2)
    onlineCnt = __GetBossOnlineHeroCnt(bossID)[0]
    GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_BossOnlineHeroCnt % bossID, onlineCnt)
    return
@@ -586,6 +597,8 @@
    
    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
@@ -888,7 +901,7 @@
        return
    totalPoint = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_BossRebornNeedPoint)
    if not totalPoint:
        totalPoint = __SetBossRebornNeedPoint()
        totalPoint = SetBossRebornNeedPoint()
    if not totalPoint:
        GameWorld.Log(' 增加boss复活点 没有总点数!!!!')
        return
@@ -935,27 +948,35 @@
def ResetBossRebornPoint():
    ## 重置boss复活点
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornPoint, 0)
    Sync_BossRebornPoint()
    # 活动开启时设置参数 服务器人数
    lvLimit = IpyGameDataPY.GetFuncCfg('ServerActivePlayerCnt')
    yesterdayPlayerCnt = len([1 for lv in PyGameData.g_yesterdayPlayerLVDict.values() if lv >= lvLimit]) #参数昨日活跃人数
    serverActivePlayerCnt = eval(IpyGameDataPY.GetFuncCompileCfg('ServerActivePlayerCnt', 2))
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BRServerPlayerCnt, serverActivePlayerCnt)
    GameWorld.Log('    boss复活活动开启时设置昨日活跃人数yesterdayPlayerCnt=%s'%yesterdayPlayerCnt)
    #重新计算需要总点数
    __SetBossRebornNeedPoint()
    SetBossRebornNeedPoint()
    Sync_BossRebornPoint()
    return
def __SetBossRebornNeedPoint():
def SetBossRebornNeedPoint(isSync=False):
    totalPointList = IpyGameDataPY.GetFuncEvalCfg('BossRebornTotalPoint')
    worldLVList = IpyGameDataPY.GetFuncEvalCfg('BossRebornTotalPoint', 2)
    playerCntList = IpyGameDataPY.GetFuncEvalCfg('BossRebornTotalPoint', 2)
    
    actWorldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_OActWorldLV % ShareDefine.OperationActionName_BossReborn)
    BRServerPlayerCnt = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BRServerPlayerCnt)
    
    index = len(worldLVList)-1
    for i, lv in enumerate(worldLVList):
        prelv = 0 if i ==0 else worldLVList[i-1]
        if prelv <=actWorldLV < lv:
    index = len(playerCntList)-1
    for i, cnt in enumerate(playerCntList):
        preCnt = 0 if i ==0 else playerCntList[i-1]
        if preCnt <=BRServerPlayerCnt < cnt:
            index = i
            break
    
    totalPoint = totalPointList[-1] if index >= len(totalPointList) else totalPointList[index]
    GameWorld.GetGameWorld().SetDict(ChConfig.Def_WorldKey_BossRebornNeedPoint, totalPoint)
    if isSync:
        Sync_BossRebornPoint()
    return totalPoint
def BossRebornWorldNotify(curTime):
@@ -974,6 +995,10 @@
    ##通知BOSS复活点数
    packData = ChPyNetSendPack.tagGCBossRebornPoint()
    packData.Point = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornPoint)
    totalPoint = GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_BossRebornNeedPoint)
    if not totalPoint:
        totalPoint = SetBossRebornNeedPoint()
    packData.TotalPoint = totalPoint
    playerManager = GameWorld.GetPlayerManager()
    if not curPlayer:
        for i in xrange(playerManager.GetActivePlayerCount()):
@@ -989,20 +1014,23 @@
        NetPackCommon.SendFakePack(curPlayer, packData)
    return
def Sync_OperationAction_BossReborn(ipyData, curPlayer=None):
    ## 通知boss复活活动信息
    if not ipyData:
def Sync_DogzNPCRefreshTime(msgList):
    #同步神兽副本NPC刷新时间
    playerID, refreshTimeDict = msgList
    curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) if playerID else None
    if playerID and not curPlayer:
        return
    bossRebornInfo = ChPyNetSendPack.tagGCBossRebornInfo()
    bossRebornInfo.Clear()
    bossRebornInfo.StartDate = ipyData.GetStartDate()
    bossRebornInfo.EndtDate = ipyData.GetEndDate()
    bossRebornInfo.WorldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_OActWorldLV % ShareDefine.OperationActionName_BossReborn)
    bossRebornInfo.LimitLV = ipyData.GetLVLimit()
    if not curPlayer:
        # 全服广播在线玩家
    if not refreshTimeDict:
        return
    packData = ChPyNetSendPack.tagGCDogzNPCRefreshTime()
    packData.InfoList=[]
    for npcid, rTime in refreshTimeDict.items():
        timeInfo = ChPyNetSendPack.tagDogzTimeInfoObj()
        timeInfo.NPCID = npcid
        timeInfo.RefreshSecond = rTime
        packData.InfoList.append(timeInfo)
    packData.Cnt = len(packData.InfoList)
    if not playerID:
        playerManager = GameWorld.GetPlayerManager()
        for i in xrange(playerManager.GetActivePlayerCount()):
            curPlayer = playerManager.GetActivePlayerAt(i)
@@ -1010,9 +1038,104 @@
                continue
            if PlayerControl.GetIsTJG(curPlayer):
                continue
            NetPackCommon.SendFakePack(curPlayer, bossRebornInfo)
            NetPackCommon.SendFakePack(curPlayer, packData)
    else:
        if PlayerControl.GetIsTJG(curPlayer):
            return
        NetPackCommon.SendFakePack(curPlayer, bossRebornInfo)
        NetPackCommon.SendFakePack(curPlayer, packData)
    return
## -----------------------------------------------------------------------------------------------
def MapServer_HorsePetRobBossHurtPlayer(msgInfo):
    ## 骑宠争夺boss伤血玩家同步
    GameWorld.Log("骑宠争夺boss伤血玩家同步: %s" % str(msgInfo))
    if not isinstance(msgInfo, list) and len(msgInfo) != 2:
        return
    bossID, familyHurtPlayerIDListDict = msgInfo
    PyGameData.g_horsePetRobBossHurtPlayerIDInfo[bossID] = familyHurtPlayerIDListDict
    GameWorld.Log("伤血玩家汇总: %s" % PyGameData.g_horsePetRobBossHurtPlayerIDInfo)
    # 判断是否都同步上来了
    horsePetRobBossIDList = IpyGameDataPY.GetFuncEvalCfg("FairyGrabBossID", 1)
    for needBossID in horsePetRobBossIDList:
        if needBossID not in PyGameData.g_horsePetRobBossHurtPlayerIDInfo:
            return
    # 结算活动参与奖励
    joinAwardItemList = IpyGameDataPY.GetFuncEvalCfg("FairyGrabBossID", 2)
    joinPlayerIDList = []
    for familyHurtPlayerIDDict in PyGameData.g_horsePetRobBossHurtPlayerIDInfo.values():
        for playerIDList in familyHurtPlayerIDDict.values():
            for playerID in playerIDList:
                if playerID not in joinPlayerIDList:
                    joinPlayerIDList.append(playerID)
    GameWorld.Log("结算骑宠争夺参与奖玩家: joinPlayerIDList=%s" % joinPlayerIDList)
    PlayerCompensation.SendMailByKey("FairyGrabBossJoin", joinPlayerIDList, joinAwardItemList)
    PyGameData.g_horsePetRobBossHurtPlayerIDInfo = {}
    return
def MapServer_FamilyOwnerBossInfo(msgInfo):
    ## 地图同步仙盟归属boss信息
    #GameWorld.DebugLog("地图同步仙盟归属boss信息: %s" % msgInfo)
    if not isinstance(msgInfo, dict):
        return
    PyGameData.g_familyOwnerBossInfo.update(msgInfo)
    #GameWorld.DebugLog("    PyGameData.g_familyOwnerBossInfo=%s" % PyGameData.g_familyOwnerBossInfo)
    return
#// AC 04 查询仙盟抢Boss所有Boss当前进度 #tagCGQueryAllFamilyBossHurt
#
#struct    tagCGQueryAllFamilyBossHurt
#{
#    tagHead        Head;
#};
def OnQueryAllFamilyBossHurt(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    hurtPack = ChPyNetSendPack.tagGCAllFamilyBossHurtInfoList()
    hurtPack.NPCHurtInfo = []
    for npcID, hurtInfo in PyGameData.g_familyOwnerBossInfo.items():
        curHP, maxHP, firstFamilyID, firstFamilyName = hurtInfo
        hurtInfo = ChPyNetSendPack.tagGCFamilyBossHurtInfo()
        hurtInfo.NPCID = npcID
        hurtInfo.CurHP = curHP%ShareDefine.Def_PerPointValue
        hurtInfo.CurHPEx = curHP/ShareDefine.Def_PerPointValue
        hurtInfo.MaxHP = maxHP%ShareDefine.Def_PerPointValue
        hurtInfo.MaxHPEx = maxHP/ShareDefine.Def_PerPointValue
        hurtInfo.FamilyID = firstFamilyID
        hurtInfo.FamilyName = firstFamilyName
        hurtInfo.NameLen = len(hurtInfo.FamilyName)
        hurtPack.NPCHurtInfo.append(hurtInfo)
    hurtPack.NPCCount = len(hurtPack.NPCHurtInfo)
    NetPackCommon.SendFakePack(curPlayer, hurtPack)
    return
#// AC 05 召集仙盟成员打boss #tagCGCallupFamilyMemberToBoss
#
#struct    tagCGCallupFamilyMemberToBoss
#{
#    tagHead        Head;
#    DWORD        NPCID;
#};
def OnCallupFamilyMemberToBoss(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    npcID = clientData.NPCID
    curFamily = curPlayer.GetFamily()
    if curFamily == None:
        return
    curMember = curFamily.FindMember(playerID)
    if curMember == None:
        return
    if curMember.GetFamilyLV() == IPY_GameServer.fmlMember:
        GameWorld.DebugLog("普通成员无法召集!", playerID)
        return
    PlayerControl.FamilyNotify(curFamily.GetID(), "FairyGrabBossHelp", [npcID])
    return