Skip to content

Instantly share code, notes, and snippets.

@samrocketman
Last active May 6, 2016 05:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samrocketman/12057af8bbf1463ca2a6 to your computer and use it in GitHub Desktop.
Save samrocketman/12057af8bbf1463ca2a6 to your computer and use it in GitHub Desktop.
http://www.sikuli.org/ doppler_heal.sikuli script. Spins mouse in a circle from a central point in your game. e.g. your space ship.
#doppler heal with hotkeys
#Created by Sam Gleske
#https://gist.github.com/samrocketman/12057af8bbf1463ca2a6
#rev 35
################################################################################
#DOCUMENTATION
# About this program
# This program is designed to add hotkey functionality to my game.
# Additionally, it augments my ability to play using more keyboard shortcuts
# instead of just the mouse.
#
# Starting and stopping this script (keyboard shortcuts)
# * Start - CMD+R (Mac) or CTRL+R (Windows)
# * Stop - CTRL+C
# Note: do NOT use CMD+SHIFT+C or ALT+SHIFT+C to exit. Hotkey handlers do not
# properly clean up.
#
# Cool gameplay shortcuts (all other default game shortcuts unmodified). Note: you can
# customize these shortcust in the advanced settings section of this code.
# * 1 - activate booster 1 (e.g. Shield Booster)
# * 2 - activate booster 2
# * 3 - activate booster 3
# * 4 - activate booster 4
# * c - activate mining tool
# * C - (SHIFT+C) Toggle spam click. Good for adding or removing dozens of boosters to your ship.
# * ^c - (CTRL+C) Cancel all hotkeys and quit sikuli.
# * v - Toggle sector map.
# * m - Toggle auto-mining. When pressing R it starts by mining. This disables that.
# * r - heal
# * z - use jumpgate
# * Z - build outpost
# * x - transfer resources at an outpost; have launcher weapon selected when pressing key
# * q - auto-rotate mouse in a circular doppler pattern; initially mines
# * e - click and hold mouse
# * t - while rotating toggle auto-switch weapons every N rotations (e.g. auto heal)
# * y - activate chat NOTE: will disable shortcuts so you can chat
# * ^g - (CTRL+G) resume game from chat NOTE: will enable shortcuts again
#END DOCUMENTATION
################################################################################
################################################################################
# SETUP SETTINGS
#these MUST be edited before you use the script.
#TIP: before you update the script don't forget to backup your settings.
#ship center location (Important! because it is the center of your circle)
center = Location(720, 505)
#Can be Firefox or Google Chrome or whatever you use this script will auto
#alt+tab to your browser
browser = "Google Chrome"
#locations for clicking... can be any kind of sikuli location, region, or
#screenshot.
#All of the following settings are intended to be Location types
booster1_location = Location(49, 855)
booster2_location = Location(46, 774)
booster3_location = Location(47, 693)
booster4_location = Location(46, 611)
chat_close_location = Location(1318, 767)
chat_open_location = Location(734, 113)
health_location = Location(1400, 736)
map_location = Location(1364, 175)
mine_location = Location(1403, 836)
#All of the following are intended to be screenshot types
#note: for best experience take below screenshots with launcher weapon selected
build_outpost_location = "buildoutpost_location.png"
chat_invitation = "chat_invitation.png"
jumpgate_location = "jumpgate_location.png"
transfer_resources_button_location = "depositmining_location.png"
transfer_resources_close_location = "transfer_resources_close_location.png"
transfer_resources_gear_location = "transfer_resources_gear_location.png"
transfer_resources_house_location = "transfer_resources_house_location.png"
# END SETUP SETTINGS
################################################################################
################################################################################
# ADVANCED USER SETTINGS
#edit these settings only if you know what you're doing
#customize keys
#how to customize keys
# * h - means your hotkey will simply be H.
# * H - means your hotkey will be SHIFT+H.
# * ^h - means your hotkey will be CTRL+H.
# * ^H - means your hotkey will be CTRL+SHIFT+H.
#note: leaving a shortcut key an empty string or null (i.e. None) will disable it
shortcut_keys = {
"active_rotate": "q",
"auto_switch": "t",
"automine": "m",
"booster1": "1",
"booster2": "2",
"booster3": "3",
"booster4": "4",
"build_outpost": "Z",
"cancel": "^c",
"chat": "y",
"chat_close": "^g",
"click_and_hold": "e",
"health": "",
"jumpgate": "z",
"map": "v",
"mine": "c",
"spamclick": "C",
"transfer_resources": "x"
}
#Rotation settings
#How far away should the mouse be from the center of the screen when moving in a circle?
centerOffset = 100
#imagine the mouse moving in a circle creating a pie. How many slices do you want?
slicesOfPie = 30
#how fast to rotate? Smaller is faster.
#waitValue = 0.04
waitValue = 0.04
#how quickly to transfer resources (X hotkey) at an outpost? smaller is faster
#note: I found a value of 0 can be buggy.
transferSequenceDelay = 0.2
#auto-switch toggle weapons settings (i.e. press "f" automatically)
#toggle weapons every 10 doppler rotations (e.g. toggle to heal)
switchEvery = 10
#how many rotations to heal? (e.g. for ever 10 rotations 2 of them are dedicated to healing)
numRotations = 2
# END ADVANCED USER SETTINGS
################################################################################
#NOT RECOMMENDED TO EDIT BEYOND THIS POINT
#library imports
from math import sin,cos,radians
import re
#global Sikuli settings
Settings.DelayBeforeMouseDown = 0
Settings.DelayBeforeMouseUp = 0.001
Settings.MoveMouseDelay = 0
Settings.WaitScanRate = 0.5
#system state variables
#should rotating mouse be active?
activeRotate = False
#Start mining with activeRotate
autoMine = True
#toggle between weapons every N rotations while rotating?
autoSwitch = False
#am I in chat?
chatEnabled = False
#Spamclick powers activated
spamClick = False
#is the transfer resources sequence active?
transferResources = False
#registered hot keys (for deactivating)
#list of touples where first element is key an second element is modifier
registered_hot_keys = []
#functions
def reset_state():
global activeRotate
global autoSwitch
global transferResources
global spamClick
if activeRotate:
activeRotate = False
mouseUp(Button.LEFT)
autoSwitch = False
transferResources = False
spamClick = False
def toggle_activerotate(event):
global activeRotate
if activeRotate:
activeRotate = False
mouseUp(Button.LEFT)
else:
if autoMine:
doClick(mine_location, False)
activeRotate = True
#hold down mouse and start rotating
mouseDown(Button.LEFT)
count = numRotations + 1
cX = center.getX()
cY = center.getY()
while activeRotate:
if autoSwitch:
count = count % switchEvery
if count == 0 or count == numRotations:
type("f")
count = count + 1
#move the mouse in a circle based on number of slices
for degrees in range(0, 360, 360 / slicesOfPie):
if not activeRotate:
break
mouseX = cX + int(centerOffset * cos(radians(degrees)))
mouseY = cY + int(centerOffset * sin(radians(degrees)))*-1
mouseMove(Location(mouseX, mouseY))
wait(waitValue)
def toggle_autoswitch(event):
global autoSwitch
autoSwitch = not autoSwitch
def doExit(event):
unregisterHotkeys()
exit()
def doClick(some_location, reset = True, image_search_delay = 3):
if reset:
reset_state()
last_mouse_location = Env.getMouseLocation()
try:
#images are detected as strings
if isinstance(some_location, basestring):
#only click the image location if image exists on screen
if exists(some_location, image_search_delay):
click(some_location)
else:
click(some_location)
except:
pass
mouseMove(last_mouse_location)
def click_mine(event):
doClick(mine_location)
def click_map(event):
doClick(map_location)
def click_spamclick(event):
global spamClick
if not spamClick:
spamClick = True
#click as fast as inhumanly possible
while spamClick:
mouseMove(Env.getMouseLocation())
doubleClick(Env.getMouseLocation())
else:
#stop spam clicking
spamClick = False
def click_health(event):
doClick(health_location)
def click_build_outpost(event):
doClick(build_outpost_location)
def click_transfer_resources(event):
global transferResources
reset_state()
if not transferResources:
transferResources = True
click_in_order = [
transfer_resources_gear_location,
transfer_resources_button_location,
transfer_resources_house_location,
transfer_resources_close_location
]
for x in click_in_order:
if not transferResources:
break
if isinstance(x, basestring) and len(x) > 0:
doClick(x, False)
wait(transferSequenceDelay)
def click_jumpgate(event):
doClick(jumpgate_location)
def click_booster1(event):
doClick(booster1_location)
def click_booster2(event):
doClick(booster2_location)
def click_booster3(event):
doClick(booster3_location)
def click_booster4(event):
doClick(booster4_location)
def click_chat(event):
global chatEnabled
reset_state()
unregisterHotkeys()
doClick(chat_invitation, False, 1)
doClick(chat_open_location, False)
chatEnabled = True
def click_and_hold(event):
mouseMove(Env.getMouseLocation())
mouseDown(Button.LEFT)
def registerHotkey(key, modifier, func):
global registered_hot_keys
if not (key, int(modifier)) in registered_hot_keys:
registered_hot_keys.append((key, int(modifier)))
Env.addHotkey(key, modifier, func)
def unregisterHotkeys():
global registered_hot_keys
#unregister all hot keys
for key,modifier in registered_hot_keys[:]:
if not (key, int(modifier)) in ignore_unregister:
registered_hot_keys.remove((key, int(modifier)))
Env.removeHotkey(key, modifier)
def getKey(key):
#Get a key an convert it to a touple
modifier = 0
if key[0] == '^':
modifier += int(KeyModifier.CTRL)
key = key[-1]
if re.match(r'[A-Z]', key):
modifier += int(KeyModifier.SHIFT)
return (key.lower(), modifier)
def registerHotkeys():
#set up all the hot keys
#https://bugs.launchpad.net/sikuli/+bug/1565417
for k,v in shortcut_keys.items():
if v == None or len(v) == 0:
continue
#touple with (key, modifier)
key = getKey(v)
registerHotkey(key[0], key[1], shortcut_functions[k])
def doResume(event):
global chatEnabled
if chatEnabled:
chatEnabled = False
doClick(chat_close_location)
registerHotkeys()
def click_automine(event):
global autoMine
autoMine = not autoMine
#functions for hotkeys
shortcut_functions = {
"active_rotate": toggle_activerotate,
"auto_switch": toggle_autoswitch,
"automine": click_automine,
"booster1": click_booster1,
"booster2": click_booster2,
"booster3": click_booster3,
"booster4": click_booster4,
"build_outpost": click_build_outpost,
"cancel": doExit,
"chat": click_chat,
"chat_close": doResume,
"click_and_hold": click_and_hold,
"health": click_health,
"jumpgate": click_jumpgate,
"map": click_map,
"mine": click_mine,
"spamclick": click_spamclick,
"transfer_resources": click_transfer_resources
}
ignore_unregister = [shortcut_keys["cancel"], shortcut_keys["chat_close"]]
ignore_unregister = map(lambda x: getKey(x), ignore_unregister[:])
#change to browser
switchApp(browser)
registerHotkeys()
#infinitely run the script so it must be canceled
while True:
wait(1)
@samrocketman
Copy link
Author

