Skip to content

Instantly share code, notes, and snippets.

@Gateswong
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save Gateswong/3aa2c10354ff54b38834 to your computer and use it in GitHub Desktop.

Select an option

Save Gateswong/3aa2c10354ff54b38834 to your computer and use it in GitHub Desktop.
// =====================================================
// GLOBAL VARIABLES
// =====================================================
// misc
Dim CURSOR_LOOT, LOOT_X, LOOT_Y, SCREEN_WIDTH, SCREEN_HEIGHT
CURSOR_LOOT = 1434778618
LOOT_X = -1
LOOT_Y = -1
SCREEN_WIDTH = 1920
SCREEN_HEIGHT = 1080
// Key defination *
Dim KEY_OPEN_A_BAG, KEY_MOUNT, KEY_DISMOUNT, KEY_INTERACT_TARGET, KEY_TARGET_VENDOR
KEY_OPEN_A_BAG = "1"
KEY_MOUNT = "2"
KEY_DISMOUNT = "3"
KEY_INTERACT_TARGET = "]"
KEY_TARGET_VENDOR = "4"
// Workflow control *
Dim IS_SELLING_ITEM
IS_SELLING_ITEM = false
// modify this as your will *
Dim BAG_SLOTS
BAG_SLOTS = 90
// ======================================================
// FUNCTIONS
// ======================================================
// Obtain a bag from target area.
Function obtain_a_bag (delay_click, delay_press)
MoveTo LOOT_X, LOOT_Y
Delay delay_click
RightClick 1
Delay delay_press
KeyPress KEY_OPEN_A_BAG, 1
End Function
// Mount and sell all the items
Function sell_items
Delay 2000
KeyPress KEY_MOUNT, 1
Delay 5000
KeyPress KEY_TARGET_VENDOR, 1
Delay 1000
KeyPress KEY_INTERACT_TARGET, 1
Delay 2000
KeyPress KEY_DISMOUNT, 1
End Function
// Fill the bag with the junks!
Function fill
For BAG_SLOTS * 10
Call obtain_a_bag (300, 250)
Next
End Function
// Function get cursor position
Function find_position
Dim x, y
x = SCREEN_WIDTH / 2 - 300
y = SCREEN_HEIGHT / 2 - 300
While True
Delay 25
x = x + 25
If x > SCREEN_WIDTH / 2 + 300 Then
x = SCREEN_WIDTH / 2 - 300
y = y + 25
End If
If y > SCREEN_HEIGHT / 2 + 300 Then
Goto find_position_position_not_found
End If
MoveTo x, y
If CURSOR_LOOT = GetCursorShape(0) Then
LOOT_X = x
LOOT_Y = y
Delay 1000
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
Plugin.Msg.SendSMS ²ÎÊý1,²ÎÊý2,²ÎÊý3,²ÎÊý4
EndScript
Rem find_position_end
End Function
// ========================================================
// MAIN LOOP
// ========================================================
Call find_position
While True
Call fill
If Not IS_SELLING_ITEM Then
EndScript
End If
Wend
// ==========================================================
// LOGIN
// ==========================================================
Function input_username
MoveTo 951, 568
LeftClick 1
SayString "gstore0"
End Function
Function input_password
MoveTo 957, 663
LeftClick 1
SayString "iceiceice"
End Function
Function submit_login
MoveTo 958, 808
LeftClick 1
Delay 10000
End Function
Function detect_login
// Detect message "Disconnected from server."
FindPic 597,468,1329,612,"Attachment:\mainmenu_disconnected.bmp",0.9,x,y
If x > 0 And y > 0 Then
Call mouse_click(920, 558, 1, 1000)
End If
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 = "]"
Function mouse_turn_right
GetCursorPos x, y
MoveTo x + 5, 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
MoveTo x, y
LeftClick 1
Delay interval
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 = - 1
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
// ===========================================================
// TEST
// ===========================================================
//Call move(KEY_MOVE_RIGHT, 500)
//Call target_unit("Thuul")
//Call interact_target
//Call begin_move(KEY_MOVE_FORWARD)
//Delay 2000
//Call jump
//Delay 10000
//Call stop_move(KEY_MOVE_FORWARD)
//Call move(KEY_MOVE_RIGHT, 2500)
Call scan_for_cursors(CURSOR_MAILBOX, CURSOR_MAILBOX_DISABLED, -1, -1)
RightClick 1
Delay 10000
Call scan_for_cursor(CURSOR_MAILBOX)
RightClick 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment