hch
2019-07-22 5f18b0ab13594fe5a7e60af7f38c8c4443b553d7
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_SealDemon.py
@@ -33,15 +33,15 @@
import PlayerActivity
import NetPackCommon
import PlayerVip
import PlayerMagicWeapon
import GameObj
import PlayerBossReborn
import PlayerFairyCeremony
import PlayerNewFairyCeremony
import PlayerWeekParty
import PlayerActLogin
import EventReport
FBDict_StartTick = 'FBDict_StartTick%s' #开始时间
FBDict_Speed = 'FBDict_Speed%s' #掉血速度 /s
FBDict_RemainHP = 'FBDict_RemainHP%s' #剩余时间
FBPlayerDict_EncourageLV = 'FBPlayerDict_EncourageLV'   # 鼓舞等级
FBDict_IsOver = 'FBDict_IsOver' #是否已结算, 结算时的tick
@@ -51,12 +51,6 @@
def OnFBPlayerOnLogin(curPlayer):
    if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_VersionFix, ChConfig.Def_VerFix_FMTDouble):
        GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_VersionFix, ChConfig.Def_VerFix_FMTDouble, 1)
        needViplv = IpyGameDataPY.GetFuncCfg('DemonJarSpecial')
        if curPlayer.GetVIPLv() >= needViplv:
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FMTOldDouble, 1)
            GameWorld.DebugLog('1.3版本前可以双倍挑战')
    NotifyFMTDouble(curPlayer)
    return
@@ -74,6 +68,12 @@
        enterCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_EnterFbCntDay % mapID)
        maxCnt = FBCommon.GetEnterFBMaxCnt(curPlayer, mapID)
        if enterCnt + 2 > maxCnt:
            return False
    if lineID in newbielineList:
        hasEnter = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, False,
                                               [ChConfig.Def_FBMapID_SealDemon])
        if hasEnter:
            GameWorld.DebugLog("    已进入过该新手线路 %s" % lineID)
            return False
    return True
@@ -110,12 +110,7 @@
    if mapID == ChConfig.Def_FBMapID_SealDemonEx:
        return
    lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
    bossID = CurFBLineBOSSID(lineID)
    key = ShareDefine.Def_Notify_WorldKey_GameWorldBossReborn % bossID
    GameWorld.GetGameWorld().SetGameWorldDict(key, 1)
    GameWorld.DebugLog('    ˢBOSSbossID=%s' % bossID)
    refreshIDList = FBCommon.GetFBLineRefreshNPC(ChConfig.Def_FBMapID_SealDemon, lineID)
    if refreshIDList:
        for refreshID in refreshIDList:
@@ -136,11 +131,11 @@
        FBCommon.SetFBPropertyMark(lineID)
    else:
        lineID = GameWorld.GetGameWorld().GetPropertyID() - 1    
    gameFB = GameWorld.GetGameFB()
    playerCnt = GameWorld.GetGameWorld().GetMapCopyPlayerManager().GetPlayerCount()
    GameWorld.DebugLog("DoEnterFB...playerCnt=%s,lineID=%s" % (playerCnt, lineID), playerID)
    if lineID < 0:
    overTick = gameFB.GetGameFBDictByKey(FBDict_IsOver)
    if lineID < 0 or overTick:
        PlayerControl.PlayerLeaveFB(curPlayer)
        return
    hadDelTicket = FBCommon.GetHadDelTicket(curPlayer)
@@ -164,9 +159,8 @@
                PlayerControl.PlayerLeaveFB(curPlayer)
                return
        UpdateHurtInfo(curPlayer, 0, True)
    
    UpdateHPReduceSpeed(tick)
    gameFB = GameWorld.GetGameFB()
    # 上鼓舞buff
    encourageLV = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_EncourageLV)
    if encourageLV > 0:
@@ -174,7 +168,7 @@
    else:
        FBCommon.SendFBEncourageInfo(curPlayer, encourageLV)
        
    #DoFBHelp(curPlayer, tick)
    DoFBHelp(curPlayer, tick)
    return
##关闭副本
@@ -183,11 +177,7 @@
# @remarks 
def OnCloseFB(tick):
    gameWorld = GameWorld.GetGameWorld()
    lineID = gameWorld.GetPropertyID() - 1
    gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, 0)
    gameWorld.SetGameWorldDict(FBDict_Speed % lineID, 0)
    gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, 0)
    gameWorld.SetPropertyID(0)
    return
