xdh
2019-05-24 58bb708f8c974e4cb37021b42a3f78a173438160
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_AllFamilyBoss.py
@@ -21,6 +21,7 @@
import GameWorldProcess
import IpyGameDataPY
import ChConfig
import PlayerBossReborn
import PyGameData
import PlayerControl
import ShareDefine
@@ -29,17 +30,12 @@
import ItemControler
import PlayerActivity
import EventReport
import GameObj
FBDict_StartTick = 'FBDict_StartTick'  #开始时间
FBDict_Speed = 'FBDict_Speed'  #掉血速度 /s
FBDict_RemainHP = 'FBDict_RemainHP'  #剩余时间
FBPlayerDict_EncourageLV = 'FBPlayerDict_EncourageLV'  # 鼓舞等级
FBDict_IsOver = 'FBDict_IsOver'  #是否已结算, 结算时的tick
FBDict_IsReduceing = 'FBDict_IsReduceing'  #是否掉血中
FBDict_BossTotalHP = 'FBDict_BossTotalHP'  #BOSS血量
FBDict_LastHurtTick = 'FBDict_LastHurtTick'  #上次伤害时间
FBDict_IsEncourage = 'FBDict_IsEncourage'  #是否鼓舞过
FBDict_LastHPNotify = 'FBDict_LastHPNotify'  #上一个血量广播
(
    Def_BossTime,  #BOSS时间
@@ -115,8 +111,6 @@
    if not bossID:
        return
    NPCCustomRefresh.SetNPCRefresh(101, [bossID])
    BossTime = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_AllFamilyBoss, lineID)[Def_BossTime]
    GameWorld.GetGameWorld().SetGameWorldDict(FBDict_BossTotalHP, BossTime * 1000)
    return
@@ -128,7 +122,7 @@
    GameWorld.DebugLog('    多仙盟BOSS活动状态变更 state=%s' % state)
    if not state:
        if GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_StartTick) and not GameWorld.GetGameFB().GetGameFBDictByKey(FBDict_IsOver):
        if not GameWorld.GetGameFB().GetGameFBDictByKey(FBDict_IsOver):
            GameWorld.GetGameFB().SetGameFBDict(FBDict_IsOver, tick)
            __DoLogicAllFamilyBossOver(0, tick)
    return
@@ -151,10 +145,9 @@
    if not hadDelTicket:
        FBCommon.SetHadDelTicket(curPlayer)
        FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_AllFamilyBoss, 1)
        if lineID == 0:
            PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_FamilyBoss1, 1)
        else:
            PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_FamilyBoss2, 1)
        PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_FamilyBoss1, 1)
        PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_FamilyBoss, 1)
        if fbStep == FB_Step_Open:
            FBCommon.SetFBStep(FB_Step_Fighting, tick)
@@ -168,7 +161,6 @@
    elif playerID not in PyGameData.g_allfamilyBossDict[familyID][2]:
        PyGameData.g_allfamilyBossDict[familyID][2].append(playerID)
    
    UpdateHPReduceSpeed(tick)
    gameFB = GameWorld.GetGameFB()
    # 上鼓舞buff
    encourageLV = gameFB.GetPlayerGameFBDictByKey(familyID, FBPlayerDict_EncourageLV)
@@ -188,10 +180,6 @@
def OnCloseFB(tick):
    gameWorld = GameWorld.GetGameWorld()
    gameWorld.SetGameWorldDict(FBDict_StartTick, 0)
    gameWorld.SetGameWorldDict(FBDict_Speed, 0)
    gameWorld.SetGameWorldDict(FBDict_RemainHP, 0)
    gameWorld.SetGameWorldDict(FBDict_IsReduceing, 0)
    gameWorld.SetPropertyID(0)
    PyGameData.g_allfamilyBossDict = {}
    return
@@ -213,8 +201,6 @@
#        GameWorldProcess.CloseFB(tick)
#        return
        
    UpdateHPReduceSpeed(tick, True)
    return
@@ -231,13 +217,6 @@
        if playerID in familyHurtInfo[2]:
            familyHurtInfo[2].remove(playerID)
            FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
    return
##玩家切换地图
def DoPlayerChangeMapLogic(curPlayer):
    #FBCommon.SetHadDelTicket(curPlayer, 0)
    return
