1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/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