#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#
|
# @todo: ³èÎïAI
|
#
|
# @author: Alee
|
# @date 2017-11-25 ÏÂÎç05:33:43
|
# @version 1.0
|
#
|
# @note: ³èÎïͬʱ¸úËæÈËÎïÒÆ¶¯ºÍÕ½¶·
|
#
|
#---------------------------------------------------------------------
|
#µ¼Èë
|
import NPCCommon
|
import IPY_GameWorld
|
import GameWorld
|
import SkillCommon
|
import AICommon
|
import ChConfig
|
import GameObj
|
import PetControl
|
|
Def_LastAI1ProTick = "LastAI1ProTick" # ×îºóÒ»´ÎÖ´ÐÐtick
|
|
#---------------------------------------------------------------------
|
## ³õʼ»¯
|
# @param rolePet ³èÎïʵÀý
|
# @return None
|
# @remarks ³õʼ»¯
|
def DoInit(rolePet):
|
rolePet.GetNPCAngry().Init(1)
|
return
|
#---------------------------------------------------------------------
|
## Ö´ÐÐAI
|
# @param rolePet ³èÎïʵÀý
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks Ö´ÐÐAI
|
def ProcessAI(rolePet, tick):
|
#===========================================================================
|
# ## Ö´ÐÐÆµÂÊ, ¸ù¾ÝÈËÊý½µµÍ---------------------------
|
# if tick - rolePet.GetDictByKey(Def_LastAI1ProTick) < 3000:
|
# return
|
# rolePet.SetDict(Def_LastAI1ProTick, tick)
|
# #-------------------------------------------------------
|
#===========================================================================
|
|
curPlayer = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, rolePet)
|
|
if curPlayer == None:
|
GameWorld.ErrLog('³èÎï = %sÎÞ·¨²éÕÒÖ÷ÈË, AIÖ´ÐÐʧ°Ü'%(rolePet.GetID()))
|
return
|
|
rolePetControl = NPCCommon.NPCControl(rolePet)
|
rolePetControl.RefreshBuffState(tick)
|
|
dist = GameWorld.GetDist(curPlayer.GetPosX(), curPlayer.GetPosY(), rolePet.GetPosX(), rolePet.GetPosY())
|
if dist > 12:
|
# ·¢Éú´«Ë͵ÈÇé¿öµ¼Ö¾àÀëͻȻ¹ýÔ¶
|
petControl = NPCCommon.NPCControl(rolePet)
|
posX, posY = petControl.GetMoveNearPos(curPlayer.GetPosX(), curPlayer.GetPosY(), 1)
|
rolePet.ResetPos(posX, posY)
|
|
|
if tick - rolePet.GetAttackTick() >= rolePet.GetAtkInterval():
|
PetControl.PetFight(curPlayer, tick)
|
|
#===========================================================================
|
# skillManager = rolePet.GetSkillManager()
|
# for index in range(0, skillManager.GetSkillCount()):
|
# useSkill = skillManager.GetSkillByIndex(index)
|
# #ÒѾµ½Î²²¿ÁË
|
# if not useSkill or useSkill.GetSkillTypeID() == 0:
|
# break
|
#
|
# if SkillCommon.isPassiveSkill(useSkill):
|
# #GameWorld.Log('±»¶¯¼¼Äܲ»ÊͷŲ»ÊÍ·Å = %s'%(useSkill.GetSkillName()))
|
# continue
|
#
|
# effect = SkillCommon.GetSkillEffectByEffectID(useSkill, ChConfig.Def_Skill_Effect_HPPerLimit)
|
# if not effect:
|
# continue
|
#
|
# if GameObj.GetHP(curPlayer)*ChConfig.Def_MaxRateValue/GameObj.GetMaxHP(curPlayer) >= effect.GetEffectValue(0):
|
# continue
|
#
|
# AICommon.DoNPCUseSkill(rolePet, curPlayer, useSkill, 0, tick)
|
#===========================================================================
|
return
|
|