From 5f18b0ab13594fe5a7e60af7f38c8c4443b553d7 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期一, 22 七月 2019 20:48:44 +0800
Subject: [PATCH] 860312 仙盟答题结束后不踢玩家出地图

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerHorse.py |  256 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 203 insertions(+), 53 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerHorse.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerHorse.py
index 629e380..dee4a1b 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerHorse.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerHorse.py
@@ -41,6 +41,7 @@
 import PassiveBuffEffMng
 import CrossPlayerData
 import PlayerWeekParty
+import PlayerPet
 #---------------------------------------------------------------------
 
 #---------------------------------------------------------------------
@@ -188,11 +189,18 @@
     # 未加载成功骑乘会导致模型加载失败报错
     if not curPlayer.GetInitOK():
         return False
-                    
-    #地图不允许骑马 RideLimit_lhs_0
-    if not GameWorld.GetMap().GetMapCanRide():
-        PlayerControl.NotifyCode(curPlayer, "RideLimit_lhs_0")
-        return False
+    
+    customMapID = PlayerControl.GetCustomMapID(curPlayer)
+    if customMapID:
+        ipyMapData = IpyGameDataPY.GetIpyGameData("ChinMap", customMapID)
+        if not ipyMapData or not ipyMapData.GetCanRide():
+            PlayerControl.NotifyCode(curPlayer, "RideLimit_lhs_0")
+            return False
+    else:
+        #地图不允许骑马 RideLimit_lhs_0
+        if not GameWorld.GetMap().GetMapCanRide():
+            PlayerControl.NotifyCode(curPlayer, "RideLimit_lhs_0")
+            return False
     
     #检查玩家状态,只有在空闲状态才能上马
     if curPlayer.GetPlayerVehicle() != IPY_GameWorld.pvNull :
@@ -366,7 +374,7 @@
         GameWorld.DebugLog("OnPlayerChangeHorse() pack(%s) no horse(%s) item" \
                            % (ShareDefine.rptTempSwap, horseItemID))
         return
-    
+    curHorse.SetUserAttr(ShareDefine.Def_IudetHorsePetSkinIndex, GetHorsePetSkinIndex(curPlayer, 1, horseIndex))
     #检查玩家状态是否可以换装
     if not ChEquip.CheckPlayerCanEquipItem(curPlayer):
         return
@@ -493,6 +501,7 @@
     allAttrList = [{} for _ in range(4)]
     allAttrListHorseSoul = [{} for _ in range(4)]
     skillAttrList = [{} for _ in range(4)]
+    allAttrListSkin = [{} for _ in range(4)]
     # 判断玩家是否可以升级马匹
     if isCheckOpen and not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Horse):
         #对应的任务限制未完成
@@ -520,6 +529,11 @@
                 maxSpeed = max(maxSpeed, attrValueList[i])
                 continue
             PlayerControl.CalcAttrDict_Type(attrID, attrValueList[i], allAttrList)
+        skinData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HorsePetSkinData % (1, horseID), 0)
+        skinIpyData = IpyGameDataPY.GetIpyGameDataNotLog('HorsePetSkin', 1, horseID, skinData/100)
+        if skinIpyData:
+            for attrID, attrValue in skinIpyData.GetAttrInfo().items():
+                PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrListSkin)
     
     curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_Horse, skillFPEx+initFPAdd)
     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_HorseSkill, skillAttrList)
@@ -537,6 +551,8 @@
     # 保存计算值
     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Horse, allAttrList)
     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_HorseSoul, allAttrListHorseSoul)
+    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_HorseSkin, allAttrListSkin)
+    
     return
 
 def __CalcHorseSkillAttr(curPlayer, allAttrList):
@@ -726,7 +742,6 @@
     #EventReport.WriteEvent_horse_class(curPlayer, horseLV, curExp, delCnt, updClassLV, updExp)
     return
 
-
 ## 坐骑阶级提升
 #  @param curPlayer
 #  @param horseID: 坐骑id
@@ -789,53 +804,8 @@
 # @param curPlayer 玩家
 # @return None
 def PlayerHorseLogin(curPlayer):