@@ -207,13 +197,10 @@
            lineID = gameWorld.GetPropertyID() - 1
            PyGameData.g_sealDemonPlayerHurtDict[lineID] = {}
            g_npcHurtDict[lineID] = {}
            gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, 0)
            GameWorld.GetGameFB().ClearGameFBDict()
            GameWorldProcess.CloseFB(tick)
            return
        
    UpdateHPReduceSpeed(tick, True)
    return
##玩家主动离开副本.
@@ -274,12 +261,8 @@
        hurtDict["hurtEx"] = hurt / ChConfig.Def_PerPointValue
        hurtInfo.append(hurtDict)
    
    curSpeed = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_Speed % lineID)
    remainHP = GetBossRemainHP(lineID, tick)
    totalHP = __GetBossTotalHP()
    hpReduceSpeed = curSpeed * 10000 / totalHP if totalHP else 0
    remainHPPer = min(100, remainHP * 100 / totalHP) if totalHP else 0
    fbHelpDict = {FBCommon.Help_lineID:lineID, "hurtInfo":hurtInfo, 'hpReduceSpeed':hpReduceSpeed, 'remainHPPer':remainHPPer}
    fbHelpDict = {FBCommon.Help_lineID:lineID, "hurtInfo":hurtInfo}
    GameWorld.DebugLog("DoFBHelp: %s" % fbHelpDict, curPlayer.GetPlayerID())
    FBCommon.Notify_FBHelp(curPlayer, fbHelpDict)
    return
@@ -388,50 +371,43 @@
    lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
    if lineID <0:
        return
    gameWorld = GameWorld.GetGameWorld()
    startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID)
    if not startTick:
        return
    FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 5000)
    __CheckBossHP(tick)
    
    return
def __CheckBossHP(tick):
    gameFB = GameWorld.GetGameFB()
    isOver = gameFB.GetGameFBDictByKey(FBDict_IsOver)
def DoFB_Npc_KillNPC(attacker, curNPC, tick):
    __FBNPCOnKilled(curNPC, tick)
    return
def DoFB_Player_KillNPC(curPlayer, curNPC, tick):
    __FBNPCOnKilled(curNPC, tick)
    return
## 执行副本杀怪逻辑
def __FBNPCOnKilled(curNPC, tick):
    lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
    bossID = CurFBLineBOSSID(lineID)
    if curNPC.GetNPCID() != bossID:
        return
    dropPosX, dropPosY = curNPC.GetPosX(), curNPC.GetPosY()
    FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
    GameWorld.DebugLog('结束 设置BOSS死亡 lineID=%s' % lineID)
    newbielineList = IpyGameDataPY.GetFuncEvalCfg('SealDemonNewbieLine')
    isNewbieLine = lineID in newbielineList
    if not isOver and GetBossRemainHP(lineID, tick) == 0:
        guardNPCIDList = __GetGuardNPCIDList(lineID)
        bossID = CurFBLineBOSSID(lineID)
        curBoss = GameWorld.FindNPCByNPCID(bossID)
        dropPosX, dropPosY = 0, 0
        if curBoss:
            dropPosX, dropPosY = curBoss.GetPosX(), curBoss.GetPosY()
        #结束 设置BOSS死亡
        FBCommon.ClearFBNPC(guardNPCIDList)
        FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
        GameWorld.DebugLog('结束 设置BOSS死亡 lineID=%s' % lineID)
    if not isNewbieLine:
        playerHurtList = __GetSortHurtList(lineID)
        if not isNewbieLine:
            if playerHurtList:
                killerName, hurtValue = playerHurtList[0][1]
                NPCCommon.GameServer_KillGameWorldBoss(bossID, killerName, hurtValue)
        if playerHurtList:
            killerName, hurtValue = playerHurtList[0][1]
            NPCCommon.GameServer_KillGameWorldBoss(bossID, killerName, hurtValue)
            
            msgList = [bossID, 0]
            GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'GameWorldBossState',
                                                                '%s' % (msgList), len(str(msgList)))
            bosskey = ShareDefine.Def_Notify_WorldKey_GameWorldBossReborn % bossID
            GameWorld.GetGameWorld().SetGameWorldDict(bosskey, 0)
        __DoLogicSealDemonOver(1, tick, dropPosX, dropPosY)
        gameFB.SetGameFBDict(FBDict_IsOver, tick)
        NPCCommon.GameServe_GameWorldBossState(bossID, 0)
        
    __DoLogicSealDemonOver(1, tick, dropPosX, dropPosY)
    GameWorld.GetGameFB().SetGameFBDict(FBDict_IsOver, tick)
    return
def __GetSortHurtList(lineID):
    playerHurtDict = PyGameData.g_sealDemonPlayerHurtDict.get(lineID, {})