Automation script

Open a terminal, set up the environment, and launch Sikuli (see commands below).

export JAVA_HOME="$(/usr/libexec/java_home -v 1.7)"
export PATH="$JAVA_HOME/bin:$PATH"
~/Downloads/SikuliX.app/run

In Mac OS X, Sikuli freezes if you're using Java 1.8. That is why the above environment setup commands use Oracle Java 1.7.

Recommended short cuts:

  • CMD+R is the shortcut to run a script. (Windows is Ctrl+R)
  • CMD+SHIFT+C is the shortcut to cancel a script. (Windows is Ctrl+Shift+C)

@samrocketman
Copy link
Author

List of exploits

  • Auto lock exploit - Click on a non-weapon tool (e.g. heal tool or mine tool) then switch to a weapon. When the weapon is running it will only fire when it actually locks on.
  • Zoom out exploit - Use the browser zoom (ctrl scroll) to zoom out of the game to see the entire map all at once. Nukes can then be launched across the map. Note: can also load the game when the browser window is really small. When the browser window size is increase the map will be really wide. Launching nukes across the map make them invisible.
  • Ghost building exploit - In a fight group, pull up the radar and view the galaxy map. Then when the fightrgoup has the "entering sector" text, exit the fight group. You'll be invisible on the map. You can only build outposts. Other interactions are not possible.
  • Royal Guard exploit - Have a bot hang out in a sector but be inside the sector map. This will prevent the royal guard from spawning. Additionally, the only way to respawn the royal guard is to build the outpost with an enemy unit.

@samrocketman
Copy link
Author

Screenshot of some settings examples using screenshot type.

screen shot 2016-04-06 at 8 51 32 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment