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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/python
# -*- coding: GBK -*-
#
# @todo: ¹¥»÷ÓëÍæ¼ÒͬƵÂʵÄÕÙ»½ÊÞ£¬AIÖ»´¦Àí¸úËæ
#
# @author: Alee
# @date 2018-1-29 ÉÏÎç11:42:59
# @version 1.0
#
# @note: 
#
#---------------------------------------------------------------------
#------------------------------------------------------------------------------
 
import IPY_GameWorld
import GameWorld
import NPCCommon
import ChConfig
import GameObj
#---------------------------------------------------------------------
 
## ³õʼ³ðºÞ
#  @param curNPC ÊµÀý
#  @return None
def DoInit(curNPC):
    curNPC.GetNPCAngry().Init(ChConfig.Def_BossAngryCount)
 
 
## AIÑ­»·µ÷ÓÃ
#  @param curNPC ÊµÀý
#  @return None
def ProcessAI(curNPC, tick):
    if not curNPC.IsAlive():
        #NPCËÀÍö
        return
    
    curNPCControl = NPCCommon.NPCControl(curNPC)
    if curNPC.GetLastTime() != 0 and tick - curNPC.GetBornTime() >= curNPC.GetLastTime():
        #ÕÙ»½ÊÞ³¬¹ý´æ»îʱ¼ä, ÉèÖÃËÀÍö
        curNPCControl.SetKilled()
        return
        
    curNPCOwner = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curNPC)
    if curNPCOwner == None:
        #ûÓÐÖ÷ÈË, ²»×öÈκζ¯×÷
        return
    
        
    #NPC¿ìËÙ±¼ÅÜÖÐ, ´¦Àí
    if curNPC.GetCurAction() == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun:
        __SummonOutRefreshArea(curNPC, curNPCControl)
        return
 
    curNPCAction = curNPC.GetCurAction()
 
    #³ðºÞ¶ÈÁбíÖеÄÈËΪ¿Õ
    if curNPCAction == IPY_GameWorld.laNPCMove:
        #ÒÆ¶¯ÖÐ, ÔÝʱ²»´¦Àí
        pass
    elif curNPCAction == IPY_GameWorld.laNPCNull:
        #¿ÕÏÐ״̬,ÐèÒª¸úËæÖ÷ÈËÒÆ¶¯
        __SummonMove(curNPC, curNPCOwner)
    elif curNPCAction == IPY_GameWorld.laNPCAttack:
        #Èç¹û¹¥»÷״̬,ÉèÖÃΪ¿ÕÏÐ״̬
        curNPC.SetCurAction(IPY_GameWorld.laNPCNull)
    return
    
 
## ÕÙ»½ÊÞÒÆ¶¯
#  @param curNPC ÊµÀý
#  @return None
def __SummonMove(curNPC, curPlayer):
    npcControl = NPCCommon.NPCControl(curNPC)
    dist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curPlayer.GetPosX(), curPlayer.GetPosY())
    #Í£Ö¹¾àÀë
    stopDist = 3
    #¸úËæ¾àÀë
    followDist = ChConfig.Def_Screen_Area
    
    if dist < stopDist:
        pass
    elif dist < followDist:
        npcControl.MoveToObj_Detel(curPlayer, stopDist)
    else:
        #˲¼äÒÆ¶¯
        __SummonResetPos(curNPC, curPlayer, npcControl)
    
    return
 
 
##ÕÙ»½ÊÞ³¬¹ýÇø¼ä
#  @param curNPC ÊµÀý
#  @return None
def __SummonOutRefreshArea(curNPC, npcControl):
    curPlayer = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curNPC)
    if curPlayer == None:
        return
    
    dist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curPlayer.GetPosX(), curPlayer.GetPosY())
    
    if dist < ChConfig.Def_PlayerSight_Default:
        return
    
    #ÖØÖÃλÖÃ
    __SummonResetPos(curNPC, curPlayer, npcControl)
    return True
 
 
##ÖØÖÃλÖÃ
#  @param curNPC ÊµÀý
#  @return None
def __SummonResetPos(curNPC, curPlayer, npcControl):
    #Çå¿Õ³ðºÞ,Çå¿ÕÉËѪÁбí
    npcControl.ClearNPCAngry()
    npcControl.ClearNPCHurtList()
    moveDestX, moveDestY = npcControl.GetMoveNearPos(curPlayer.GetPosX(), curPlayer.GetPosY(), 
                                                     ChConfig.Def_PlayerTurckBeginMoveDist)
    curNPC.ResetPos(moveDestX, moveDestY)
    #ÖØÖÃNPCΪ¿ÕÏÐ״̬
    curNPC.SetCurAction(IPY_GameWorld.laNPCNull)
    return