@@ -476,6 +452,9 @@
def GiveSealDemonAward(curPlayer, lineID, rank, isMail=False, isClientSend=False, dropItemMapInfo=[]):
    newbielineList = IpyGameDataPY.GetFuncEvalCfg('SealDemonNewbieLine')
    isNewbieLine = lineID in newbielineList
    sealDemonIpyData = GetSealDemonIpyData(lineID)
    if not sealDemonIpyData:
        return {}
    prizeMultiple = 1
    addCnt = 1
    if isNewbieLine:
@@ -486,17 +465,19 @@
    elif isClientSend:
        return {}
    else:
        prizeMultiple = 2 if rank == 1 else 1 # 第一名执行双倍掉落奖励,其他一次
        #prizeMultiple = 2 if rank == 1 else 1 # 第一名执行双倍掉落奖励,其他一次
        prizeMultiple = 1 # 去除第一名双倍逻辑,改为放在额外奖励产出
        isDouble = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FMTDouble)
        if isDouble:
            addCnt = 2
    equipList = []
    prizeItemDict ={}
    bossID = CurFBLineBOSSID(lineID)
    extraItemList = sealDemonIpyData.GetOwnerAwardItemEx() * addCnt if rank == 1 else []
    #for _ in xrange(addCnt):
    jsonItemList, totalExp, totalMoney = NPCCommon.GiveKillNPCDropPrize(curPlayer, ChConfig.Def_FBMapID_SealDemon, {bossID:addCnt}, 
                                                                        mailTypeKey="SealDemonMail", isMail=isMail, prizeMultiple=prizeMultiple,
                                                                        dropItemMapInfo=dropItemMapInfo)
                                                                        mailTypeKey="SealDemonMail", isMail=isMail, extraItemList=extraItemList, prizeMultiple=prizeMultiple,
                                                                        dropItemMapInfo=dropItemMapInfo,isVirtualDrop=isClientSend)
    for jsonItem in jsonItemList:
        if 'UserData' in jsonItem:
            equipList.append(jsonItem)
@@ -508,21 +489,6 @@
                       % (lineID, bossID, rank, totalExp, totalMoney, jsonItemList), curPlayer.GetPlayerID())
    
    prizeItemList = equipList + FBCommon.GetJsonItemList(prizeItemDict.items())
    #===============================================================================================
    # if not isMail:
    #    for itemDict in prizeItemList:
    #        itemID = itemDict["ItemID"]
    #        itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
    #        if not itemData:
    #            continue
    #        userData = itemDict.get("UserData", '')
    #        equipInfo = [itemData.GetEquipPlace(), ItemCommon.GetItemClassLV(itemData), itemData.GetItemColor(),
    #                 itemData.GetItemQuality(), userData]
    #        mapID = ChConfig.Def_FBMapID_SealDemon
    #        NPCCommon.SendGameServerGoodItemRecord(mapID, bossID, curPlayer.GetName(),
    #                                               curPlayer.GetPlayerID(), itemID, equipInfo)
    #===============================================================================================
    
    if rank == 1:
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FMTFirst, addCnt)
@@ -548,10 +514,12 @@
    if rank == 1 and lineID >= 4:
        EventShell.EventRespons_SealDemon(curPlayer)
    
    PlayerMagicWeapon.SetMWPrivilegeData(curPlayer, ChConfig.MWPrivilege_SealDemonAddAttr, addCnt, True)
    PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_FMT, addCnt)
    PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_FMT, addCnt)
    PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_FMT, addCnt)
    PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_FMT, addCnt)
    PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_FMT, addCnt)
    return prizeItemList
