#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#---------------------------------------------------------------------
|
##@package AIType_21
|
#ѲÂßÊØÎÀAI,¹¥»÷·Ç±¾¹ú¼ÒÍæ¼Ò,ºÍºìÃûÍæ¼Ò
|
#
|
# @author PanWei
|
# @date 2010-4-28ÏÂÎç06:01:33
|
# @version 1.4
|
#
|
#Ä£¿éÏêϸ˵Ã÷.
|
# @change: "2010-05-12 18:30" zhengyang Ìí¼Ó×¢ÊÍ
|
# @change: "2010-06-09 09:50" zhengyang ÊØÎÀnpc¼ÓÈëÒ쳣״̬ѣÔÎÅжÏ
|
# @change: 2010-06-14 16:00 zhengyang ÐÞÕýÆÕ¹¥²ÎÊý´«´í
|
# @change: "2010-11-22 12:15" Alee ɾ³ýÒì³£/³ÁĬÅж¨
|
#---------------------------------------------------------------------
|
"""Version = 2010-11-22 12:15"""
|
#---------------------------------------------------------------------
|
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_BossAngryCount)
|
|
#---------------------------------------------------------------------
|
##Õý³£AIÂß¼´¦Àí
|
#@param curNPC NPCʵÀý
|
#@param tick ʱ¼ä´Á
|
#@return ·µ»ØÖµÎÞÒâÒå
|
#@remarks Õý³£AIÂß¼´¦Àí
|
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 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 :
|
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)
|
#NPCµÄ´ò¹ÖAI
|
if not npcControl.IsInRefreshArea():
|
#×·»÷·µ»Ø
|
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 tagDist > curNPC.GetAtkDist() :
|
npcControl.MoveToObj_Detel(curTag)
|
return
|
|
if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval():
|
#¹¥»÷¼ä¸ôûÓе½, ·µ»Ø
|
return
|
|
if npcControl.FixTagPos(curTag.GetPosX(), curTag.GetPosY()):
|
#ÐÞÕýÕâ¸öNPCµÄÕ¾Á¢Î»ÖÃ
|
return
|
|
#ÆÕͨ¹¥»÷
|
BaseAttack.Attack(curNPC, curTag, None, tick)
|
return
|
|
|
|
|