Skip to content

Instantly share code, notes, and snippets.

@Gateswong
Created August 10, 2014 09:39
Show Gist options
  • Select an option

  • Save Gateswong/71ea4fbfd64ecbc4cf6b to your computer and use it in GitHub Desktop.

Select an option

Save Gateswong/71ea4fbfd64ecbc4cf6b to your computer and use it in GitHub Desktop.
// =========================================================
// FSM
// =========================================================
FSM_NULL = 0
FSM_LOGIN_SCREEN = 1
FSM_CHAR_SELECT = 2
FSM_CHAR_CREATE = 3
FSM_LOADING = 4
FSM_NEW_CHAR = 5
FSM_CHAR_UNDERCITY = 6
STATE = FSM_NULL
// ==========================================================
// LOGIN
// ==========================================================
Function input_username(name)
MoveTo 951, 638
LeftClick 1
SayString name
End Function
Function input_password(password)
MoveTo 957, 740
LeftClick 1
SayString password
End Function
Function submit_login
MoveTo 958, 896
LeftClick 1
Delay 1000
End Function
Function detect_disconnect
// Detect message "Disconnected from server."
FindPic 825, 599, 1090, 636, "D:\MyDocuments\app.SourceTree\wow-auto\images\mainmenu_disconnected.bmp",0.5,x,y
TracePrint CStr(x) + "," + CStr(y)
If x > 0 And y > 0 Then
Call mouse_click(965, 614, 1, 1000)
End If
Delay 500
End Function
ACC_SUBFIX = 1
ACC_PREFIX = "dalaran"
FIRST_NAME = "pgup"
LAST_NAME = "abcd"
Function convert
Dim j, k
i = ACC_SUBFIX
If Int(j / 1000) = 0 Then
last = "k"
k = j
End If
If Int(j / 1000) = 1 Then
last = "l"
k = j - 10
End If
If Int(j / 1000) = 2 Then
last = "m"
k = j - 20
End If
If Int(j / 1000) = 3 Then
last = "n"
k = j - 30
End If
If Int(j / 1000) = 4 Then
last = "o"
k = j - 40
End If
If Int(j / 1000) = 5 Then
last = "p"
k = j - 50
End If
If Int(j / 1000) = 6 Then
last = "q"
k = j - 60
End If
If Int(j / 1000) = 7 Then
last = "r"
k = j - 70
End If
If Int(j / 1000) = 8 Then
last = "s"
k = j - 80
End If
If Int(j / 1000) = 9 Then
last = "t"
k = j - 90
End If
lastT = last
If Int(i / 100) = 0 Then
last = "a"
j = i
End If
If Int(i / 100) = 1 Then
last = "b"
j = i - 100
End If
If Int(i / 100) = 2 Then
last = "c"
j = i - 200
End If
If Int(i / 100) = 3 Then
last = "d"
j = i - 300
End If
If Int(i / 100) = 4 Then
last = "e"
j = i - 400
End If
If Int(i / 100) = 5 Then
last = "f"
j = i - 500
End If
If Int(i / 100) = 6 Then
last = "g"
j = i - 600
End If
If Int(i / 100) = 7 Then
last = "h"
j = i - 700
End If
If Int(i / 100) = 8 Then
last = "i"
j = i - 800
End If
If Int(i / 100) = 9 Then
last = "j"
j = i - 900
End If
lastF = last
If Int(j / 10) = 0 Then
last = "k"
k = j
End If
If Int(j / 10) = 1 Then
last = "l"
k = j - 10
End If
If Int(j / 10) = 2 Then
last = "m"
k = j - 20
End If
If Int(j / 10) = 3 Then
last = "n"
k = j - 30
End If
If Int(j / 10) = 4 Then
last = "o"
k = j - 40
End If
If Int(j / 10) = 5 Then
last = "p"
k = j - 50
End If
If Int(j / 10) = 6 Then
last = "q"
k = j - 60
End If
If Int(j / 10) = 7 Then
last = "r"
k = j - 70
End If
If Int(j / 10) = 8 Then
last = "s"
k = j - 80
End If
If Int(j / 10) = 9 Then
last = "t"
k = j - 90
End If
lastM = last
If k = 0 Then
last = "a"
End If
If k = 1 Then
last = "b"
End If
If k = 2 Then
last = "c"
End If
If k = 3 Then
last = "d"
End If
If k = 4 Then
last = "e"
End If
If k = 5 Then
last = "f"
End If
If k = 6 Then
last = "g"
End If
If k = 7 Then
last = "h"
End If
If k = 8 Then
last = "i"
End If
If k = 9 Then
last = "j"
End If
lastL = last
LAST_NAME = lastT + lastF + lastM + lastL
End Function
// ===========================================================
// MOVE & ACTION
// ===========================================================
KEY_MOVE_FORWARD = "w"
KEY_MOVE_BACKWARD = "s"
KEY_MOVE_LEFT = "q"
KEY_MOVE_RIGHT = "e"
KEY_TURN_LEFT = "a"
KEY_TURN_RIGHT = "d"
KEY_JUMP = "Space"
KEY_INTERACT_TARGET = "r"
Function mouse_turn_right
GetCursorPos x, y
MoveTo x + 1, y
Delay 30
End Function
Function begin_move(key)
KeyDown key, 1
End Function
Function stop_move(key)
KeyUp key, 1
End Function
Function move(key, time)
Call begin_move(key)
t = 0
While t < time
t = t + 50
Delay 50
Wend
Call stop_move(key)
End Function
Function mouse_click(x, y, times, interval)
For times
Delay interval
MoveTo x, y
LeftClick 1
Next
End Function
Function mouse_rightclick(x, y, times, interval)
For times
Delay interval
MoveTo x, y
RightClick 1
TracePrint "RightClick"
Next
End Function
Function jump
KeyPress KEY_JUMP, 1
End Function
Function interact_target
KeyPress KEY_INTERACT_TARGET, 1
End Function
// ===========================================================
// CHATTING & MACRO
// ===========================================================
Function chat_send(str)
KeyPress "Enter", 1
Delay 25
SayString str
Delay 125
KeyPress "Enter", 1
End Function
Function target_unit(name)
Call chat_send("/target " + name)
End Function
// ===========================================================
// SCREEN SCAN
// ===========================================================
CURSOR_NORMAL = 965986689
CURSOR_NORMAL_CASTABLE = - 1
CURSOR_GEAR = 1884068285
CURSOR_GEAR_DISABLED = 461731387
CURSOR_MAILBOX = 111939411
CURSOR_MAILBOX_DISABLED = 919159681
CURSOR_VENDOR = 1184891248
CURSOR_VENDOR_DISABLED = 1422072268
CURSOR_LOOT = - 1
CURSOR_LOOT_DISABLED = - 1
CURSOR_FISHING = - 1
SCREEN_WIDTH = 1920
SCREEN_HEIGHT = 1080
Function scan_for_cursors(cursor, cursor2, cursor3, cursor4)
x = 50
y = 50
While True
Delay 25
x = x + 25
If x > SCREEN_WIDTH - 50 Then
x = 50
y = y + 25
End If
If y > SCREEN_HEIGHT - 50 Then
Goto find_position_position_not_found
End If
MoveTo x, y
cursor_shape = GetCursorShape(0)
If cursor = cursor_shape Or _
cursor2 = cursor_shape Or _
cursor3 = cursor_shape Or _
cursor4 = cursor_shape Then
Delay 500
Goto find_position_position_found
End If
Wend
Rem find_position_position_found
Goto find_position_end
Rem find_position_position_not_found
Call Plugin.Msg.Tips("ERROR: Can't find position!")
Delay 10000
EndScript
Rem find_position_end
End Function
Function scan_for_cursor(cursor)
Call scan_for_cursors(cursor, -1, -1, -1)
End Function
// ===========================================================
// WORKFLOW
// ===========================================================
Function journey_undercity_inn()
call target_unit("bethor iceshard")
Delay 20
call interact_target
Delay 1500
call target_unit("hannah akeley")
Delay 20
call interact_target
Delay 3000
Call target_unit("kor'kron overseer")
Delay 20
Call interact_target
Delay 7000
call move(KEY_MOVE_FORWARD,1600)
call move(KEY_MOVE_RIGHT,1000)
call move(KEY_MOVE_FORWARD,6300)
call move(KEY_MOVE_RIGHT,500)
Call move(KEY_MOVE_FORWARD, 1500)
call target_unit("ralston farnsley")
Delay 20
Call interact_target
Delay 4500
call target_unit("sheldon von croy")
Delay 20
Call interact_target
Delay 2000
call target_unit("ralston farnsley")
Delay 20
Call interact_target
Delay 2000
Call move(KEY_TURN_LEFT,390)
Delay 200
Call MOVE(KEY_MOVE_FORWARD,4000)
Delay 200
Call move(KEY_TURN_LEFT,480)
Delay 200
Call MOVE(KEY_MOVE_FORWARD,8500)
Delay 200
Call move(KEY_TURN_LEFT,465)
Delay 200
Call MOVE(KEY_MOVE_FORWARD, 5000)
Call MOVE(KEY_MOVE_FORWARD, 1000)
Call MOVE(KEY_MOVE_FORWARD, 1000)
Call MOVE(KEY_MOVE_FORWARD, 1500)
Call move(KEY_MOVE_BACKWARD,1500)
call target_unit("auctioneer cain")
Delay 20
Call interact_target
Delay 4000
KeyPress "w",1
Call move(KEY_MOVE_FORWARD,2300)
DELAY 200
Call move(KEY_MOVE_LEFT,2500)
call target_unit("auctioneer yarly")
Delay 20
Call interact_target
Delay 3000
KeyPress "w",1
Call move(KEY_MOVE_FORWARD,800)
Delay 200
Call move(KEY_TURN_RIGHT, 330)
Delay 200
Call move(KEY_MOVE_FORWARD,5150)
Delay 200
Call move(KEY_TURN_LEFT,293)
Delay 200
Call move(KEY_MOVE_FORWARD,700)
Call move(KEY_MOVE_FORWARD, 700)
Call move(KEY_MOVE_FORWARD,700)
call target_unit("edward remington")
Delay 20
Call interact_target
Delay 2500
call target_unit("mortimer montague")
Delay 20
Call interact_target
Delay 4500
Call move(KEY_TURN_RIGHT, 520)
Delay 200
Call move(KEY_MOVE_FORWARD, 420)
Call move(KEY_MOVE_FORWARD, 420)
Call move(KEY_MOVE_FORWARD, 420)
Delay 200
Call move(KEY_MOVE_LEFT,1400)
Call move(KEY_MOVE_FORWARD,3000)
Call target_unit("innkeeper norman")
Delay 20
Call interact_target
Delay 1000
Call interact_target
Delay 1000
Call interact_target
Delay 1000
Call move(KEY_MOVE_FORWARD, 500)
Call move(KEY_MOVE_RIGHT, 300)
End Function
Function login_new_account(name, password)
Call detect_disconnect
Rem input_login_info
Call input_username(name)
Call input_password(password)
Call submit_login
t = True
x = - 1
y = - 1
Delay 500
While t
Delay 500
FindPic 898, 671, 1016, 697, "D:\MyDocuments\app.SourceTree\wow-auto\images\mainmenu_btn_okay.bmp", 0.9, xx, yy
If xx > 0 And yy > 0 Then
Call mouse_click(959, 678, 1, 300)
Delay 1000
Goto input_login_info
End If
FindPic 33,1069,205,1127,"D:\MyDocuments\app.SourceTree\wow-auto\images\mainmenu_state_sign.bmp",0.9,x,y
If x < 0 And y < 0 Then
t = False
End If
Wend
// Check state
// Delay 5000
// FindPic 33,1069,205,1127,"D:\MyDocuments\app.SourceTree\wow-auto\images\mainmenu_state_sign.bmp",0.9,x,y
// If x > 0 And y > 0 Then
// login_new_account = FSM_LOGIN_SCREEN
// Exit Function
// End If
//
// FindPic 59, 1118, 234, 1145, "D:\MyDocuments\app.SourceTree\wow-auto\images\charselect_btn_addons.bmp", 0.9, x, y
// If x > 0 And y > 0 Then
// login_new_account = FSM_CHAR_SELECT
// Exit Function
// End If
End Function
Function enter_game_world
Delay 200
FindColorEx 1025,1075,1075,1125,"03036D",0,0.9,x,y
If x < 0 And y < 0 Then
Delay 250
//FindPic 840, 1092, 1081, 1120, "D:\MyDocuments\app.SourceTree\wow-auto\images\charselect_btn_enter_disabled.bmp", 0.5, x, y
FindColorEx 866,1094,890,1118,"202123",0,0.9,x,y
If x > 0 And y > 0 Then
STATE = FSM_CHAR_CREATE
Delay 100
Call mouse_click(1725, 964, 1, 100)// Create new character
Delay 1000
Call mouse_click(293, 222, 1, 300)// Undead
Delay 200
Call mouse_click(216, 650, 1, 200)// Female
Delay 200
Call mouse_click(191, 830, 1, 200)// Mage
Delay 200
Call mouse_click(946, 1080, 1, 300)// Input name
Delay 200
Call convert
SayString FIRST_NAME + LAST_NAME
Call mouse_click(1715, 1123, 1, 400)// Submit
STATE = FSM_CHAR_SELECT
End If
End If
//Call mouse_click(159, 1129, 1, 2500)// Addons
//Call mouse_click(651, 949, 1, 250)// Disable All @ Addons
//Call mouse_click(1143, 948, 1, 250)// Okay @ Addons
Call mouse_click(953, 1101, 1, 2000)// Enter World
Delay 2000
x = -1
y = -1
Do While x < 0 And y < 0
Delay 200
FindPic 477,14, 1125,109, "D:\MyDocuments\app.SourceTree\wow-auto\images\pure_black.bmp", 1.0, x, y
Loop
Delay 2000
KeyPress "Esc", 1
Delay 1000
STATE = FSM_NEW_CHAR // new character entered game.
End Function
// For open portal:
// You should 'Windowed (Maximum)' the window in main screen, for normal one
// Open second in a second 1920x1080 screen at (-1920, 0) and 'Windowed' then maximum it. (not Windowed (Maximum))
Function open_portal
// Mage: Leave party
Call mouse_click(-866 , 245, 2, 200)// active window
Call chat_send("/leave")
// XXX: Invite party
Call mouse_click(500, 500, 1, 100)// active window
Call chat_send("/invite Kaimende")
// Mage: Accept party invite
Call mouse_click(- 500 , 500, 1, 100)// active window
Call mouse_click(- 1046 , 249, 1, 500)// accept invite
Call mouse_click(1029, 636, 1, 300)// active window
// Find out if there is a portal
t = True
While t
MoveTo 1029, 636
Delay 250
c = GetCursorShape(1)
TracePrint c
If c = "1545080280" Then // There is a portal
t = False
Call mouse_rightclick(1029, 636, 1, 100)
// Find out if in undercity
t2 = True
While t2
TracePrint "Find out if in undercity..."
Delay 200
// FindPic 1726,9,1868,29,"Attachment:\world_minimap_magicquarter.bmp",0.9,x,y
FindColorEx 1664,903,1714,953,"49ffb4",0,0.9,x,y
If x > 0 And y > 0 Then
t2 = False
Delay 2000
Call chat_send("/logout")
Call mouse_click(1794, 1129, 1, 1000)
End If
Wend
Else
// Mage: Open a portal
Call mouse_click(- 500 , 500, 1, 500)// active window
KeyPress "6", 1
Call mouse_click(1029, 636, 1, 1000)// active window
Delay 10000
End If
Wend
End Function
Function save_option
Call Plugin.File.WriteINI("acc", "index", CStr(ACC_SUBFIX), "D:\MyDocuments\app.SourceTree\wow-auto\wlk.ini")
End Function
Function load_option
text = Plugin.File.ReadINI("acc", "index", "D:\MyDocuments\app.SourceTree\wow-auto\wlk.ini")
ACC_SUBFIX = CInt(text)
TracePrint "Readed subfix progress: " + text
End Function
Function setup
IfColor 271,69 , "00D900", 0 Then
Delay 200
keypress "esc",1//open menu
Delay 200
MoveTo 976, 550//open interface
Delay 200
LeftClick 1
Delay 500
MoveTo 623, 617//mouse
Delay 200
LeftClick 1
Delay 400
MoveTo 1129, 420//click to move
Delay 200
LeftClick 1
Delay 200
MoveTo 1199, 933//okay
Delay 200
LeftClick 1
Delay 200
KeyPress "esc", 1
Delay 500
Call chat_send("/run SetBinding(""R"",""INTERACTTARGET"")")
Delay 300
End If
End Function
Function set_waypoint(x, y)
Call chat_send("/way " + CStr(x) + " " + CStr(y))
End Function
COLOR_GOOD = "00C600"
COLOR_MIDDLE = "00DEE1"
COLOR_BAD = "0000E1"
Function goto_waypoint
not_reach = true
current = 1 // red
Goto rem_get_color
While not_reach
Rem rem_get_color
FindColorEx 960,585,965,590,"00DEE1",0,0.95,x,y
If x > 0 And y > 0 Then
End If
Wend
End Function
Function journey_undercity_inn2
End Function
// ===========================================================
// MAIN LOOP
// ===========================================================
// ===========================================================
// FISHING PART
// ===========================================================
// ===========================================================
// TEST
// ===========================================================
ltimes = 5000
Call load_option
STATE = 1
Goto rem_main_loop
//call login_new_account(ACC_PREFIX + CStr(ACC_SUBFIX), "iceiceice")
//Call enter_game_world
//Call setup
//call journey_undercity_inn
For ltimes
Rem rem_main_loop
Call login_new_account(ACC_PREFIX + CStr(ACC_SUBFIX), "kirintor")
Call enter_game_world
// Call setup
// call journey_undercity_inn
Call open_portal
Delay 2000
Call chat_send("/logout")
Call mouse_click(1794, 1129, 1, 1000)
ACC_SUBFIX = ACC_SUBFIX + 1
Call save_option
Next
//Call setup
//Call journey_undercity_inn
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment