-
Notifications
You must be signed in to change notification settings - Fork 3
/
showmefish.py
79 lines (61 loc) · 1.64 KB
/
showmefish.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
# Copyright 2013, Up Chen
# Released under the MIT License.
#
# Author: Up Chen
# Github: https://github.com/wallat/showmefish.sikuli
import logging
# finding vars
APP_NAME = 'World of Warcraft-64'
bouyImg = "buoy.png" # use this image to find the bouy
findBouySimilarity = 0.5 # threshold to find the bouy
findSplashSimilarity = 0.7 # threshold to find the splash
# setup envs
Settings.MoveMouseDelay = 0
# init logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(message)s')
def log(msg):
logging.debug(msg)
# define constants
CAST_BOUY = 'cast_bouy'
FIND_BOUY = 'find_bouy'
WAIT_SPLASH = 'wait_splash'
PICK_FISH = 'pick_fish'
# setup the searching area
App.focus(APP_NAME)
searchingArea = selectRegion('Drag the fishing area')
# select the WOW application
App.focus(APP_NAME)
# init
status = CAST_BOUY
startTime = time.time()
foundBouy = None
bouyImg = Pattern(bouyImg)
while True:
elapsedTime = time.time() - startTime
if elapsedTime>20:
status = CAST_BOUY
# rethrow if it cannot find the buoy for a long time
if status==FIND_BOUY and elapsedTime>8:
status = CAST_BOUY
if status==CAST_BOUY:
type('1')
mouseMove(searchingArea.getTopLeft())
startTime = time.time()
status = FIND_BOUY
sleep(1)
if status==FIND_BOUY:
foundBouy = searchingArea.exists(bouyImg.similar(findBouySimilarity))
if foundBouy:
status = WAIT_SPLASH
mouseMove(foundBouy)
if status==WAIT_SPLASH:
expand = foundBouy.nearby(10)
if not expand.exists(bouyImg.similar(findSplashSimilarity), 1):
log('SPLASH!!')
status = PICK_FISH
if status==PICK_FISH:
rightClick(foundBouy, KeyModifier.SHIFT)
status = CAST_BOUY
sleep(3)