hch
2019-03-20 3744bec3b23aa4840b1e7934b1c3378e32937912
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerPet.py
@@ -35,9 +35,11 @@
import IpyGameDataPY
import PlayerAttrFruit
import GameMap
import OpenServerCampaign
import PlayerMagicWeapon
import PassiveBuffEffMng
import PlayerWeekParty
import CalcNoLineEffect
import CrossPlayerData
import CalcLineEffect
import random
@@ -104,7 +106,6 @@
    if not newPetItem:
        return
    
    newPetItem.SetIsBind(True)
    newPetItem.SetUserAttr(ShareDefine.Def_IudetPet_NPCID, petNPCID)
    newPetItem.SetUserAttr(ShareDefine.Def_IudetPet_State, ShareDefine.Def_PetState_Null)
    
@@ -235,15 +236,16 @@
    
    # 当前状态处理
    if curState == ShareDefine.Def_PetState_Fight:
        curPet = curPlayer.GetPetMgr().GetFightPet()
        if curPet:
            #已是出战状态, C++召唤坐标和人重叠
            resultPos = GameMap.GetEmptyPlaceInArea(curPlayer.GetPosX(), curPlayer.GetPosY(), ChConfig.Def_SummonAppearDist)
            curPet.ResetPos(resultPos.GetPosX(), resultPos.GetPosY())
            PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPet)
            PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveBuff(curPet)
        return
        #PetControl.ReCallFightPet(curPlayer)
#        curPet = curPlayer.GetPetMgr().GetFightPet()
#        if curPet:
#            #已是出战状态, C++召唤坐标和人重叠
#            resultPos = GameMap.GetEmptyPlaceInArea(curPlayer.GetPosX(), curPlayer.GetPosY(), ChConfig.Def_SummonAppearDist)
#            curPet.ResetPos(resultPos.GetPosX(), resultPos.GetPosY())
#            PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPet)
#            PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveBuff(curPet)
#        return
        #18/10/15 因为某种未知原因宠物物品的状态是出战(实际场景中未出战),导致该宠物无法出战,故再次发包出战时,此处不拦!
        PetControl.ReCallFightPet(curPlayer)
   
    else:
        pass
@@ -264,8 +266,39 @@
#        petItem.SetUserAttr(ShareDefine.Def_IudetPet_State, tagState)
#        GameWorld.DebugLog("切换宠物状态异常防范! curState=%s,tagState=%s" % (curState, tagState))
        
    if not GameWorld.IsCrossServer():
        dataList = [petNPCID, curClasslv, tagState]
        CrossPlayerData.SendDataToCrossServer(curPlayer, CrossPlayerData.CrossData_PetState, dataList)
    return
def CrossServer_DoChangePetState(curPlayer, dataList):
    ## 跨服处理 宠物战斗状态变更
    petNPCID, curClasslv, tagState = dataList
    petItem = GetPetDataItemByNPCID(curPlayer, petNPCID)
    if not petItem:
        newPetItem = GetNewPetDataItem(curPlayer, petNPCID)
        if not newPetItem:
            return
        if not ItemControler.PlayerItemControler(curPlayer).PutInItem(ShareDefine.rptPet, newPetItem):
            return
        petItem = GetPetDataItemByNPCID(curPlayer, petNPCID)
    if not petItem:
        return
    curItemClasslv = petItem.GetUserAttr(ShareDefine.Def_IudetPet_ClassLV)
    # 处理技能问题,暂不处理
    if curClasslv > curItemClasslv:
        pass
    curState = petItem.GetUserAttr(ShareDefine.Def_IudetPet_State) # 当前状态
    if curState == ShareDefine.Def_PetState_Fight:
        PetControl.ReCallFightPet(curPlayer)
    if tagState == ShareDefine.Def_PetState_Fight:
        __DoPetGoOutToFight(curPlayer, petItem)
    return
