#!/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 GameWorld
|
import PlayerPet
|
import PlayerControl
|
import NPCCommon
|
|
import GameObj
|
import PassiveBuffEffMng
|
import IpyGameDataPY
|
import ChConfig
|
#---------------------------------------------------------------------
|
|
##»ñµÃ³èÎïµÄÓµÓÐÕß
|
# @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
|
#---------------------------------------------------------------------
|
|
def IsPetNPC(curObj):
|
''' ÊÇ·ñÁé³èNPC£¬ÕÙ»½ÊÞÀàÐÍ£¬Íæ¼Ò¡¢Íæ¼Ò¾µÏñ¡¢NPCͨÓ㬾ù¿ÉÓÐÁé³èÕÙ»½ÊÞ
|
Çø±ðÓÚ IsPet Ϊ¾É°æµÄ PY_GameWorld.gnotPet ʵÀý¶ÔÏ󣬽öÍæ¼ÒʵÀýÓÐ
|
'''
|
curObjType = curObj.GetGameObjType()
|
if curObjType != IPY_GameWorld.gotNPC:
|
return False
|
npcObjType = curObj.GetGameNPCObjType()
|
if npcObjType != IPY_GameWorld.gnotSummon:
|
return False
|
return curObj.GetType() == IPY_GameWorld.ntPet
|
|
def GetPetNPCOwner(curPet):
|
''' »ñµÃ³èÎïµÄÓµÓÐÕߣ¬¿ÉÄÜÎªÍæ¼Ò¡¢Íæ¼Ò¾µÏñ¡¢NPC
|
Çø±ðÓÚ GetPetOwner Ϊ¾É°æµÄ PY_GameWorld.gnotPet ¹éÊôÕß½öÖ§³ÖÍæ¼Ò
|
'''
|
if curPet == None:
|
return
|
|
atkObjType = curPet.GetGameObjType()
|
if atkObjType != IPY_GameWorld.gotNPC:
|
return
|
|
summonOwner = None
|
npcObjType = curPet.GetGameNPCObjType()
|
# ÅжÏÕÙ»½ÊÞÖ÷ÈË
|
if npcObjType == IPY_GameWorld.gnotSummon:
|
curNPCDetail = GameWorld.GetObjDetail(curPet)
|
if curNPCDetail:
|
curNPCOwner = curNPCDetail.GetOwner()
|
if curNPCOwner:
|
summonOwner = GameWorld.GetObjDetail(curNPCOwner)
|
# ÕÙ»½ÊÞÖ÷ÈËÎªÍæ¼Ò
|
#if summonOwner and summonOwner.GetGameObjType() == IPY_GameWorld.gotPlayer:
|
# return summonOwner, npcObjType
|
return summonOwner
|
|
##Çå¿Õ³èÎïÉíÉÏËùÓÐbuff
|
# @param curPet ³èÎï¶ÔÏó
|
# @return None
|
# @remarks Çå¿Õ³èÎïÉíÉÏËùÓÐbuff
|
def ClearPetBuff(curPet):
|
buffRefreshList = NPCCommon.GetNPCBuffRefreshList(curPet, True)
|
|
for buffState, canPileup in buffRefreshList:
|
buffState.Clear()
|
|
return
|
|
#---------------------------------------------------------------------
|
def GetFightPet(curObj, placeNum=1):
|
## »ñÈ¡¶ÔÓ¦Õ½¶·Î»ÖÃÁé³èʵÀý
|
for index in range(curObj.GetSummonCount()):
|
curSummonNPC = curObj.GetSummonNPCAt(index)
|
if not IsPetNPC(curSummonNPC):
|
continue
|
if placeNum and placeNum == curSummonNPC.GetDictByKey(ChConfig.Def_Obj_Dict_FightPetPlaceNum):
|
return curSummonNPC
|
return
|
|
def CalloutFightPet(curObj, petCacheInfo):
|
## ÕÙ»½³öÕ½ÉÏÕóµÄÁé³è
|
# @param curObj: Áé³èËùÊôÕ½¶·ÊµÀý
|
# @param petCacheInfo: ³öÕ½Áé³èÐÅÏ¢ÁÐ±í£¬¼æÈÝÁé³è¹¦ÄÜ»º´æÐÅÏ¢
|
# @return: [µÚ1λÖÃʵÀý, µÚ2, ...] °´Î»ÖÃ˳Ðò£¬ÊµÀý¿ÉÄÜΪNone
|
|
fightPlaceCount = len(IpyGameDataPY.GetFuncEvalCfg("PetGoOutFight", 1)) # Õ½¶·Î»ÖÃÊý
|
fightPetObjList = [None] * fightPlaceCount
|
if not petCacheInfo:
|
return fightPetObjList
|
|
fightPetDict = {} # ÉÏÕóµÄÁé³è
|
for cacheInfo in petCacheInfo:
|
state = cacheInfo.get("state", 0)
|
if not state:
|
continue
|
fightPetDict[state] = cacheInfo
|
|
if not fightPetDict: # ûÓÐÉÏÕóµÄ
|
return fightPetObjList
|
|
posX, posY = curObj.GetPosX(), curObj.GetPosY()
|
for index in range(fightPlaceCount):
|
placeNum = index + 1
|
if placeNum not in fightPetDict:
|
continue
|
petInfo = fightPetDict[placeNum]
|
petNPCID = petInfo.get("npcID", 0)
|
if not petNPCID:
|
continue
|
quality = petInfo.get("quality", 0)
|
skillIDList = petInfo.get("skills", [])
|
petObj = NPCCommon.SummonNPC(curObj, petNPCID, posX, posY, skillIDList)
|
if not petObj:
|
continue
|
petObj.SetDict(ChConfig.Def_Obj_Dict_FightPetPlaceNum, placeNum)
|
petObj.SetDict(ChConfig.Def_Obj_Dict_FightPetQuality, quality)
|
fightPetObjList[index] = petObj
|
return fightPetObjList
|
|
##ÕٻسöÕ½µÄ³èÎï
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @return ²¼¶ûÖµ
|
# @remarks ÕٻسöÕ½µÄ³èÎï
|
def ReCallFightPet(curPlayer):
|
return True
|
|
def SetPetHP(rolePet, value, canSyncClient=True):
|
##ÉèÖóèÎïHP
|
GameObj.SetHP(rolePet, value, canSyncClient)
|
if not canSyncClient:
|
return
|
#rolePet.Sync_RefreshProp(IPY_GameWorld.PetInfoRefresh_HP, value, True)
|
return
|
|
def AddPetHP(rolePet, value):
|
##Ôö¼Ó³èÎïHP
|
#remainValue = min(GameObj.GetHP(rolePet) + value, GameObj.GetMaxHP(rolePet))
|
#SetPetHP(rolePet, remainValue)
|
return
|
|
def RefurbishPetAttr(curPet):
|
##ˢгèÎïµÄÊôÐÔ£¬½öÖ§³ÖÕÙ»½ÊÞ£¬·ÏÆúÔ IPY_GameWorld.gnotPet
|
petOwner = GetPetNPCOwner(curPet)
|
if not petOwner:
|
return
|
|
#³èÎï²»¿É±»¹¥»÷, Áé³è¼Ì³ÐÈËÎïµÄ °Ù·Ö°Ù¹¥»÷ºÍ¹¥ËÙ
|
curPet.SetMinAtk(petOwner.GetMinAtk())
|
curPet.SetMaxAtk(petOwner.GetMaxAtk())
|
GameObj.SetAtkSpeed(curPet, GameObj.GetAtkSpeed(petOwner))
|
|
#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,maxAtk=%s,atkSpeed=%s"
|
% (curPet.GetID(), curPet.GetNPCID(), curPet.GetMaxAtk(), curPet.GetMaxAtk()))
|
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
|
|
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
|
|