| | |
| | | #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
|
| | | import ChConfig
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | ##获得宠物的拥有者
|
| | |
| | |
|
| | | 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
|
| | |
| | | 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)
|
| | | def CalloutFightPet(curObj, petCacheInfo=None):
|
| | | ## 出战上阵的灵宠
|
| | | # @param petCacheInfo: 玩家灵宠功能缓存信息
|
| | | # @return: [第1位置实例, 第2, ...] 按位置顺序,实例可能为None
|
| | |
|
| | | #---初始化仇恨列表---
|
| | | npcAngry = rolePet.GetNPCAngry()
|
| | | if npcAngry.GetAngryCount() == 0:
|
| | | npcAngry.Init(ChConfig.Def_Pet_Angry_Count)
|
| | | else:
|
| | | npcAngry.Clear()
|
| | | fightPlaceCount = len(IpyGameDataPY.GetFuncEvalCfg("PetGoOutFight", 1)) # 战斗位置数
|
| | | fightPetObjList = [None] * fightPlaceCount
|
| | | if petCacheInfo == None and curObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
|
| | | petCacheInfo = PlayerPet.GetPetCacheInfo(curObj)
|
| | | 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
|
| | |
|
| | | #---初始化宠物属性---
|
| | | 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):
|
| | | ##设置宠物HP
|
| | | 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)
|
| | | ##增加宠物HP
|
| | | #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:
|
| | | def RefurbishPetAttr(curPet):
|
| | | ##刷新宠物的属性,仅支持召唤兽,废弃原 IPY_GameWorld.gnotPet
|
| | | if not IsPetNPC(curPet):
|
| | | return
|
| | | petOwner = GetPetNPCOwner(curPet)
|
| | | if not petOwner:
|
| | | return
|
| | |
|
| | | petDataItem = PlayerPet.GetPetDataItem(curPlayer, rolePet)
|
| | | if not petDataItem:
|
| | | return
|
| | | #宠物不可被攻击, 灵宠继承人物的 百分百攻击和攻速
|
| | | curPet.SetMinAtk(petOwner.GetMinAtk())
|
| | | curPet.SetMaxAtk(petOwner.GetMaxAtk())
|
| | | GameObj.SetAtkSpeed(curPet, GameObj.GetAtkSpeed(petOwner))
|
| | |
|
| | | # 变更需要同步的信息配置, 客户端取宠物信息全部以宠物物品数据为准
|
| | | 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))
|
| | | #allAttrList = [{} for i in range(4)]
|
| | | ##计算技能对战斗属性的影响
|
| | | #PlayerPet.CalcSkill_PetBattleEffect(curPlayer, rolePet, allAttrList)
|
| | | ##计算Buff对战斗属性的影响
|
| | | #PlayerPet.CalcBuffer_PetBattleEffect(rolePet, allAttrList)
|
| | |
|
| | | #添加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]))
|
| | | #===========================================================================
|
| | | GameWorld.DebugLog("RefurbishPetAttr ID=%s,npcID=%s,maxAtk=%s,atkSpeed=%s" |
| | | % (curPet.GetID(), curPet.GetNPCID(), curPet.GetMaxAtk(), curPet.GetMaxAtk()))
|
| | | 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)
|
| | |
| | | #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)
|
| | |
| | | else:
|
| | | canOutPet = GameWorld.GetMap().GetMapCanOutPet()
|
| | | return canOutPet
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | ## 刷新宠物信息并通知客户端
|
| | | # @param rolePet 宠物实例
|
| | | # @return 无返回值
|
| | | # @remarks 刷新宠物信息并通知客户端
|
| | | def __RefreshAndSyncPetInfo(rolePet):
|
| | | #---刷新宠物信息(不通知客户端)---
|
| | | InitRolePet(rolePet, False)
|
| | |
|
| | | return
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | |
|