hxp
2018-08-10 ccfc87e02e2ae7d153bbab0754639a1a663d34d3
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 -*-
#
# @todo: ¶ÓÎé
#
# @author: Alee
# @date 2018-1-5 ÏÂÎç05:30:16
# @version 1.0
#
# @note: 
#
#---------------------------------------------------------------------
 
from AI.AIBase import *
import logging
from Robot.PlayerData import PlayerData, g_ServerTick
from Protocol.PacketsSendPY import tagCMLoginState
from Robot import DataDefine
 
import random
#from Protocol.PacketsSend import tagCLeaveTeam, tagCPlayerLogOut
from Protocol.PacketsSendPY import tagCMSuperAtk, tagSkillPosHurtObj
 
import time
 
 
## 
#
# ¼Ì³ÐAIBase
class AIPlayerActPlayer(AIBase):
    
    ## ËùÓÐAI±ØÐë²ÉÓÃÕâÖй̶¨µÄ³õʼ»¯Ô­ÐÍ£¬ÒÔ±ãAIMgr×Ô¶¯¼ÓÔØ
    #  @param None : None
    #  @return bool
    #  @remarks ´ËAI²»ÐèÒªÖÜÆÚÐÔ±»µ÷Óã¬ËùÒÔÉèÖÃΪ²»ÆôÓÃTimer
    def __init__(self, robot):
        AIBase.__init__(self, robot, 3, True, True)
        self.SetActive(True)
 
    def _Process( self ):
 
        if not self.robot.GetPlayerInfo().GetStartWorldTick():
            return
        
        sendPack = tagCMSuperAtk()
        sendPack.Clear()
        job = self.robot.GetPlayerInfo().GetJob()
        if not job:
            return
        sendPack.SkillID = job *100+random.randint(0, 3)
        
        sendPack.PosX = self.robot.GetPlayerInfo().GetPosX() 
        sendPack.PosY = self.robot.GetPlayerInfo().GetPosY()
        sendPack.TagPosX = self.robot.GetPlayerInfo().GetPosX() + random.randint(-2, 2)
        sendPack.TagPosY = self.robot.GetPlayerInfo().GetPosY() + random.randint(-2, 2)
        sendPack.WorldTick = self.robot.GetPlayerInfo().GetWorldTick()
 
        #print "attack--------%s-%s-%s-%s"%(job, sendPack.SkillID, sendPack.WorldTick, self.robot.GetPlayerInfo().GetAccID())
        self.robot.SendMapServerPYPack(sendPack)
 
    ## ÏòAIMgr×¢²áÏûÏ¢»Øµ÷º¯Êý
    #  @param None : None
    #  @return bool
    #  @remarks 
    def _RegisterPacket(self, aiMgr):
        #aiMgr.RegNetMsg(0x0614, self.PlayerAttack, True)
        pass
 
    def PlayerAttack(self, pack):
        if pack.ObjType != 1:
            return
        playerID = self.robot.GetPlayerInfo().GetPlayerID()
        beAttacked = False
        
        for atk in pack.HurtList:
            if atk.ObjType != 1:
                continue
            if atk.ObjID == playerID:
                beAttacked = True
                break
            
        if not beAttacked:
            return
        
        
        #skillIDDict = {1:100, 2:200, 3:300}
        job = self.robot.GetPlayerInfo().GetJob()
        
        sendPack = tagCMSuperAtk()
        sendPack.SkillID = job *100 + random.randint(0,3)
        
        sendPack.PosX = self.robot.GetPlayerInfo().GetPosX()
        sendPack.PosY = self.robot.GetPlayerInfo().GetPosY()
        sendPack.TagPosX = self.robot.GetPlayerInfo().GetPosX() + 3
        sendPack.TagPosY = self.robot.GetPlayerInfo().GetPosY() + 3
        sendPack.WorldTick = self.robot.GetPlayerInfo().GetWorldTick()
        sendPack.HurtCount = 1
        defender = tagSkillPosHurtObj()
        defender.ObjType = 1
        defender.ObjID = pack.ObjID
 
        sendPack.HurtList = [defender]
        
        self.robot.SendMapServerPYPack(sendPack)
#===============================================================================
#        //B4 05 ´øÉ˺¦¶ÓÁеĹ¥»÷ #tagCMSuperAtk
# struct    tagSkillPosHurtObj
# {
#    BYTE        ObjType;
#    DWORD        ObjID;
#    BYTE        AttackType;        //±¬»÷, miss
#    DWORD        HurtHP;
# };
# struct    tagCMSuperAtk
# {
#    tagHead        Head;
#    WORD        SkillID;
#    WORD        PosX;    //¹¥»÷Æðµã
#    WORD        PosY;    
#    WORD        TagPosX;        //Ä¿±êµã
#    WORD        TagPosY;
#    DWORD        WorldTick;
#    WORD        HurtCount;        //É˺¦ÊýÄ¿
#    tagSkillPosHurtObj        HurtList[HurtCount];        //size = HurtCount
# };
#===============================================================================