#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package NPCAI.AIType_197
|
#
|
# @todo:ÅÜÅÜÅÜ
|
# @author hxp
|
# @date 2017-11-25
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ÅÜÅÜÅÜ
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2017-11-25 16:00"""
|
#-------------------------------------------------------------------------------
|
import IPY_GameWorld
|
import IpyGameDataPY
|
import GameWorld
|
import NPCCommon
|
import OperControlManager
|
import ChConfig
|
import GameObj
|
#-------------------------------------------------------------------------------
|
Def_NPCKey_PointIndex = "PointIndex" # µ±Ç°Ä¿±êµãË÷Òý
|
|
## ³õʼ»¯
|
# @param curNPC µ±Ç°npc
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def DoInit(curNPC):
|
return
|
|
def OnNPCReborn(curNPC):
|
curNPC.SetDict(Def_NPCKey_PointIndex, 0)
|
#curNPC.SetVisible(True)
|
curNPC.SetIsNeedProcess(True)
|
return
|
|
## Ö´ÐÐAI
|
# @param curNPC µ±Ç°npc
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def ProcessAI(curNPC, tick):
|
curNPCAction = curNPC.GetCurAction()
|
|
if curNPCAction == IPY_GameWorld.laNPCDie or not curNPC.IsAlive():
|
return
|
|
npcControl = NPCCommon.NPCControl(curNPC)
|
#Ë¢ÐÂ×Ô¼ºµÄbuff
|
npcControl.RefreshBuffState(tick)
|
if GameObj.GetHP(curNPC) == 0 :
|
# BUFFË¢ÐÂÖпÉÄܻᵼÖÂNPCËÀÍö
|
return
|
|
ai197PointDict = IpyGameDataPY.GetFuncEvalCfg("AI197Point")
|
mapID = GameWorld.GetMap().GetMapID()
|
# Ö§³ÖJson¸ñʽkey£¬¿Í»§¶ËÐèÒªÓõ½
|
if str(mapID) in ai197PointDict:
|
movePointList = ai197PointDict[str(mapID)]
|
elif mapID in ai197PointDict:
|
movePointList = ai197PointDict[mapID]
|
else:
|
GameWorld.ErrLog("µØÍ¼Ã»ÓÐÅäÖÃAI197NPCÅÜÅÜÅÜÒÆ¶¯Ä¿±êÏß·µã£¡mapID=%s" % mapID)
|
return
|
if not movePointList:
|
return
|
pointIndex = curNPC.GetDictByKey(Def_NPCKey_PointIndex)
|
destPosX, destPosY = movePointList[pointIndex]
|
curPosX, curPosY = curNPC.GetPosX(), curNPC.GetPosY()
|
curDis = GameWorld.GetDist(curPosX, curPosY, destPosX, destPosY)
|
#Èç¹ûÀëÄ¿±êµã±È½Ï½üµÄ»° È¡ÏÂÒ»¸öÄ¿±êµã
|
while curDis <= 6 and pointIndex < len(movePointList) - 1:
|
pointIndex += 1
|
curNPC.SetDict(Def_NPCKey_PointIndex, pointIndex)
|
destPosX, destPosY = movePointList[pointIndex]
|
curDis = GameWorld.GetDist(curPosX, curPosY, destPosX, destPosY)
|
|
if curDis != 0:
|
if curNPC.GetCurAction() == IPY_GameWorld.laNPCMove:
|
return
|
|
|
#²»¿ÉÒÆ¶¯ÐÐΪ״̬, ·þÎñ¶ËÏÞÖÆ
|
if not OperControlManager.IsObjCanDoAction(curNPC,
|
ChConfig.Def_Obj_ActState_ServerAct,
|
IPY_GameWorld.oalMove):
|
return
|
|
curNPC.Move(destPosX, destPosY)
|
return
|
|
# µ½´ïÄ¿µÄµØ
|
#curNPC.SetVisible(False)
|
NPCCommon.SetDeadEx(curNPC)
|
return
|
|
|