#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#  
 | 
#  
 | 
##@package AIType_63.py  
 | 
#  
 | 
# @todo:ÕÙ»½ÊÞAI (¹¥»÷5´Î¾Í»á¼ÌÐø·ÖÁÑ)  
 | 
#  
 | 
# @author jiang  
 | 
# @date 2012-07-13  
 | 
# @version 1.0  
 | 
# @note:  
 | 
#  
 | 
#------------------------------------------------------------------------------   
 | 
"""Version = 2012-07-13 15:30"""  
 | 
#------------------------------------------------------------------------------   
 | 
# µ¼Èë  
 | 
import GameWorld  
 | 
import IPY_GameWorld  
 | 
import ChConfig  
 | 
import NPCCommon  
 | 
import SkillShell  
 | 
import BaseAttack  
 | 
import SkillCommon  
 | 
import AICommon  
 | 
import GameObj  
 | 
#------------------------------------------------------------------------------  
 | 
   
 | 
Def_AtkCount = "AtkCount"  # ¹¥»÷´ÎÊý  
 | 
Def_MaxAtkCountSplit = 5  # ¹¥»÷¶àÉÙ´Î×Ô¶¯·ÖÁÑ  
 | 
Def_SplitSkillID = 33787  # ·ÖÁѼ¼ID  
 | 
#------------------------------------------------------------------------------   
 | 
## ³õʼ»¯  
 | 
#  @param curNPC µ±Ç°npc  
 | 
#  @return None  
 | 
def DoInit(curNPC):  
 | 
    curNPC.GetNPCAngry().Init(ChConfig.Def_SummonNPC_Angry_Count)  
 | 
    return  
 | 
  
 | 
  
 | 
## Ö´ÐÐAI  
 | 
#  @param curNPC µ±Ç°npc  
 | 
#  @param tick µ±Ç°Ê±¼ä  
 | 
#  @return None  
 | 
def ProcessAI(curNPC, tick):  
 | 
      
 | 
    #NPCÒÑËÀÍö£¬Ìø³ö  
 | 
    if curNPC.IsAlive() != True:  
 | 
        return  
 | 
      
 | 
    curNPCAction = curNPC.GetCurAction()  
 | 
    #NPC¿ìËÙ±¼ÅÜÖÐ, ´¦Àí  
 | 
    if curNPCAction == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun:  
 | 
        AICommon.NormalNPCFast_Move(curNPC, tick)  
 | 
        return  
 | 
      
 | 
    npcControl = NPCCommon.NPCControl(curNPC)  
 | 
      
 | 
    #Ë¢ÐÂ×Ô¼º³ðºÞ¶ÈÁÐ±í  
 | 
    npcControl.RefreshAngryList(tick)  
 | 
    curAngry = npcControl.GetMaxAngryTag()  
 | 
    if not curAngry:  
 | 
        #ûÓгðºÞ¶ÔÏó  
 | 
        AICommon.NormalNPCFree_Move(curNPC, tick)  
 | 
        return  
 | 
      
 | 
    if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval():  
 | 
        #¹¥»÷¼ä¸ôûÓе½  
 | 
        return  
 | 
      
 | 
    #³ðºÞ¶ÔÏóÀàÐÍ, ³ðºÞ¶ÔÏóID  
 | 
    curNPCAngryType = curAngry.GetObjType()  
 | 
    curNPCAngryID = curAngry.GetObjID()  
 | 
  
 | 
    #npc¹¥»÷Âß¼  
 | 
    if not __NPCFight(curNPC, curNPCAngryID, curNPCAngryType, tick):  
 | 
        return  
 | 
      
 | 
    #¼Ç¼NPC¹¥»÷´ÎÊý, ²¢·ÖÁÑ  
 | 
    __SetAccumulativeAtkCount(curNPC, tick)  
 | 
    return  
 | 
  
 | 
  
 | 
## ¼Ç¼NPC¹¥»÷´ÎÊý, ²¢·ÖÁÑ  
 | 
