From c60cba7154e4f968ea23060de3c7c49b60d86e36 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 11 六月 2019 17:23:44 +0800
Subject: [PATCH] 860312 属性刷新修复

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py |   98 ++++++++++++++++++++++++++++++++-----------------
 1 files changed, 64 insertions(+), 34 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
index 898b782..52b00b2 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
@@ -260,6 +260,8 @@
     if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene):
         PlayerFB.DoExitCustomScene(curPlayer)
         
+    PetControl.DoLogic_PetLoadMapOK(curPlayer)
+    
     msgInfo = ""
     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetPlayerID(), 0, 0, "RefreshMainServerRole", msgInfo, len(msgInfo))
     return
@@ -1032,12 +1034,15 @@
     #切地图要清除的buff
     __CheckClearBuffOnMapChange(curPlayer, tick)
             
+    #上线和切地图加有限无敌Buff
+    if curPlayer.GetLV() > 50:
+        SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, ChConfig.Def_SkillID_LimitSuperBuff, tick)
+            
     #刷新玩家的视野
-    if not GameWorld.IsCrossServer() and (PlayerControl.GetCrossMapID(curPlayer) or curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene)):
+    if not GameWorld.IsCrossServer() and (PlayerControl.GetCrossMapID(curPlayer) or PlayerControl.GetCustomMapID(curPlayer)):
         GameWorld.DebugLog("===登录本服地图时,处于跨服或自定义场景状态,不刷新视野!", curPlayer.GetPlayerID())
         PlayerControl.SetPlayerSightLevel(curPlayer, curPlayer.GetID())
-    if curPlayer.GetLV() > 1:
-        PlayerState.ChangePlayerSigh(curPlayer, tick)
+    PlayerState.ChangePlayerSigh(curPlayer, tick)
     
     if GameWorld.IsCrossServer():
         curPlayer.SetForbiddenSyncClientState(False)
@@ -1381,10 +1386,6 @@
     #if not __CheckGMCanLoadMapOK(curPlayer):
     #    return
     
-    #上线和切地图加有限无敌Buff, 移到切换地图成功,太早发包客户端不显示
-    if curPlayer.GetLV() > 50:
-        SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, ChConfig.Def_SkillID_LimitSuperBuff, tick)
-    
     
     #检测账号是否锁定
     if not __CheckForbidLogin(curPlayer):
@@ -1404,10 +1405,10 @@
         #刷新自己的视野
         if not GameWorld.IsCrossServer() and (PlayerControl.GetCrossMapID(curPlayer) or curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene)):
             GameWorld.DebugLog("===本服LoadMapOK时玩家处于跨服或自定义场景状态,不设置可见!", curPlayer.GetPlayerID())
-        else:
-            curPlayer.RefreshView()
-            curPlayer.SetVisible(True)
-    
+            PlayerControl.SetPlayerSightLevel(curPlayer, curPlayer.GetID())
+        curPlayer.RefreshView()
+        curPlayer.SetVisible(True)
+        
     #如果玩家hp为0,设置玩家为死亡状态
     if curPlayer.GetHP() <= 0:
         curPlayer.SetPlayerAction(IPY_GameWorld.paDie)
@@ -1738,13 +1739,37 @@
         return
     isFree = curPlayer.GetLV() < IpyGameDataPY.GetFuncCfg('LVUPAddPoint', 4)
     if not isFree:
-        needItemID = IpyGameDataPY.GetFuncCfg('LVUPAddPoint', 5)
+        #优先使用剩余时间最短的时效物品
+        needItemIDList = IpyGameDataPY.GetFuncEvalCfg('LVUPAddPoint', 5)
         itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
-        hasEnough, itemList = ItemCommon.GetItem_FromPack_ByID(needItemID, itemPack, 1)
-        if not hasEnough:
-            GameWorld.DebugLog("重置加点 item(%s) isn't enough" % (needItemID))
+        delIndex = -1
+        expireTime = 0
+        for itemID in needItemIDList:
+            hasEnough, itemIndexList = ItemCommon.GetItem_FromPack_ByID(itemID, itemPack, 10)
+            if not itemIndexList:
+                #GameWorld.DebugLog("重置加点 item(%s) isn't enough" % (needItemID))
+                continue
+            
+            for itemIndex in itemIndexList:
+                curItem = itemPack.GetAt(itemIndex)
+                if not ItemCommon.CheckItemCanUse(curItem):
+                    continue
+                isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
+                if isExpireItem:
+                    if remainingTime <= 0:
+                        #过期
+                        continue
+                    if not expireTime or remainingTime < expireTime:
+                        expireTime = remainingTime
+                        delIndex = itemIndex
+                else:
+                    delIndex = itemIndex
+                    break
+            if delIndex != -1:
+                break
+        if delIndex is -1:
             return
