from pynput.keyboard import Key, Controller
import time
SLEEP_BEFORE_START = 3
SLEEP_TIMES = {
'movement': 0.15,
'yes no': 0.2,
'regular spell': 0.6,
'altar change location': 8,
'teleport no location change' : 1.2,
'teleport change location': 6
}
SORCERER_POSITION = 5
CLERIC_POSITION = 4
SPELL_POSITION_SORCERER = {
'teleport' : 21,
'power shield' : 16,
}
SPELL_POSITION_CLERIC = {
'blessed': 14,
'holy bonus': 15,
'heroism': 17
}
keyboard = Controller()
def banal_click(to_press, time_sleep = SLEEP_TIMES['movement']):
keyboard.press(to_press)
keyboard.release(to_press)
time.sleep(time_sleep)
def move_forward(amount):
to_press = Key.up
for x in range(amount):
banal_click(to_press)
def spell(person=None, spell_number=-1, additional = (), post_wait = SLEEP_TIMES['regular spell']):
spell_button = 'c'
banal_click(spell_button)
if person:
to_press = Key.__getattr__(f'f{person}')
banal_click(to_press)
if spell_number >= 0:
banal_click('n')
for x in range(spell_number-10):
banal_click(Key.down)
if spell_number >= 10:
banal_click('0')
else:
banal_click(spell_number)
banal_click('s')
banal_click(spell_button)
for button in additional:
banal_click(button)
time.sleep(post_wait)
def turn_left():
banal_click(Key.left)
def turn_right():
banal_click(Key.right)
def yes():
banal_click('y', SLEEP_TIMES['yes no'])
def no():
banal_click('n', SLEEP_TIMES['yes no'])
def spell_buffing():
for spell_number in [SPELL_POSITION_CLERIC[_] for _ in ('blessed', 'holy bonus', 'heroism')]:
first_time = False
for key in [Key.f1, Key.f2]:
spell(person=CLERIC_POSITION, spell_number=-1 if first_time else spell_number, additional = (key,), post_wait=SLEEP_TIMES['regular spell']) #Spellcaster's Buffs (No protection from elements
first_time = True
time.sleep(1)
first_time = False
for key in [Key.__getattr__(f'f{_}') for _ in range(1, 7)]:
spell(person=SORCERER_POSITION, spell_number=-1 if first_time else SPELL_POSITION_SORCERER['power shield'], additional = (key,), post_wait=SLEEP_TIMES['regular spell']) #Spellcaster's Buffs (No protection from elements
first_time = True
def write(txt):
for _ in txt:
banal_click(_)
banal_click(Key.enter)
def to_the_well():
turn_right()
turn_right()
spell(SORCERER_POSITION, SPELL_POSITION_SORCERER['teleport'], ('4', Key.enter), SLEEP_TIMES['teleport no location change'])
turn_right()
spell(SORCERER_POSITION, additional = ('9', Key.enter), post_wait = SLEEP_TIMES['teleport change location'])
spell(SORCERER_POSITION, additional = ('5', Key.enter), post_wait = SLEEP_TIMES['teleport no location change'])
spell(SORCERER_POSITION, additional = ('9', Key.enter), post_wait = SLEEP_TIMES['teleport change location'])
spell(SORCERER_POSITION, additional = ('9', Key.enter), post_wait = SLEEP_TIMES['teleport no location change'])
turn_right()
yes()
yes()
yes()
def sequencer(*args):
for x in args:
if type(x) == int:
move_forward(x)
if x == 'l':
turn_left()
if x == 'r':
turn_right()
if type(x) == tuple and x[0] == 's':
spell(**x[1])
if type(x) == str and x[0] == 'y': #yes + amount of times to execute it
amount = 1
if len(x) > 0:
amount = int(x[1:])
for _ in range(amount):
yes()
if x == 'n':
no()
if x=='t': #turn around
turn_right()
turn_right()
def resistances_to_well():
sequencer('t', 1, 'l', 4, 'r', 1, 'y1')
time.sleep(1)
write('air')
time.sleep(SLEEP_TIMES['altar change location'])
to_the_well()
time.sleep(SLEEP_BEFORE_START)
# Start: face North, (14, 6) - Blistering Heights (location after Town Portal / Box use)
spell_buffing()
time.sleep(2)
sequencer(2, 'l', 3, 'y2', 4, 'n', 4, 'y2', 't', 4, 'n', 'l', 4, #Here - elemental resistances
'y2', 't', 4, 'n', 5, 'y2')
time.sleep(2)
resistances_to_well()