hxp
2019-05-11 5759384f488b6bb4a99e6cddc6761a1ce6c94309
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/AttackCommon.py
@@ -1790,9 +1790,9 @@
def UpdateTimeMonsterHP(curNPC, ipyData, tick):
    '''
    NPC总血量 = 单人每秒掉血量*理论击杀所需时间
         掉血值 = 单人每秒掉血量+min(当前人数, 最大人数)*附加掉血量
         掉血值 = 单人每秒掉血量+min(当前人数, 最大人数)*附加掉血量+(有效战力-标准战力)/x战力*x战力附加掉血
    '''
    lastLostHPTick = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_TimeLostHPTick)
    curNPC.SetDict(ChConfig.Def_NPC_Dict_TimeLostHPTick, tick)
    if not lastLostHPTick or tick - lastLostHPTick >= 2000:
@@ -1806,11 +1806,17 @@
    lostHPPerSecond = ipyData.GetLostHPPerSecond()
    maxPlayerCount = ipyData.GetMaxPlayerCount()
    lostHPPerSecondEx = ipyData.GetLostHPPerSecondEx()
    fightPowerMin = ipyData.GetFightPowerMin()
    fightPowerMax = ipyData.GetFightPowerMax()
    everyFightPower = ipyData.GetEveryFightPower()
    everyFightPowerLostHPEx = ipyData.GetEveryFightPowerLostHPEx()
    
    effFightPower = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_TimeLostHPFightPower)
    effPlayerCount = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_TimeLostHPPlayerCount)
    refreshPlayerCountTick = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_TimeLostHPPlayerCountTick)
    if not refreshPlayerCountTick or tick - refreshPlayerCountTick >= 3000:
        curNPC.SetDict(ChConfig.Def_NPC_Dict_TimeLostHPPlayerCountTick, tick)
        fightPowerTotal = 0
        effPlayerCount = 0
        for i in xrange(curNPC.GetInSightObjCount()):
            seeObj = curNPC.GetInSightObjByIndex(i)
@@ -1819,24 +1825,43 @@
            if not seeObj.GetVisible():
                continue
            seeObjType = seeObj.GetGameObjType()
            if seeObjType == IPY_GameWorld.gotPlayer:
                effPlayerCount += 1
                if maxPlayerCount and effPlayerCount >= maxPlayerCount:
                    effPlayerCount = maxPlayerCount
                    break
            if seeObjType != IPY_GameWorld.gotPlayer:
                continue
            effPlayerCount += 1
            if fightPowerMin:
                seePlayer = GameWorld.GetObj(seeObj.GetID(), seeObjType)
                fightPowerTotal += (0 if not seePlayer else seePlayer.GetFightPower())
        effFightPower = int(fightPowerTotal / effPlayerCount)
        if fightPowerMax and effFightPower > fightPowerMax:
            effFightPower = fightPowerMax
        if maxPlayerCount and effPlayerCount > maxPlayerCount:
            effPlayerCount = maxPlayerCount
        curNPC.SetDict(ChConfig.Def_NPC_Dict_TimeLostHPFightPower, effFightPower)
        curNPC.SetDict(ChConfig.Def_NPC_Dict_TimeLostHPPlayerCount, effPlayerCount)
        #GameWorld.DebugLog("刷新影响人数: effPlayerCount=%s" % effPlayerCount)
        #GameWorld.DebugLog("刷新影响人数: effPlayerCount=%s,effFightPower=%s" % (effPlayerCount, effFightPower))
        
    hurtValuePerSecond = lostHPPerSecond
    #人数附加伤害
    if effPlayerCount > 1:
        hurtValuePerSecond = lostHPPerSecond + (effPlayerCount - 1) * lostHPPerSecondEx
    else:
        hurtValuePerSecond = lostHPPerSecond
    lostHPTotal = int(hurtValuePerSecond * passTick / 1000.0)
        playerCountHurtEx = (effPlayerCount - 1) * lostHPPerSecondEx
        hurtValuePerSecond += playerCountHurtEx
        #GameWorld.DebugLog("playerCountHurtEx=%s,hurtValuePerSecond=%s" % (playerCountHurtEx, hurtValuePerSecond))
    #战力附加伤害
    if fightPowerMin and effFightPower and everyFightPower and everyFightPowerLostHPEx:
        fightPowerHurtEx = (effFightPower - fightPowerMin) / float(everyFightPower) * everyFightPowerLostHPEx # 可能为负值
        hurtValuePerSecond += fightPowerHurtEx
        #GameWorld.DebugLog("fightPowerHurtEx=%s,hurtValuePerSecond=%s" % (fightPowerHurtEx, hurtValuePerSecond))
    lostHPTotal = max(1, int(hurtValuePerSecond * passTick / 1000.0))
    
    remainHP = min(GameObj.GetMaxHP(curNPC), max(0, GameObj.GetHP(curNPC) - lostHPTotal))
    GameObj.SetHP(curNPC, remainHP, isByTime=True)
    #GameWorld.DebugLog("怪物按时间掉血: npcID=%s,effPlayerCount=%s,hurtValuePerSecond=%s,passTick=%s,lostHPTotal=%s"
    #                   % (npcID, effPlayerCount, hurtValuePerSecond, passTick, lostHPTotal))
    #GameWorld.DebugLog("怪物按时间掉血: npcID=%s,effPlayerCount=%s,effFightPower=%s,hurtValuePerSecond=%s,passTick=%s,lostHPTotal=%s"
    #                   % (curNPC.GetNPCID(), effPlayerCount, effFightPower, hurtValuePerSecond, passTick, lostHPTotal))
    return
# 计算伤害后,因各种buff和状态的影响处理