| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package NPCAI.AIType_4  | 
| #  | 
| # @todo:¿ìËÙÒÆ¶¯µÄѲÂß¹Ö  | 
| # @author hxp  | 
| # @date 2016-11-25  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ¿ìËÙÒÆ¶¯µÄѲÂß¹Ö, ÒÔË¢¹ÖµãΪÖÐÐÄµã£¬ÒÆ¶¯ÇøÓòΪ°ë¾¶µÄÇøÓòËæ»úÒÆ¶¯  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2016-11-25 15:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import NPCCommon  | 
| import IPY_GameWorld  | 
| import GameWorld  | 
| import random  | 
|   | 
|   | 
| ## ³õʼ»¯  | 
| #  @param curNPC µ±Ç°npc  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DoInit(curNPC):  | 
|     curNPC.GetNPCAngry().Init(0)  | 
|     return  | 
|   | 
| ## Ö´ÐÐAI  | 
| #  @param curNPC µ±Ç°npc  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def ProcessAI(curNPC, tick):  | 
|     #GameWorld.DebugLog("AIType_4... id=%s,npcID=%s" % (curNPC.GetID(), curNPC.GetNPCID()))  | 
|       | 
|     npcControl = NPCCommon.NPCControl(curNPC)  | 
|       | 
|     if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or curNPC.IsAlive() != True:  | 
|         #NPCËÀÍö, ½øÈëËÀÍöµ¹¼ÆÊ±  | 
|         if npcControl.DieTick(tick) == 0:  | 
|             return  | 
|           | 
|     curNPCAction = curNPC.GetCurAction()      | 
|     if curNPCAction == IPY_GameWorld.laNPCMove:  | 
|         return  | 
|       | 
|     PosMap = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())  | 
|     if not PosMap:  | 
|         return  | 
|     posMapX = PosMap.GetPosX()  | 
|     posMapY = PosMap.GetPosY()  | 
|     #posMapArea = PosMap.GetArea() # Ë¢¹ÖÇøÓò  | 
|       | 
|     moveDist = PosMap.GetMoveDist() # Òƶ¯ÇøÓò  | 
|       | 
|     #moveArea = curNPC.GetMoveArea()  | 
|     #posX = curNPC.GetPosX()  | 
|     #posY = curNPC.GetPosY()  | 
|       | 
|     minMovePosX = posMapX - moveDist  | 
|     maxMovePosX = posMapX + moveDist  | 
|     minMovePosY = posMapY - moveDist  | 
|     maxMovePosY = posMapY + moveDist  | 
|       | 
|     # Ëæ»úÒ»¸öÒÔË¢¹ÖµãΪÖÐÐÄµã£¬ÒÆ¶¯ÇøÓòΪ°ë¾¶µÄµã  | 
|     randPosX = random.randint(minMovePosX, maxMovePosX)  | 
|     randPosY = random.randint(minMovePosY, maxMovePosY)  | 
|       | 
|     #NPCÒÆ¶¯  | 
|     newPoint = GameWorld.GetMap().LineNearToPos(curNPC.GetPosX(), curNPC.GetPosY(), randPosX, randPosY, 0)  | 
|     #GameWorld.DebugLog("    posMap=(%s,%s,%s), moveDist=%s, randPos=(%s,%s),newPoint=(%s,%s)"   | 
|     #                   % (posMapX, posMapY, posMapArea, moveDist, randPosX, randPosY, newPoint.GetPosX(), newPoint.GetPosY()))  | 
|       | 
|     curNPC.Move(newPoint.GetPosX(), newPoint.GetPosY())  | 
|     return  | 
|       | 
|   | 
|   |