From 143c55479cbb2f77883ca8a87c7f42c2ddcb8673 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 03 十二月 2024 15:31:51 +0800 Subject: [PATCH] 4999 【bt】【英文】【越南】优化灵宠战斗(主人不攻击时,灵宠达到攻击间隔也会主动攻击可攻击的目标;灵宠攻击目标增加可攻击视野内主动怪,攻击顺序为:主人攻击目标 > 攻击主人的目标 > 视野内主动怪) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_105.py | 5 +++++ ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PetControl.py | 29 ++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_105.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_105.py index 25acd59..c62bf78 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_105.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_105.py @@ -18,6 +18,7 @@ import AICommon import ChConfig import GameObj +import PetControl Def_LastAI1ProTick = "LastAI1ProTick" # 最后一次执行tick @@ -60,6 +61,10 @@ posX, posY = petControl.GetMoveNearPos(curPlayer.GetPosX(), curPlayer.GetPosY(), 1) rolePet.ResetPos(posX, posY) + + if tick - rolePet.GetAttackTick() >= rolePet.GetAtkInterval(): + PetControl.PetFight(curPlayer, tick) + #=========================================================================== # skillManager = rolePet.GetSkillManager() # for index in range(0, skillManager.GetSkillCount()): diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PetControl.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PetControl.py index 371a3c2..33107f2 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PetControl.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PetControl.py @@ -47,6 +47,7 @@ import PassiveBuffEffMng import ChNetSendPack import IpyGameDataPY +import AttackCommon #--------------------------------------------------------------------- DefPetRebornHPRate = 100 # 宠物死亡复活血量百分比 @@ -92,7 +93,33 @@ curTag = curPlayer.GetAngryNPCByIndex(i) if not curTag or GameObj.GetHP(curTag) <= 0: continue - + + # 还没有就从视野中查找 + if not curTag or GameObj.GetHP(curTag) <= 0: + seePlayerCount = rolePet.GetInSightObjCount() + for i in range(0, seePlayerCount): + seeObj = rolePet.GetInSightObjByIndex(i) + if seeObj == None: + continue + seeObjID = seeObj.GetID() + seeObjType = seeObj.GetGameObjType() + # 只允许主动攻击NPC,且目标NPC是主动怪 + if seeObjType != IPY_GameWorld.gotNPC: + continue + seeObjDetail = GameWorld.GetObj(seeObjID, seeObjType) + if not seeObjDetail: + continue + if seeObjDetail.GetAtkType() == 1: + # 1为非主动怪 + continue + if not AttackCommon.CheckCanAttackTag(rolePet, seeObjDetail): + continue + relation = BaseAttack.GetTagRelation(rolePet, seeObjDetail, None, tick)[0] + if relation != ChConfig.Type_Relation_Enemy: + continue + curTag = seeObjDetail + break + if not curTag or GameObj.GetHP(curTag) <= 0: return -- Gitblit v1.8.0