hxp
2022-02-21 0c27822ef5e6c67782ed143a4ff03ecfbdfda1fb
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package NPCAI.AIType_197
#
# @todo:ÅÜÅÜÅÜ
# @author hxp
# @date 2017-11-25
# @version 1.0
#
# ÏêϸÃèÊö: ÅÜÅÜÅÜ
#
#-------------------------------------------------------------------------------
#"""Version = 2017-11-25 16:00"""
#-------------------------------------------------------------------------------
import IPY_GameWorld
import IpyGameDataPY
import GameWorld
import NPCCommon
import OperControlManager
import ChConfig
import GameObj
#-------------------------------------------------------------------------------
Def_NPCKey_PointIndex = "PointIndex" # µ±Ç°Ä¿±êµãË÷Òý
 
## ³õʼ»¯
#  @param curNPC µ±Ç°npc
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoInit(curNPC):
    return
 
def OnNPCReborn(curNPC):
    curNPC.SetDict(Def_NPCKey_PointIndex, 0)
    #curNPC.SetVisible(True)
    curNPC.SetIsNeedProcess(True)
    return
 
## Ö´ÐÐAI
#  @param curNPC µ±Ç°npc
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def ProcessAI(curNPC, tick):
    curNPCAction = curNPC.GetCurAction()
    
    if curNPCAction == IPY_GameWorld.laNPCDie or not curNPC.IsAlive():
        return
    
    npcControl = NPCCommon.NPCControl(curNPC)
    #Ë¢ÐÂ×Ô¼ºµÄbuff
    npcControl.RefreshBuffState(tick)
    if GameObj.GetHP(curNPC) == 0 :
        # BUFFË¢ÐÂÖпÉÄܻᵼÖÂNPCËÀÍö
        return
    
    ai197PointDict = IpyGameDataPY.GetFuncEvalCfg("AI197Point")
    mapID = GameWorld.GetMap().GetMapID()
    # Ö§³ÖJson¸ñʽkey£¬¿Í»§¶ËÐèÒªÓõ½
    if str(mapID) in ai197PointDict:
        movePointList = ai197PointDict[str(mapID)]
    elif mapID in ai197PointDict:
        movePointList = ai197PointDict[mapID]
    else:
        GameWorld.ErrLog("µØÍ¼Ã»ÓÐÅäÖÃAI197NPCÅÜÅÜÅÜÒÆ¶¯Ä¿±êÏß·µã£¡mapID=%s" % mapID)
        return
    if not movePointList:
        return
    pointIndex = curNPC.GetDictByKey(Def_NPCKey_PointIndex)
    destPosX, destPosY = movePointList[pointIndex]
    curPosX, curPosY = curNPC.GetPosX(), curNPC.GetPosY()
    curDis = GameWorld.GetDist(curPosX, curPosY, destPosX, destPosY)
    #Èç¹ûÀëÄ¿±êµã±È½Ï½üµÄ»° È¡ÏÂÒ»¸öÄ¿±êµã
    while curDis <= 6 and pointIndex < len(movePointList) - 1:
        pointIndex += 1
        curNPC.SetDict(Def_NPCKey_PointIndex, pointIndex)
        destPosX, destPosY = movePointList[pointIndex]
        curDis = GameWorld.GetDist(curPosX, curPosY, destPosX, destPosY)
        
    if curDis != 0:
        if curNPC.GetCurAction() == IPY_GameWorld.laNPCMove:
            return
        
        
        #²»¿ÉÒÆ¶¯ÐÐΪ״̬, ·þÎñ¶ËÏÞÖÆ
        if not OperControlManager.IsObjCanDoAction(curNPC,
                                                   ChConfig.Def_Obj_ActState_ServerAct,
                                                   IPY_GameWorld.oalMove):
            return  
        
        curNPC.Move(destPosX, destPosY)
        return
    
    # µ½´ïÄ¿µÄµØ
    #curNPC.SetVisible(False)
    NPCCommon.SetDeadEx(curNPC)
    return