| | |
| | | import IPY_GameWorld
|
| | | import ChConfig
|
| | | import GameWorld
|
| | | import ReadChConfig
|
| | | import BuffSkill
|
| | | import SkillShell
|
| | | import PlayerPet
|
| | |
| | | import BaseAttack
|
| | | import PassiveBuffEffMng
|
| | | import ChNetSendPack
|
| | | import IpyGameDataPY
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | DefPetRebornHPRate = 100 # 宠物死亡复活血量百分比
|
| | |
| | | # @return 返回值无意义
|
| | | # @remarks 初始化宠物属性
|
| | | def InitRolePet(rolePet, canSyncClient=True):
|
| | | #---初始化时钟,致命一击倍率---
|
| | | #---初始化时钟---
|
| | | NPCCommon.InitNPC(rolePet)
|
| | |
|
| | | #---初始化仇恨列表---
|
| | |
| | | # @return BOOL 是否可出战
|
| | | # @remarks 检查当前指定宠物是否可出战
|
| | | def CheckPetCanFight(curPlayer, curPetObj):
|
| | | if not GameWorld.GetMap().GetMapCanOutPet():
|
| | | if not GetMapCanOutPet(curPlayer):
|
| | | #Pet_liubo_314885 此地图禁止宠物
|
| | | PlayerControl.NotifyCode(curPlayer, "Pet_liubo_314885")
|
| | | return False
|
| | |
| | | def DoLogic_PetInfo_OnLogin(curPlayer, tick):
|
| | |
|
| | | petMgr = curPlayer.GetPetMgr()
|
| | |
|
| | | for index in range(0, petMgr.PetList_Cnt()):
|
| | | rolePet = petMgr.PetList_At(index)
|
| | | #刷新宠物信息并通知客户端
|
| | | __RefreshAndSyncPetInfo(rolePet)
|
| | | #自动出战宠物
|
| | | __AutoSummonPet_OnLogin(curPlayer, rolePet)
|
| | | |
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_VersionFix, ChConfig.Def_VerFix_Pet):
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_VersionFix, ChConfig.Def_VerFix_Pet, 1)
|
| | | #等级不能超上限,技能删了重新学
|
| | | |
| | | 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)
|
| | | curClassLV = petItem.GetUserAttr(ShareDefine.Def_IudetPet_ClassLV) + 1
|
| | | petIpyData = PlayerPet.GetPetIpydata(petItemNPCID)
|
| | | if not petIpyData:
|
| | | continue
|
| | | maxLV = petIpyData.GetMaxRank()
|
| | | if curClassLV > maxLV:
|
| | | petItem.SetUserAttr(ShareDefine.Def_IudetPet_ClassLV, max(0, maxLV - 1))
|
| | | petItem.SetUserAttr(ShareDefine.Def_IudetPet_Exp, 0)
|
| | | GameWorld.Log(' 老号宠物等级超过上限,宠物ID=%s,原LV=%s,重置为=%s'%(petItemNPCID, curClassLV, maxLV))
|
| | | curClassLV = maxLV
|
| | | petItem.ClearUserAttr(ShareDefine.Def_IudetPet_Skill)
|
| | | petSkillList = petIpyData.GetSkillID()
|
| | | petSkillUnLockList = petIpyData.GetSkillUnLock()
|
| | | for i, skillid in enumerate(petSkillList):
|
| | | limitPetClassLV = petSkillUnLockList[i] # 学习此技能所需宠物阶级
|
| | | if curClassLV < limitPetClassLV:
|
| | | continue
|
| | | petItem.AddUserAttr(ShareDefine.Def_IudetPet_Skill, skillid)
|
| | | if ReCallFightPet(curPlayer):
|
| | | PlayerPet.AutoSummonPet(curPlayer)
|
| | | # 重刷战力
|
| | | PlayerPet.SetPetSkillFightPower(curPlayer) # 技能战力重算
|
| | | PlayerPet.RefreshPetItemAddAttr(curPlayer, True)
|
| | | 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
|
| | | #---------------------------------------------------------------------
|
| | |
| | | if not rolePet.GetIsBattle():
|
| | | return
|
| | |
|
| | | if not GameWorld.GetMap().GetMapCanOutPet():
|
| | | if not GetMapCanOutPet(curPlayer):
|
| | | #此地图禁止宠物
|
| | | return
|
| | | #召唤宠物出战
|
| | |
| | | # @remarks
|
| | | def DoLogic_PetLoadMapOK(curPlayer):
|
| | |
|
| | | if GameWorld.GetMap().GetMapCanOutPet():
|
| | | if GetMapCanOutPet(curPlayer):
|
| | | #此地图宠物可以上
|
| | | PlayerPet.AutoSummonPet(curPlayer)
|
| | | return
|
| | |
| | | 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 宠物实例
|