def attack_t2(state):
    if state['last_command'] != 'attack_t2':
        toggle('a')
        time.sleep(0.1)
        left_click(280, 1180)
        state['last_command'] = 'attack_t2'
        log_action(state)
def attack_ancient(state):
    if state['last_command'] != 'attack':
        state['last_command'] = 'attack'
        toggle('a')
        time.sleep(0.1)
        left_click(360,1100)
        log_action(state)
Example #3
0
def attack_ancient(state):
    if state['last_command'] != 'attack':
        state['last_command'] = 'attack'
        toggle('a')
        time.sleep(0.2)  # Previously 0.1
        # Weird minimap interactions causing camera view to change???
        left_click(360 * 1080 / 1440, 1100 * 1080 / 1440)
        log_action(state)
def stop(state):
    if state['last_command'] == 'retreat':
        move_to_ancient(state)
        time.sleep(0.1) # approx time to 180
    if state['last_command'] != 'stop':
        toggle('s')
        state['last_command'] = 'stop'
        center_camera_on_hero()
        log_action(state)
Example #5
0
def stop(state):
    # time_last_hit is a form of stop, so no need to repeat command
    if state['last_command'] == 'time_last_hit':
        state['last_command'] = 'stop'
        return
    if state['last_command'] == 'retreat':
        move_to_ancient(state)
        time.sleep(0.1)  # approx time to 180
    if state['last_command'] != 'stop':
        toggle('s')
        state['last_command'] = 'stop'
        center_camera_on_hero()
        log_action(state)
def long_iterate(state):
    rand = int(random.random()*10)
    if rand%10 == 0:
        if state['levels_in_e'] < 3:
            level_up('e')
            time.sleep(0.3)
        level_up('w')
        if state['levels_in_e'] >= 3:
            time.sleep(0.3)
            level_up('u')
    if rand%10 == 1:
        time.sleep(0.1)
        buy_item('phase boots')
        time.sleep(0.05)
        toggle('f3')
Example #7
0
def midgame_iterate(state, code_interact=False):
    state['counter'] += 1
    if state['last_command'] != 'time_last_hit':
        if state['counter'] % 8 == 0 or state['last_command'] == 'retreat':
            center_camera_on_hero()
            # time.sleep(0.2) # time it takes after command to center camera
    image = get_image()
    # if state['save_counter'] == 200:
    #     save_image(image, '100.png')
    # if state['counter'] % 20 = 0:
    # Below "A or B" means "A unless A == 0 then B instead"
    state['hero_damage'] = get_attack_dmg(image) or state['hero_damage']
    state['levels_in_e'] = 1  #get_levels_in_e(image)
    state['minimap_position'] = 'todo'  #get_minimap_position(image)
    at_t2_5 = False  #is_at_t2_5(image)
    update_dire_creeps(state, get_dire_creeps(image, middle_area))
    update_rad_creeps(state, get_radiant_creeps(image, middle_area))
    # if state['hero_damage'] > 100:
    #     show_image(image)
    #     save_image(image, 'error.png')
    #     code.interact(local=dict(globals(), **locals()))
    reposition(state, state['rad_creeps'], state['dire_creeps'], at_t2_5)
    gold = get_gold(image)
    if gold - state[
            'gold'] > 30:  #melee bounty 36-40, ranged 42-48, siege 66-80
        if state['lh_creeps_history'] != []:
            state['lh_creeps_history'][-1].last_hit_success = True
    state['gold'] = gold
    # low priority actions
    if state['last_command'] == 'attack':
        if state['gold'] > 820:
            buy_item('phase boots')
            time.sleep(0.05)
            toggle('f3')
    # if state['last_command'] == 'last_hit':
    #     save_image(image, "last_hit_%s.png" % state['counter'])
    if code_interact:
        code.interact(local=dict(globals(), **locals()))
def startup(state):
    '''run once at beginning of program
    to force application into desired state for iteration
    '''
    buy_item('animal courier')
    time.sleep(0.1)
    toggle('z')
    time.sleep(1)
    buy_item('blades of attack') #('boots of speed')
    time.sleep(0.1)
    level_up('e')
    time.sleep(0.1)
    # toggle('a')
    # left_click(96, 1358)
    # right_click(796, 758)
    # time.sleep(2)
    right_click(96, 1348)
    time.sleep(10)
    center_camera_on_hero()
    time.sleep(0.1)
    say_in_chat(['-startgame'])
    time.sleep(3)
    state['start_time'] = time.time()
def hold_position(state):
    '''note: not actually used'''
    toggle('h')
    state['last_command'] = 'hold'
    center_camera_on_hero()
    log_action(state)