-    if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_VersionFix, ChConfig.Def_VerFix_Horse):
-        GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_VersionFix, ChConfig.Def_VerFix_Horse, 1)
-        #等级不能超上限,技能删了重新学
-        skillManager = curPlayer.GetSkillManager()
-        delCnt = 0
-        for i in xrange(skillManager.GetSkillCount()):
-            dataIndex = i-delCnt
-            skill = skillManager.GetSkillByIndex(dataIndex)
-            if skill == None:
-                continue
-            if skill.GetFuncType() != ChConfig.Def_SkillFuncType_HorseSkill:
-                continue
-            skillTypeID = skill.GetSkillTypeID()
-            skillManager.DeleteSkillBySkillTypeID(skillTypeID)
-            delCnt += 1
-            
-        tick = GameWorld.GetGameWorld().GetTick()
-        ipyDataMgr = IpyGameDataPY.IPY_Data()
-        for i in xrange(ipyDataMgr.GetHorseCount()):
-            ipyData = ipyDataMgr.GetHorseByIndex(i)
-            horseID = ipyData.GetHorseID()
-            curlv = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Horser_LV % horseID, 0, ChConfig.Def_PDictType_Horse)
-            if not curlv:
-                continue
-            maxLV = ipyData.GetMaxLV()
-            if curlv > maxLV:
-                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Horser_LV % horseID, maxLV, ChConfig.Def_PDictType_Horse)
-                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Horser_Exp % horseID, 0, ChConfig.Def_PDictType_Horse)
-                GameWorld.Log('   老号坐骑等级超过上限,坐骑ID=%s,原LV=%s,重置为=%s'%(horseID, curlv, maxLV))
-                curlv = maxLV
-        
-            for lv in xrange(1, curlv + 1):
-                upIpyData = IpyGameDataPY.GetIpyGameData("HorseUp", horseID, lv)
-                if not upIpyData:
-                    break
-                skillIDList = upIpyData.GetSkillID()
-                if not skillIDList:
-                    continue
-                for skillID in skillIDList:
-                    __GiveSkill(curPlayer, skillID, tick)
-        # 重刷战力
-        curControl = PlayerControl.PlayerControl(curPlayer)
-        curControl.RefreshAllSkill()
-        RefreshHorseAttr(curPlayer)
-        
-    
     Sync_HorseClassData(curPlayer)
+    SyncHorsePetSkinData(curPlayer)
     return
 
 
@@ -1041,4 +1011,184 @@
         if horseLV > maxLV:
             maxLV = horseLV
     return maxLV
