Addiction Automated

Spelunky576 views5 favorites4 min readby Brick SpelunkyUpdated Feb 19, 2024View on Steam ↗

Introduction

Having played Spleunky (HD) over 7 years ago, I've recently started playing it again on a new account (the one I'm using to write this guide).

Perhaps it was my experience with Spelunky 2, but Spelunky, once seemingly insurmountable, now felt surprisingly approachable. In under 100 runs, all achievements were ticked off — Full Journal, Low Scorer, Speedlunky, Big Money ... except one: Addicted. Never would have imagined that having to die a 1000 deaths anew, would exacerbate my itch for 100% Spelunky completion.

To prohibit "Addicted" from being that lonesome, yet formidable gatekeeper of "100%" ("Low Scorer" assumed that role for my initial 100% completion), I have written a couple of small scripts (AutoHotKey, and Python; take your pick) to automate the "End Adventure - Quick Restart" loop.

While the AutoHotKey route offers simplicity and ease of setup, the Pythonic way stands out as the overall better choice.

Happy Spelunky-ing! :)

AutoHotKey

To automate for the "Addicted" achievement using AutoHotKey, follow the instructions below.

Instructions
  1. Download AutoHotKey (v1.1)
  2. Save the script given below into a file ending with a '.ahk' extension (I named mine Addictlunky.ahk)
  3. Run the script (double-click the '.ahk' file created in the previous step)
  4. Launch Spelunky, and start the adventure mode in a non-paused state (e.g.: start at 1-1, with the level timer running)
  5. Press Ctrl + 0; and let AHK handle the grind, the addiction, and the toil.
  6. Press F4 when/if you want to stop the script.

Note
Ensure you have AutoHotKey v1.1 installed, as v2 cannot run the following script.
Script
^0:: Loop, 1000 { Send, {Esc down} Sleep, 10 Send, {Esc up} Sleep, 50 Send, {Down down} Sleep, 10 Send, {Down up} Sleep, 50 Send, {Enter down} Sleep, 10 Send, {Enter up} Sleep, 10 Send, {Enter down} Sleep, 10 Send, {Enter up} Sleep, 4000 Send, {x down} Sleep, 10 Send, {x up} Sleep, 10 Send, {x down} Sleep, 10 Send, {x up} Sleep, 2000 } F4::ExitApp

Python

If Python is more your jam, high five!

Details and instructions for working with this script, are directly included in the script given below. Also included below, is a video demonstrating the usage of this script.

Script
''' Addictlunky is a Python script that automates the process of dying, and restarting the game, in Spelunky, to increase the death counter. This either can be used to unlock the "Addicted" achievement, or to increase the probability of the four random coffins' generation in the four different areas of the game. To use the script, follow these steps: 1. Make sure you have Python 3 installed. 2. Install the pydirectinput and pynput libraries using pip: pip install pydirectinput pynput 3. Open Spelunky. - The game should either be on the "Game Over" screen, or in the middle of a run, with the level timer running. - The game should have keyboard input enabled. 4. Run the script using Python: python addictlunky.py 5. You have 3 seconds to switch focus back to the game window. - You can change this by modifying the PAUSE_SECONDS value below. 6. The script will run until the desired number of deaths is reached. - You can change this by modifying the DEATH_LOOPS value below. 7. Press F4 to stop the script at any time. ''' # Configuration PAUSE_SECONDS = 3 DEATH_LOOPS = 1000 import time import pydirectinput from pynput import keyboard class Addictlunky: def __init__(self, death_loops, avg_seconds_per_loop=7.51): self.death_loops = death_loops self.avg_seconds_per_loop = avg_seconds_per_loop self.session_loops = 0 self.start_time = 0 self.end_time = 0 self.time_elapsed = 0 self.running = True self.listener = keyboard.Listener(on_release=self.on_release) self.listener.start() def on_release(self, key): if key == keyboard.Key.f4: print("Addictlunky has been stopped by the user!") self.stop() def estimate(self): total_loops_remaining = self.death_loops - self.session_loops total_estimated_time = self.avg_seconds_per_loop * total_loops_remaining print("") print(f" TOTAL LOOPS REMAINING: {total_loops_remaining}") print( f"ESTIMATED COMPLETION IN: { total_estimated_time / 3600:.2f } hours | { total_estimated_time / 60:.2f } minutes | { total_estimated_time:.2f } seconds" ) print("") def stop(self): if not self.running: return False self.running = False self.end_time = time.time() self.time_elapsed = self.end_time - self.start_time print(f"\nAddictlunky has stopped!\n") print( f"TIME ELAPSED: { self.time_elapsed / 3600:.2f } hours | { self.time_elapsed / 60:.2f } minutes | { self.time_elapsed:.2f } seconds" ) return False def run_pause_timer(self, seconds=PAUSE_SECONDS, init=True): status_string = "Starting" if init else "Resuming" print(f"\n{status_string} Addictlunky in {seconds} seconds...\n") for i in range(seconds): print(f"{seconds - i}...") time.sleep(1) print("\nAddictlunky is active!\n") def run_death_loop(self): if (self.session_loops % 10 == 0): self.estimate() pydirectinput.press("x") # Quick Restart (Game Over screen) / Whip (in-game) time.sleep(2) pydirectinput.press("esc") # Pause · Options pydirectinput.press("down") # Select · End Adventure pydirectinput.press("enter") # Choose · End Adventure pydirectinput.press("enter") # Confirm · End Adventure time.sleep(2) self.session_loops += 1 print(f"{self.session_loops} out of {self.death_loops} loops done...") time.sleep(2) def start(self): self.run_pause_timer() self.start_time = time.time() for i in range(self.death_loops): if not self.running: break self.run_death_loop() self.stop() addictlunky = Addictlunky(death_loops=DEATH_LOOPS) addictlunky.start()

This guide was created by its original author on the Steam Community. Are you the author and want it removed? Request removal.