From ce1444c541211107fa3300d75982ae36589b5451 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 31 十月 2025 15:01:22 +0800
Subject: [PATCH] 165 【挑战】天子的考验-服务端(优化生命条变更时B419同步最新当前生命最大生命;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py                    |    4 +-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py                           |   68 ++++++++++++++++++++++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py                         |   15 ++++---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/TurnFight.py                     |    3 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/TurnSkill.py                           |   12 ++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_Tianzi.py |   10 +++--
 6 files changed, 98 insertions(+), 14 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
index 487394d..daf0220 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
@@ -935,7 +935,8 @@
     
     # 玩家
     if tagType == 1:
-        OnTurnFightVSPlayer(curPlayer, mapID, funcLineID, atkLineupID, defLineupID, tagID)
+        if not OnTurnFightVSPlayer(curPlayer, mapID, funcLineID, atkLineupID, defLineupID, tagID):
+            return
         
     # NPC
     else:
@@ -950,9 +951,10 @@
             if not ret:
                 return
             npcLineupIDList, strongerLV, difficulty = ret
-        OnTurnFightVSNPC(curPlayer, mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty)
+        if not OnTurnFightVSNPC(curPlayer, mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty):
+            return
         
-    return
+    return True
 
 def OnTurnFightVSNPC(curPlayer, mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty):
     playerID = curPlayer.GetPlayerID()
@@ -999,7 +1001,7 @@
     PlayerOnline.GetOnlinePlayer(curPlayer).SetLastBatBuffer(guid, turnFight.batBuffer)
     SyncTurnFightReport(curPlayer, guid, turnFight.batBuffer)
     tfMgr.delTurnFight(guid)
-    return
+    return True
 
 def OnTurnFightVSPlayer(curPlayer, mapID, funcLineID, atkLineupID, defLineupID, tagPlayerID):
     playerID = curPlayer.GetPlayerID()
@@ -1037,7 +1039,7 @@
     PlayerOnline.GetOnlinePlayer(curPlayer).SetLastBatBuffer(guid, turnFight.batBuffer)
     SyncTurnFightReport(curPlayer, guid, turnFight.batBuffer)
     tfMgr.delTurnFight(guid)
-    return
+    return True
 
 def GetTurnMax(mapID):
     if mapID == ChConfig.Def_FBMapID_Main:
@@ -1396,7 +1398,6 @@
 def TurnFightPerTurnBigStart(turnFight, turnNum):
     ## 大回合开始时
     
-    
     batObjMgr = BattleObj.GetBatObjMgr()
     for faction, num in turnFight.actionSortList:
         GameWorld.DebugLog("大回合开始逻辑: turnNum=%s,faction=%s, num=%s" % (turnNum, faction, num))
@@ -1659,7 +1660,7 @@
     
     # 非主线的PVE目标怪物
     if npcID and curPlayer and turnFight.isFBMap() and gameObj.GetFaction() != ChConfig.Def_FactionA:
-        if not FBLogic.OnFBNPCKilledBefore(curPlayer, turnFight, gameObj, killer):
+        if not FBLogic.OnFBNPCKilledBefore(curPlayer, turnFight, gameObj, killer, useSkill):
             return
         
     objID = gameObj.GetID()
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index 52a1641..be577ed 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -38956,6 +38956,74 @@
 
 
 #------------------------------------------------------
+# B4 19 对象最新生命刷新 #tagSCObjHPRefresh
+
+class  tagSCObjHPRefresh(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ("ObjID", c_int),    
+                  ("HP", c_int),    # 当前血量,求余20亿部分
+                  ("HPEx", c_int),    # 当前血量,整除20亿部分
+                  ("MaxHP", c_int),    # 最大血量,求余20亿部分
+                  ("MaxHPEx", c_int),    # 最大血量,整除20亿部分
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xB4
+        self.SubCmd = 0x19
+        return
+
+    def ReadData(self, stringData, _pos=0, _len=0):
+        self.Clear()
+        memmove(addressof(self), stringData[_pos:], self.GetLength())
+        return _pos + self.GetLength()
+
+    def Clear(self):
+        self.Cmd = 0xB4
+        self.SubCmd = 0x19
+        self.ObjID = 0
+        self.HP = 0
+        self.HPEx = 0
+        self.MaxHP = 0
+        self.MaxHPEx = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagSCObjHPRefresh)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// B4 19 对象最新生命刷新 //tagSCObjHPRefresh:
+                                Cmd:%s,
+                                SubCmd:%s,
+                                ObjID:%d,
+                                HP:%d,
+                                HPEx:%d,
+                                MaxHP:%d,
+                                MaxHPEx:%d
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd,
+                                self.ObjID,
+                                self.HP,
+                                self.HPEx,
+                                self.MaxHP,
+                                self.MaxHPEx
+                                )
+        return DumpString
+
+
+m_NAtagSCObjHPRefresh=tagSCObjHPRefresh()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagSCObjHPRefresh.Cmd,m_NAtagSCObjHPRefresh.SubCmd))] = m_NAtagSCObjHPRefresh
+
+
+#------------------------------------------------------
 # B4 18 对象属性刷新展示 #tagSCObjPropertyRefreshView
 
 class  tagSCObjPropertyRefreshView(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/TurnFight.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/TurnFight.py
index acfbbf3..f32029a 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/TurnFight.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/TurnFight.py
@@ -67,7 +67,8 @@
     clientData.TagID = tagPlayerID
     index = curPlayer.GetIndex()
     tick = GameWorld.GetGameWorld().GetTick()
-    TurnAttack.OnTurnFight(index, clientData, tick)
+    if not TurnAttack.OnTurnFight(index, clientData, tick):
+        GameWorld.DebugAnswer(curPlayer, "请求失败,详见服务器日志!")
     return
 
 def __doSetAttr(curPlayer, msgList):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
index eb0a5e2..fb10f06 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
@@ -2283,7 +2283,7 @@
     
     return callFunc(curPlayer, turnFight, npcObj)
 
-def OnFBNPCKilledBefore(curPlayer, turnFight, gameObj, killer):
+def OnFBNPCKilledBefore(curPlayer, turnFight, gameObj, killer=None, useSkill=None):
     ## 副本NPC被击杀前处理,一般用于处理一些不被击杀的副本NPC逻辑
     # @return: 可否被正常击杀
     do_FBLogic_ID = __GetFBLogic_MapID(turnFight.mapID)
@@ -2293,7 +2293,7 @@
         # 不需要逻辑时默认可被正常击杀
         return True
     
-    return callFunc(curPlayer, turnFight, gameObj, killer)
+    return callFunc(curPlayer, turnFight, gameObj, killer, useSkill)
 
 def OnPlayerLineupAttackResult(curPlayer, atkObj, killObjList, useSkill, mapID, funcLineID):
     ## 回合战斗主动发起的玩家阵容攻击结果额外处理 ,一般处理副本相关的掉落、奖励等
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_Tianzi.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_Tianzi.py
index e3abe52..f700730 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_Tianzi.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_Tianzi.py
@@ -27,6 +27,7 @@
 import ShareDefine
 import PlayerMail
 import DBDataMgr
+import TurnSkill
 import ObjPool
 
 def OnDay():
@@ -90,7 +91,7 @@
         return {}
     return __getBossAttrDict(ipyDataList[0])
 
-def OnFBNPCKilledBefore(curPlayer, turnFight, gameObj, killer):
+def OnFBNPCKilledBefore(curPlayer, turnFight, gameObj, killer=None, useSkill=None):
     ## 副本NPC被击杀前处理,一般用于处理一些不被击杀的副本NPC逻辑
     # @return: 可否被正常击杀
     
@@ -120,11 +121,12 @@
         GameWorld.Log("天子考验全部血条被击杀! totalHPMax=%s,statDefValueTotal=%s" % (totalHPMax, statDefValueTotal))
         return True
     
-    gameObj.SetMaxHP(ipyDataNow.GetMaxHP(), True)
-    gameObj.SetHP(hp, True)
+    gameObj.SetMaxHP(ipyDataNow.GetMaxHP(), False)
+    gameObj.SetHP(hp, False)
     GameWorld.DebugLog("更新NPC血条: hpNum=%s,hp=%s/%s, statDefValueTotal=%s" % (hpNum, gameObj.GetHP(), gameObj.GetMaxHP(), statDefValueTotal))
+    TurnSkill.Sync_HPRefresh(turnFight, gameObj)
     turnFight.SetDict("hpNum", hpNum)
-    turnFight.syncHelp({"hpNum":hpNum})
+    #turnFight.syncHelp({"hpNum":hpNum})
     gameObj.UpdInitBatAttr(__getBossAttrDict(ipyDataNow))
     return False
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/TurnSkill.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/TurnSkill.py
index 2aff7ab..775dd50 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/TurnSkill.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/TurnSkill.py
@@ -2051,3 +2051,15 @@
     clientPack.RelatedSkillID = relatedSkillID
     turnFight.addBatPack(clientPack)
     return
+
+def Sync_HPRefresh(turnFight, curBatObj):
+    hp, maxHP = curBatObj.GetHP(), curBatObj.GetMaxHP()
+    clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCObjHPRefresh)
+    clientPack.ObjID = curBatObj.GetID()
+    clientPack.HP = hp % ShareDefine.Def_PerPointValue
+    clientPack.HPEx = hp / ShareDefine.Def_PerPointValue
+    clientPack.MaxHP = maxHP % ShareDefine.Def_PerPointValue
+    clientPack.MaxHPEx = maxHP / ShareDefine.Def_PerPointValue
+    turnFight.addBatPack(clientPack)
+    return
+    
\ No newline at end of file

--
Gitblit v1.8.0