def warp(self, distance=0.0): bm = _bm.get_bookmark(self.name, 'Places') point = None if bm: point = BmPlace(bm.bookmarkID, bm.memo.strip(), (bm.x, bm.y, bm.z), bm) if point and not point.is_achived(): bot.log.info('Варпаем на закладку {}'.format(self.name), bot.macros.role) do_action(3 + rnd_keys()) movementFunctions.WarpToBookmark(bm, distance) elif not self.is_achived(): bot.log.info('Варпаем к {}'.format(self.name), bot.macros.role) do_action(3 + rnd_keys()) if self.type == 'anomaly': sm.GetService('menu').WarpToScanResult(self.id, distance) else: movementFunctions.WarpToItem(self.id, distance) else: bot.log.info('Место назначения достигнуто: {}'.format(self.name), bot.macros.role)
def update_jet_list(self, inside=False): if self.in_update or session.stationid or not self._up_jet: return self.in_update = True query = 'SELECT * FROM miner_jet ORDER BY jettison' jets = db_select(query) if jets == 'error': self.in_update = False return self.jets = [] for jet in jets: if jet: self.jets.append({ 'jet_id': int(jet[1]), 'place_id': int(jet[2]), 'owner_id': int(jet[3]), 'volume': float(jet[4]), 'date': jet[5] }) self.in_update = False if inside: place = self.get_place_by_bm(_bm.get_bookmark('POS')) if self.collect_is_ready() and place and place.is_achived(): self.run_action()
def __init__(self): self.actions = { 'distrib': { 'co': [lambda: self.check_empty_flags()], 'po': lambda: self.get_place_by_bm(_bm.get_bookmark('InPOS')), 'go': self.go, 'do': self.distrib, 'tm': None, 'iv': 500, } } self.in_do_flag = False self.ignoreRejumps = True self.enemyOutTime = dt.now() - datetime.timedelta(minutes=1) self.inPos = self.get_place_by_bm(_bm.get_bookmark('InPOS')) self.outPos = self.get_place_by_bm(_bm.get_bookmark('OutPOS')) self.point = None # Где находимся self.dest = None # Куда двигаться # Количество нейтралов в гриде self.enemy_in_grid = 0 Space.__init__(self, 'bonus') self.actions['wait']['co'].append(lambda: False) self.actions['hide']['co'].append(lambda: False) if self.grid_is_safety(): self.dest = self.outPos.id else: self.dest = self.inPos.id self.is_ready = True self.info('Макрос запущен', self.role) # if self.get_min_safety_level() <= 0: # self.add_flag('enemy_in_local') self.run_action()
def init(self): pos = self.get_place_by_bm(_bm.get_bookmark('POS')) if pos and pos.is_achived(): ship = sm.GetService('godma').GetItem(session.shipid) # Если текущий корабль не яхта, пересаживаемся if ship and ship.typeID != 34590: yacht = self.get_yacht_ship() stackless.tasklet(self.protect_mod_off)() pause(3000) if yacht: if yacht.surfaceDist > 6000: do_action(2 + rnd_keys()) sm.GetService('menu').Approach(yacht.id) while yacht.surfaceDist > 6000: pause(200) do_action(2 + rnd_keys()) self.info('Пересаживаемся на яхту', self.role) sm.GetService('menu').Board(yacht.id) else: self.warn('Яхта под полем не обнаружена', self.role) return self.update_exp() if self.exp and self.exp['status'] == 0: self.set_exp_status(1) _bm.del_bookmark('RetPlace') _bm.set_bookmark('RetPlace') self.del_flag('init') self.do_pass() self.run_action()
def __init__(self, _role=None): actions = { 'init': { 'co': [ lambda: self.check_in_flags('init'), lambda: not self.check_enemy_in_local() ], 'do': self.init_places, 'pr': 40 }, 'downtime': { 'co': [lambda: self.check_in_flags('downtime')], 'po': lambda: self.get_place_by_bm(_bm.get_bookmark('POS')), 'go': self.go, 'do': self.downtime, 'pr': 100 }, 'buble': { 'co': [lambda: self.check_in_flags('buble')], 'do': self.buble_out, 'tm': None, 'iv': 200, 'pr': 200 } } self.actions = dict(actions, **self.actions) # Настройки действий Mine.add_notify(Mine) Space.__init__(self, _role) notepad = _note.get_notepad() # Если в блокноте нет папки Places, создаем if not notepad.AlreadyExists('F', 'Places'): notepad.AddNote(0, 'F', 'Places') self.in_init_place_flag = False self.busy_jets = {} self.busy_owner = {}
def __init__(self, _run=True): self.actions = { 'collect': { 'co': [ lambda: self.collect_is_ready(), lambda: not self.check_enemy_in_local(), lambda: not self.check_in_flags('topos') ], 'po': lambda: self.get_jet_place(self.get_jet()), 'go': self.go, 'do': self.collect, 'tm': None, 'iv': 1000, 'ed': self.end_collect, 'pr': -100 }, 'zip': { 'co': [lambda: self.check_in_flags('zip')], 'po': lambda: self.get_place_by_bm(_bm.get_bookmark('ZIP')), 'go': self.go, 'do': self.ziping }, 'unload': { 'co': [lambda: self.check_in_flags('unload')], 'po': self.get_unload_place, 'go': self.go, 'do': self.unload }, 'wait_jet': { 'co': [lambda: not self.collect_is_ready()], 'po': lambda: self.get_place_by_bm(_bm.get_bookmark('POS')), 'go': self.go, 'do': self.wait, 'pr': -50 } } bot.log.info('Запускаем макрос') Mine.__init__(self, 'collector') # Настройки self.homeID = int(self.s.ga('HomeID', 0)) self.unloadToPOS = bool(self.s.ga('UnloadToPOS', True)) self.arrayName = self.s.ga('ArrayName', '') self.divName = self.s.ga('DivName', '') self.isZipping = bool(self.s.ga('IsZiping', False)) self.unloadVolume = int(self.s.ga('UnloadVolume', 0)) self.in_do_flag = False self.in_update = False self._up_jet = None self.npc = {} self.jets = [] self.is_ready = True self.info('Макрос запущен', self.role) if session.stationid: self.repair_ship() self.OnDownTime() self.add_flag('init') pause(1000) if not self.check_in_flags('downtime'): self.update_jet_list() self.clear_old_jets() self._up_jet = base.AutoTimer(30000, self.update_jet_list, True) self.run_action() set_bot_params('role', self.role)
def get_unload_place(self): if self.unloadToPOS: return self.get_place_by_bm(_bm.get_bookmark('POS')) else: return self.get_home()
def work(self): if self.in_work_flag or self.in_fly or self.do_fly: return self.in_work_flag = True if self.exp and self.exp['status'] != 4: if self.exp['status'] == 1: # 10ка еще не забукана # Система с 10кой еще не достигнута if session.solarsystemid != self.exp['system_id']: self.info('Устанавливаем маршрут до 10ки', self.role) self.set_route(self.exp['system_id']) self.add_flag('fly') self.run_action() # Находимся в системе с 10кой else: journal = sm.GetService('journal') exp_id = self.exp['exp_id'] gate = self.get_exp_gate() if exp_id in journal.pathPlexPositionByInstanceID: resp = journal.pathPlexPositionByInstanceID[exp_id] else: resp = sm.RemoteSvc('keeper').CanWarpToPathPlex(exp_id) # Варпаем на врата ускорения if resp is True: self.info('Варпаем на врата ускорения', self.role) self.warp_to_exp() # Если врата в гриде делаем закладку elif gate: self.info('Создаем закладку на 10ку', self.role) self.make_exp_bm(gate) self.set_exp_status(2) self.set_sta_system() bp = sm.GetService('michelle').GetBallpark() if bp: ball = bp.GetBallById(gate.itemID) if ball: mwd = self.get_modules(const.groupAfterBurner) if mwd: stackless.tasklet(self.modules_on)(mwd) do_action(3 + rnd_keys()) movementFunctions.KeepAtRange(gate.itemID, 10000) pause(500) if mwd: stackless.tasklet(self.modules_off)(mwd) while ball.surfaceDist < 5000 and self.check_in_flags('break'): pause(100) self.run_action() elif self.exp['status'] == 2: # 10ка забукана if session.stationid: hangar = invCtrl.StationItems() bms = _bm.get_bookmarks('10/10', True) bmIDs = [x.bookmarkID for x in bms if x.locationID == self.exp['system_id']] if bmIDs: self.info('Переносим буку на станку', self.role) do_action(3 + rnd_keys()) hangar.AddBookmarks(bmIDs) self.set_exp_status(3) self.run_action() elif self.exp['sta_system'] != session.solarsystemid: self.info('Устанавливаем маршрут до станки', self.role) self.set_route(self.exp['sta_system']) self.add_flag('fly') self.run_action() else: sta = self.get_station() if sta: if sta.surfaceDist() > const.minWarpDistance: self.wait_cooldown() self.info('Варпаем к станке', self.role) sta.warp() self.wait_gate_cloak() self.covert_cloak_on() else: self.info('Докаемся', self.role) self.go(sta) elif self.exp['status'] == 3: # 10ка оставлена на ближайшей станке self.info('Создаем контракт на буку', self.role) pause(5000) if session.stationid: if self.create_contract(): self.info('Контракт создан', self.role) self.set_exp_status(4) self.run_action() else: self.warn('Не удалось создать контракт', self.role) else: ret_place = _bm.get_bookmark('RetPlace', ignoreLocation=True) if ret_place: if session.solarsystemid2 != ret_place.locationID: self.info('Устанавливаем маршрут до дома', self.role) self.set_route(ret_place.locationID) self.add_flag('fly') self.run_action() else: place = self.get_place_by_bm(ret_place) if place.surfaceDist() > const.minWarpDistance: self.wait_cooldown() self.info('Варпаем на ПОС', self.role) place.warp() self.wait_gate_cloak() self.covert_cloak_on() elif place.is_achived(): _bm.del_bookmark('RetPlace') ship = self.get_old_ship() if ship: if ship.surfaceDist > 6000: do_action(3 + rnd_keys()) sm.GetService('menu').Approach(ship.id) while ship.surfaceDist > 6000: pause(200) self.info('Пересаживаемся на крабский корабль', self.role) do_action(3 + rnd_keys()) sm.GetService('menu').Board(ship.id) self.set_yacht_free() # bot.change_args = {} self.warn('Работа с 10ками звершена', self.role) bot.change_role('crub') else: self.warn('Корабль угнан или занят', self.role) ship = sm.StartService('gameui').GetShipAccess() if ship: log.LogNotice('Ejecting from ship', session.shipid) sm.ScatterEvent('OnBeforeActiveShipChanged', None, util.GetActiveShip()) sm.StartService('sessionMgr').PerformSessionChange('eject', ship.Eject) self.set_yacht_free() sm.ScatterEvent('OnScriptBreak') else: self.go(place) self.in_work_flag = False