hxp
2018-09-19 2786606d81a3938bec26619884bff65c55af657d
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
@@ -109,8 +112,8 @@
    isMapNeedShunt = IsMapNeedBossShunt(mapID)
    isAlive = __GetIsAlive(bossID)
    
    GameWorld.DebugLog("击杀世界boss DoGameWorldBossOnKilled...bossID=%s,hurtValue=%s,mapID=%s,tick=%s,isMapNeedShunt=%s,isAlive=%s"
                       % (bossID, hurtValue, mapID, tick, isMapNeedShunt, isAlive))
    GameWorld.Log("击杀世界boss DoGameWorldBossOnKilled...bossID=%s,hurtValue=%s,mapID=%s,tick=%s,isMapNeedShunt=%s,isAlive=%s"
                  % (bossID, hurtValue, mapID, tick, isMapNeedShunt, isAlive))
    if isMapNeedShunt and not isAlive:
        GameWorld.DebugLog("需要分流的地图boss被击杀,但是当前boss全局状态为死亡状态,不再更新boss击杀信息!")
        return
@@ -131,7 +134,10 @@
        # 全服广播世界boss变更信息
        Sync_BossInfo(None, [bossID])
        SendMapServerBossKilledCnt(bossID)
    horsePetRobBossIDList = IpyGameDataPY.GetFuncEvalCfg("FairyGrabBossID", 1)
    if bossID in horsePetRobBossIDList:
        OnFamilyKillHorsePetRobBoss(killPlayerName)
    return
def __UpdateBossRefreshList(bossID, killedTime=0, refreshTime=0):
@@ -176,6 +182,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 +482,14 @@
    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)
    #仙盟击杀骑宠boss数
    if PyGameData.g_familyKillHorsePetRobBossCntDict:
        GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FamilyKillHorsePetRobBossCnt, PyGameData.g_familyKillHorsePetRobBossCntDict)
    return
@@ -586,6 +604,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
@@ -898,10 +918,13 @@
    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, {})
        canRebornBossIDList = []
        for bidlist, bkey in killBossCntLimitDict.items():
            if bkey not in [0, 1]:
            if bkey not in [ShareDefine.Def_Boss_Func_World, ShareDefine.Def_Boss_Func_Home]:
                continue
            canRebornBossIDList += list(bidlist)
        
@@ -935,6 +958,8 @@
def ResetBossRebornPoint():
    ## 重置boss复活点
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornPoint, 0)
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornCnt, 0)
    # 活动开启时设置参数 服务器人数
    lvLimit = IpyGameDataPY.GetFuncCfg('ServerActivePlayerCnt')
    yesterdayPlayerCnt = len([1 for lv in PyGameData.g_yesterdayPlayerLVDict.values() if lv >= lvLimit]) #参数昨日活跃人数
@@ -986,6 +1011,7 @@
    if not totalPoint:
        totalPoint = SetBossRebornNeedPoint()
    packData.TotalPoint = totalPoint
    packData.RebornCnt = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_BossRebornCnt)
    playerManager = GameWorld.GetPlayerManager()
    if not curPlayer:
        for i in xrange(playerManager.GetActivePlayerCount()):
@@ -1001,3 +1027,183 @@
        NetPackCommon.SendFakePack(curPlayer, packData)
    return
def Sync_DogzNPCRefreshTime(msgList):
    #同步神兽副本NPC刷新时间
    playerID, refreshTimeDict = msgList
    curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) if playerID else None
    if playerID and not curPlayer:
        return
    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)
            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 OnFamilyKillHorsePetRobBoss(killFamilyName):
    ## 仙盟击杀骑宠boss
    family = GameWorld.GetFamilyManager().FindFamilyByName(killFamilyName)
    if not family:
        GameWorld.ErrLog("找不到该仙盟名: killFamilyName=%s" % killFamilyName)
        return
    familyID = family.GetID()
    PyGameData.g_familyKillHorsePetRobBossCntDict[familyID] = PyGameData.g_familyKillHorsePetRobBossCntDict.get(familyID, 0) + 1
    GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FamilyKillHorsePetRobBossCnt, PyGameData.g_familyKillHorsePetRobBossCntDict)
    GameWorld.Log("骑宠争夺仙盟击杀Boss数统计: %s" % PyGameData.g_familyKillHorsePetRobBossCntDict)
    return
def SyncMapServer_HorsePetRobBossPlayerCount():
    ## 活动开始前,同步有效活动人数到地图,作为Boss属性成长系数用
    diffWorldLV = int(IpyGameDataPY.GetFuncCfg("FairyGrabBossID", 3))
    funcLimitLV = PlayerControl.GetFuncLimitLV(ShareDefine.GameFuncID_HorsePetRobBoss)
    curWorldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
    minLV = max(funcLimitLV, curWorldLV + diffWorldLV)
    playerCount = 0
    playerManager = GameWorld.GetPlayerManager()
    for i in xrange(playerManager.GetActivePlayerCount()):
        findPlayer = playerManager.GetActivePlayerAt(i)
        if findPlayer == None or not findPlayer.GetInitOK():
            continue
        if PlayerControl.GetIsTJG(findPlayer):
            continue
        if not findPlayer.GetFamilyID():
            continue
        if findPlayer.GetLV() < minLV:
            continue
        playerCount += 1
    GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_HorsePetRobBossPlayerCount, playerCount)
    GameWorld.Log("同步骑宠争夺有效参与人数: playerCount=%s,minLV=%s,funcLimitLV=%s,curWorldLV=%s,diffWorldLV=%s"
                  % (playerCount, minLV, funcLimitLV, curWorldLV, diffWorldLV))
    return
def OnHorsePetRobBossActionChange(isOpen):
    ## 骑宠争夺活动状态变更
    # 无论开关都重置, 服务器活动中维护暂时不处理
    PyGameData.g_familyKillHorsePetRobBossCntDict = {}
    GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FamilyKillHorsePetRobBossCnt, PyGameData.g_familyKillHorsePetRobBossCntDict)
    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