@@ -272,17 +251,11 @@
            hurtDict["hurt"] = hurt % ChConfig.Def_PerPointValue
            hurtDict["hurtEx"] = hurt / ChConfig.Def_PerPointValue
            hurtInfo.append(hurtDict)
    curSpeed = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_Speed)
    isReduceing = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_IsReduceing)
    remainHP = GetBossRemainHP(tick)
    totalHP = __GetBossTotalHP()
    hpReduceSpeed = curSpeed * 10000 / totalHP if totalHP else 0
    remainHPPer = min(1000000, remainHP * 1000000 / totalHP) if totalHP else 0
    remainHPPer = GetBossRemainHPPer(0, tick)
    playerID = curPlayer.GetPlayerID()
    IsEncourage = GameWorld.GetGameFB().GetPlayerGameFBDictByKey(playerID, FBDict_IsEncourage)
    fbHelpDict = {"hurtInfo":hurtInfo, 'hpReduceSpeed':hpReduceSpeed, 'IsEncourage':IsEncourage,
                  'remainHPPer':remainHPPer, 'isReduceing':isReduceing, 'myHurt':myHurt % ChConfig.Def_PerPointValue,
    fbHelpDict = {"hurtInfo":hurtInfo, 'IsEncourage':IsEncourage,'remainHPPer':remainHPPer,
                  'myHurt':myHurt % ChConfig.Def_PerPointValue,
                  'myHurtEx':myHurt / ChConfig.Def_PerPointValue, 'myRank':myRank, 'myMenberCnt':myMenberCnt
                  }
    GameWorld.DebugLog("DoFBHelp: %s" % fbHelpDict, playerID)
@@ -319,7 +292,6 @@
#  @return None
def DoFB_Player_HurtNPC(curPlayer, curNPC, hurtHP):
    UpdateHurtInfo(curPlayer, hurtHP)
    GameWorld.GetGameFB().SetGameFBDict(FBDict_LastHurtTick, GameWorld.GetGameWorld().GetTick())
    return
@@ -332,8 +304,6 @@
    PyGameData.g_allfamilyBossDict[familyID][1] += hurtHP
        
    #有人上榜开始掉血
    StartReduceHP(GameWorld.GetGameWorld().GetTick())
    return
@@ -360,16 +330,10 @@
            return
    
    elif fbStep == FB_Step_Fighting:
        startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick)
        if not startTick or overTick:
        if overTick:
            return
        lastHurtTick = gameFB.GetGameFBDictByKey(FBDict_LastHurtTick)
        if lastHurtTick and tick - lastHurtTick >= 2000:
            StopReduceHP(tick)
            gameFB.SetGameFBDict(FBDict_LastHurtTick, 0)
                
        FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 5000)
        __CheckBossHP(tick)
        
    return
@@ -490,122 +454,35 @@
    return familyAuctionItemList, menberItemList
def __CheckBossHP(tick):
    gameFB = GameWorld.GetGameFB()
    isOver = gameFB.GetGameFBDictByKey(FBDict_IsOver)
    if not isOver:
        if GetBossRemainHP(tick) == 0:
            #结束 设置BOSS死亡
            FBCommon.ClearFBNPC()
            FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
            GameWorld.DebugLog('结束 设置BOSS死亡')
            gameFB.SetGameFBDict(FBDict_IsOver, tick)
            __DoLogicAllFamilyBossOver(1, tick)
        else:
            #血量广播
            needNotifyHPPerList = [50, 20]
            lastIndex = gameFB.GetGameFBDictByKey(FBDict_LastHPNotify)
            if lastIndex >= len(needNotifyHPPerList):
                return
            remainPer = GetBossRemainHPPer(tick)
            notifyHPPer = needNotifyHPPerList[lastIndex]
            if remainPer == notifyHPPer or remainPer - 1 == notifyHPPer:
                gameFB.SetGameFBDict(FBDict_LastHPNotify, lastIndex + 1)
                lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
                bossID = CurFBLineBOSSID(lineID)
                msgMark = 'AllianceBossHP1' if lineID == 0 else 'AllianceBossHP2'
                PlayerControl.WorldNotify(0, msgMark, [bossID, remainPer])
