#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
#-------------------------------------------------------------------------------
|
#
|
##@package AIType_222
|
#
|
# @todo: ÏÝÚå
|
# @author Alee
|
# @date 2010-12-16 20:50
|
# @version 1.1
|
#
|
# @change: "2016-11-26 19:00" hxp ÏÝÚå¸ÄΪËÀÍöÊͷŹ¥»÷¼¼ÄÜ, Ö§³Öʱ¼äµ½ºó×Ô±¬
|
#
|
# ÏêϸÃèÊö:ÏÝÚå
|
#
|
#------------------------------------------------------------------------------
|
#"""Version = 2016-11-26 19:00"""
|
#------------------------------------------------------------------------------
|
import SkillShell
|
import NPCCommon
|
import ChConfig
|
import GameWorld
|
import IPY_GameWorld
|
import GameObj
|
import GameMap
|
import AttackCommon
|
import SkillCommon
|
import AICommon
|
|
#---------------------------------------------------------------------
|
|
#---------------------------------------------------------------------
|
## ³õʼ»¯
|
# @param curNPC µ±Ç°npc
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def DoInit(curNPC):
|
curNPC.GetNPCAngry().Init(ChConfig.Def_SummonNPC_Angry_Count)
|
|
## Ö´ÐÐAI
|
# @param curNPC µ±Ç°npc
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def ProcessAI(curNPC, tick):
|
#1.¼ì²éÕâ¸öNPCµÄ³ðºÞÁÐ±í£¬ Èç¹û³ðºÞÁбíΪ¿Õ£¬ ²»´¦Àí
|
if curNPC.IsAlive() != True:
|
#NPCËÀÍö, ½øÈëËÀÍöµ¹¼ÆÊ±
|
return
|
|
#»ñµÃNPC¹ÜÀíÆ÷
|
npcControl = NPCCommon.NPCControl(curNPC)
|
if curNPC.GetLastTime() != 0 and tick - curNPC.GetBornTime() >= curNPC.GetLastTime():
|
#GameWorld.Log("ÏÝÚ峬¹ý´æÔÚʱ¼ä,ÒÑÏûʧ")
|
npcControl.SetKilled()
|
return
|
|
if tick - curNPC.GetBornTime() <= ChConfig.Def_Trap_Born_Idle_Time:
|
return
|
|
npcControl = NPCCommon.NPCControl(curNPC)
|
#Ë¢ÐÂ×Ô¼º³ðºÞ¶ÈÁбí
|
npcControl.RefreshAngryList(tick, 500) # Ϊȷ±£²ÈÏÝÚåÌåÑ飬
|
#±éÀú³ðºÞÁбíÕÒµ½×î½üµÄ,²¢´¥·¢
|
for i in range(0, curNPC.GetNPCAngry().GetAngryCount()):
|
curAngry = curNPC.GetNPCAngry().GetAngryValueTag(i)
|
|
if curAngry == None or curAngry.GetObjID() == 0:
|
continue
|
|
curObj = GameWorld.GetObj(curAngry.GetObjID(), curAngry.GetObjType())
|
|
if curObj == None or GameObj.GetHP(curObj) <= 0:
|
continue
|
|
#ÓÐNPC¿¿½ü,µ±³¬¹ý¹¥»÷¾àÀë
|
if GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(),
|
curObj.GetPosX(), curObj.GetPosY()) > curNPC.GetAtkDist():
|
continue
|
|
#½øÈëÕ½¶·
|
if not NPCFight(curNPC, npcControl, curObj, tick):
|
continue
|
return
|
|
return
|
|
## npc¹¥»÷Âß¼
|
# @param curNPC µ±Ç°npc
|
# @param npcControl NPC¹ÜÀíÆ÷
|
# @param curObj Ä¿±êʵÀý
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def NPCFight(curNPC, npcControl, curObj, tick):
|
#»ñµÃ¼¼ÄܹÜÀíÆ÷
|
skillManager = curNPC.GetSkillManager()
|
#´Ó¼¼ÄܹÜÀíÆ÷,»ñÈ¡¿ÉÒÔʹÓõļ¼ÄÜ
|
curSkill = skillManager.GetSkillByIndex(0)
|
|
if curSkill == None:
|
GameWorld.Log("ÏÝÚå = %s Êý¾Ý¿â²éÕÒ¼¼ÄÜʧ°Ü"%curNPC.GetName())
|
return True
|
|
battleRelationType = AttackCommon.GetBattleRelationType(curNPC, curObj)
|
|
skillBattleType = SkillCommon.GetSkillBattleType(curSkill)
|
if not AttackCommon.CheckBattleRelationType(skillBattleType, battleRelationType):
|
# PKģʽµÄÅж¨
|
return False
|
|
curNPC.SetDict("traptagType", curObj.GetGameObjType())
|
curNPC.SetDict("traptagID", curObj.GetID())
|
|
#´¥·¢¼¼ÄÜ, ¸ÄΪͳһÔÚËÀÍöʱÊͷż¼ÄÜ
|
#SkillShell.NPCUseSkillTag(curNPC, curObj, curSkill, tick)
|
|
#ÓÐÍæ¼Ò½øÈë³ðºÞÁбí,,,×Ô±¬
|
npcControl.SetKilled()
|
return True
|
|
## NPCËÀÍö
|
# @param curNPC µ±Ç°npc
|
# @param hurtType É˺¦ÕßµÄobjÀàÐÍ
|
# @param hurtID É˺¦ÕßµÄobjID
|
# @return None
|
def OnDie(curNPC, hurtType, hurtID):
|
|
#ËÀÍöNPC²»Äܹ¥»÷, ÕâÀïÉèÖÃNPCѪÁ¿Îª1
|
GameObj.SetHP(curNPC, 1)
|
|
#»ñµÃ¼¼ÄܹÜÀíÆ÷
|
skillManager = curNPC.GetSkillManager()
|
curSkill = skillManager.GetSkillByIndex(0)
|
if not curSkill:
|
return
|
|
curObj = GameWorld.GetObj(curNPC.GetDictByKey("traptagID"), curNPC.GetDictByKey("traptagType"))
|
tick = GameWorld.GetGameWorld().GetTick()
|
if curObj == None or GameObj.GetHP(curObj) <= 0:
|
SkillShell.NPCUseSkill(curNPC, curSkill, tick)
|
return
|
|
AICommon.DoNPCUseSkill(curNPC, curObj, curSkill, 0, tick)
|
|
GameObj.SetHP(curNPC, 0)
|
return
|
|
#===============================================================================
|
# def OnGetOwnerRelation(curNPC, owner):
|
# # ÏÝÚåÓëÖ÷È˵ĹØÏµ
|
#
|
# if owner.GetGameObjType() == IPY_GameWorld.gotPlayer:
|
# #×ÔÓÉPKÇø or ·Ç°²È«ÇøÄÚ¿ªÈ«Ìå ʱ¿É¹¥»÷Ö÷ÈË
|
# if GameMap.GetAreaTypeByMapPos(owner.GetPosX(), owner.GetPosY()) == IPY_GameWorld.gatFreePK \
|
# or (GameMap.GetAreaTypeByMapPos(owner.GetPosX(), owner.GetPosY()) != IPY_GameWorld.gatSafe and \
|
# owner.GetAttackMode() == IPY_GameWorld.amAll):
|
# return ChConfig.Type_Relation_Enemy , ChConfig.Def_PASysMessage_None
|
#
|
# return ChConfig.Type_Relation_Friend , ChConfig.Def_PASysMessage_None
|
#===============================================================================
|
|