#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#---------------------------------------------------------------------
|
#
|
#---------------------------------------------------------------------
|
##@package AIType_180
|
# @todo: С¹ÖͨÓÃ×Ô¶¯Êͷż¼ÄÜAI
|
#
|
# @author: panwei
|
# @date 2010-08-04
|
# @version 1.2
|
#
|
# @note:
|
# @change: "2010-11-22 12:15" Alee ɾ³ýÒì³£/³ÁĬÅж¨
|
# @change: "2011-05-09 15:00" panwei ³ðºÞÁбí±ä¸ü
|
#---------------------------------------------------------------------
|
"""Version = 2011-05-09 15:00"""
|
#---------------------------------------------------------------------
|
import IPY_GameWorld
|
import GameWorld
|
import NPCCommon
|
import BaseAttack
|
import ChConfig
|
import AICommon
|
import GameObj
|
#---------------------------------------------------------------------
|
|
#---------------------------------------------------------------------
|
## ³õʼ»¯
|
# @param curNPC µ±Ç°npc
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def DoInit(curNPC):
|
curNPC.GetNPCAngry().Init(ChConfig.Def_SuperFBBossAngryCount)
|
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 not curNPC.IsAlive():
|
#NPCËÀÍö, ½øÈëËÀÍöµ¹¼ÆÊ±
|
if npcControl.DieTick(tick) == 0:
|
return
|
|
#Ë¢ÐÂ×Ô¼ºµÄbuff
|
npcControl.RefreshBuffState(tick)
|
if GameObj.GetHP(curNPC) == 0 :
|
# BUFFË¢ÐÂÖпÉÄܻᵼÖÂNPCËÀÍö
|
return
|
# #ÅжÏÒ쳣״̬
|
# if curNPC.GetAbnormalState() == IPY_GameWorld.sctFaint:
|
# return
|
|
curNPCAction = curNPC.GetCurAction()
|
#NPC¿ìËÙ±¼ÅÜÖÐ, ´¦Àí
|
if curNPC.GetSpeed() != 0 and curNPCAction == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun:
|
AICommon.NormalNPCFast_Move(curNPC, tick)
|
return
|
|
#Ë¢ÐÂ×Ô¼º³ðºÞ¶ÈÁбí
|
npcControl.RefreshAngryList(tick)
|
curNPCAngry = npcControl.GetMaxAngryTag()
|
|
#³ðºÞ¶ÈÁбíÖеÄÈËΪ¿Õ
|
if curNPCAngry == None:
|
if curNPC.GetSpeed() != 0:
|
AICommon.NormalNPCFree_Move(curNPC, tick)
|
return
|
|
#³ðºÞ¶ÔÏóÀàÐÍ,³ðºÞ¶ÔÏóID
|
curNPCAngryType = curNPCAngry.GetObjType()
|
curNPCAngryID = curNPCAngry.GetObjID()
|
#Õ½¶·ÖлØÑª
|
npcControl.ProcessBattleHPRestore(tick)
|
#Ö´Ðй¥»÷Âß¼
|
__NPCFight(curNPC, curNPCAngryID, curNPCAngryType, tick)
|
|
#---------------------------------------------------------------------
|
## npc¹¥»÷Âß¼
|
# @param curNPC µ±Ç°npc
|
# @param tagID curNPCAngryID
|
# @param tagType curNPCAngryType
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def __NPCFight(curNPC, tagID, tagType, tick):
|
#ÉèÖýøÈëÕ½¶·×´Ì¬
|
NPCCommon.SetNPCInBattleState(curNPC)
|
npcControl = NPCCommon.NPCControl(curNPC)
|
|
#ÊÇ·ñÔÚÒÆ¶¯·¶Î§ÄÚ
|
if not npcControl.IsInRefreshArea() and curNPC.GetSpeed() != 0:
|
#×·»÷·µ»Ø
|
npcControl.MoveBack()
|
return
|
|
#¿ªÊ¼¹¥»÷
|
curTag = GameWorld.GetObj(tagID, tagType)
|
|
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 curNPC.GetSpeed() == 0:
|
# ²»¿ÉÒÆ¶¯NPC
|
if tagDist > curNPC.GetAtkDist():
|
return
|
|
if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval():
|
#¹¥»÷¼ä¸ôûÓе½, ·µ»Ø
|
return
|
|
#ÆÕͨ¹¥»÷
|
BaseAttack.Attack(curNPC, curTag, None, tick)
|
return
|
|
#³¬¹ý¹¥»÷¾àÀë,ÒÆ¶¯¹ýÈ¥
|
if tagDist > curNPC.GetAtkDist():
|
|
destDist = GameWorld.GetDist(curNPC.GetDestPosX() , curNPC.GetDestPosY(), curTag.GetPosX(), curTag.GetPosY())
|
if destDist <= curNPC.GetAtkDist() and curNPC.GetCurAction() == IPY_GameWorld.laNPCMove:
|
# Ä¿±êÔÚÒÆ¶¯µÄ¹¥»÷·¶Î§ÄÚ£¬²»¸Ä±äÄ¿±êµã
|
return
|
npcControl.MoveToObj_Detel(curTag)
|
return
|
else:
|
curNPC.StopMove()
|
|
if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval():
|
#¹¥»÷¼ä¸ôûÓе½, ·µ»Ø
|
return
|
|
if npcControl.FixTagPos(curTag.GetPosX(), curTag.GetPosY()):
|
#ÐÞÕýÕâ¸öNPCµÄÕ¾Á¢Î»ÖÃ
|
return
|
|
#ÆÕͨ¹¥»÷
|
BaseAttack.Attack(curNPC, curTag, None, tick)
|
return
|
|
## NPCËÀÍö
|
# @param curNPC µ±Ç°npc
|
# @param hurtType É˺¦ÕßµÄobjÀàÐÍ
|
# @param hurtID É˺¦ÕßµÄobjID
|
# @return None
|
def OnDie(curNPC, hurtType, hurtID):
|
AICommon.DoNPCUseSkillOnDie(curNPC)
|
return
|
|