#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package AIType_100 # # @todo: ÕÙ»½ÊÞAI # @author Alee # @date 2013-06-18 22:30 # @version 1.1 # # ÏêϸÃèÊö: # @change: "2013-11-28 18:20" Alee ÉèÖÃÕÙ»½Ê޿ɹ¥»÷ #------------------------------------------------------------------------------ """Version = 2013-11-28 18:20""" #------------------------------------------------------------------------------ import IPY_GameWorld import GameWorld import NPCCommon import BaseAttack import ChConfig import AICommon import SkillShell import GameObj #--------------------------------------------------------------------- ## ³õʼ³ðºÞ # @param curNPC ʵÀý # @return None def DoInit(curNPC): curNPC.GetNPCAngry().Init(ChConfig.Def_BossAngryCount) ## AIÑ­»·µ÷Óà # @param curNPC ʵÀý # @return None def ProcessAI(curNPC, tick): if not curNPC.IsAlive(): #NPCËÀÍö return curNPCControl = NPCCommon.NPCControl(curNPC) if curNPC.GetLastTime() != 0 and tick - curNPC.GetBornTime() >= curNPC.GetLastTime(): #ÕÙ»½ÊÞ³¬¹ý´æ»îʱ¼ä, ÉèÖÃËÀÍö curNPCControl.SetKilled() return if not curNPC.GetCanAttack(): curNPC.SetCanAttack(True) curNPCOwner = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curNPC) if curNPCOwner == None: #ûÓÐÖ÷ÈË, ²»×öÈκζ¯×÷ return #ÕÙ»½ÊÞÓÅÏȹ¥»÷×Ô¼ºÖ÷ÈË´òµÄÄ¿±ê #Ë¢ÐÂ×Ô¼ºµÄbuff curNPCControl.RefreshBuffState(tick) if GameObj.GetHP(curNPC) == 0 : # BUFFË¢ÐÂÖпÉÄܻᵼÖÂNPCËÀÍö return #NPC¿ìËÙ±¼ÅÜÖÐ, ´¦Àí if curNPC.GetCurAction() == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun: __SummonOutRefreshArea(curNPC, curNPCControl) return #¿ÉÒÔ¹¥»÷µÄ¶ÔÏó masterAttackObj = AICommon.PlayerSummonAkObj(curNPC, tick, False) if masterAttackObj != None: __NPCFight(curNPC, masterAttackObj.GetID(), masterAttackObj.GetGameObjType(), tick) return #----------------ÕÙ»½ÊÞ¹¥»÷×Ô¼º³ðºÞÁбíÖеĶÔÏó #Ë¢ÐÂ×Ô¼º³ðºÞ¶ÈÁбí curNPCControl.RefreshAngryList(tick) curAngry = curNPCControl.GetMaxAngryTag() if curAngry == None: curNPCAction = curNPC.GetCurAction() #³ðºÞ¶ÈÁбíÖеÄÈËΪ¿Õ if curNPCAction == IPY_GameWorld.laNPCMove: #ÒÆ¶¯ÖÐ, ÔÝʱ²»´¦Àí pass elif curNPCAction == IPY_GameWorld.laNPCNull: #¿ÕÏÐ״̬,ÐèÒª¸úËæÖ÷ÈËÒÆ¶¯ __SummonMove(curNPC, curNPCOwner) elif curNPCAction == IPY_GameWorld.laNPCAttack: #Èç¹û¹¥»÷״̬,ÉèÖÃΪ¿ÕÏÐ״̬ curNPC.SetCurAction(IPY_GameWorld.laNPCNull) return __NPCFight(curNPC, curAngry.GetObjID(), curAngry.GetObjType(), tick) ## Õ½¶· # @param curNPC ʵÀý # @param tagID ¹¥»÷Ä¿±êID # @param tagType ¹¥»÷Ä¿±êÀàÐÍ # @param tick µ±Ç°Ê±¼ä # @return None def __NPCFight(curNPC, tagID, tagType, tick): curNPCControl = NPCCommon.NPCControl(curNPC) #×·»÷·µ»Ø if __SummonOutRefreshArea(curNPC, curNPCControl): return #¿ªÊ¼¹¥»÷ curTag = GameWorld.GetObj(tagID, tagType) if curTag == None or GameObj.GetHP(curTag) <= 0: return tagDist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curTag.GetPosX(), curTag.GetPosY()) #---ÓÅÏÈÊͷż¼ÄÜ--- if AICommon.DoAutoUseSkill(curNPC, curTag, tagDist, tick): return #---ÊÍ·ÅÆÕͨ¹¥»÷--- if tagDist > curNPC.GetAtkDist(): curNPCControl.MoveToObj_Detel(curTag) return #¹¥»÷Âß¼­ if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval(): #¹¥»÷¼ä¸ôûÓе½, ·µ»Ø return if curNPCControl.FixTagPos(curTag.GetPosX(), curTag.GetPosY()): #ÐÞÕýÕâ¸öNPCµÄÕ¾Á¢Î»Öà return #ÆÕͨ¹¥»÷ BaseAttack.Attack(curNPC, curTag, None, tick) return ## ÕÙ»½ÊÞÒÆ¶¯ # @param curNPC ʵÀý # @return None def __SummonMove(curNPC, curPlayer): npcControl = NPCCommon.NPCControl(curNPC) dist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curPlayer.GetPosX(), curPlayer.GetPosY()) #Í£Ö¹¾àÀë stopDist = 3 #¸úËæ¾àÀë followDist = ChConfig.Def_Screen_Area if dist < stopDist: pass elif dist < followDist: npcControl.MoveToObj_Detel(curPlayer) else: #˲¼äÒÆ¶¯ __SummonResetPos(curNPC, curPlayer, npcControl) return ##ÕÙ»½ÊÞ³¬¹ýÇø¼ä # @param curNPC ʵÀý # @return None def __SummonOutRefreshArea(curNPC, npcControl): curPlayer = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curNPC) if curPlayer == None: return dist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curPlayer.GetPosX(), curPlayer.GetPosY()) if dist < ChConfig.Def_PlayerSight_Default: return #ÖØÖÃλÖà __SummonResetPos(curNPC, curPlayer, npcControl) return True ##ÖØÖÃλÖà # @param curNPC ʵÀý # @return None def __SummonResetPos(curNPC, curPlayer, npcControl): #Çå¿Õ³ðºÞ,Çå¿ÕÉËѪÁбí npcControl.ClearNPCAngry() npcControl.ClearNPCHurtList() moveDestX, moveDestY = npcControl.GetMoveNearPos(curPlayer.GetPosX(), curPlayer.GetPosY(), ChConfig.Def_PlayerTurckBeginMoveDist) curNPC.ResetPos(moveDestX, moveDestY) #ÖØÖÃNPCΪ¿ÕÏÐ״̬ curNPC.SetCurAction(IPY_GameWorld.laNPCNull) return