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
#!/usr/bin/python
# -*- coding: GBK -*-
#
#---------------------------------------------------------------------
##@package AIType_102
# ½£Óü¿ñÀ½ÒþÐÎÕÙ»½ÊÞ£¬Íæ¼ÒÎÞ·¨¸ÐÖª£¬Êͷű©·çÑ©
#
# @author Alee
# @date 2010-6-4 ÉÏÎç10:51:04
# @version 1.3
#
# @change: "2010-06-08 18:00" È¥³ýÈßÓàµÄ²»¿ÉÒÆ¶¯´¦ÀíÂß¼­
# @change: "2010-06-08 18:00" Ìí¼Ó¹«Ë¾°æ±¾
# @change: "2016-01-15 15:00" ÐÞ¸ÄΪ×î´óÉúÃüÖµ¾ö¶¨¹¥»÷´ÎÊý
#
#Ä£¿éÏêϸ˵Ã÷.
#---------------------------------------------------------------------
#µ¼Èë
import IPY_GameWorld
import GameWorld
import NPCCommon
import BaseAttack
import ChConfig
import AICommon
import SkillShell
import GameObj
import PassiveBuffEffMng
#---------------------------------------------------------------------
 
#---------------------------------------------------------------------
## ³õʼ»¯
#  @param curNPC µ±Ç°npc
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoInit(curNPC):
    curNPC.GetNPCAngry().Init(ChConfig.Def_BossAngryCount)
 
## Ö´ÐÐAI
#  @param curNPC µ±Ç°npc
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def ProcessAI(curNPC, tick):
    #1.¼ì²éÕâ¸öNPCµÄ³ðºÞÁÐ±í£¬ Èç¹û³ðºÞÁбíΪ¿Õ£¬ ²¢ÇÒÒÆ¶¯ÖУ¬ ²»´¦Àí
    if curNPC.IsAlive() != True:
        #NPCËÀÍö, ½øÈëËÀÍöµ¹¼ÆÊ±
        return
    
    if not hasattr(curNPC, "GetLastTime") or not hasattr(curNPC, "GetBornTime"):
        return
    curNPCControl = NPCCommon.NPCControl(curNPC)
    if GameObj.GetHP(curNPC) <= 0 or (curNPC.GetLastTime() != 0 and tick - curNPC.GetBornTime() >= curNPC.GetLastTime()):
        #GameWorld.Log("ÕÙ»½ÊÞ³¬¹ý´æ»îʱ¼ä, ÉèÖÃËÀÍö")
        curNPCControl.SetKilled()
        return
    
    #¹¥»÷Âß¼­ Êͷż¼ÄÜ
    __NPCFight(curNPC, tick)
 
## npc¹¥»÷Âß¼­
#  @param curNPC µ±Ç°npc 
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def __NPCFight(curNPC, tick):
    # ÊÓÒ°ÖÐÎÞÆäËû¹Ø×¢¶ÔÏ󣬲»¹¥»÷
    if curNPC.GetAttentionCount() <= 0:
        return
    
    
    if tick - curNPC.GetAttackTick() < curNPC.GetAtkInterval():
        #¹¥»÷¼ä¸ôûÓе½, ·µ»Ø
        return
    
    skillManager = curNPC.GetSkillManager()
    useSkill = None
    for i in range(skillManager.GetSkillCount()):
        curSkill = skillManager.GetSkillByIndex(i)
        
        if curSkill == None:
            GameWorld.Log("NPC = %s Êý¾Ý¿â²éÕÒ¼¼ÄÜʧ°Ü"%curNPC.GetName())
            return
    
        #¹¥»÷¼ä¸ô
        if tick - curSkill.GetLastUseTick() < curSkill.GetCoolDownTime():
            continue
    
        useSkill = curSkill
        break
        
    if not useSkill:
        return
    
    if curNPC.GetCurAction() != IPY_GameWorld.laNPCAttack:
        curNPC.SetCurAction(IPY_GameWorld.laNPCAttack)
    
    SkillShell.NPCUseSkill(curNPC, useSkill, tick)
    # Ã¿´Î¹¥»÷ºó£¬×ÔÉíÉúÃüÖµ¼õ1£¬ÓÉ×î´óÉúÃüÖµ¾ö¶¨¹¥»÷´ÎÊý
    GameObj.SetHP(curNPC, GameObj.GetHP(curNPC) - 1)
    if GameObj.GetHP(curNPC) <= 0:
        NPCCommon.NPCControl(curNPC).SetKilled()
    return
 
 
## NPCËÀÍö´¦Àí
#  @param curNPC ËÀÍöNPC
#  @param HurtType µôÂäÀàÐÍ
#  @param HurtID ¶ÔÓ¦ÓµÓÐÕßid
#  @param modulus µôÂäϵÊý
#  @return None
def OnDie(curNPC, HurtType, HurtID):
    # Òý±¬ÖÖ×Ӡ˪±¬¼¼ÄÜ
    # ntElf ¶¨ÒåΪÈËÎïʹÓöԵسÖÐøÐÔ¼¼ÄÜ£¬²¢ÇÒÈËÎï¿ÉÒÔÒÆ¶¯£¬ÔòÐèÒªntElf×öÒÀÍÐÎïµÄÇé¿ö
    # ÄÇôntElfÖ´ÐÐÈËÎïµÄÉ˺¦¼ÆËãºÍ±»¶¯´¥·¢Ð§¹û
    if curNPC.GetType() != IPY_GameWorld.ntElf:
        return
    curSkill = curNPC.GetSkillManager().GetSkillByIndex(0)
    if not curSkill:
        return
    
    attacker = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curNPC)
    if not attacker:
        return
    
    skillID = PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(curNPC, None, curSkill, ChConfig.TriggerType_BeBoomSeed)
    seedSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
    if not seedSkill:
        return
    
    SkillShell.UsePassiveTriggerSkill(curNPC, seedSkill, None, GameWorld.GetGameWorld().GetTick())
    return