+
+
+def IsHorseMaxLV(curPlayer, horseID):
+    horseLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Horser_LV % horseID, 0, ChConfig.Def_PDictType_Horse)
+    if horseLV <= 0:
+        return
+    horseIpyData = IpyGameDataPY.GetIpyGameData("Horse", horseID)
+    if not horseIpyData:
+        return
+    maxLV = horseIpyData.GetMaxLV()
+    return horseLV >= maxLV
+
+
+#============================骑宠觉醒=============================
+#// A5 29 骑宠觉醒 #tagCMHorsePetAwake
+#
+#struct    tagCMHorsePetAwake
+#{
+#    tagHead        Head;
+#    WORD    Type;    // 1-坐骑 2-灵宠
+#    DWORD    ID;    // 对应坐骑表灵宠表ID
+#    DWORD    EatItemID;    // 吞噬的物品ID
+#};
+def OnHorsePetAwake(index, curPackData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    skintype = curPackData.Type
+    horsePetID = curPackData.ID
+    eatItemID = curPackData.EatItemID
+    if not IpyGameDataPY.GetIpyGameDataByCondition('HorsePetSkin', {'Type':skintype, 'ID':horsePetID}):
+        return
+    if skintype == 1:
+        if not IsHorseMaxLV(curPlayer, horsePetID):
+            GameWorld.DebugLog('骑宠觉醒 对应骑宠未满级 horsePetID=%s'%horsePetID)
+            return
+    else:
+        if not PlayerPet.IsPetMaxLV(curPlayer, horsePetID):
+            GameWorld.DebugLog('骑宠觉醒 对应骑宠未满级 horsePetID=%s'%horsePetID)
+            return
+    
+    skinData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HorsePetSkinData % (skintype, horsePetID), 0)
+    curSkinLV, curSkinIndex = skinData/100, skinData%100
+    ipyData = IpyGameDataPY.GetIpyGameData('HorsePetSkin', skintype, horsePetID, curSkinLV)
+    if not ipyData:
+        return
+    upNeedExp = ipyData.GetNeedExp()
+    if not upNeedExp:
+        GameWorld.DebugLog('骑宠觉醒 已满级')
+        return
+    curExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HorsePetSkinExp % (skintype, horsePetID), 0)
+    curItem = GameWorld.GetGameData().GetItemByTypeID(eatItemID)
+    if not curItem:
+        return
+    curEff = curItem.GetEffectByIndex(4)
+    curEffID = curEff.GetEffectID()
+    if curEffID != ChConfig.Def_Effect_HorsePetSkinExp:
+        return
+    addExp = curEff.GetEffectValue(0)
+    if not addExp:
+        return
+    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
+    hasEnough, itemList = ItemCommon.GetItem_FromPack_ByID(eatItemID, itemPack, 1)
+    if not hasEnough:
+        GameWorld.DebugLog("OnHorsePetAwake() item(%s[%s]) isn't enough" % (eatItemID, 1))
+        return
+    ItemCommon.ReduceItem(curPlayer, itemPack, itemList, 1, False, ChConfig.ItemDel_HorsePetAwake)
+    
+    updExp = curExp + addExp
+    updSkinLV = curSkinLV
+    updSkinIndex = curSkinIndex
+    if updExp >= upNeedExp:
+        for _ in xrange(10):
+            ipyData = IpyGameDataPY.GetIpyGameDataNotLog('HorsePetSkin', skintype, horsePetID, updSkinLV+1)
+            if not ipyData:
+                break
+            if updExp < upNeedExp:
+                break
+            updExp -= upNeedExp
+            updSkinLV += 1
+            updSkinIndex = ipyData.GetSkinIndex()
+            upNeedExp = ipyData.GetNeedExp()
+            
+    updSkinData = updSkinLV*100+updSkinIndex
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HorsePetSkinData % (skintype, horsePetID), updSkinData)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HorsePetSkinExp % (skintype, horsePetID), updExp)
+    if curSkinIndex != updSkinIndex:
+        __DoHorsePetSkinChange(curPlayer, skintype, horsePetID, updSkinIndex)
+    if updSkinLV != curSkinLV:
+        if skintype == 1:
+            RefreshHorseAttr(curPlayer)
+        else:
+            PlayerPet.RefreshPetItemAddAttr(curPlayer, True)
+        
+    SyncHorsePetSkinData(curPlayer, [[skintype, horsePetID]])
+    return
+
+#// A5 30 骑宠外观选择 #tagCMHorsePetSkinSelect
+#struct    tagCMHorsePetSkinSelect
+#{
+#    tagHead        Head;
+#    WORD    Type;    // 1-坐骑 2-灵宠
+#    DWORD    ID;    // 对应坐骑表灵宠表ID
+#    BYTE    SkinIndex;    // 外观索引
+#};
+def OnHorsePetSkinSelect(index, curPackData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    skintype = curPackData.Type
+    horsePetID = curPackData.ID
+    skinIndex = curPackData.SkinIndex
+    ipyData = IpyGameDataPY.GetIpyGameDataByCondition('HorsePetSkin', {'Type':skintype, 'ID':horsePetID, 'SkinIndex':skinIndex})
+    if not ipyData:
+        return
+    skinData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HorsePetSkinData % (skintype, horsePetID), 0)
+    curSkinLV, curSkinIndex = skinData/100, skinData%100
+    if skinIndex == curSkinIndex:
+        return
+    if curSkinLV < ipyData.GetSkinLV():
+        return
+    
+    updSkinData = curSkinLV*100+skinIndex
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HorsePetSkinData % (skintype, horsePetID), updSkinData)
+    
+    __DoHorsePetSkinChange(curPlayer, skintype, horsePetID, skinIndex)
+    
+    SyncHorsePetSkinData(curPlayer, [[skintype, horsePetID]])
+    return
+
+def __DoHorsePetSkinChange(curPlayer, skinType, horsePetID, skinIndex):
+    ##骑宠觉醒外观更换
+    ChEquip.ChangeEquipfacadeByHorsePetSkin(curPlayer, skinType, skinIndex)
+    if skinType == 1:#坐骑
+        playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
+        itemRideHorse = playerEquip.GetAt(Def_HorseEquipIndex)
+        #无指定道具
+        if itemRideHorse.IsEmpty():
+            return
+        ipyData = IpyGameDataPY.GetIpyGameData("Horse", horsePetID)
+        if not ipyData:
+            return
+        horseItemID = ipyData.GetItemID()
+        if itemRideHorse.GetItemTypeID() != horseItemID:
+            return
+        itemRideHorse.SetUserAttr(ShareDefine.Def_IudetHorsePetSkinIndex, skinIndex)
+    elif skinType == 2:#灵宠
+        pass
+    return
+
+def GetHorsePetSkinIndex(curPlayer, skintype, horsePetID):
+    # 获取骑宠觉醒外观索引
+    skinData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HorsePetSkinData % (skintype, horsePetID), 0)
+    return skinData%100
+
+def SyncHorsePetSkinData(curPlayer, skinList=None):
+    if not skinList:
+        skinList = []
+        ipyMgr = IpyGameDataPY.IPY_Data()
+        for i in xrange(ipyMgr.GetHorsePetSkinCount()):
+            ipyData = ipyMgr.GetHorsePetSkinByIndex(i)
+            if [ipyData.GetType(), ipyData.GetID()] not in skinList:
+                skinList.append([ipyData.GetType(), ipyData.GetID()])
+    
+    packData = ChPyNetSendPack.tagMCHorsePetSkinData()
+    packData.Clear()
+    packData.InfoList = []
+    for skintype, horsePetID in skinList:
+        skinInfo = ChPyNetSendPack.tagMCHorsePetSkinInfo()
+        skinInfo.Type = skintype
+        skinInfo.ID = horsePetID
+        curExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HorsePetSkinExp % (skintype, horsePetID), 0)
+        skinData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HorsePetSkinData % (skintype, horsePetID), 0)
+        if not curExp and not skinData:
+            continue
+        curSkinLV, curSkinIndex = skinData/100, skinData%100
+        skinInfo.Exp = curExp
+        skinInfo.SkinLV = curSkinLV
+        skinInfo.SkinIndex = curSkinIndex
+        packData.InfoList.append(skinInfo)
+    packData.Num = len(packData.InfoList)
+    NetPackCommon.SendFakePack(curPlayer, packData)
+    return
+
         
\ No newline at end of file

--
Gitblit v1.8.0