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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package AIType_186
#
# @todo: NPCͨ¹ý±í¶ÁÈ¡Êͷż¼ÄÜ
# @author Alee
# @date 2011-05-18 18:00
# @version 2.2
#
# ÏêϸÃèÊö:
# @change: "2013-06-18 22:30" Alee Ð¡¹Ö³ðºÞÊýËõС
# @change: "2014-01-28 15:30" hxp Ôö¼ÓÄêÊÞÊ£ÓàѪÁ¿¹ã²¥
# @change: "2014-02-21 14:20" hxp Ôö¼ÓÊÀ½çbossÂß¼­£¬¹¥»÷»ÆÃû£¬Ê£ÓàѪÁ¿¹ã²¥
# @change: "2014-02-27 12:00" hxp Ôö¼ÓNPCѪÁ¿°Ù·Ö±ÈÂß¼­Èë¿Ú
# @change: "2014-03-11 19:30" hxp ÐÞ¸ÄÃþÊÀ½çboss»ÆÃûbuffID
# @change: "2014-04-14 12:00" hxp Ôö¼ÓbossËÀÍöÕÙ»½²É¼¯Îï
# @change: "2014-09-24 17:00" hxp ÃþÊÀ½çbossbuffÌí¼ÓÂß¼­ÐÞ¸Ä
# @change: "2014-10-27 21:00" hxp ¹¥»÷bossÊÇ·ñ»ñµÃbuff¿ª³öÅäÖÃ
# @change: "2014-12-08 21:30" hxp ÓÅ»¯AI
# @change: "2014-12-15 07:20" Alee ½µµÍNPCAIÏûºÄ
# @change: "2014-12-31 14:40" Alee ½µµÍNPCAIÏûºÄ
# @change: "2016-11-22 21:00" hxp Ö§³ÖÌí¼Ó×î´ó³ðºÞbuff
#------------------------------------------------------------------------------ 
#"""Version = 2016-11-22 21:00"""
#-------------------------------------------------------------------------------
import ChConfig
import NPCCommon
import AICommon
import IPY_GameWorld
import GameWorld
import BaseAttack
import PlayerState
import GameObj
 
## ³õʼ»¯
#  @param curNPC µ±Ç°npc
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoInit(curNPC):
    angryCount = ChConfig.Def_NormalNPCAngryCount
    if ChConfig.IsGameBoss(curNPC):
        angryCount = ChConfig.Def_SuperFBBossAngryCount
    # ³ðºÞ¹éÊôÒòΪÐèÒª¶ÓԱͬʱ¼Ó³ðºÞ£¬ËùÒÔ³ðºÞÊýÉèÖôóµã
    if NPCCommon.GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_MaxAngry:
        angryCount = ChConfig.Def_SuperBossAngryCount
        
    curNPC.GetNPCAngry().Init(angryCount)
    return
 
## Ö´ÐÐAI
#  @param curNPC µ±Ç°npc
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def ProcessAI(curNPC, tick):
    npcControl = NPCCommon.NPCControl(curNPC)
    
    if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or curNPC.IsAlive() != True:
        #NPCËÀÍö, ½øÈëËÀÍöµ¹¼ÆÊ±
        if npcControl.DieTick(tick) == 0:
            return
    
    #Ë¢ÐÂ×Ô¼ºµÄbuff
    if curNPC.GetIsBoss():
        npcControl.RefreshBuffState(tick) 
        if GameObj.GetHP(curNPC) == 0 :
            # BUFFË¢ÐÂÖпÉÄܻᵼÖÂNPCËÀÍö
            return
    curNPCAction = curNPC.GetCurAction()
    if curNPCAction == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun:
        AICommon.NormalNPCFast_Move(curNPC, tick)
        return
    
    #ĬÈϹ¥»÷¹éÊôÕß
    tagObj = npcControl.RefreshDropOwner(tick)
    
    if not curNPC.GetIsNeedProcess() or not tagObj:
        # ÏÈ»ØÑª£¬µÈ»ØÂúÔÙ×öÆäËûÊÂÇé
        if curNPCAction == IPY_GameWorld.laNPCNull and not npcControl.ProcessHPRestore(tick):
            AICommon.NormalNPCFree_Move(curNPC, tick)
        return
    
    #¹¥»÷Âß¼­
    __NPCFight(curNPC, tagObj, tick)
    
    npcControl.DoHPPerLogic(ChConfig.Def_NPCHurtTypeAll, 0)
    return
 
