hxp
2019-06-17 5c0d309ecb9aebef468660a09700a2b78dee78b8
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerHorse.py
@@ -39,6 +39,8 @@
import SkillCommon
import PlayerMagicWeapon
import PassiveBuffEffMng
import CrossPlayerData
import PlayerWeekParty
#---------------------------------------------------------------------
#---------------------------------------------------------------------
@@ -65,6 +67,7 @@
#注意2:
#玩家移动的时候, 如果玩家有马匹 , 则允许玩家移动
################################################
Def_HorseEquipIndex = 5
## 玩家骑马脚本(封包参数)
#  @param index 玩家索引
@@ -98,6 +101,12 @@
    pack = IPY_GameWorld.IPY_CRideHorse()
    #//1: 骑马 0: 下马
    curPlayerRideType = pack.GetRide()
    if PlayerControl.GetCrossMapID(curPlayer):
        # 暂只处理上马
        if curPlayerRideType:
            dataList = [curPlayerRideType]
            CrossPlayerData.SendDataToCrossServer(curPlayer, CrossPlayerData.CrossData_RideHorse, dataList)
        return
    #骑马行为状态, 客户端限制
    if not OperControlManager.IsObjCanDoAction(curPlayer,
                                               ChConfig.Def_Obj_ActState_ClientAct,
@@ -130,6 +139,15 @@
    
    #if curPlayer.IsMoving():
    #    curPlayer.Move(curPlayer.GetDestPosX(), curPlayer.GetDestPosY())    
    return
def CrossServer_RideHorse(curPlayer, dataList):
    curPlayerRideType = dataList[0]
    #骑马
    if curPlayerRideType == 1:
        PlayerRideHorseUp(curPlayer, True)
    return
#---------------------下马逻辑
@@ -170,11 +188,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 :
@@ -183,7 +208,7 @@
    
    #检查是否装备指定ID物品
    playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    itemRideHorse = playerEquip.GetAt(ShareDefine.retHorse)
    itemRideHorse = playerEquip.GetAt(Def_HorseEquipIndex)
    #无指定道具
    if itemRideHorse.IsEmpty():
        #PlayerControl.NotifyCode(curPlayer, "NotPrepareSteed")
@@ -280,8 +305,43 @@
    horseIndex = packData.Index
    
    DoChangeHorse(curPlayer, horseIndex, tick)
    if not GameWorld.IsCrossServer():
        dataList = [horseIndex]
        CrossPlayerData.SendDataToCrossServer(curPlayer, CrossPlayerData.CrossData_HorseChange, dataList)
    return
def CrossServer_ChangeHorse(curPlayer, dataList):
    ## 跨服处理 坐骑变更
    horseIndex = dataList[0]
    ipyData = IpyGameDataPY.GetIpyGameData("Horse", horseIndex)
    if not ipyData:
        return
    horseItemID = ipyData.GetItemID()
    if ItemCommon.FindItemInPackByItemID(curPlayer, horseItemID, IPY_GameWorld.rptEquip):
        return
    isOK = ItemControler.PutItemInTempSwap(curPlayer, horseItemID)
    if not isOK:
        return
    curHorse = ItemCommon.FindItemInPackByItemID(curPlayer, horseItemID, ShareDefine.rptTempSwap)
    if not curHorse:
        return
    isRideHorse = curPlayer.GetPlayerVehicle() == IPY_GameWorld.pvHorse
    if isRideHorse:
        PlayerRideHorseDown(curPlayer, False)
    #---执行玩家换装逻辑---
    tick = GameWorld.GetGameWorld().GetTick()
    if ChEquip.DoPlayerEquipItem(curPlayer, curHorse, ItemCommon.GetEquipPackIndex(curHorse), tick):
        if isRideHorse:
            PlayerRideHorseUp(curPlayer, False)
    return
def DoChangeHorse(curPlayer, horseIndex, tick):
    ipyData = IpyGameDataPY.GetIpyGameData("Horse", horseIndex)
@@ -325,7 +385,7 @@
        PlayerRideHorseDown(curPlayer, False)
    
    #---执行玩家换装逻辑---
    if ChEquip.DoPlayerEquipItem(curPlayer, curHorse, ShareDefine.retHorse, tick):
    if ChEquip.DoPlayerEquipItem(curPlayer, curHorse, ItemCommon.GetEquipPackIndex(curHorse), tick):
        if isRideHorse:
            PlayerRideHorseUp(curPlayer, False)
        return
@@ -350,7 +410,7 @@
#    
#    #---执行玩家换装逻辑---
#    tick = GameWorld.GetGameWorld().GetTick()
#    ChEquip.DoPlayerEquipItem(curPlayer, curHorse, ShareDefine.retHorse, tick)
#    ChEquip.DoPlayerEquipItem(curPlayer, curHorse, Def_HorseEquipIndex, tick)
#    
#    __HorseLearnSkill(curPlayer, 0)
#    # 计算属性 防止给第一只坐骑后,客户端坐骑战斗力为0
@@ -570,7 +630,7 @@
                curItem = curItemPack.GetAt(itemIndex)
                
                #检查物品
                if not ItemCommon.CheckItemCanUse(curItem):
                if not ItemCommon.CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
                    continue
                
                itemCnt = curItem.GetCount()
@@ -683,7 +743,6 @@
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Horser_LV%horseID, updateClassLV, ChConfig.Def_PDictType_Horse)
    #EventReport.WriteEvent_custom_mission_log(curPlayer, ChConfig.CME_Class_Horse, ChConfig.CME_Log_End, 1, cmeInfoEx=str(updateClassLV))
    sumLV = GetHorseSumLV(curPlayer)
    PlayerMagicWeapon.SetMWPrivilegeData(curPlayer, ChConfig.MWPrivilege_Horse, sumLV)
    # 刷属性,更新排行榜
    RefreshHorseAttr(curPlayer)
@@ -737,52 +796,6 @@
# @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)
    return
@@ -874,9 +887,10 @@
    # 记录开服活动马匹阶级
    sumLV = GetHorseSumLV(curPlayer)
    OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_HorseLV, sumLV)
    PlayerMagicWeapon.SetMWPrivilegeData(curPlayer, ChConfig.MWPrivilege_Horse, sumLV)
    PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Horse, horseID, False)
    playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    itemRideHorse = playerEquip.GetAt(ShareDefine.retHorse)
    itemRideHorse = playerEquip.GetAt(Def_HorseEquipIndex)
    #无指定道具
    if itemRideHorse.IsEmpty():
        DoChangeHorse(curPlayer, horseID, tick)
@@ -889,7 +903,7 @@
#        tick = GameWorld.GetGameWorld().GetTick()
#        PlayerRideHorseDown(curPlayer, False)
#        # 执行玩家换装逻辑
#        if ChEquip.DoPlayerEquipItem(curPlayer, curHorseSkin, ShareDefine.retHorse, tick):
#        if ChEquip.DoPlayerEquipItem(curPlayer, curHorseSkin, Def_HorseEquipIndex, tick):
#            PlayerRideHorseUp(curPlayer, False)