Esempio n. 1
0
def toggle_inventory():
    if utils.is_game_in_foreground() or config.debug:
        if GameState.screen == Screens.inventory:
            GameState.screen = Screens.play
            screenshot(time.perf_counter(), force_update=True)
        else:
            GameState.screen = Screens.inventory
Esempio n. 2
0
def cancel_ads():
    if utils.is_game_in_foreground() or config.debug:
        GameState.ads_active = False
        if GameState.active_weapon in [
                WeaponSlots.primary, WeaponSlots.secondary
        ]:
            enable_crosshair()
Esempio n. 3
0
def toggle_ads():
    if utils.is_game_in_foreground() or config.debug:
        if GameState.screen == Screens.play and GameState.active_weapon in [
                WeaponSlots.primary, WeaponSlots.secondary
        ]:
            GameState.ads_active = not GameState.ads_active
            if GameState.ads_active:
                disable_crosshair()
            else:
                enable_crosshair()
Esempio n. 4
0
def decrease_recoil():
    if utils.is_game_in_foreground() or config.debug:
        if GameState.active_weapon == WeaponSlots.primary:
            GameState.primary_gun = cycle_gun(GameState.primary_gun, -1)
        elif GameState.active_weapon == WeaponSlots.secondary:
            GameState.secondary_gun = cycle_gun(GameState.secondary_gun, -1)
Esempio n. 5
0
def set_weapon_other():
    if utils.is_game_in_foreground() or config.debug:
        GameState.active_weapon = WeaponSlots.other
        cancel_ads()
        disable_crosshair()
Esempio n. 6
0
def set_weapon_secondary():
    if utils.is_game_in_foreground() or config.debug:
        GameState.active_weapon = WeaponSlots.secondary
        cancel_ads()
        enable_crosshair()
Esempio n. 7
0
def toggle_map():
    if utils.is_game_in_foreground() or config.debug:
        if GameState.screen == Screens.map:
            GameState.screen = Screens.play
        else:
            GameState.screen = Screens.map
Esempio n. 8
0
def set_zoom(value: Zoom):
    if utils.is_game_in_foreground() or config.debug:
        if GameState.active_weapon == WeaponSlots.primary:
            GameState.primary_zoom = value
        elif GameState.active_weapon == WeaponSlots.secondary:
            GameState.secondary_zoom = value
Esempio n. 9
0
def toggle_script():
    if utils.is_game_in_foreground() or config.debug:
        ScriptState.active = not ScriptState.active
Esempio n. 10
0
def main_loop():
    while True:
        time.sleep(config.main_loop_sleep_time)

        ts = time.perf_counter()
        poll_keyboard(ts)
        poll_mouse(ts)
        screenshot(ts)

        update_ui()

        if not ScriptState.active or not utils.is_game_in_foreground():
            continue

        gun, zoom = get_active()
        multiplier = zoom.recoil_multiplier
        ts = time.perf_counter()

        if GameState.is_firing and GameState.fire_start_time is not None and GameState.active_weapon in [
                WeaponSlots.primary, WeaponSlots.secondary
        ]:
            dt = ts - GameState.fire_start_time
            if gun.type_ == GunTypes.single_fire:
                if ScriptState.single_fire_bullet_index * gun.time_between_shots < dt:
                    keyboard.press_and_release(GameKeys.fire)
                    ScriptState.single_fire_bullet_index += 1
            elif gun.type_ == GunTypes.full_auto and not ScriptState.fire_pressed:
                keyboard.press(GameKeys.fire)
                ScriptState.fire_pressed = True
            elif gun.type_ == GunTypes.bolt_action and not ScriptState.fire_pressed:
                keyboard.press(GameKeys.fire)
                ScriptState.fire_pressed = True

            x_moved, y_moved = ScriptState.recoil_compensated
            dx, dy = gun.get_mouse_move_amount(time_since_fire_start=dt,
                                               x_moved=x_moved,
                                               y_moved=y_moved,
                                               multiplier=multiplier)

            if config.enabled_anti_recoil and dt >= config.time_between_mouse_move:
                if dx != 0 or dy > 0:
                    utils.in_game_mouse_move(dx, dy)
                    ScriptState.recoil_compensated = x_moved + dx, y_moved + dy

            if gun.get_bullets_fired(dt) == min(config.bullet_limit,
                                                len(gun.vertical_recoil)):
                mouse.release('left')
                GameState.fire_start_time = None
                ScriptState.recoil_compensated = 0, 0
        elif GameState.is_firing and GameState.active_weapon == WeaponSlots.other:
            if not ScriptState.fire_pressed:
                keyboard.press(GameKeys.fire)
                ScriptState.fire_pressed = True
        else:
            if ScriptState.fire_pressed:
                keyboard.release(GameKeys.fire)
                ScriptState.fire_pressed = False
            if GameState.fire_start_time is not None:
                if config.enabled_anti_recoil and gun is not None:
                    last_vertical_recoil = gun.vertical_recoil[
                        ScriptState.single_fire_bullet_index]
                    readjust_amount = -int(last_vertical_recoil / 0.7)
                    utils.in_game_mouse_move(0, readjust_amount)
                GameState.fire_start_time = None
            ScriptState.recoil_compensated = 0, 0
            ScriptState.single_fire_bullet_index = 0