#  @param curNPC: NPCʵÀý  
 | 
#  @return:   
 | 
def __SetAccumulativeAtkCount(curNPC, tick):  
 | 
      
 | 
    #¼Ç¼¹¥»÷´ÎÊý  
 | 
    curNPC.SetDict(Def_AtkCount, curNPC.GetDictByKey(Def_AtkCount) + 1)  
 | 
      
 | 
    atkCount = curNPC.GetDictByKey(Def_AtkCount)  
 | 
    if atkCount < Def_MaxAtkCountSplit:  
 | 
        #δ´ïµ½¹¥»÷´ÎÊý, ÎÞ·¨·ÖÁÑ  
 | 
        return  
 | 
      
 | 
    curSkill = GameWorld.GetGameData().GetSkillBySkillID(Def_SplitSkillID)  
 | 
    if curSkill == None:  
 | 
        return  
 | 
      
 | 
    #Ê©·Å·ÖÁѼ¼ÄÜ, ·ÖÁÑ×Ô¼º  
 | 
    curSummonNPCOwner = NPCCommon.GetSummonOwnerDetel(curNPC)  
 | 
    if not curSummonNPCOwner:  
 | 
        return  
 | 
      
 | 
    SkillShell.NPCUseSkill(curSummonNPCOwner, curSkill, tick)  
 | 
          
 | 
    #ÖØÖù¥»÷´ÎÊý  
 | 
    curNPC.SetDict(Def_AtkCount, 0)  
 | 
    return  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## npc¹¥»÷Âß¼  
 | 
#  @param curNPC µ±Ç°npc  
 | 
#  @param tagID curNPCAngryID  
 | 
#  @param tagType curNPCAngryType   
 | 
#  @param tick µ±Ç°Ê±¼ä  
 | 
#  @return ¹¥»÷ÊÇ·ñ³É¹¦  
 | 
def __NPCFight(curNPC, tagID, tagType, tick):  
 | 
    #ÉèÖýøÈëÕ½¶·×´Ì¬  
 | 
    NPCCommon.SetNPCInBattleState(curNPC)  
 | 
    npcControl = NPCCommon.NPCControl(curNPC)  
 | 
      
 | 
    #ÊÇ·ñÔÚÒÆ¶¯·¶Î§ÄÚ  
 | 
    if not npcControl.IsInRefreshArea():  
 | 
        #×·»÷·µ»Ø  
 | 
        npcControl.MoveBack()  
 | 
        return False  
 | 
      
 | 
    #¿ªÊ¼¹¥»÷  
 | 
    curTag = GameWorld.GetObj(tagID, tagType)  
 | 
    if curTag == None or GameObj.GetHP(curTag) <= 0:  
 | 
        return False  
 | 
      
 | 
    tagDist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curTag.GetPosX(), curTag.GetPosY())  
 | 
      
 | 
    #---ÓÅÏÈÊͷż¼ÄÜ---  
 | 
    if AICommon.DoAutoUseSkill(curNPC, curTag, tagDist, tick):  
 | 
        return True  
 | 
      
 | 
    #---ÊÍ·ÅÆÕͨ¹¥»÷---  
 | 
      
 | 
    #³¬¹ý¹¥»÷¾àÀë,ÒÆ¶¯¹ýÈ¥  
 | 
    if tagDist > curNPC.GetAtkDist():  
 | 
        npcControl.MoveToObj_Detel(curTag)  
 | 
        return False  
 | 
      
 | 
    if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval():  
 | 
        #¹¥»÷¼ä¸ôûÓе½, ·µ»Ø  
 | 
        return False  
 | 
      
 | 
    if npcControl.FixTagPos(curTag.GetPosX(), curTag.GetPosY()):  
 | 
        #ÐÞÕýÕâ¸öNPCµÄÕ¾Á¢Î»Öà  
 | 
        return False  
 | 
      
 | 
    #ÆÕͨ¹¥»÷  
 | 
    return BaseAttack.Attack(curNPC, curTag, None, tick)  
 | 
          
 |