-        ItemCommon.ReduceItem(curPlayer, itemPack, itemList, 1, False, ChConfig.ItemDel_ResetAttrPoint)
+        ItemCommon.ReduceItem(curPlayer, itemPack, [delIndex], 1, False, ChConfig.ItemDel_ResetAttrPoint)
     
     Item_ResetAttrPoint.DoResetAttrPoint(curPlayer, 0, 0, 0)
     
@@ -2454,7 +2479,7 @@
         GameWorld.DebugLog("当前无跨服地图!")
         return
     
-    if not __CheckCanReborn(curPlayer, rebornType):
+    if not __CheckCanReborn(curPlayer, rebornType, checkHPState=False):
         return
     
     msgDict = {"PlayerID":curPlayer.GetPlayerID(), "RebornType":rebornType}
@@ -4089,10 +4114,17 @@
 
 #---------------------------------------------------------------------
 
-def __CheckCanReborn(curPlayer, rebornType, gameMap=None):
+def __CheckCanReborn(curPlayer, rebornType, gameMap=None, checkHPState=True):
     ''' 检查可否复活,为了逻辑统一,这里不适用玩家所在的地图,支持跨服状态下判断跨服地图
                 本函数不验证玩家死亡状态等,因为有可能前后端复活状态不一致,如果这里拦住可能导致前端躺尸复活不了
     '''
+    
+    if checkHPState and curPlayer.GetHP() > 0 and curPlayer.GetPlayerAction() != IPY_GameWorld.paDie:
+        # 当血量大于0收到复活请求时,一般是前后端复活状态不一致的情况下导致的
+        # 由于前端需要根据复活状态判断复活界面相关逻辑,所以这里需要做一些特殊处理,防止某些情况下前后端复活状态不一致导致的一些异常问题
+        # 后端非死亡状态的情况,补同步一次复活包给前端
+        SyncPlayerReborn(curPlayer, rebornType)
+        return
     
     if rebornType not in ChConfig.Def_RebornTypeList:
         return
@@ -4151,13 +4183,6 @@
 
 def __DoPlayerReborn(curPlayer, rebornType, tick, mapBornPlace=0, isAddSuperBuff=True):
     ## 执行玩家复活逻辑,该函数没有执行验证是否可复活等,不可直接调用
-    
-    if curPlayer.GetHP() > 0 and curPlayer.GetPlayerAction() != IPY_GameWorld.paDie:
-        # 当血量大于0收到复活请求时,一般是前后端复活状态不一致的情况下导致的
-        # 由于前端需要根据复活状态判断复活界面相关逻辑,所以这里需要做一些特殊处理,防止某些情况下前后端复活状态不一致导致的一些异常问题
-        # 后端非死亡状态的情况,补同步一次复活包给前端
-        SyncPlayerReborn(curPlayer, rebornType)
-        return
     
     resetHpPercent = ChConfig.Def_MaxRateValue
     isFBReborn = False
@@ -5820,18 +5845,23 @@
     NetPackCommon.SendFakePack(curPlayer, sendPack)
     return
 
-#// B4 0E 设置玩家自身血量 #tagCMSetRoleHP
+#// B4 0E 玩家掉血 #tagCMRoleLostHP
 #
-#struct    tagCMSetRoleHP
+#struct    tagCMRoleLostHP
 #{
 #    tagHead        Head;
-#    DWORD        HP;
+#    DWORD        LostHP;
 #};
-def OnSetRoleHP(index, clientData, tick):
+def OnRoleLostHP(index, clientData, tick):
     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
-    if not curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene):
-        GameWorld.DebugLog("玩家当前不是在自定义场景中,不允许设置自身血量!")
-        return
-    setHP = max(1, min(clientData.HP, curPlayer.GetMaxHP()))
-    curPlayer.SetHP(setHP)
+    lostHP = clientData.LostHP
+    curHP = curPlayer.GetHP()
+    updHP = curHP - lostHP
+    if updHP <= 0:
+        #玩家已经死亡
+        playerControl = PlayerControl.PlayerControl(curPlayer)
+        playerControl.SetDead()
+    else:
+        curPlayer.SetHP(updHP)
+        
     return

--
Gitblit v1.8.0