def OnPickUpItem(curPlayer, curItem, tick):
@@ -608,81 +576,24 @@
    GameWorld.DebugLog('封魔坛 客户端副本发送结束mapID=%s,lineID=%s,dataList=%s' % (mapID,lineID,dataList), curPlayer.GetPlayerID())
    rank, hurt = dataList[:2]
    prizeItemList = GiveSealDemonAward(curPlayer, lineID, rank, False, True, [curPlayer.GetPosX(), curPlayer.GetPosY(), True])
    if rank == 1:
    if rank == 1 and prizeItemList:
        bossID = CurFBLineBOSSID(lineID)
        NPCCommon.GameServer_KillGameWorldBoss(bossID, curPlayer.GetName(), hurt, False)
    if not prizeItemList:
        leaveTick = FBCommon.GetFBLineStepTime(mapID, lineID) * 1000
        GameWorld.Log("没有奖励,直接通知前端结算!mapID=%s,lineID=%s" % (mapID, lineID), curPlayer.GetPlayerID())
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True)
        overDict = {FBCommon.Over_rank:rank, FBCommon.Over_itemInfo:prizeItemList}
        FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_SealDemon, lineID, 1, overDict)
        return
    gameFB = GameWorld.GetGameFB()
    tick = GameWorld.GetGameWorld().GetTick()
    gameFB.SetGameFBDict(FBDict_IsOver, tick)
    gameFB.SetPlayerGameFBDict(curPlayer.GetPlayerID(), FBPlayerDict_Rank, rank)
    curPlayer.Sync_TimeTick(ChConfig.tttPickupItem, 0, ChConfig.Def_FBPickupItemTime, True)
    #GameWorld.Log("通知前端结算!mapID=%s,lineID=%s" % (mapID, lineID), curPlayer.GetPlayerID())
    overDict = {FBCommon.Over_rank:rank, FBCommon.Over_itemInfo:prizeItemList}
    FBCommon.NotifyFBOver(curPlayer, mapID, lineID, 1, overDict)
    PlayerControl.SetCustomMap(curPlayer, 0, 0)
    return
def UpdateHPReduceSpeed(tick, isExit=False):
    mapID = GameWorld.GetMap().GetMapID()
    if mapID == ChConfig.Def_FBMapID_SealDemonEx:
        return
    playerCnt = GameWorld.GetGameWorld().GetMapCopyPlayerManager().GetPlayerCount()
    playerCnt = playerCnt - 1 if isExit else playerCnt
    if playerCnt <=0:
        return
    lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
    if lineID < 0:
        return
    gameWorld = GameWorld.GetGameWorld()
    startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID)
    lastSpeed = gameWorld.GetGameWorldDictByKey(FBDict_Speed % lineID)
    remainHP = gameWorld.GetGameWorldDictByKey(FBDict_RemainHP % lineID)
    curSpeed = int(min(1 + 0.08 * (playerCnt - 1), 1.8) * 1000)
    if not startTick:
        startTick = tick
        lastSpeed = curSpeed
        remainHP = __GetBossTotalHP()
    remainHP = max(0, int((remainHP - (tick - startTick) / 1000.0 * lastSpeed)))
    gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, tick)
    gameWorld.SetGameWorldDict(FBDict_Speed % lineID, curSpeed)
    gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, remainHP)
    GameWorld.DebugLog('    curSpeed=%s, remainHP=%s, passTime=%s, lastSpeed=%s' % (curSpeed, remainHP, tick - startTick, lastSpeed))
    FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
    return
def __GetBossTotalHP():
    lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
    bossID = CurFBLineBOSSID(lineID)
    ipyData = IpyGameDataPY.GetIpyGameData('SealDemon', bossID)
    if not ipyData:
        return 0
    return ipyData.GetKillTime() * 1000
def GetBossRemainHP(lineID, tick):
    gameWorld = GameWorld.GetGameWorld()
    
    startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID)
    lastSpeed = gameWorld.GetGameWorldDictByKey(FBDict_Speed % lineID)
    remainHP = gameWorld.GetGameWorldDictByKey(FBDict_RemainHP % lineID)
    if not startTick:
        startTick = tick
        remainHP = __GetBossTotalHP()
    else:
        remainHP = max(0, int((remainHP - (tick - startTick) / 1000.0 * lastSpeed)))
    return remainHP
def GetBossRemainHPPer(lineID, tick):
    remainHP = GetBossRemainHP(lineID, tick)
    totalHP = __GetBossTotalHP()
    if not totalHP:
        return 0
    return remainHP * 100 / totalHP
def GetBossRemainHPPer(copyMapID, funcLineID, tick):
    bossID = CurFBLineBOSSID(funcLineID)
    curBoss = GameWorld.FindNPCByNPCIDEx(copyMapID, bossID)
    if not curBoss:
        return 100
    return GameObj.GetHP(curBoss) * 100 / GameObj.GetMaxHP(curBoss)
def CurFBLineBOSSID(lineID= -1):
    #该分线刷的BOSSID
@@ -695,6 +606,14 @@
        return 0
    bossID = ipyData.GetNPCID()
    return bossID
def GetSealDemonIpyData(lineID= -1):
    #该分线刷的BOSSID
    if lineID == -1:
        lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
    if lineID == -1:
        return
    return IpyGameDataPY.GetIpyGameDataByCondition('SealDemon', {'LineID':lineID})
##玩家死亡.
# @param curPlayer:死亡的玩家 
@@ -728,4 +647,3 @@
    packData.OldDouble = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FMTOldDouble)
    NetPackCommon.SendFakePack(curPlayer, packData)
    return