From 254193aa2af834a522c6847b6b85250427563961 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 12 四月 2019 10:34:20 +0800
Subject: [PATCH] 6459 【后端】【2.0】缥缈仙域开发单(增加按时间掉血的NPC支持)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/AttackCommon.py |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/AttackCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/AttackCommon.py
index 7884aa0..bd598f7 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/AttackCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/AttackCommon.py
@@ -1725,6 +1725,9 @@
         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,只扣其血
@@ -1756,6 +1759,59 @@
     
     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):
     # 优先处理神兵护盾

--
Gitblit v1.8.0