hxp
2024-06-13 e4db2ba641edc50c65e7e4b9f52f7b4e261a9c33
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/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