def bleed(line, time, backrefs): if core.is_paused() \ or core.aeon_mode: return bleed = int(backrefs[0]) if bleed >= player.max_health: return global clotting, clot_num if player.afflictions['haemophilia'] or \ player.afflictions['aeon'] or \ player.afflictions['sleep'] or \ player.stunned: return clots = (bleed - 61) / 20 mana_cost = clots * 60 h = player.health_percentage / 100.0 m = (player.mana - mana_cost) / float(player.max_mana) d = (bleed / float(player.max_health)) * 5 clot_factor = 1 / (1 + exp((-(m * 2.5) + (h / 2.0) + 1) * (5 - d))) num_clots = round(clot_factor * clots) if num_clots > 0: clotting = True clot_num = num_clots - 1 core.enable_trigger('clot_tick', 'general_afflictions') core.enable_trigger('no_clot', 'general_afflictions') core.write('clot', int(num_clots))
def stun(line, time, backrefs): if core.is_paused(): return if player.stunned is False: player.stun_ticks = 0 core.enable_trigger('cures_stun', 'cures') core.enable_trigger('cures_unconciousness', 'cures') core.enable_trigger('ai_stun_check', 'anti-illusion') player.stunned = True player.stun_ticks += 1 player.stun_time = time if player.stun_ticks < 3: if core.aeon_mode == False: core.write('touch stun') core.debug("stunned") # should probably add more balance resets here if player.focus_balance == .5: player.focus_balance = 1 if player.herb_balance == .5: player.herb_balance = 1 if player.salve_balance == .5: player.salve_balance = 1 if player.hmsip_balance == .5: player.hmsip_balance = 1 player.waiting_for_aeon = 0
def hmsip_event(now): if player.afflictions['sleep'] or player.afflictions['anorexia'] or player.afflictions['amnesia'] or player.stunned: return if now - player.hmsip_lastfire > (6 + player.latency): player.hmsip_balance = 1 # flush queues queues.hmsip_queue.empty() health = player.health_percentage mana = player.mana_percentage # Determine which sip gets priority over the other priority = sip_priority(health, mana) if health <= core.config['health_sip_percentage']: if priority is 'health': queues.hmsip_queue.add('sip_health', 'sip health', 10) else: queues.hmsip_queue.add('sip_health', 'sip health', 5) if mana <= core.config['mana_sip_percentage']: if priority is 'mana': queues.hmsip_queue.add('sip_mana', 'sip mana', 10) else: queues.hmsip_queue.add('sip_mana', 'sip mana', 5) if player.hmsip_balance == 1 and queues.hmsip_queue.is_empty() is False: core.enable_trigger('cure_enablers_health', 'cure_enablers') core.enable_trigger('cure_enablers_mana', 'cure_enablers') core.write(queues.hmsip_queue.fire()) player.hmsip_balance = .5 player.hmsip_lastfire = now elif player.hmsip_balance == .5: if now - player.hmsip_lastfire > 2: player.hmsip_balance = 1 # Lestagii healing if core.config['eat_lestagii']: if player.lestagii_balance == 1 and core.is_paused() is False: if health <= player.lestagii_health_percentage: core.enable_trigger('cure_enablers_lestagii', 'cure_enablers') herbs.lestagii.eat() player.lestagii_balance = .5 player.lestagii_lastfire = now elif mana <= player.lestagii_mana_percentage: core.enable_trigger('cure_enablers_lestagii', 'cure_enablers') herbs.lestagii.eat() player.lestagii_balance = .5 player.lestagii_lastfire = now else: if now - player.lestagii_lastfire > 7: player.lestagii_balance = 1
def preempt_clot(line, time, backrefs): global auto_clotting if core.is_paused() \ or core.aeon_mode: return if player.mana_percentage > 55 and player.afflictions['haemophilia'] is False and player.afflictions['aeon'] is False: core.enable_trigger('clot_tick', 'general_afflictions') core.enable_trigger('no_clot', 'general_afflictions') auto_clotting = True core.write('clot')
def aeon_tick(line, time, backrefs): player.waiting_for_aeon = 1 player.afflictions['amnesia'] = False if player.afflictions['concussion'] \ and aeon_cures.conc_curing is not False \ and core.is_paused() is False: if aeon_cures.conc_cure_enabled == False: aeon_cures.conc_cure_enabled = True core.call_later(0.65, aeon_cures.conc_cure) if core.retardation_mode: core.line = ansi.color['lwhite'] + core.line + ansi.color['default']
def clot_tick(line, time, backrefs): global clot_num, clotting if core.is_paused() \ or core.aeon_mode: return if auto_clotting: if player.mana_percentage > 55 and player.afflictions['haemophilia'] is False and player.afflictions['aeon'] is False: core.write('clot') elif clotting: if clot_num > 0: core.write('clot') clot_num -= 1 else: clotting = False clot_num = 0
def run_events(now = None): if now == None: now = time.time() lag_delay = player.latency if core.is_paused() == False: hooks.prompt_events.run() events.stun_event(now) events.keepup_event(now) if core.aeon_mode: aeon_cures.aeon_event(now) return if now - player.wake_lastfire > lag_delay: events.sleep_event(now) if now - queues.immediate_queue.lastfire > lag_delay: events.immediate_event() if now - player.kelventari_event_last > lag_delay: events.kelventari_event(now) if now - player.focus_lastfire > lag_delay: events.focus_event(now) if now - player.tree_lastfire > lag_delay: events.tree_event(now) events.pipe_event(now) if now - queues.smoke_queue.lastfire > lag_delay: events.smoke_event(now) if now - queues.free_queue.lastfire > lag_delay: events.free_event(now) if now - queues.hmsip_queue.lastfire > lag_delay: events.hmsip_event(now) if now - queues.action_queue.lastfire > lag_delay: events.action_event() if now - queues.balance_queue.lastfire > lag_delay: events.balance_event() if now - queues.equilibrium_queue.lastfire > lag_delay: events.equilibrium_event() events.deaf_event(now) if now - queues.herb_queue.lastfire > lag_delay: events.herb_event(now) if now - queues.asip_queue.lastfire > lag_delay: events.asip_event(now) if now - queues.salve_queue.lastfire > lag_delay: events.salve_event(now) if now - queues.writhe_queue.lastfire > lag_delay: events.writhe_event(now) events.inv_event()
def affliction_event(now): """Prompt-fired event that loads queues for curing.""" global ai, focus_unknown player.fire_tree = False flush_aff_from_queues() process_pre_afflictions(now) process_dynamic_priorities() if player.afflictions['blackout'] == False: core.disable_trigger_group('venoms') core.disable_trigger_group('evileye') core.disable_trigger('failure_apply_slickness', 'failures') disable_restro_break_triggers() if player.afflictions['amnesia'] \ and player.afflictions['aeon'] is False \ and player.afflictions['sleep'] is False \ and core.is_paused() is False \ and player.stunned is False \ and now - player.last_amnesia > player.latency: if player.herb_balance == .5: player.herb_balance = 1 if player.salve_balance == .5: player.salve_balance = 1 if player.focus_balance == .5: player.focus_balance = 1 if player.hmsip_balance == .5: player.hmsip_balance = 1 if player.asip_balance == .5: player.asip_balance = 1 if player.writhe_balance == .5: player.writhe_balance = 1 if player.moss_balance == .5: player.moss_balance = 1 core.enable_trigger('cures_amnesia', 'cures') core.write("touch amnesia\ntouch amnesia\n") player.last_amnesia = now return # Load cures if player.afflictions['aeon'] \ and core.retardation_mode == False \ and 'aeon' not in player.ignored_afflictions: core.aeon_mode = True aeon_cures.load_queue() flush_queues() core.disable_trigger('symptoms_aeon', 'symptoms') core.enable_trigger('cures_aeon', 'cures') player.waiting_for_aeon = 0 if core.paused == False: input.lock = True core.alert("AEON! Input is locked down! " + ansi.color['lcyan'] + "BREAK" + ansi.color['default'] + " out to allow input again.") return # Use Tree to catch up on limb breaks if num_broken_limbs() >= 2: if num_lvl1_breaks() >= 1 and player.salve_balance == 0: player.fire_tree = True focus_engaged = False for aff in player.afflictions: if player.afflictions[aff] is True: if aff in player.ignored_afflictions: continue symptoms.symptoms[aff].reset() focus = False cure = cures[aff] priority = 0 if cure[0] == 'ignore': priority = 0 else: priority = cure[len(cure)-1:][0] if aff in temporary_priorities.keys(): priority = temporary_priorities[aff] if aff == 'sleep': player.afflictions['prone'] = True player.defences['insomnia'] = 0 #if aff == 'shivering' or aff == 'frozen': #player.afflictions['disruption'] = True elif aff == 'impale': player.afflictions['prone'] = True if aff == 'impatience': if core.config['focus_on_impatience_mana_threshold'] != 0 \ and core.config['focus_on_impatience_mana_threshold'] < player.mana_percentage \ and player.ableto_focus \ and player.allow_focus \ and player.fire_focus == False \ and player.proximity_to_vlock() > 3: focus_unknown = True player.focus_on_impatience = True continue # If affliction is focusable, we trigger focus and hold off loading a cure for it until next prompt if aff in focusable and player.afflictions['impatience'] is False: if player.ableto_focus \ and player.allow_focus: use_focus = True # Focus special handling if aff == 'anorexia': if salve_queue.length() == 0 \ and player.afflictions['slickness'] is False \ and player.salve_balance == 1: use_focus = False if use_focus: if player.focus_balance == 1 and player.fire_focus is False: player.fire_focus = True focus = True focus_engaged = True elif player.focus_balance == 1 and player.fire_focus is True: # it didn't fire? focus = True focus_engaged = True elif player.focus_balance == .5 and player.fire_focus is True: # another misfire? #player.focus_balance = 1 focus = True focus_engaged = True if focus is False: load_cure = True if cure[0] == 'salve': for x in range(cure[3]): salve_queue.add(aff, cure[1] + ' to ' + cure[2], priority) elif cure[0] == 'limb': limb_affliction(aff) elif cure[0] == 'herb': herb_queue.add(aff, cure[1], priority) elif cure[0] == 'smoke': # Fight against pufflock if player.can_outr() is False \ and player.afflictions['slickness'] \ and player.valerian_puffs == 0: herb_queue.add('slickness', 'bloodroot', 990) smoke_queue.add(aff, cure[1], priority) elif cure[0] == 'action': action_queue.add(aff, cure[1], priority) elif cure[0] == 'balance': balance_queue.add(aff, cure[1], priority) elif cure[0] == 'asip': asip_queue.add(aff, cure[1], priority) elif cure[0] == 'free': free_queue.add(aff, cure[1], priority) elif cure[0] == 'equilibrium': equilibrium_queue.add(aff, cure[1], priority) elif cure[0] == 'immediate': if aff == 'disruption': if player.equilibrium is True: load_cure = False player.afflictions['disruption'] = False if load_cure: immediate_queue.add(aff, cure[1], priority) elif cure[0] == 'writhe': writhe_queue.add(aff, 'writhe', priority) else: # If the aff is False, make sure it's not in any queues flush_queues(aff) if len(lusted) > 0 and 'lust' not in player.ignored_afflictions: core.enable_trigger('cures_lust', 'cures') for person in lusted: action_queue.add('lust', 'reject ' + person, 693) if len(emperor) > 0 and 'emperor' not in player.ignored_afflictions: core.enable_trigger('cures_emperor', 'cures') for person in emperor: action_queue.add('emperor', 'lose ' + person, 392) if focus_unknown is True: player.fire_focus = True focus_engaged = True focus_unknown = False elif focus_engaged == False: player.fire_focus = False # Disable all cure triggers disable_cure_triggers()
def aeon_event(now): global aeon_currently_curing, next_cure, rr_auto if core.is_paused() is True: return if aeon_queue.is_empty(): next_cure = "" rr_auto = False return if player.waiting_for_aeon == 1 and player.afflictions['amnesia'] is True: player.waiting_for_aeon = 0 if player.waiting_for_aeon == 1: # if something more important becomes apparent, we force that instead of waiting if aeon_queue.get_index(aeon_currently_curing) != 0: # reset what we're curing here player.waiting_for_aeon = 0 if player.waiting_for_aeon == .5 and now - player.waiting_for_aeon_last > (1 + player.latency): player.waiting_for_aeon = 0 if player.waiting_for_aeon == 0 \ or now - player.waiting_for_aeon_last > 2 \ or (core.retardation_mode and rr_auto == False): action = aeon_queue.fire() affliction = aeon_queue.actions[0][1] if action[0] == 'writhe': writhe(now) elif action[0] == 'do': if action[1] == 'wake' and player.wake_balance == 1: sleep_cures = ('cures_sleep_waking', 'cures_sleep_1', 'cures_sleep_2', 'cures_sleep_3', 'cures_sleep_metawake') for cure in sleep_cures: core.enable_trigger(cure, 'cures') player.wake_balance = .5 output('wake') elif action[1] == 'touch tree': player.tree_balance = .5 core.enable_trigger('cure_enablers_tree', 'cure_enablers') elif action[1] == 'stand': core.enable_trigger('cures_prone', 'cures') core.enable_trigger('cures_prone_redundant', 'cures') if action[1] != 'wake': output(action[1]) elif action[0] == 'smoke': core.enable_trigger('smoke_puff', 'balances') core.enable_trigger('failure_smoking', 'failures') core.enable_trigger('failure_asthma_smoking', 'failures') pipe = action[1] player.puffs.append(pipe) if pipe == 'elm': if player.elm_puffs > 0: output('smoke ' + player.elm_pipe) else: if herbs.elm.inv == 0: if player.is_hindered(): writhe(now) else: output(herbs.elm.outr_action(herbs.elm.keep_out)) else: core.enable_trigger('elm', 'pipes') core.enable_trigger('pipe_full', 'pipes') player.elm_lastfill = now output('put elm in ' + player.elm_pipe) elif pipe == 'valerian': if player.valerian_puffs > 0: output('smoke ' + player.valerian_pipe) else: if herbs.valerian.inv == 0: if player.is_hindered(): writhe(now) else: output(herbs.valerian.outr_action(herbs.valerian.keep_out)) else: core.enable_trigger('valerian', 'pipes') core.enable_trigger('pipe_full', 'pipes') player.valerian_lastfill = now output('put valerian in ' + player.valerian_pipe) player.puffs.append(pipe) elif action[0] == 'herb': if player.herb_balance: herbname = action[1] core.enable_trigger('cure_enablers_' + herbname, 'cure_enablers') core.enable_trigger('failure_eating', 'failures') core.enable_trigger('failure_eating_anorexia', 'failures') core.enable_trigger('failure_eating_mickey', 'failures') herb = herbs.herbs[herbname] if herb.inv <= 0: if player.is_hindered(): writhe(now) else: output(herb.outr_action(herb.keep_out)) else: output(herb.eat_action()) elif action[0] == 'salve': salve = action[1] where = action[2] core.enable_trigger('cure_enablers_salves', 'cure_enablers') core.enable_trigger('failure_apply_slickness', 'failures') player.last_salve = salve output("apply " + salve + " to " + where) elif action[0] == 'focus': core.enable_trigger('survival_focusing', 'survival') #player.focus_balance = .5 #player.focus_lastfire = now output('focus') aeon_currently_curing = affliction player.waiting_for_aeon_last = now