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
#!/usr/bin/python
# -*- coding: GBK -*-
#
#---------------------------------------------------------------------
##@package AIType_61
# @todo: ÍòÄê±ùÀεڶþ¹ØBossÕÙ»½ÊÞAI £¨³åÏòÍæ¼Ò×Ô±¬£©
#
# @author zhangd
# @date 2011-07-15 18:00
# @version 1.1
#
# @note: 
# @change: "2011-07-19 21:00" zhangd ÐÞ¸Äbuff²»Ë¢ÐÂbug
#---------------------------------------------------------------------
"""Version = 2011-07-19 21:00"""
#---------------------------------------------------------------------
#µ¼Èë
import IPY_GameWorld
import GameWorld
import NPCCommon
import BaseAttack
import ChConfig
import SkillShell
import AICommon
import FBDefenseCommon
import random
import GameObj
#---------------------------------------------------------------------
 
#---------------------------------------------------------------------
## ³õʼ»¯
#  @param curNPC µ±Ç°npc
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoInit(curNPC):
    curNPC.GetNPCAngry().Init(ChConfig.Def_NormalNPCAngryCount)
    curNPC.SetIsNeedProcess(True)
    return
 
 
## Ö´ÐÐAI
#  @param curNPC µ±Ç°npc
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def ProcessAI(curNPC, tick):
    
    #NPCÒÑËÀÍö£¬Ìø³ö
    if curNPC.IsAlive() != True:
        return
    
    npcControl = NPCCommon.NPCControl(curNPC)
    
    #ÕÙ»½ÊÞ³¬¹ý´æ»îʱ¼ä, ÉèÖÃËÀÍö
    if curNPC.GetLastTime() != 0 and tick - curNPC.GetBornTime() >= curNPC.GetLastTime():
        npcControl.SetKilled()
        return
 
    #Ë¢ÐÂ×Ô¼ºµÄbuff
    npcControl.RefreshBuffState(tick)  
    if GameObj.GetHP(curNPC) == 0 :
        # BUFFË¢ÐÂÖпÉÄܻᵼÖÂNPCËÀÍö
        return
    #---¹¥»÷Âß¼­---
    playerList = NPCCommon.GetInSightPlayerList_NPC(curNPC)
    if not playerList:
        return
    
    tagPlayer = random.choice(playerList)
 
    #»ñµÃ¼¼ÄܹÜÀíÆ÷
    skillManager = curNPC.GetSkillManager()
    SkillOne = skillManager.GetSkillByIndex(0)    
#    skillTwo = skillManager.GetSkillByIndex(1)    
    
    tagDist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), tagPlayer.GetPosX(), tagPlayer.GetPosY())
    if tagDist > SkillOne.GetAtkDist():
        npcControl.MoveToObj_Detel(tagPlayer, 1)
        return
    
    result = AICommon.DoNPCUseSkill(curNPC, tagPlayer, SkillOne, tagDist, tick)
    
    # Êͷż¼Äܳɹ¦£¬×Ôɱ£¬´¥·¢±¬Õ¨ÌØÐ§¼¼ÄÜ
    if result:
        npcControl.SetKilled()   
          
    return result
 
 
##ËÀºó·Å±¬Õ¨ÌØÐ§¼¼ÄÜ
#  @param curNPC µ±Ç°npc
#  @param hurtType É˺¦ÕßµÄobjÀàÐÍ
#  @param hurtID É˺¦ÕßµÄobjID
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnDie(curNPC, hurtType, hurtID):
    FBDefenseCommon.DeadUseSkillByIndex(curNPC, 1)