| | |
| | | elif defObj.GetType() == ChConfig.ntHelpBattleRobot:
|
| | | remainHP = min(dHP, max(GameObj.GetMaxHP(defObj)/2, remainHP)) # 助战机器人剩余血量不能少于一半
|
| | | GameObj.SetHP(defObj, remainHP)
|
| | | |
| | | elif defObj.GetType() == ChConfig.ntMonsterTime:
|
| | | UpdateTimeMonsterHP(defObj, tick)
|
| | |
|
| | | else:
|
| | | #防守方是怪物NPC,只扣其血
|
| | |
| | |
|
| | | return resultHurtType
|
| | |
|
| | | def UpdateTimeMonsterHP(curNPC, tick):
|
| | | '''
|
| | | NPC总血量 = 单人每秒掉血量*理论击杀所需时间
|
| | | 掉血值 = 单人每秒掉血量*min(攻击人数, 最大人数)*衰减万分率/10000
|
| | | '''
|
| | | |
| | | npcID = curNPC.GetNPCID()
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("NPCTimeLostHP", npcID)
|
| | | if not ipyData:
|
| | | return
|
| | | |
| | | lastLostHPTick = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_TimeLostHPTick)
|
| | | curNPC.SetDict(ChConfig.Def_NPC_Dict_TimeLostHPTick, tick)
|
| | | if not lastLostHPTick or tick - lastLostHPTick >= 2000:
|
| | | passTick = 1000
|
| | | else:
|
| | | passTick = tick - lastLostHPTick
|
| | | |
| | | if passTick <= 0:
|
| | | return
|
| | | |
| | | 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)
|
| | | effPlayerCount = 0
|
| | | for i in xrange(curNPC.GetInSightObjCount()):
|
| | | seeObj = curNPC.GetInSightObjByIndex(i)
|
| | | if seeObj == None :
|
| | | continue
|
| | | if not seeObj.GetVisible():
|
| | | continue
|
| | | seeObjType = seeObj.GetGameObjType()
|
| | | if seeObjType == IPY_GameWorld.gotPlayer:
|
| | | effPlayerCount += 1
|
| | | curNPC.SetDict(ChConfig.Def_NPC_Dict_TimeLostHPPlayerCount, effPlayerCount)
|
| | | #GameWorld.DebugLog("刷新影响人数: effPlayerCount=%s" % effPlayerCount)
|
| | | |
| | | lostHPPerSecond = ipyData.GetLostHPPerSecond()
|
| | | maxPlayerCount = ipyData.GetMaxPlayerCount()
|
| | | reduceRate = ipyData.GetReduceRate()
|
| | | if effPlayerCount > 1:
|
| | | hurtValuePerSecond = lostHPPerSecond * min(maxPlayerCount, effPlayerCount) * reduceRate / 10000.0
|
| | | else:
|
| | | hurtValuePerSecond = lostHPPerSecond
|
| | | lostHPTotal = 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))
|
| | | return
|
| | |
|
| | | # 计算伤害后,因各种buff和状态的影响处理
|
| | | def CalcHurtHPWithBuff(atkObj, defObj, hurtValue, curSkill, tick):
|
| | | # 优先处理神兵护盾
|