-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMain.py
99 lines (87 loc) · 2.64 KB
/
Main.py
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
# -*- coding: utf-8 -*-
import WOW
import time
import thread
import random
from World import *
from OpCodes import *
import sys
from colors import *
from struct import *
import os
random.seed()
# Host Username Password Nome pg Razza Classe
client = WOW.WOW(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4],int(sys.argv[5]),int(sys.argv[6]))
brainresetschedule = time.time()+30.0
rm = False
def rmthread():
global rm
while 1:
#debug("RMLOOP: %s\n"%str(rm))
if rm:
client.gotodest(client.x+20*random.random()-20*random.random(),client.y+20*random.random()-20*random.random())
time.sleep(5.0)
gworld = None
def createobjectcb(guid,world):
notice("Nuovo %s , Guid %s"%(objectnames[world.getobject(guid).t],str(guid)))
global gworld
gworld = world
def onchatmsg(typ,fromguid,msg):
global rm
global gworld
msg = msg.strip("\x00")
m = msg.split(" ")
if m[0] == "go":
client.gotodest(float(m[1]),float(m[2]))
if m[0] == "randommove":
rm = True
if m[0] == "stoprandommove":
rm = False
if m[0] == "attack" and m[1] == "mytarget":
print "Attack"
player = gworld.getobject(fromguid)
print player.values
client.attackphysical(player.getunitfieldtarget())
print "Target: "+str(player.getunitfieldtarget())
if m[0] == "cast" and m[2] == "mytarget":
player = gworld.getobject(fromguid)
target = player.getunitfieldtarget()
client.castspell(7,target)
if m[0] == "stop":
client.stopmoving()
if m[0] == "follow":
client.following = fromguid
if m[0] == "say" and typ == CHAT_MSG_YELL:
pdata = ""
pdata += pack("I",1)
pdata += pack("I",1)
pdata += ' '.join(m[1:])
client.sendpacket(CMSG_MESSAGECHAT,pdata)
global brainresetschedule
#if typ == 1:
# print "Chat",typ,fromguid,msg
# msg = msg.strip("\x00")
# print msg[0]
# if msg[0] == "#":
# if msg.startswith("#learn"):
# mh_python.learn(' '.join(msg.split(" ")[1:]).replace("\x00",""))
# return
# if msg.startswith("#reset"):
# brainresetschedule = time.time()
# return
# return
# brainresetschedule = time.time()+120.0
# pdata = ""
# pdata += pack("I",1)
# pdata += pack("I",1)
# pdata += mh_python.doreply(msg.replace("\x00",""))
# client.sendpacket(CMSG_MESSAGECHAT,pdata)
client.chatcb = onchatmsg
client.createobjectcb = createobjectcb
thread.start_new_thread(rmthread,())
try:
while 1:
time.sleep(10.0)
except:
pass
mh_python.cleanup()