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
#!/usr/bin/python
# -*- coding: GBK -*-
#
#
##@package AIType_63.py
#
# @todo:ÕÙ»½ÊÞAI (¹¥»÷5´Î¾Í»á¼ÌÐø·ÖÁÑ)
#
# @author jiang
# @date 2012-07-13
# @version 1.0
# @note:
#
#------------------------------------------------------------------------------ 
"""Version = 2012-07-13 15:30"""
#------------------------------------------------------------------------------ 
# µ¼Èë
import GameWorld
import IPY_GameWorld
import ChConfig
import NPCCommon
import SkillShell
import BaseAttack
import SkillCommon
import AICommon
import GameObj
#------------------------------------------------------------------------------
 
Def_AtkCount = "AtkCount"  # ¹¥»÷´ÎÊý
Def_MaxAtkCountSplit = 5  # ¹¥»÷¶àÉÙ´Î×Ô¶¯·ÖÁÑ
Def_SplitSkillID = 33787  # ·ÖÁѼ¼ID
#------------------------------------------------------------------------------ 
## ³õʼ»¯
#  @param curNPC µ±Ç°npc
#  @return None
def DoInit(curNPC):
    curNPC.GetNPCAngry().Init(ChConfig.Def_SummonNPC_Angry_Count)
    return
 
 
## Ö´ÐÐAI
#  @param curNPC µ±Ç°npc
#  @param tick µ±Ç°Ê±¼ä
#  @return None
def ProcessAI(curNPC, tick):
    
    #NPCÒÑËÀÍö£¬Ìø³ö
    if curNPC.IsAlive() != True:
        return
    
    curNPCAction = curNPC.GetCurAction()
    #NPC¿ìËÙ±¼ÅÜÖÐ, ´¦Àí
    if curNPCAction == IPY_GameWorld.laNPCMove and curNPC.GetCurMoveType() == IPY_GameWorld.mtRun:
        AICommon.NormalNPCFast_Move(curNPC, tick)
        return
    
    npcControl = NPCCommon.NPCControl(curNPC)
    
    #Ë¢ÐÂ×Ô¼º³ðºÞ¶ÈÁбí
    npcControl.RefreshAngryList(tick)
    curAngry = npcControl.GetMaxAngryTag()
    if not curAngry:
        #ûÓгðºÞ¶ÔÏó
        AICommon.NormalNPCFree_Move(curNPC, tick)
        return
    
    if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval():
        #¹¥»÷¼ä¸ôûÓе½
        return
    
    #³ðºÞ¶ÔÏóÀàÐÍ, ³ðºÞ¶ÔÏóID
    curNPCAngryType = curAngry.GetObjType()
    curNPCAngryID = curAngry.GetObjID()
 
    #npc¹¥»÷Âß¼­
    if not __NPCFight(curNPC, curNPCAngryID, curNPCAngryType, tick):
        return
    
    #¼Ç¼NPC¹¥»÷´ÎÊý, ²¢·ÖÁÑ
    __SetAccumulativeAtkCount(curNPC, tick)
    return
 
 
## ¼Ç¼NPC¹¥»÷´ÎÊý, ²¢·ÖÁÑ
#  @param curNPC: NPCʵÀý
#  @return: 
def __SetAccumulativeAtkCount(curNPC, tick):
    
    #¼Ç¼¹¥»÷´ÎÊý
    curNPC.SetDict(Def_AtkCount, curNPC.GetDictByKey(Def_AtkCount) + 1)
    
    atkCount = curNPC.GetDictByKey(Def_AtkCount)
    if atkCount < Def_MaxAtkCountSplit:
        #δ´ïµ½¹¥»÷´ÎÊý, ÎÞ·¨·ÖÁÑ
        return
    
    curSkill = GameWorld.GetGameData().GetSkillBySkillID(Def_SplitSkillID)
    if curSkill == None:
        return
    
    #Ê©·Å·ÖÁѼ¼ÄÜ, ·ÖÁÑ×Ô¼º
    curSummonNPCOwner = NPCCommon.GetSummonOwnerDetel(curNPC)
    if not curSummonNPCOwner:
        return
    
    SkillShell.NPCUseSkill(curSummonNPCOwner, curSkill, tick)
        
    #ÖØÖù¥»÷´ÎÊý
    curNPC.SetDict(Def_AtkCount, 0)
    return
 
#---------------------------------------------------------------------
## npc¹¥»÷Âß¼­
#  @param curNPC µ±Ç°npc
#  @param tagID curNPCAngryID
#  @param tagType curNPCAngryType 
#  @param tick µ±Ç°Ê±¼ä
#  @return ¹¥»÷ÊÇ·ñ³É¹¦
def __NPCFight(curNPC, tagID, tagType, tick):
    #ÉèÖýøÈëÕ½¶·×´Ì¬
    NPCCommon.SetNPCInBattleState(curNPC)
    npcControl = NPCCommon.NPCControl(curNPC)
    
    #ÊÇ·ñÔÚÒÆ¶¯·¶Î§ÄÚ
    if not npcControl.IsInRefreshArea():
        #×·»÷·µ»Ø
        npcControl.MoveBack()
        return False
    
    #¿ªÊ¼¹¥»÷
    curTag = GameWorld.GetObj(tagID, tagType)
    if curTag == None or GameObj.GetHP(curTag) <= 0:
        return False
    
    tagDist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curTag.GetPosX(), curTag.GetPosY())
    
    #---ÓÅÏÈÊͷż¼ÄÜ---
    if AICommon.DoAutoUseSkill(curNPC, curTag, tagDist, tick):
        return True
    
    #---ÊÍ·ÅÆÕͨ¹¥»÷---
    
    #³¬¹ý¹¥»÷¾àÀë,ÒÆ¶¯¹ýÈ¥
    if tagDist > curNPC.GetAtkDist():
        npcControl.MoveToObj_Detel(curTag)
        return False
    
    if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval():
        #¹¥»÷¼ä¸ôûÓе½, ·µ»Ø
        return False
    
    if npcControl.FixTagPos(curTag.GetPosX(), curTag.GetPosY()):
        #ÐÞÕýÕâ¸öNPCµÄÕ¾Á¢Î»ÖÃ
        return False
    
    #ÆÕͨ¹¥»÷
    return BaseAttack.Attack(curNPC, curTag, None, tick)