def fireOnce(): print '--> establishing hatred' key.pressEx(sc.HeightSlot1) time.sleep(1) key.pressEx(sc.HeightSlot1) print '<-- establishing hatred\n' return True
def closeInventory(): print '--> close inventory' key.pressEx(sc.Inventory) time.sleep(1) print '<-- close inventory\n' return True
def enableDefense(): print '--> enable defense' # key.pressEx(sc.LowSlot1) # key.pressEx(sc.LowSlot2) # key.pressEx(sc.LowSlot3) key.pressEx(sc.AllLow) print '<-- enable defense\n' return True
def enterStarMap(): print '--> enter star map' key.pressEx(sc.Map) begin = time.time() while findAtProgressBar('initializing_map') or time.time() - begin < 3: time.sleep(0.5) mouse.moveToP(panel.center(panel.Full)) mouse.wheel(100) print '<-- enter star map\n'
def openInventory(): print '--> open inventory' key.pressEx(sc.Inventory) mouse.moveToP(panel.center(panel.Inventory)) while not findAtInventory('x'): time.sleep(0.2) print '<-- open inventory\n' return True
def engage(): print '--> drones engaging\n' key.pressEx(sc.DronesEngage) while not findAtDrones('fighting'): key.pressEx(sc.DronesEngage) time.sleep(0.5) print '<-- drones engaging\n' return True
def handleDangerousAction(): result = findAtFull('dangerous') if result: mouse.moveToP(result) result = None while not result: result = findAtFull('x') mouse.leftClickAtP(result) key.pressEx(sc.Unlock) return True else: return False
def approachFor(second): print '--> approaching target' key.pressEx(sc.Approach) while second > 0: time.sleep(1) second -= 1 if second % 5 == 0: print str(second) + "second's left" print '<-- approaching target\n' return True
def repair(): print '--> repair' result = findAtStationServices('repair_shop') if not result: return mouse.leftClickAtP(result) print 'wait until open repair facilities' result = None while not result: result = findAtFull('repair_facilities') time.sleep(0.5) time.sleep(0.5) mouse.leftClickAt(result[0], result[1] + 70) key.pressEx('ctrl+a') result = None while not result: result = findAtFull('repair_item') time.sleep(0.2) mouse.leftClickAtP(result) print 'wait...' while not findAtFull('pick_new_item'): time.sleep(0.2) result = findAtFull('repair_all') if result: mouse.leftClickAtP(result) print 'repairing...' result = None while not result: time.sleep(0.2) result = findAtFull('ok') if not result: result = findAtFull('yes') mouse.leftClickAtP(result) result = findAtFull('repair_facilities') mouse.moveToP(result) else: print 'nothing to repair' result = None while not result: time.sleep(0.2) result = findAtFull('x') mouse.leftClickAtP(result) print '<-- repair\n' return True
def lockEnemy(wait = 5): print '--> lock enemy' result = findEnemy() if not result: return False mouse.leftClickAtP(result) key.pressEx(sc.Lock) print 'wait for ' + str(wait) + ' seconds' time.sleep(wait) print '<-- lock enemy' return True
def lockTarget(target, wait = 5): result = findTarget(target) if not result: return False print '--> lock target "' + target + '"' mouse.leftClickAtP(result) key.pressEx(sc.Lock) print 'wait for ' + str(wait) + ' seconds' time.sleep(wait) print '<-- lock target "' + target + '"\n' return True
def activateAccelerationGate(): switchTo('pilot') general.enterStarMap() print '--> activate acceleration gate\n' mouse.leftDownAtP(panel.center(panel.Full)) mouse.move(500, 200) mouse.leftUp() result = findTarget('acceleration_gate') if not result: return False mouse.leftClickAtP(result) key.pressEx(sc.Activate) print 'wait to activate gate' while not findAtDashboard('warp_drive_active'): result = findAtFull('close') if not result: result = findAtFull('ok') if result: mouse.leftClickAtP(result) mouse.moveTo(result[0], result[1] - 200) handleDangerousAction(); key.pressEx(sc.Activate) time.sleep(1) print 'wait until reach location' while findAtDashboard('warp_drive_active'): time.sleep(0.5) result = findAtFull('close') if not result: result = findAtFull('ok') if result: mouse.leftClickAtP(result) mouse.moveTo(result[0], result[1] - 200) time.sleep(1) while findAtDashboard('warp_drive_active'): time.sleep(0.5) print '<-- activate acceleration gate\n' general.exitStarMap() return True
def back(): print '--> drones return' key.pressEx(sc.DronesReturn) mouse.moveToP(panel.center(panel.Drones)) mouse.wheel(-100) mouse.moveToP(panel.center(panel.Full)) print 'wait until drones return' while findAtDrones('returning') or findAtDrones('fighting') or findAtDrones('idle'): key.pressEx(sc.DronesReturn) time.sleep(0.2) print '<-- drones return\n' return True
def activateShip(ship): print '--> activate ship "' + ship + '"' key.pressEx(sc.ShipHangar) time.sleep(3) result = None while not result: time.sleep(0.5) result = findAtInventory(ship) mouse.rightClickAtP(result) mouse.moveTo(result[0] + 200, result[1]) result = findAtInventory('make_active') if result: mouse.leftClickAtP(result) key.pressEx(sc.ShipHangar) time.sleep(2) print '<-- activate ship "' + ship + '"\n' return True
def autopilot(): print '--> autopilot' overview.switchTo('pilot') while True: print 'try to find target stargate or station' finded = '' result = None for retry in range(3): print 'try: ' + str(retry + 1) result = findAtOverview('target_station', 0.2) if result: print 'station finded' finded = 'station' break result = findAtOverview('target_star_gate', 0.2) if result: print 'stargate finded' finded = 'gate' break x, y = panel.center(panel.Overview) y += random.random() * 200 - 100 mouse.leftClickAt(x, y) mouse.wheel(-12) mouse.moveToP(panel.center(panel.Full)) if finded == '': print "can't find any waypoint" print '<-- autopilot\n' return False if finded == 'station': print 'docking...' mouse.leftClickAtP(result) key.pressEx(sc.Activate) print 'wait until entering station' begin = time.time() result = findAtProgressBar('entering_station', 0.1) while not result and time.time() - begin < 80: result = findAtProgressBar('entering_station', 0.1) time.sleep(0.1) if result: print 'entering station' time.sleep(4) print '<-- autopilot\n' return True if finded == 'gate': print 'jump...' mouse.leftClickAtP(result) key.pressEx(sc.Activate) print 'wait until entering space' begin = time.time() result = findAtProgressBar('entering_space', 0.1) while not result and time.time() - begin < 80: result = findAtProgressBar('entering_space', 0.1) time.sleep(0.1) if result: print 'entering space' time.sleep(3)
def mine(): print '--> mine' key.pressEx(sc.HeightSlot2) key.pressEx(sc.HeightSlot3) print '<-- mine\n' return True
def stop(): print '--> ship stop' key.pressEx(sc.Stop) print '<-- ship stop\n' return True
def approach(): print '--> approaching target' key.pressEx(sc.Approach) print '<-- approaching target\n' return True
def enableAfterburn(): print '--> enable afterburn' key.pressEx(sc.MiddleSlot1) print '<-- enable afterburn\n' return True
def exitStarMap(): print '--> exit star map' key.pressEx(sc.Map) time.sleep(2) print '<-- exit star map\n'
def run(): print '--> mission Intercept The Sabateurs' if not ship.enableDefense(): return False if not drones.launchSmall(): return False overview.seekAndDestory() if not drones.back(): return False ship.enableAfterburn() if not overview.activateAccelerationGate(): return False # pocket 1 # main enemies are 90km away # approach for 85 secs # mean while clean up nearby enemy drones.launchSmall() if not overview.switchTo('battle'): return False if not overview.lockEnemy(20): return False ship.fireOnce() if not overview.lockTarget('transport', 1): return False ship.enableAfterburn() ship.approachFor(85) # wait for stop begin = time.time() while time.time() - begin < 20: ship.stop() key.pressEx(sc.Unlock) mouse.moveToP(panel.center(panel.Drones)) mouse.wheel(-100) while findAtDrones('fighting'): time.sleep(10) drones.back() # use sentry to destory all the smalls for i in range(6): overview.lockTarget('s', 1) drones.launchSentry() begin = time.time() while overview.lockTarget('s', 1) and time.time() - begin < 130: ship.fireOnce() drones.engage() drones.back() # do the rest ship.fireOnce() drones.launchSmall() overview.seekAndDestory() while not overview.pickCargo(): pass drones.back() print '<-- mission Intercept The Sabateurs\n' return True