| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PetControl  | 
| #  | 
| # @todo:³èÎï¿ØÖÆÆ÷  | 
| # @author hxp  | 
| # @date 2016-4-29  | 
| # @version 1.2  | 
| #  | 
| # @change: "2016-06-15 12:00" hxp Ôö¼Ó³èÎïÊØ»¤×´Ì¬  | 
| # @change: "2016-07-02 16:30" hxp ³èÎï¼Ì³ÐÖ÷ÈËÒÆ¶¯ËÙ¶È  | 
| #  | 
| # ÏêϸÃèÊö: ³èÎï¿ØÖÆÆ÷  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2016-07-02 16:30"""  | 
| #-------------------------------------------------------------------------------  | 
| #³èÎïC++½Ó¿Ú£º  | 
| #curPlayer.GetPetMgr -> IPY_RolePetMgr;   | 
| #IPY_RolePetMgr.PetList_Find\GetFightPet\PetList_At -> IPY_RolePet;  | 
| #IPY_RolePet.GetRolePet -> tagIPY_RolePet(½á¹¹Ìå);   | 
| #IPY_RolePet.GetPetData -> IPY_Pet;  | 
| #  | 
| #  | 
| #---------------------------------------------------------------------  | 
| import IPY_GameWorld  | 
| import ChConfig  | 
| import GameWorld  | 
| import BuffSkill  | 
| import SkillShell  | 
| import PlayerPet  | 
| import PlayerControl  | 
| import NPCCommon  | 
| import SkillCommon  | 
| import GameMap  | 
| import OperControlManager  | 
| import ShareDefine  | 
|   | 
| import random  | 
| import copy  | 
| import math  | 
| import GameObj  | 
| import AICommon  | 
| import BaseAttack  | 
| import PassiveBuffEffMng  | 
| import ChNetSendPack  | 
| import IpyGameDataPY  | 
| #---------------------------------------------------------------------  | 
|   | 
| DefPetRebornHPRate = 100  # ³èÎïËÀÍö¸´»îѪÁ¿°Ù·Ö±È  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## ¼ì²é³èÎïÊÇ·ñ³öÕ½ÖÐ  | 
| #  @param curPlayer Íæ¼Ò¶ÔÏó  | 
| #  @param curPetID ³èÎïID  | 
| #  @return True or False ÊÇ·ñ³öÕ½ÖÐ  | 
| #  @remarks ¼ì²é³èÎïÊÇ·ñ³öÕ½ÖÐ  | 
| def CheckPetIsFight(curPlayer, curPetID):  | 
|     petMgr = curPlayer.GetPetMgr()  | 
|     #³öÕ½µÄ³èÎï¶ÔÏó  | 
|     fightPetObj = petMgr.GetFightPet()    | 
|       | 
|     if fightPetObj == None:  | 
|         return False  | 
|       | 
|     if fightPetObj.GetRolePet().PetID == curPetID:  | 
|         return True  | 
|       | 
|     return False  | 
|   | 
|   | 
|   | 
|   | 
| # ³èÎï¸úËæÈËÎïͬʱ¹¥»÷  | 
| def PetFight(curPlayer, tick):  | 
|       | 
|     rolePet = curPlayer.GetPetMgr().GetFightPet()  | 
|     #ÎÞ³öÕ½³èÎï  | 
|     if rolePet == None:  | 
|         return  | 
|     rolePetControl = NPCCommon.NPCControl(rolePet)  | 
|       | 
|     useSkillTagID = curPlayer.GetUseSkillTagID()  | 
|     useSkillTagType = curPlayer.GetUseSkillTagType()  | 
|       | 
|     curTag = GameWorld.GetObj(useSkillTagID, useSkillTagType)  | 
|     if not curTag or GameObj.GetHP(curTag) <= 0:  | 
|         # Ã»ÓÐÖ÷Ä¿±ê¾Í´Ó³ðºÞÖÐÕÒ  | 
|         for i in range(curPlayer.GetAngryNPCCount()):  | 
|             curTag = curPlayer.GetAngryNPCByIndex(i)  | 
|             if not curTag or GameObj.GetHP(curTag) <= 0:  | 
|                 continue  | 
|           | 
|     if not curTag or GameObj.GetHP(curTag) <= 0:  | 
|         return  | 
|       | 
|     #tagDist = GameWorld.GetDist(rolePet.GetPosX(), rolePet.GetPosY(), curTag.GetPosX(), curTag.GetPosY())  | 
|     tagDist = 0  | 
|     #---ÓÅÏÈÊͷż¼ÄÜ---  | 
|     if AICommon.DoAutoUseSkill(rolePet, curTag, tagDist, tick):  | 
|         return  | 
|       | 
|     #---ÊÍ·ÅÆÕͨ¹¥»÷--- ±ß×߱߹¥»÷¾ÀÕýÒ»´ÎλÖà  | 
|     #if tagDist > rolePet.GetAtkDist():  | 
|     #    rolePetControl.MoveToObj_Detel(curTag)  | 
|       | 
|     #ÆÕͨ¹¥»÷  | 
|     BaseAttack.Attack(rolePet, curTag, None, tick)  | 
|     return  | 
|   | 
|   | 
| #---------------------------------------------------------------------  | 
| ##³öÕ½³èÎï¸úËæÒÆ¶¯  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param destPosX Òƶ¯Ä¿±êXµã  | 
| # @param destPosY Òƶ¯Ä¿±êYµã  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ³öÕ½³èÎï¸úËæÒÆ¶¯  | 
| def FightPetFollowMove(curPlayer, destPosX, destPosY):  | 
|     #Ö÷ÈËÔÚÕ½¶·ÖÐ, ³èÎï²»¸úËæÒÆ¶¯  | 
|   | 
|     fightPet = curPlayer.GetPetMgr().GetFightPet()  | 
|     #ÎÞ³öÕ½³èÎï  | 
|     if fightPet == None:  | 
|         return  | 
|   | 
|     petControl = NPCCommon.NPCControl(fightPet)  | 
|     movePosX, movePosY = petControl.GetMoveNearPos(destPosX, destPosY, 2)  | 
|     # Ö´ÐÐÒ»´ÎÖØÖÃλÖ㬱ÜÃâ¿ìËÙ·¢°üµ¼ÖÂÎÞ·¨Òƶ¯  | 
|     fightPet.ChangePos(movePosX, movePosY)  | 
|       | 
|     #movePosX, movePosY = petControl.GetMoveNearPos(destPosX, destPosY, 1)  | 
|     PetMove(fightPet, movePosX, movePosY)  | 
|     return  | 
|   | 
|   | 
| def PetMove(fightPet, posX, posY):  | 
|       | 
|     sendPack = ChNetSendPack.tagObjMove()  | 
|       | 
|     sendPack.Clear()  | 
|     sendPack.ObjID = fightPet.GetID()  | 
|     sendPack.ObjType = IPY_GameWorld.gotNPC  | 
|     sendPack.MoveType = IPY_GameWorld.mtNormal  | 
|     sendPack.DestPosX = posX  | 
|     sendPack.DestPosY = posY  | 
|     sendPack.Speed = fightPet.GetSpeed()  | 
|     sendPack.StartPosX = fightPet.GetPosX()  | 
|     sendPack.StartPosY = fightPet.GetPosY()  | 
|       | 
|     fightPet.NotifyAll(sendPack.GetBuffer(), sendPack.GetLength())  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##Çå³ý³öÕ½³èÎï³ðºÞ.  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks Çå³ý³öÕ½³èÎï³ðºÞ  | 
| def ClearFightPetAngry(curPlayer):  | 
|     fightPet = curPlayer.GetPetMgr().GetFightPet()  | 
|     #ÎÞ³öÕ½³èÎï  | 
|     if fightPet == None:  | 
|         return  | 
|   | 
|     petControl = NPCCommon.NPCControl(fightPet)  | 
|     petControl.ClearNPCAngry()  | 
|     return  | 
| #---------------------------------------------------------------------  | 
|   | 
| ##»ñµÃ³èÎïµÄÓµÓÐÕß  | 
| # @param curPet ³èÎï  | 
| # @return ·µ»ØÖµ, ³èÎïÓµÓÐÕß(ʵÀý) or None  | 
| # @remarks »ñµÃ³èÎïµÄÓµÓÐÕß  | 
| def GetPetOwner(curPet):  | 
|     if curPet == None:  | 
|         return  | 
|       | 
|     curPlayerID = curPet.GetRolePet().PlayerID  # ³èÎïÖ÷ÈËID  | 
|       | 
|     if curPlayerID <= 0:  | 
|         return  | 
|       | 
|     curObj = GameWorld.GetObj(curPlayerID, IPY_GameWorld.gotPlayer)  | 
|       | 
|     #ÈËÎïÐèÒªÅжÏÊÇ·ñΪ¿Õ  | 
|     if curObj != None and curObj.IsEmpty():  | 
|         return  | 
|       | 
|     return curObj  | 
| #---------------------------------------------------------------------  | 
| ##ÊÇ·ñÊdzèÎï  | 
| # @param curObj ¶ÔÏó£¨NPC¡¢ÕÙ»½ÊÞ¡¢³èÎï¡¢Íæ¼ÒµÈ£©  | 
| # @return ÊÇ·ñ³èÎï  | 
| # @remarks Í¨¹ý´«ÈëµÄ¶ÔÏóÅжÏÊÇ·ñÊdzèÎï  | 
| def IsPet(curObj):  | 
|     curObjType = curObj.GetGameObjType()  | 
|       | 
|     if curObjType != IPY_GameWorld.gotNPC:  | 
|         return False  | 
|       | 
|     npcObjType = curObj.GetGameNPCObjType()  | 
|       | 
|     if npcObjType == IPY_GameWorld.gnotPet:  # ³èÎï        | 
|         return True  | 
|       | 
|     return False  | 
| #---------------------------------------------------------------------      | 
| ##Çå¿Õ³èÎïÉíÉÏËùÓÐbuff  | 
| # @param curPet ³èÎï¶ÔÏó  | 
| # @return None  | 
| # @remarks Çå¿Õ³èÎïÉíÉÏËùÓÐbuff  | 
| def ClearPetBuff(curPet):  | 
|     buffRefreshList = NPCCommon.GetNPCBuffRefreshList(curPet, True)  | 
|       | 
|     for buffState, canPileup in buffRefreshList:  | 
|         buffState.Clear()  | 
|       | 
|     return  | 
| #---------------------------------------------------------------------      | 
| ##ÕÙ»½³èÎï  | 
| # @param curPet ³èÎï¶ÔÏó  | 
| # @param curPosX ³èÎï³öÉíµãλÖà  | 
| # @param curPosY ³èÎï³öÉíµãλÖà  | 
| # @return None  | 
| # @remarks ÕÙ»½³èÎ³õʼ»¯³èÎïËùÓÐÊôÐÔ(C++´¦Àí)  | 
| def SummonPet(curPet, curPosX, curPosY):  | 
|     #³öÏÖ(³öÕ½Âß¼ÔÚC++, ½«Çå¿Õ³èÎïµÄÏà¹ØÐÅÏ¢)  | 
|     curPet.Summon(curPosX, curPosY)  | 
|     #¼Ç¼¸Ã³èÎï±»ÕÙ»Ø  | 
|     curPet.SetIsBattle(True)  | 
|     #³õʼ»¯³èÎï  | 
|     InitRolePet(curPet)  | 
|     PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPet)  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##³õʼ»¯³èÎïÊôÐÔ  | 
| # @param rolePet ³èÎïʵÀý  | 
| # @param canSyncClient ÊÇ·ñ֪ͨ¿Í»§¶Ë  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ³õʼ»¯³èÎïÊôÐÔ  | 
| def InitRolePet(rolePet, canSyncClient=True):  | 
|     #---³õʼ»¯Ê±ÖÓ---  | 
|     NPCCommon.InitNPC(rolePet)  | 
|       | 
|     #---³õʼ»¯³ðºÞÁбí---  | 
|     npcAngry = rolePet.GetNPCAngry()  | 
|     if npcAngry.GetAngryCount() == 0:  | 
|         npcAngry.Init(ChConfig.Def_Pet_Angry_Count)  | 
|     else:  | 
|         npcAngry.Clear()  | 
|   | 
|     #---³õʼ»¯³èÎïÊôÐÔ---  | 
|     petControl = NPCCommon.NPCControl(rolePet)  | 
|     petControl.RefreshNPCState(canSyncClient)  | 
|   | 
|     #¼ÓÒ»¸ö·ÀÓù´ëÊ©, Èç¹û³èÎïѪΪ0, ²»¿ÉÕÙ»½³öÀ´, Ä¬ÈÏΪ³èÎïÕÙ»ØÊ±ºòµÄѪÁ¿  | 
|     if GameObj.GetHP(rolePet) <= 0:  | 
|         PetDead_ReStoreHP(rolePet, GameObj.GetMaxHP(rolePet))  | 
|         GameWorld.ErrLog('³èÎïÖØÉúѪÁ¿Îª0, PetID = %s' % (rolePet.GetRolePet().PetID))  | 
|   | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##ÕٻسöÕ½µÄ³èÎï  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks ÕٻسöÕ½µÄ³èÎï  | 
| def ReCallFightPet(curPlayer):  | 
|     rolePetMgr = curPlayer.GetPetMgr()  | 
|     #»ñµÃÕ½¶·µÄ³èÎï  | 
|     fightPet = rolePetMgr.GetFightPet()  | 
|       | 
|     if fightPet == None:  | 
|         return False  | 
|       | 
|     #Çå¿Õ³èÎïÉíÉϸ½¼ÓµÄbuff  | 
|     ClearPetBuff(fightPet)  | 
|     #¼Ç¼¸Ã³èÎï±»ÕÙ»Ø  | 
|     fightPet.SetIsBattle(False)  | 
|     #´ËËÀÍö½Ó¿Ú(C++½«ÖØÖÃËùÓÐÕ½¶·ÊôÐÔ, ÒªÔÚË¢Ò»´Î)  | 
|     NPCCommon.SetDeadEx(fightPet)  | 
|     #ˢгèÎïÊôÐÔ  | 
|     petControl = NPCCommon.NPCControl(fightPet)  | 
|     petControl.RefreshNPCState(canSyncClient=True)  | 
|       | 
|     #³èÎïÊý¾ÝÎïÆ·×´Ì¬±ä¸ü  | 
|     petItemIndex = PlayerPet.GetPetObjItemIndex(fightPet)  | 
|     petItem = PlayerPet.GetPetDataItemByIndex(curPlayer, petItemIndex)  | 
|     if petItem:  | 
|         petItem.SetUserAttr(ShareDefine.Def_IudetPet_State, ShareDefine.Def_PetState_Null)  | 
|       | 
|     petID = fightPet.GetRolePet().PetID  | 
|     npcID = fightPet.GetRolePet().NPCID  | 
|     rolePetMgr.PetList_SetFree(petID) # ÓÀºãÕٻغóĬÈÏ·ÅÉú, ×î¶àÖ»´æÔÚÒ»¸ö³öÕ½³èÎïʵÀý  | 
|     GameWorld.DebugLog("Ëæ´ÓÕٻغóĬÈÏ·ÅÉú, petID=%s, npcID=%s" % (petID, npcID))  | 
|     return True  | 
| #---------------------------------------------------------------------  | 
| ## ÉèÖóèÎïËÀÍö  | 
| #  @param curPet ³èÎï¶ÔÏó  | 
| #  @return None  | 
| #  @remarks ÉèÖóèÎïËÀÍö  | 
| def SetPetDead(curPet):  | 
|     #---Ö´ÐÐËÀÍö³Í·£Âß¼---  | 
|       | 
|     #³èÎïÖ÷ÈË  | 
|     curPetOwner = GetPetOwner(curPet)  | 
|     if not curPetOwner:  | 
|         return  | 
|     ReCallFightPet(curPetOwner)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##³èÎïËÀÍö»Ö¸´ÑªÁ¿  | 
| # @param index Íæ¼ÒË÷Òý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ³èÎïËÀÍö»Ö¸´ÑªÁ¿  | 
| def PetDead_ReStoreHP(curPet, maxHP):  | 
|     #ÉèÖóèÎﵱǰѪÁ¿ÎªÆäÉÏÏÞµÄ30%  | 
|     SetPetHP(curPet, int(maxHP * DefPetRebornHPRate / 100))  | 
|     return  | 
| #---------------------------------------------------------------------  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ÉèÖóèÎïHP  | 
| # @param rolePet Íæ¼Ò³èÎï  | 
| # @param Öµ  | 
| # @param canSyncClientÊÇ·ñ֪ͨ¿Í»§¶Ë  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ÉèÖóèÎïHP  | 
| def SetPetHP(rolePet, value, canSyncClient=True):  | 
|     GameObj.SetHP(rolePet, value, canSyncClient)  | 
|       | 
|     if not canSyncClient:  | 
|         return  | 
|       | 
|     #rolePet.Sync_RefreshProp(IPY_GameWorld.PetInfoRefresh_HP, value, True)  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##Ôö¼Ó³èÎïHP  | 
| # @param rolePet Íæ¼Ò³èÎï  | 
| # @param Öµ  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ¼Ó³èÎïHP  | 
| def AddPetHP(rolePet, value):  | 
|     remainValue = min(GameObj.GetHP(rolePet) + value, GameObj.GetMaxHP(rolePet))  | 
|     SetPetHP(rolePet, remainValue)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ˢгèÎïµÄÊôÐÔ  | 
| # @param rolePet Íæ¼Ò³èÎï  | 
| # @param canSyncClient ÊÇ·ñ֪ͨ¿Í»§¶Ë(ĬÈÏΪTrue)  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks Ë¢Ð³èÎïµÄÊôÐÔ  | 
| def RefurbishPetAttr(rolePet, canSyncClient=True):  | 
|     curPlayer = GetPetOwner(rolePet)  | 
|     if not curPlayer:  | 
|         return  | 
|       | 
|     petDataItem = PlayerPet.GetPetDataItem(curPlayer, rolePet)  | 
|     if not petDataItem:  | 
|         return  | 
|       | 
|     # ±ä¸üÐèҪͬ²½µÄÐÅÏ¢ÅäÖÃ, ¿Í»§¶ËÈ¡³èÎïÐÅϢȫ²¿ÒÔ³èÎïÎïÆ·Êý¾ÝΪ׼  | 
|     syncList = [  | 
|                 [lambda petObj:petObj.GetMaxAtk(), IPY_GameWorld.PetInfoRefresh_PhysicAtk], #¹¥»÷  | 
|                 #[lambda petObj:petObj.GetQualityLV(), IPY_GameWorld.PetInfoRefresh_QualityLV], #Æ·ÖÊ  | 
|                 ]  | 
|     beforeValueList = []  | 
|     for syncInfo in syncList:  | 
|         beforeValueList.append(syncInfo[0](rolePet))  | 
|       | 
|     #Ìí¼ÓBuffµ½³èÎïÉíÉÏ  | 
|     #AddPlayerPetSkillBuff(rolePet)  | 
|       | 
|     #¼ÆËãBuff¶Ô»ù´¡ÊôÐÔµÄÓ°Ïì  | 
|     #SkillShell.CalcBuffer_NPCBaseEffect(rolePet)  | 
|       | 
|     #³èÎï²»¿É±»¹¥»÷, ÃüÖÐÓë¹¥ËÙÖ±½Ó¼Ì³ÐÖ÷È˹¥»÷ÊôÐÔ£¬¹¥»÷È¡µÈ¼¶½×¼¶¼Ó³É  | 
|     rolePet.SetMinAtk(PlayerControl.GetPetMinAtk(curPlayer))  | 
|     rolePet.SetMaxAtk(PlayerControl.GetPetMaxAtk(curPlayer))  | 
|     rolePet.SetSkillAtkRate(PlayerControl.GetPetSkillAtkRate(curPlayer))  | 
|     GameObj.SetPetDamPer(rolePet, GameObj.GetPetDamPer(curPlayer))  | 
|     #rolePet.SetMAtkMin(curPlayer.GetMAtkMin())  | 
|     #rolePet.SetMAtkMax(curPlayer.GetMAtkMax())  | 
|     rolePet.SetHit(curPlayer.GetHit())  | 
|     rolePet.SetSpeed(curPlayer.GetSpeed())  | 
|       | 
|     allAttrList = [{} for i in range(4)]  | 
|     #¼ÆËã¼¼ÄܶÔÕ½¶·ÊôÐÔµÄÓ°Ïì  | 
|     PlayerPet.CalcSkill_PetBattleEffect(curPlayer, rolePet, allAttrList)  | 
|     #¼ÆËãBuff¶ÔÕ½¶·ÊôÐÔµÄÓ°Ïì  | 
|     PlayerPet.CalcBuffer_PetBattleEffect(rolePet, allAttrList)  | 
|       | 
|     GameWorld.DebugLog("RefurbishPetAttr ID=%s,npcID=%s,atk=%s,hit=%s,skillAtkRate=%s"   | 
|                        % (rolePet.GetID(), rolePet.GetNPCID(), rolePet.GetMaxAtk(), rolePet.GetHit(), rolePet.GetSkillAtkRate()))  | 
|       | 
|     #ÊÇ·ñÐèҪ֪ͨ¿Í»§¶ËÊôÐÔˢР | 
|     if not canSyncClient:  | 
|         return  | 
|       | 
|     #===========================================================================  | 
|     # for i, syncInfo in enumerate(syncList):  | 
|     #    nowValue = syncInfo[0](rolePet)  | 
|     #    if beforeValueList[i] != nowValue:  | 
|     #        rolePet.Sync_RefreshProp(syncInfo[1], nowValue, True)  | 
|     #        #GameWorld.DebugLog("Sync_RefreshProp i=%s,befValue=%s,nowValue=%s,type=%s" % (i, beforeValueList[i], nowValue, syncInfo[1]))  | 
|     #===========================================================================  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Ìí¼Ó³èÎï¼¼ÄÜBuff  | 
| # @param rolePet ³èÎïʵÀý  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks Ìí¼Ó³èÎï¼¼ÄÜBuff  | 
| #===============================================================================  | 
| # def AddPlayerPetSkillBuff(rolePet):  | 
| #    tick = GameWorld.GetGameWorld().GetTick()  | 
| #   | 
| #    #---ÏÈÇåµô---  | 
| #    passiveBuffManager = rolePet.GetPassiveBuf()  | 
| #    passiveBuffManager.Clear()  | 
| #      | 
| #    #---ÔÚ¼ÓÉÏ---  | 
| #    rolePetSkillManager = rolePet.GetSkillManager()  | 
| #      | 
| #    for i in range(0, rolePetSkillManager.GetSkillCount()):  | 
| #        learnSkill = rolePetSkillManager.GetSkillByIndex(i)  | 
| #        #Ö»Ìí¼Ó±»¶¯¼¼ÄÜ  | 
| #        if not SkillCommon.isPassiveBuffSkill(learnSkill):  | 
| #            continue  | 
| #          | 
| #        #¼ÓÉÏbuff²»Ë¢ÐÂ״̬  | 
| #        BuffSkill.AddBuffNoRefreshState(rolePet, IPY_GameWorld.btPassiveBuf, learnSkill, tick)  | 
| #      | 
| #    return  | 
| #===============================================================================  | 
| #---------------------------------------------------------------------  | 
| def DoLogic_PlayerPetLearnSkillList(rolePet, learnSkillList):  | 
|     #GameWorld.DebugLog("DoLogic_PlayerPetLearnSkillList----%s"%learnSkillList)  | 
|     gameData = GameWorld.GetGameData()  | 
|       | 
|     rolePetSkillManager = rolePet.GetSkillManager()  | 
|     for leSkillID in learnSkillList:  | 
|         learnSkillData = gameData.GetSkillBySkillID(leSkillID)  | 
|         if not learnSkillData:  | 
|             GameWorld.ErrLog('PlayerPetLearnSkillList LeanrSkillID = %s, noFindInTable' % leSkillID)  | 
|             return  | 
|         rolePetSkillManager.LearnSkillByID(leSkillID)  | 
|           | 
|     PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(rolePet)  | 
|     #rolePet.Sync_PetInfo()  | 
|     #rolePet.Sync_SkillList()       | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##¼ì²éµ±Ç°Ö¸¶¨³èÎïÊÇ·ñ¿É³öÕ½  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curPetObj Ö¸¶¨³èÎïʵÀý  | 
| # @return BOOL ÊÇ·ñ¿É³öÕ½  | 
| # @remarks ¼ì²éµ±Ç°Ö¸¶¨³èÎïÊÇ·ñ¿É³öÕ½  | 
| def CheckPetCanFight(curPlayer, curPetObj):  | 
|     if not GetMapCanOutPet(curPlayer):  | 
|         #Pet_liubo_314885 ´ËµØÍ¼½ûÖ¹³èÎï  | 
|         #PlayerControl.NotifyCode(curPlayer, "Pet_liubo_314885")  | 
|         return False  | 
|       | 
|     petData = curPetObj.GetPetData()  | 
|       | 
|     #·À³ÁÃÔ  | 
|     if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_Wallow_LV) > ChConfig.Def_GameWallow_LV_First:  | 
|         PlayerControl.NotifyCode(curPlayer, "AvoidSink09")  | 
|         return False  | 
|       | 
|     if GameObj.GetHP(curPlayer) <= 0:  | 
|         #ËÀÍö״̬ÎÞ·¨³öÕ½³èÎï  | 
|         return False  | 
|       | 
| #    if curPlayer.GetLV() < petData.GetBringLV():  | 
| #        #Pet_hgg_442426 ¶Ô²»Æð,ÄúÉÐδµ½´ï¸Ã³èÎïµÄЯ´øµÈ¼¶.  | 
| #        PlayerControl.NotifyCode(curPlayer, "Pet_hgg_442426")  | 
| #        return False  | 
| #      | 
| #    if curPetObj.GetLV() - curPlayer.GetLV() > ChConfig.Def_PetRoleGapLVMax:  | 
| #        #Pet_liubo_570355 ¶Ô²»Æð,Äú²»ÄܳöÕ½³¬¹ýÈËÎï5¼¶µÄ³èÎï!  | 
| #        PlayerControl.NotifyCode(curPlayer, "Pet_liubo_570355", [ChConfig.Def_PetRoleGapLVMax])  | 
| #        return False  | 
|       | 
|     #---ÊÇ·ñÒÑÓгèÎï³öÕ½---  | 
|     #fightPetObj = curPlayer.GetPetMgr().GetFightPet()  # ³öÕ½µÄ³èÎï¶ÔÏó  | 
|       | 
|     #if fightPetObj != None:  | 
|     #    #Pet_hgg_892377 ¶Ô²»Æð£¬ÄúÖ»ÄÜͬʱ³öÕ½Ò»Ö»³èÎÇëÏÈÕٻسöÕ½µÄ³èÎï!  | 
|     #    PlayerControl.NotifyCode(curPlayer, "Pet_hgg_892377")  | 
|     #    return False  | 
|       | 
|     #GameWorld.Log('³èÎïѪÁ¿:%s£¬³èÎïID:%s'%(curPetStruct.HP,curPetStruct.PetID))  | 
|     return True  | 
| #---------------------------------------------------------------------  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Íæ¼ÒÀ뿪·þÎñÆ÷֪ͨ³èÎïÐÅÏ¢  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks Íæ¼ÒÀ뿪·þÎñÆ÷֪ͨ³èÎïÐÅÏ¢  | 
| def DoLogic_PetInfo_OnLeaveServer(curPlayer, tick):  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Íæ¼ÒµÇ½֪ͨ³èÎïÐÅÏ¢  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks Íæ¼ÒµÇ½֪ͨ³èÎïÐÅÏ¢  | 
| def DoLogic_PetInfo_OnLogin(curPlayer, tick):  | 
|      | 
|     petMgr = curPlayer.GetPetMgr()  | 
|     if GameWorld.IsCrossServer():  | 
|         ''' 0435³èÎï³öÏÖ°üͬ²½µÄIDÊǸù¾Ý³èÎïµÄÁбíλÖÃÀ´µÄ£¬±ÈÈçÔÚµÚ2λ·¢µÄ¾ÍÊÇ2£¬¶øµØÍ¼µÄ¿ÉÄÜÊÇ1£¬»áµ¼ÖÂID²»Ò»Ö  | 
|                             ËùÒÔ¿ç·þ·þÎñÆ÷µÇ¼ʱÏÈÇå³ý³öÕ½³èÎïÁÐ±í£¬È·±£µÇ¼µØÍ¼³É¹¦ºó¶¼ÊÇ´Ó1¿ªÊ¼µÄ¼´¿É  | 
|         '''  | 
|         petList = []  | 
|         for index in range(0, petMgr.PetList_Cnt()):  | 
|             rolePet = petMgr.PetList_At(index)  | 
|             petList.append(rolePet)  | 
|         for rolePet in petList:  | 
|             petMgr.PetList_SetFree(rolePet.GetRolePet().PetID)  | 
|     else:  | 
|         for index in range(0, petMgr.PetList_Cnt()):  | 
|             rolePet = petMgr.PetList_At(index)  | 
|             #ˢгèÎïÐÅÏ¢²¢Í¨Öª¿Í»§¶Ë  | 
|             __RefreshAndSyncPetInfo(rolePet)  | 
|             #×Ô¶¯³öÕ½³èÎï  | 
|             __AutoSummonPet_OnLogin(curPlayer, rolePet)  | 
|   | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##Íæ¼ÒÉÏÏß, ×Ô¶¯³öÕ½³èÎï  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks Íæ¼ÒÉÏÏß, ×Ô¶¯³öÕ½³èÎï  | 
| def __AutoSummonPet_OnLogin(curPlayer, rolePet):  | 
|     #ÊÇ·ñÓгöÕ½±êÖ¾  | 
|     if not rolePet.GetIsBattle():  | 
|         return  | 
|       | 
|     if not GetMapCanOutPet(curPlayer):  | 
|         #´ËµØÍ¼½ûÖ¹³èÎï  | 
|         return  | 
|     #ÕÙ»½³èÎï³öÕ½  | 
|     resultPos = GameMap.GetEmptyPlaceInArea(curPlayer.GetPosX(), curPlayer.GetPosY(), ChConfig.Def_SummonAppearDist)  | 
|       | 
|     SummonPet(rolePet, resultPos.GetPosX(), resultPos.GetPosY())  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Íæ¼ÒÇл»µØÍ¼Í¨Öª³èÎïÐÅÏ¢.  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks Íæ¼ÒÇл»µØÍ¼Í¨Öª³èÎïÐÅÏ¢.  | 
| def Sync_PetInfo_ChangeMap(curPlayer, tick):  | 
|     petMgr = curPlayer.GetPetMgr()  | 
|       | 
|     for index in range(0, petMgr.PetList_Cnt()):  | 
|         rolePet = petMgr.PetList_At(index)  | 
|         #ˢгèÎïÐÅÏ¢²¢Í¨Öª¿Í»§¶Ë  | 
|         __RefreshAndSyncPetInfo(rolePet)  | 
|   | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Íæ¼ÒЯ´ø³èÎïµÇ½µØÍ¼  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def DoLogic_PetLoadMapOK(curPlayer):  | 
|       | 
|     if GetMapCanOutPet(curPlayer):  | 
|         #´ËµØÍ¼³èÎï¿ÉÒÔÉÏ  | 
|         PlayerPet.AutoSummonPet(curPlayer)  | 
|         return  | 
|       | 
|     #´ËµØÍ¼½ûÖ¹³èÎï, ÕٻسöÕ½µÄ³èÎï  | 
|     if not ReCallFightPet(curPlayer):  | 
|         return  | 
|       | 
|     #Pet_liubo_314885 ´ËµØÍ¼½ûÖ¹³èÎï  | 
|     #PlayerControl.NotifyCode(curPlayer, "Pet_liubo_314885")  | 
|     return  | 
|   | 
| def GetMapCanOutPet(curPlayer):  | 
|     ## ¼ì²é±¾µØÍ¼¿É·ñ³öÕ½³èÎ֧³Öǰ¶Ë×Ô¶¨Ò峡¾°  | 
|     customMapID = PlayerControl.GetCustomMapID(curPlayer)  | 
|     if customMapID:  | 
|         ipyMapData = IpyGameDataPY.GetIpyGameData("ChinMap", customMapID)  | 
|         canOutPet = True if ipyMapData and ipyMapData.GetCanOutPet() else False  | 
|     else:  | 
|         canOutPet = GameWorld.GetMap().GetMapCanOutPet()  | 
|     return canOutPet  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Ë¢Ð³èÎïÐÅÏ¢²¢Í¨Öª¿Í»§¶Ë  | 
| #  @param rolePet ³èÎïʵÀý  | 
| #  @return ÎÞ·µ»ØÖµ  | 
| #  @remarks Ë¢Ð³èÎïÐÅÏ¢²¢Í¨Öª¿Í»§¶Ë  | 
| def __RefreshAndSyncPetInfo(rolePet):  | 
|     #---ˢгèÎïÐÅÏ¢(²»Í¨Öª¿Í»§¶Ë)---  | 
|     InitRolePet(rolePet, False)  | 
|   | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
|   | 
|   |