def DoFB_Npc_KillNPC(attacker, curNPC, tick):
    __FBNPCOnKilled(curNPC, tick)
    return
def DoFB_Player_KillNPC(curPlayer, curNPC, tick):
    __FBNPCOnKilled(curNPC, tick)
    return
def UpdateHPReduceSpeed(tick, isExit=False):
    gameWorld = GameWorld.GetGameWorld()
    playerCnt = gameWorld.GetMapCopyPlayerManager().GetPlayerCount()
    playerCnt = playerCnt - 1 if isExit else playerCnt
    if playerCnt <= 0:
        return
## 执行副本杀怪逻辑
def __FBNPCOnKilled(curNPC, tick):
    lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
    if lineID < 0:
    bossID = CurFBLineBOSSID(lineID)
    if curNPC.GetNPCID() != bossID:
        return
    curSpeed = eval(FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_AllFamilyBoss, lineID)[Def_HPSpeed])
    gameWorld.SetGameWorldDict(FBDict_Speed, curSpeed)
    if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing):
        return
    startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick)
    remainHP = gameWorld.GetGameWorldDictByKey(FBDict_RemainHP)
    lastSpeed = gameWorld.GetGameWorldDictByKey(FBDict_Speed)
    if not startTick:
        startTick = tick
        lastSpeed = curSpeed
        remainHP = __GetBossTotalHP()
    remainHP = max(0, int((remainHP - (tick - startTick) / 1000.0 * lastSpeed)))
    gameWorld.SetGameWorldDict(FBDict_StartTick, tick)
    gameWorld.SetGameWorldDict(FBDict_RemainHP, remainHP)
    GameWorld.DebugLog('    curSpeed=%s, remainHP=%s, passTime=%s, lastSpeed=%s' % (curSpeed, remainHP, tick - startTick, lastSpeed))
    FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
    return
    GameWorld.DebugLog('结束 设置BOSS死亡')
def StopReduceHP(tick):
    ##暂停BOSS血量减少
    gameWorld = GameWorld.GetGameWorld()
    if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing):
        return
    remainHP = GetBossRemainHP(tick)
    if not remainHP:
        return
    gameWorld.SetGameWorldDict(FBDict_IsReduceing, 0)
    gameWorld.SetGameWorldDict(FBDict_RemainHP, remainHP)
    return
def StartReduceHP(tick):
    ##开始BOSS掉血
    gameWorld = GameWorld.GetGameWorld()
    if gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing):
        return
    gameWorld.SetGameWorldDict(FBDict_IsReduceing, 1)
    startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick)
    if not startTick:
        gameWorld.SetGameWorldDict(FBDict_RemainHP, __GetBossTotalHP())
    gameWorld.SetGameWorldDict(FBDict_StartTick, tick)
    FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
    return
def __GetBossTotalHP():return GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_BossTotalHP)
    GameWorld.GetGameFB().SetGameFBDict(FBDict_IsOver, tick)
    
def GetBossRemainHP(tick):
    gameWorld = GameWorld.GetGameWorld()
    startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick)
    lastSpeed = gameWorld.GetGameWorldDictByKey(FBDict_Speed)
    remainHP = gameWorld.GetGameWorldDictByKey(FBDict_RemainHP)
    if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing):
        return remainHP if startTick else __GetBossTotalHP()
    if not startTick:
        startTick = tick
        remainHP = __GetBossTotalHP()
    else:
        remainHP = max(0, int((remainHP - (tick - startTick) / 1000.0 * lastSpeed)))
    return remainHP
    __DoLogicAllFamilyBossOver(1, tick)
    return
def GetBossRemainHPPer(tick):
    remainHP = GetBossRemainHP(tick)
    totalHP = __GetBossTotalHP()
    if not totalHP:
        return 0
    return remainHP * 100 / totalHP
def GetBossRemainHPPer(copyMapID, tick):
    bossID = CurFBLineBOSSID()
    curBoss = GameWorld.FindNPCByNPCIDEx(copyMapID, bossID)
    if not curBoss:
        return 100
    return GameObj.GetHP(curBoss) * 100 / GameObj.GetMaxHP(curBoss)
def CurFBLineBOSSID(lineID=-1):