From 41057fec56d9aac981044aead9a74aac4b09ba4f Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期一, 09 十一月 2020 17:43:55 +0800 Subject: [PATCH] 8596 【港台】【后端】每日分享好礼;8599 【港台】【后端】好评有礼; --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py | 173 ++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 116 insertions(+), 57 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py index ac0b481..4cacc9f 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py @@ -1,63 +1,60 @@ #!/usr/bin/python # -*- coding: GBK -*- -#--------------------------------------------------------------------- -##@package AIType_21 -#巡逻守卫AI,攻击非本国家玩家,和红名玩家 +#------------------------------------------------------------------------------- # -# @author PanWei -# @date 2010-4-28下午06:01:33 -# @version 1.4 +##@package NPCAI.AIType_21 # -#模块详细说明. -# @change: "2010-05-12 18:30" zhengyang 添加注释 -# @change: "2010-06-09 09:50" zhengyang 守卫npc加入异常状态眩晕判断 -# @change: 2010-06-14 16:00 zhengyang 修正普攻参数传错 -# @change: "2010-11-22 12:15" Alee 删除异常/沉默判定 -#--------------------------------------------------------------------- -"""Version = 2010-11-22 12:15""" -#--------------------------------------------------------------------- -import IPY_GameWorld -import GameWorld -import NPCCommon -import BaseAttack +# @todo:副本活动机器人 +# @author hxp +# @date 2018-12-06 +# @version 1.0 +# +# 详细描述: 副本活动机器人 +# +#------------------------------------------------------------------------------- +#"""Version = 2018-12-06 20:00""" +#------------------------------------------------------------------------------- + import ChConfig import AICommon +import NPCCommon +import BaseAttack +import IpyGameDataPY +import IPY_GameWorld +import GameWorld +import FBCommon import GameObj + +import random +#--------------------------------------------------------------------- + #--------------------------------------------------------------------- ## 初始化 -# @param curNPC NPC实例 +# @param curNPC 当前npc # @return None # @remarks 函数详细说明. def DoInit(curNPC): - curNPC.GetNPCAngry().Init(ChConfig.Def_BossAngryCount) + curNPC.GetNPCAngry().Init(ChConfig.Def_SuperFBBossAngryCount) + return -#--------------------------------------------------------------------- -##正常AI逻辑处理 -#@param curNPC NPC实例 -#@param tick 时间戳 -#@return 返回值无意义 -#@remarks 正常AI逻辑处理 +def OnNPCReborn(curNPC): + curNPC.SetIsNeedProcess(True) + return + +## 执行AI +# @param curNPC 当前npc +# @param tick 当前时间 +# @return None +# @remarks 函数详细说明. def ProcessAI(curNPC, tick): npcControl = NPCCommon.NPCControl(curNPC) if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or not curNPC.IsAlive(): - #NPC死亡, 进入死亡倒计时 - if npcControl.DieTick(tick) == 0: - return - - #刷新自己的buff - npcControl.RefreshBuffState(tick) - if GameObj.GetHP(curNPC) == 0 : - # BUFF刷新中可能会导致NPC死亡 return -# #判断异常状态 -# if curNPC.GetAbnormalState() == IPY_GameWorld.sctFaint: -# return - - curNPCAction = curNPC.GetCurAction() - #NPC快速奔跑中, 处理 - if curNPCAction == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun : - AICommon.NormalNPCFast_Move(curNPC , tick) + #刷新自己的buff + npcControl.RefreshBuffState(tick) + if GameObj.GetHP(curNPC) == 0: + # BUFF刷新中可能会导致NPC死亡 return #刷新自己仇恨度列表 @@ -65,35 +62,64 @@ curNPCAngry = npcControl.GetMaxAngryTag() #仇恨度列表中的人为空 - if curNPCAngry == None : - AICommon.NormalNPCFree_Move(curNPC , tick) + if curNPCAngry == None: + if curNPC.GetSpeed() != 0: + __RobotMove(curNPC) return #仇恨对象类型,仇恨对象ID curNPCAngryType = curNPCAngry.GetObjType() curNPCAngryID = curNPCAngry.GetObjID() - #战斗中回血 - npcControl.ProcessBattleHPRestore(tick) + #执行攻击逻辑 __NPCFight(curNPC, curNPCAngryID, curNPCAngryType, tick) + return + +def __RobotMove(curNPC): + if curNPC.GetCurAction() == IPY_GameWorld.laNPCMove: + #GameWorld.DebugLog("移动中不处理!(%s,%s)" % (curNPC.GetPosX(), curNPC.GetPosY())) + return + mapID = GameWorld.GetMap().GetMapID() + lineID = FBCommon.GetFBPropertyMark() + posKey = "%d%02d" % (mapID, lineID) + fbMovePosDict = IpyGameDataPY.GetFuncCfg("AI198Point", 1) + if posKey not in fbMovePosDict: + posKey = "%d%02d" % (mapID, 0) + if posKey not in fbMovePosDict: + return + + posList = fbMovePosDict[posKey] + Key_PosIndex = "RobotMovePosIndex" # NPC上次移动的坐标索引,存值+1 + posIndex = curNPC.GetDictByKey(Key_PosIndex) - 1 + if posIndex < 0: + # 还没有走过点的,寻找所有点中最近的点 + posIndex = random.randint(0, len(posList) - 1) + else: + tagPosX, tagPosY = posList[posIndex] + tagDist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), tagPosX, tagPosY) + if tagDist < 2: + posIndex += 1 + + if posIndex < 0 or posIndex >= len(posList): + posIndex = random.randint(0, len(posList) - 1) + + curNPC.SetDict(Key_PosIndex, posIndex + 1) + tagPosX, tagPosY = posList[posIndex] + curNPC.Move(tagPosX, tagPosY) + return #--------------------------------------------------------------------- -## npc攻击战斗 +## npc攻击逻辑 # @param curNPC 当前npc # @param tagID curNPCAngryID # @param tagType curNPCAngryType # @param tick 当前时间 # @return None -# @remarks 战斗逻辑实现 +# @remarks 函数详细说明. def __NPCFight(curNPC, tagID, tagType, tick): #设置进入战斗状态 NPCCommon.SetNPCInBattleState(curNPC) npcControl = NPCCommon.NPCControl(curNPC) - #NPC的打怪AI - if not npcControl.IsInRefreshArea(): - #追击返回 - npcControl.MoveBack() - return #开始攻击 curTag = GameWorld.GetObj(tagID, tagType) @@ -103,10 +129,37 @@ tagDist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curTag.GetPosX(), curTag.GetPosY()) - if tagDist > curNPC.GetAtkDist() : - npcControl.MoveToObj_Detel(curTag) + #---优先释放技能--- + if AICommon.DoAutoUseSkill(curNPC, curTag, tagDist, tick): return + #---释放普通攻击--- + + if curNPC.GetSpeed() == 0: + # 不可移动NPC + if tagDist > curNPC.GetAtkDist(): + return + + if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval(): + #攻击间隔没有到, 返回 + return + + #普通攻击 + BaseAttack.Attack(curNPC, curTag, None, tick) + return + + #超过攻击距离,移动过去 + if tagDist > curNPC.GetAtkDist(): + + destDist = GameWorld.GetDist(curNPC.GetDestPosX() , curNPC.GetDestPosY(), curTag.GetPosX(), curTag.GetPosY()) + if destDist <= curNPC.GetAtkDist() and curNPC.GetCurAction() == IPY_GameWorld.laNPCMove: + # 目标在移动的攻击范围内,不改变目标点 + return + npcControl.MoveToObj_Detel(curTag) + return + else: + curNPC.StopMove() + if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval(): #攻击间隔没有到, 返回 return @@ -118,7 +171,13 @@ #普通攻击 BaseAttack.Attack(curNPC, curTag, None, tick) return - +## NPC死亡 +# @param curNPC 当前npc +# @param hurtType 伤害者的obj类型 +# @param hurtID 伤害者的objID +# @return None +def OnDie(curNPC, hurtType, hurtID): + AICommon.DoNPCUseSkillOnDie(curNPC) + return - -- Gitblit v1.8.0