## 执行宠物出战逻辑
@@ -303,22 +336,22 @@
    PetControl.DoLogic_PlayerPetLearnSkillList(rolePet, learnSkillList)
    
    #---刷新属性(不通知)---
    #GameWorld.DebugLog("ˢǰ: petID=%s,playerID=%s,npcID=%s,BindType=%s,AIMode=%s,PetIndex=%s,petFinalHurtPer=%s,grade=%s,qualLV=%s,"
    #GameWorld.DebugLog("ˢǰ: petID=%s,playerID=%s,npcID=%s,BindType=%s,AIMode=%s,PetIndex=%s,grade=%s,qualLV=%s,"
    #                   % (petStruct.PetID, petStruct.PlayerID, petStruct.NPCID, petStruct.BindType, petStruct.AIMode, petStruct.PetIndex,
    #                      rolePet.GetBattleValEx5(), rolePet.GetGrade(), rolePet.GetQualityLV()))
    #                      rolePet.GetGrade(), rolePet.GetQualityLV()))
    petControl = NPCCommon.NPCControl(rolePet)
    petControl.RefreshNPCState(canSyncClient=False)
    #GameWorld.DebugLog("刷后: petID=%s,playerID=%s,npcID=%s,BindType=%s,AIMode=%s,PetIndex=%s,petFinalHurtPer=%s,grade=%s,qualLV=%s,"
    #GameWorld.DebugLog("刷后: petID=%s,playerID=%s,npcID=%s,BindType=%s,AIMode=%s,PetIndex=%s,grade=%s,qualLV=%s,"
    #                   % (petStruct.PetID, petStruct.PlayerID, petStruct.NPCID, petStruct.BindType, petStruct.AIMode, petStruct.PetIndex,
    #                      rolePet.GetBattleValEx5(), rolePet.GetGrade(), rolePet.GetQualityLV()))
    #                      rolePet.GetGrade(), rolePet.GetQualityLV()))
    
    #当前血量(不通知)
    PetControl.SetPetHP(rolePet, rolePet.GetMaxHP(), False)
    
    #---通知客户端---
    rolePet.Sync_PetInfo()
    #rolePet.Sync_PetInfo()
    #刷新技能栏
    rolePet.Sync_SkillList()
    #rolePet.Sync_SkillList()
    
    #---收到"宠物出战"请求---
    #检查是否可出战
@@ -469,6 +502,10 @@
            PetControl.DoLogic_PlayerPetLearnSkillList(rolePet, learnSkillList)
    RefreshPetItemAddAttr(curPlayer, True)
    SetPetSkillFightPower(curPlayer)    # 技能战力重算
    # 开服活动数据
    OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_PetLV, GetTotalPetLV(curPlayer))
    PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Pet, petNPCID, False)
    return True
@@ -682,16 +719,34 @@
    
        SetPetSkillFightPower(curPlayer)    # 技能战力重算
        RefreshPetItemAddAttr(curPlayer, True)
        # 开服活动数据
        OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_PetLV, GetTotalPetLV(curPlayer))
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_PetClassLV, 1, [petNPCID, updClassLV + 1])
    extraInfoDict = {"petItemIndex":PetItemIndex, "petNPCID":petNPCID}
    extraInfoDict.update(eval(petDataItem.GetUserData()))
    DataRecordPack.DR_ClassUpSystem(curPlayer, "PetClassUp", updClassLV, extraInfoDict)
        
    #EventReport.WriteEvent_pet_class(curPlayer, petNpcData.GetName(), classLV, petClassExp, updClassLV, newClassExp)
    return
def GetTotalPetLV(curPlayer):
    totalPetLV = 0
    petPackIndex = ShareDefine.rptPet
    petPack = curPlayer.GetItemManager().GetPack(petPackIndex)
    for i in range(petPack.GetCount()):
        petItem = petPack.GetAt(i)
        if petItem.IsEmpty():
            continue
        petItemNPCID = petItem.GetUserAttr(ShareDefine.Def_IudetPet_NPCID)
        classLV = petItem.GetUserAttr(ShareDefine.Def_IudetPet_ClassLV) + 1
        petIpyData = GetPetIpydata(petItemNPCID)
        if not petIpyData:
            continue
        totalPetLV += classLV
    return totalPetLV
## 刷新宠物数据物品增加的属性
def RefreshPetItemAddAttr(curPlayer, isUpdBillboard):
@@ -756,7 +811,8 @@
    PlayerControl.CalcAttrDict_Type(ShareDefine.Def_Effect_PetMaxAtk, totalMaxAtk, allAttrListPet)
    totalSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalSignNum) # 总签到天数
    # 果实给人物加属性, 魂石果实算附加属性层,单独计算
    PlayerAttrFruit.CalcAttrFruitAddAtrr(curPlayer, allAttrListPetSoul, ShareDefine.Def_AttrFruitFunc_Pet)
    fightPowerEx = PlayerAttrFruit.CalcAttrFruitAddAtrr(curPlayer, allAttrListPetSoul, ShareDefine.Def_AttrFruitFunc_Pet)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_PetSoul, fightPowerEx)
    
    #灵兽技能给人物加的属性
    learnSkillList, passiveSkillList = GetPetLearnSkill(curPlayer)