## Ã¿´Î±»¹¥»÷´¦Àí½á¹û
#  @param atkObj ¹¥»÷·¢ÆðÕß
#  @param defObj ±»¹¥»÷Õß
#  @param skill ¹¥»÷¼¼ÄÜ
#  @param tick 
#  @return ¾ßÌåÉ˺¦Öµ
def OnAttacked(atkObj, curNPC, skill, tick):
    if atkObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
        PlayerState.SetBossStateTick(atkObj, tick)
    return
 
def OnCheckCanDie(atkObj, curNPC, skill, tick):
    ## ¼ì²éNPCÊÇ·ñ¿ÉËÀÍö
    dropOwnerType = NPCCommon.GetDropOwnerType(curNPC)
    if dropOwnerType not in [ChConfig.DropOwnerType_MaxHurt]:
        return True
    npcControl = NPCCommon.NPCControl(curNPC)
    tagObj = npcControl.RefreshDropOwner(tick, 0, checkCanDead=True)
    if not atkObj or not tagObj:
        GameObj.SetHP(curNPC, 1)
        skillID = 0 if not skill else skill.GetSkillID()
        GameWorld.ErrLog("Bossµ±Ç°×´Ì¬Ï²»¿ÉÒÔËÀÍö£¡npcID=%s,skillID=%s,atkObj=%s,tagObj=%s" % (curNPC.GetNPCID(), skillID, atkObj, tagObj))
        return False
    return True
 
## NPC±»Íæ¼ÒɱËÀ
def OnAttackDieByPlayer(curNPC, curPlayer, skill):
    tick = GameWorld.GetGameWorld().GetTick()
    PlayerState.SetBossStateTick(curPlayer, tick)
    
    #±»»÷É±Ê±Ç¿ÖÆË¢Ð¹éÊô
    npcControl = NPCCommon.NPCControl(curNPC)
    npcControl.RefreshDropOwner(tick, 0, True)
    return
 
## NPCËÀÍö´¦Àí
#  @param curNPC ËÀÍöNPC
#  @param HurtType µôÂäÀàÐÍ
#  @param HurtID ¶ÔÓ¦ÓµÓÐÕßid
#  @param modulus µôÂäϵÊý
#  @return None
def OnDie(curNPC, HurtType, HurtID):
    AICommon.DoNPCUseSkillOnDie(curNPC)
    return
 
def OnNPCSetDead(curNPC):
    npcControl = NPCCommon.NPCControl(curNPC)
    npcControl.DelayDropOwnerBuffDisappearTime()
    return
 
## npc¹¥»÷Âß¼­
#  @param curNPC µ±Ç°npc
#  @param tagID curNPCAngryID
#  @param tagType curNPCAngryType 
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.   
def __NPCFight(curNPC, curTag, tick):
    #Ô¤¾¯´¦Àí
    if AICommon.DoNPCSkillWarningProcess(curNPC, tick):
        return
    
    #ÉèÖýøÈëÕ½¶·×´Ì¬
    NPCCommon.SetNPCInBattleState(curNPC)
    
    npcControl = NPCCommon.NPCControl(curNPC)
    
    #²»ÔÚÒÆ¶¯·¶Î§
    if npcControl.IsInRefreshArea() != True: 
        #×·»÷·µ»Ø
        npcControl.MoveBack()
        return
    
    #¿ªÊ¼¹¥»÷
    if curTag == None or GameObj.GetHP(curTag) <= 0:
        return
    
    tagDist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curTag.GetPosX(), curTag.GetPosY())
    
    #---ÓÅÏÈÊͷż¼ÄÜ---
    if AICommon.DoAutoUseSkill(curNPC, curTag, tagDist, tick):
        return
    
    #---ÊÍ·ÅÆÕͨ¹¥»÷---
    
    #³¬¹ý¹¥»÷¾àÀë,ÒÆ¶¯¹ýÈ¥
    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