| | |
| | | def UpdateTimeMonsterHP(curNPC, ipyData, tick):
|
| | | '''
|
| | | NPC总血量 = 单人每秒掉血量*理论击杀所需时间
|
| | | 掉血值 = 单人每秒掉血量+min(当前人数, 最大人数)*附加掉血量
|
| | | 掉血值 = 单人每秒掉血量+min(当前人数, 最大人数)*附加掉血量+(有效战力-标准战力)/x战力*x战力附加掉血
|
| | | '''
|
| | |
|
| | | lastLostHPTick = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_TimeLostHPTick)
|
| | |
| | | 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)
|
| | |
| | | if not seeObj.GetVisible():
|
| | | continue
|
| | | seeObjType = seeObj.GetGameObjType()
|
| | | if seeObjType == IPY_GameWorld.gotPlayer:
|
| | | if seeObjType != IPY_GameWorld.gotPlayer:
|
| | | continue
|
| | | effPlayerCount += 1
|
| | | if maxPlayerCount and effPlayerCount >= maxPlayerCount:
|
| | | effPlayerCount = maxPlayerCount
|
| | | break
|
| | | curNPC.SetDict(ChConfig.Def_NPC_Dict_TimeLostHPPlayerCount, effPlayerCount)
|
| | | #GameWorld.DebugLog("刷新影响人数: effPlayerCount=%s" % effPlayerCount)
|
| | | if fightPowerMin: |
| | | seePlayer = GameWorld.GetObj(seeObj.GetID(), seeObjType)
|
| | | fightPowerTotal += (0 if not seePlayer else seePlayer.GetFightPower())
|
| | |
|
| | | if effPlayerCount > 1:
|
| | | hurtValuePerSecond = lostHPPerSecond + (effPlayerCount - 1) * lostHPPerSecondEx
|
| | | else:
|
| | | 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,effFightPower=%s" % (effPlayerCount, effFightPower))
|
| | | |
| | | hurtValuePerSecond = lostHPPerSecond
|
| | | lostHPTotal = int(hurtValuePerSecond * passTick / 1000.0)
|
| | | #人数附加伤害
|
| | | if effPlayerCount > 1:
|
| | | 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和状态的影响处理
|