| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #  | 
| # @todo: ¹¥»÷ÓëÍæ¼ÒͬƵÂʵÄÕÙ»½ÊÞ£¬AIÖ»´¦Àí¸úËæ  | 
| #  | 
| # @author: Alee  | 
| # @date 2018-1-29 ÉÏÎç11:42:59  | 
| # @version 1.0  | 
| #  | 
| # @note:   | 
| #  | 
| #---------------------------------------------------------------------  | 
| #------------------------------------------------------------------------------  | 
|   | 
| import IPY_GameWorld  | 
| import GameWorld  | 
| import NPCCommon  | 
| import ChConfig  | 
| 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  | 
|           | 
|     curNPCOwner = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curNPC)  | 
|     if curNPCOwner == None:  | 
|         #ûÓÐÖ÷ÈË, ²»×öÈκζ¯×÷  | 
|         return  | 
|       | 
|           | 
|     #NPC¿ìËÙ±¼ÅÜÖÐ, ´¦Àí  | 
|     if curNPC.GetCurAction() == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun:  | 
|         __SummonOutRefreshArea(curNPC, curNPCControl)  | 
|         return  | 
|   | 
|     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  | 
|       | 
|   | 
| ## ÕÙ»½ÊÞÒÆ¶¯  | 
| #  @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, stopDist)  | 
|     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  | 
|   | 
|   |