#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package AIType_186 # # @todo: NPCͨ¹ý±í¶ÁÈ¡Êͷż¼ÄÜ # @author Alee # @date 2011-05-18 18:00 # @version 2.2 # # ÏêϸÃèÊö: # @change: "2013-06-18 22:30" Alee С¹Ö³ðºÞÊýËõС # @change: "2014-01-28 15:30" hxp Ôö¼ÓÄêÊÞÊ£ÓàѪÁ¿¹ã²¥ # @change: "2014-02-21 14:20" hxp Ôö¼ÓÊÀ½çbossÂß¼­£¬¹¥»÷»ÆÃû£¬Ê£ÓàѪÁ¿¹ã²¥ # @change: "2014-02-27 12:00" hxp Ôö¼ÓNPCѪÁ¿°Ù·Ö±ÈÂß¼­Èë¿Ú # @change: "2014-03-11 19:30" hxp ÐÞ¸ÄÃþÊÀ½çboss»ÆÃûbuffID # @change: "2014-04-14 12:00" hxp Ôö¼ÓbossËÀÍöÕÙ»½²É¼¯Îï # @change: "2014-09-24 17:00" hxp ÃþÊÀ½çbossbuffÌí¼ÓÂß¼­ÐÞ¸Ä # @change: "2014-10-27 21:00" hxp ¹¥»÷bossÊÇ·ñ»ñµÃbuff¿ª³öÅäÖà # @change: "2014-12-08 21:30" hxp ÓÅ»¯AI # @change: "2014-12-15 07:20" Alee ½µµÍNPCAIÏûºÄ # @change: "2014-12-31 14:40" Alee ½µµÍNPCAIÏûºÄ # @change: "2016-11-22 21:00" hxp Ö§³ÖÌí¼Ó×î´ó³ðºÞbuff #------------------------------------------------------------------------------ #"""Version = 2016-11-22 21:00""" #------------------------------------------------------------------------------- import ChConfig import NPCCommon import AICommon import IPY_GameWorld import GameWorld import BaseAttack import PlayerState import GameObj ## ³õʼ»¯ # @param curNPC µ±Ç°npc # @return None # @remarks º¯ÊýÏêϸ˵Ã÷. def DoInit(curNPC): angryCount = ChConfig.Def_NormalNPCAngryCount if ChConfig.IsGameBoss(curNPC): angryCount = ChConfig.Def_SuperFBBossAngryCount # ³ðºÞ¹éÊôÒòΪÐèÒª¶ÓԱͬʱ¼Ó³ðºÞ£¬ËùÒÔ³ðºÞÊýÉèÖôóµã if NPCCommon.GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_MaxAngry: angryCount = ChConfig.Def_SuperBossAngryCount curNPC.GetNPCAngry().Init(angryCount) 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 curNPC.IsAlive() != True: #NPCËÀÍö, ½øÈëËÀÍöµ¹¼ÆÊ± if npcControl.DieTick(tick) == 0: return #Ë¢ÐÂ×Ô¼ºµÄbuff if curNPC.GetIsBoss(): npcControl.RefreshBuffState(tick) if GameObj.GetHP(curNPC) == 0 : # BUFFË¢ÐÂÖпÉÄܻᵼÖÂNPCËÀÍö return curNPCAction = curNPC.GetCurAction() if curNPCAction == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun: AICommon.NormalNPCFast_Move(curNPC, tick) return #ĬÈϹ¥»÷¹éÊôÕß tagObj = npcControl.RefreshDropOwner(tick) if not curNPC.GetIsNeedProcess() or not tagObj: # ÏÈ»ØÑª£¬µÈ»ØÂúÔÙ×öÆäËûÊÂÇé if curNPCAction == IPY_GameWorld.laNPCNull and not npcControl.ProcessHPRestore(tick): AICommon.NormalNPCFree_Move(curNPC, tick) return #¹¥»÷Âß¼­ __NPCFight(curNPC, tagObj, tick) npcControl.DoHPPerLogic(ChConfig.Def_NPCHurtTypeAll, 0) return ## ÿ´Î±»¹¥»÷´¦Àí½á¹û # @param atkObj ¹¥»÷·¢ÆðÕß # @param defObj ±»¹¥»÷Õß # @param skill ¹¥»÷¼¼ÄÜ # @param tick # @return ¾ßÌåÉ˺¦Öµ def OnAttacked(atkObj, curNPC, skill, tick): if atkObj.GetGameObjType() == IPY_GameWorld.gotPlayer: PlayerState.SetBossStateTick(atkObj, tick) return def OnCheckCanDie(atkObj, curNPC, skill, tick): ## ¼ì²éNPCÊÇ·ñ¿ÉËÀÍö dropOwnerType = NPCCommon.GetDropOwnerType(curNPC) if dropOwnerType not in [ChConfig.DropOwnerType_MaxHurt]: return True npcControl = NPCCommon.NPCControl(curNPC) tagObj = npcControl.RefreshDropOwner(tick, 0, checkCanDead=True) if not atkObj or not tagObj: GameObj.SetHP(curNPC, 1) skillID = 0 if not skill else skill.GetSkillID() GameWorld.ErrLog("Bossµ±Ç°×´Ì¬Ï²»¿ÉÒÔËÀÍö£¡npcID=%s,skillID=%s,atkObj=%s,tagObj=%s" % (curNPC.GetNPCID(), skillID, atkObj, tagObj)) return False return True ## NPC±»Íæ¼ÒɱËÀ def OnAttackDieByPlayer(curNPC, curPlayer, skill): tick = GameWorld.GetGameWorld().GetTick() PlayerState.SetBossStateTick(curPlayer, tick) #±»»÷É±Ê±Ç¿ÖÆË¢Ð¹éÊô npcControl = NPCCommon.NPCControl(curNPC) npcControl.RefreshDropOwner(tick, 0, True) return ## NPCËÀÍö´¦Àí # @param curNPC ËÀÍöNPC # @param HurtType µôÂäÀàÐÍ # @param HurtID ¶ÔÓ¦ÓµÓÐÕßid # @param modulus µôÂäϵÊý # @return None def OnDie(curNPC, HurtType, HurtID): AICommon.DoNPCUseSkillOnDie(curNPC) return def OnNPCSetDead(curNPC): npcControl = NPCCommon.NPCControl(curNPC) npcControl.DelayDropOwnerBuffDisappearTime() return ## npc¹¥»÷Âß¼­ # @param curNPC µ±Ç°npc # @param tagID curNPCAngryID # @param tagType curNPCAngryType # @param tick µ±Ç°Ê±¼ä # @return None # @remarks º¯ÊýÏêϸ˵Ã÷. def __NPCFight(curNPC, curTag, tick): #Ô¤¾¯´¦Àí if AICommon.DoNPCSkillWarningProcess(curNPC, tick): return #ÉèÖýøÈëÕ½¶·×´Ì¬ NPCCommon.SetNPCInBattleState(curNPC) npcControl = NPCCommon.NPCControl(curNPC) #²»ÔÚÒÆ¶¯·¶Î§ if npcControl.IsInRefreshArea() != True: #×·»÷·µ»Ø npcControl.MoveBack() return #¿ªÊ¼¹¥»÷ 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(): npcControl.MoveToObj_Detel(curTag) return if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval(): #¹¥»÷¼ä¸ôûÓе½, ·µ»Ø return if npcControl.FixTagPos(curTag.GetPosX(), curTag.GetPosY()): #ÐÞÕýÕâ¸öNPCµÄÕ¾Á¢Î»Öà return #ÆÕͨ¹¥»÷ BaseAttack.Attack(curNPC, curTag, None, tick) return