示例#1
0
文件: channels.py 项目: AKJ/sage
def channels(line, time, backrefs):
	core.disable_trigger_group('start_channels')
	core.enable_trigger_group('channels')
	channels = ('earth', 'fire', 'water', 'air', 'spirit')
	for channel in channels:
		player.defences[channel] = False
	core.trigger_groups_pending_disable.append('channels')
示例#2
0
文件: smoking.py 项目: AKJ/sage
def pipe_full(line, time, backrefs):
	# Assume 10??
	player.elm_puffs = 10
	player.skullcap_puffs = 10
	player.valerian_puffs = 10
	player.waiting_for_aeon = 0
	core.disable_trigger('pipe_full', 'pipes')
	core.disable_trigger('pipes_paralysis_nofill', 'pipes')
	core.enable_trigger_group('plist')
	core.write('plist')
示例#3
0
文件: diagnose.py 项目: AKJ/sage
def start_diagnose(line, time, backrefs):
	# we reset insomnia to 0 because we expect to see it in this list...
	player.defences['insomnia'] = 0
	for aff in player.afflictions:
		player.afflictions[aff] = False
		flush_queues(aff)

	if core.retardation_mode == False:
		core.aeon_mode = False
	player.unknown_affliction = 0
	core.disable_trigger_group('start_diagnose')
	core.enable_trigger_group('diagnose')
	core.trigger_groups_pending_disable.append('diagnose')
示例#4
0
文件: misc.py 项目: AKJ/sage
def attacks_rebounding(line, time, backrefs):
	limbs = (
		'rightarm_lvl2',
		'rightarm_lvl3',
		'leftarm_lvl2',
		'leftarm_lvl3',
		'rightleg_lvl2',
		'rightleg_lvl3',
		'leftleg_lvl2',
		'leftleg_lvl3',
		'head_lvl1',
		'head_lvl2'
	)

	for limb in limbs:
		core.enable_trigger('limb_breaks_' + limb, 'limb_breaks')
		core.triggers_pending_disable.append(['limb_breaks_' + limb, 'limb_breaks'])

	core.enable_trigger_group('venoms')
	cures.ai['three_line_check'] = True
示例#5
0
文件: cures.py 项目: AKJ/sage
def unknown_affliction_hit():
	if core.config['unknown_affliction_ticks'] == 0:
		return

	if "** Illusion **" in input.buffer:
		return

	known = False

	# Determine reckless
	if player.health_percentage == 100 \
	and player.mana_percentage == 100:
		if (player.last_health < (0.85 * player.max_health)) or \
		(player.last_mana < (0.85 * player.max_mana)):
			player.afflictions['reckless'] = True
			known = True

	if known == False:
		player.unknown_affliction += 1

	if player.unknown_affliction >= core.config['unknown_affliction_ticks']:
		if action_queue.get_index('diag') == -1:
			core.enable_trigger_group('start_diagnose')
			action_queue.add('diag', 'diag', 500, True)
示例#6
0
文件: woodlore.py 项目: AKJ/sage
def woodlore_trap(line, time, backrefs):
	global trap_timer
	core.enable_trigger_group('venoms_traps')
	trap_timer = Timer(10, woodlore_disable_venoms)
	trap_timer.start()
示例#7
0
def enable_group(group):
	core.enable_trigger_group(group)
示例#8
0
def qsc(line, time, backrefs):
	core.enable_trigger_group('qsc')
	return "qsc"
示例#9
0
def plist(line, time, backrefs):
	core.enable_trigger_group('plist')
	core.trigger_groups_pending_disable.append('plist')
	return "plist"
示例#10
0
def deflist(line, time, backrefs):
	core.enable_trigger_group('start_def')
	return "def"
示例#11
0
def inra(line, time, backrefs):
	player.inra = 'plant'
	player.inramode = True
	core.enable_trigger_group('inra')
	core.write('inr all plant')
	herbsin()
示例#12
0
文件: cures.py 项目: AKJ/sage
def process_pre_afflictions(now):
	"""Most of the anti-illusion logic and fault redundancy."""
	global pre_afflictions, ai, focus_unknown, dlp, asthmapara

	pa_len = len(pre_afflictions)

	""" We don't do pre-processing for affs in blackout"""
	if player.afflictions['blackout']:
		if pa_len > 0:
			for aff in pre_afflictions:
				player.afflictions[aff] = True
			pre_afflictions = []
		return

	real = True

	""" Not actually an AI feature, but it makes sense to use the
	AI engine to do this. This has to run outside the pre_aff len check"""
	if ai['blank_deadeye_check']:
		if pa_len == 0:
			focus_unknown = True
		elif len(input.buffer) == 3: # what about rebounding? etc?
			focus_unknown = True

	if ai['reckless_check']:
		if player.afflictions['reckless'] == False \
		and 'reckless' not in pre_afflictions:
			if player.health >= player.max_health \
			and player.mana >= player.max_mana:
				player.afflictions['reckless'] = True

	if pa_len > 0:
		for aff in pre_afflictions:
			if aff == 'reckless':
				if player.health < player.max_health or player.mana < player.max_mana:
					real = False

			if ai['trample_prone_check']:
				if broken_legs(pre_afflictions):
					player.afflictions['prone'] = True
					core.debug("detected broken legs on trample, setting prone to true")
					ai['trample_prone_check'] = False

			#checks to see if we took damage
			if ai['delta_check'] and player.afflictions['reckless'] is False and 'reckless' not in pre_afflictions:
				if player.delta_health == 0:
					real = False
					core.debug("affliction " + aff + " failed delta_check")

			if ai['connect_check_attack']:
				real = False
				if ai['connect_check']:
					if player.delta_health < 0:
						real = True
					elif len(input.buffer) >= 3:
						real = True

			# stupidity failures
			if aff == 'stupidity' and player.afflictions['stupidity'] is True:
				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
				if player.asip_balance == .5:
					player.asip_balance = 1
				if player.writhe_balance == .5:
					player.writhe_balance = 1

			"""
			# prevent 2-line writhe/bal illusions
			if ai['writhe_balance_illusion']:
				if 'You have writhed free of your entanglement by webs.' in input.buffer:
					real = False
				elif 'You have writhed free of your state of transfixation.' in input.buffer:
					real = False
				elif 'You have writhed free of your entanglement by ropes.' in input.buffer:
					real = False
				elif 'You have writhed free of your entanglement by tied ropes.' in input.buffer:
					real = False
				elif 'With an heroic effort you manage to writhe yourself free from the weapon that impaled you.' in input.buffer:
					real = False

			if ai['three_line_check']:
				if len(input.buffer) < 3:
					real = False

			if ai['hypnosis_affliction'] > 1:
				real = False
			"""

			# asthma bite checks
			if ai['bitten']:
				if aff == 'asthma' and player.afflictions['asthma'] is False:
					# hold breath and see if we show asthma..
					real = False # not really but whatever..
					core.enable_trigger('test_asthma_hold_breath', 'anti-illusion')
					immediate_queue.add('breathing', 'hold breath', True)
				elif aff == 'paralysis' and player.afflictions['paralysis'] is False:
					# fling is our test for paralysis
					real = False
					core.enable_trigger_group('ai_paralysis')
					immediate_queue.add('test_paralysis', 'fling', True)

			if ai['single_line_paralysis']:
				if aff == 'paralysis' \
				and player.afflictions['paralysis'] is False \
				and len(input.buffer) == 1:
					real = False
					core.enable_trigger_group('ai_paralysis')
					immediate_queue.add('test_paralysis', 'fling', True)

			if ai['dstab']:
				attacker = ai['dstab']

				# Real dstab
				if len(input.buffer) >= 3:
					player.dstabs[attacker] = time.time()

				#Single paralysis dstab - potentially an illusion.
				elif len(input.buffer) == 2 \
				and aff == 'paralysis' \
				and player.afflictions['paralysis'] is False:
					real = False
					core.enable_trigger_group('ai_paralysis')
					immediate_queue.add('test_paralysis', 'fling', True)

				else:
					# Single aff dstab? Are we too close to the previous?
					if attacker in player.dstabs.keys():
						if time.time() - player.dstabs[attacker] <= 2:
							real = False

			# spirituality smash and smite
			if ai['smash_check']:
				if aff in ('leftleg_lvl1', 'rightleg_lvl1', 'leftarm_lvl1', 'rightarm_lvl1'):
					# this is a spirtuality smash, not smite
					real = True
				elif player.delta_health >= 0 and player.afflictions['reckless'] is False and 'reckless' not in pre_afflictions:
					real = False

			if ai['camus_check'] and player.afflictions['reckless'] is False and 'reckless' not in pre_afflictions:
				if player.delta_health < 0:
					# bite was real... we don't have sileris
					player.defences['sileris'] = 0
					real = True
					core.debug("Camus check evaluated bite was real. Sileris is down.")
				else:
					real = False

			if ai['one_line']:
				if len(input.buffer) != 1:
					real = False

			if ai['reflection_strike']:
				# FIXME: Only works for one reflection
				if "One of your reflections has been destroyed! You have 0 left." in input.buffer:
					core.debug("reflection strike detected, ignoring affliction %s" % aff)
					real = False

					if len(lusted) > 0:
						core.debug("lust ignored because of reflection")
						lusted.pop()

			# single-line asthma check
			if aff == 'asthma':
				if len(input.buffer) == 1:
					if input.buffer[0] == "You feel a tightening sensation grow in your lungs.":
						real = False # not really, testing for symptom
						core.enable_trigger('test_asthma_hold_breath', 'anti-illusion')
						immediate_queue.add('breathing', 'hold breath', True)

			if lifevision:
				real = False

			if real:
				escalate_breaks(aff)
				player.afflictions[aff] = True
			else:
				core.debug("AI ruled out affliction " + aff)

		if real:
			"""DLP Enabling"""
			if pa_len > 0:
				if ai['dlp_legs'] and player.combat_class != 'priest':
					broken = broken_limbs(pre_afflictions)
					if broken:
						dlp['legs'] = True
				if ai['dlp_arms'] and player.combat_class != 'priest':
					broken = broken_limbs(pre_afflictions)
					if broken:
						dlp['arms'] = True

			"""Para/Asthma Overloading"""
			if 'asthma' in pre_afflictions \
			and 'paralysis' in pre_afflictions:
				now = time.time()
				if now - asthmapara['last'] - player.latency <= 3 \
				and player.tree_balance == 0:
					asthmapara['switch'] = True
					asthmapara['last'] = 0
				else:
					asthmapara['last'] = now

			if now - player.last_snap <= 1.5:
				if player.salve_balance == 0 \
				and player.afflictions['asthma'] == True:
					player.fire_tree = True

		pre_afflictions = []

	for item in ai:
		ai[item] = False
示例#13
0
文件: hypnosis.py 项目: AKJ/sage
def hypnosis_snap(line, time, backrefs):
	player.last_snap = time
	core.enable_trigger_group('hypnosis')
	player.hypnosis_timer = Timer(61, hypnosis_disable)
	player.hypnosis_timer.start()
示例#14
0
文件: deflist.py 项目: AKJ/sage
def start_def(line, time, backrefs):
	core.disable_trigger_group('start_def')
	core.enable_trigger_group('def_list')
	core.trigger_groups_pending_disable.append('def_list')
示例#15
0
文件: input.py 项目: AKJ/sage
def prompt_receiver(line):
	global buffer, pfunctions, pfunction_args, previous_stats, current_stats, gagnext

	if len(line) == 0:
		return line

	clean_line = ansi.filter_ansi(line)
	# Strip newlines
	if clean_line[0] == NL:
		clean_line = clean_line[1:]

	match = prompt.match(clean_line)
	if match:
	
		# pending triggers to be disabled
		if len(core.triggers_pending_disable) > 0:
			for trigger in core.triggers_pending_disable:
				core.disable_trigger(trigger[0], trigger[1])

			core.triggers_pending_disable = []

		if len(core.trigger_groups_pending_disable) > 0:
			for group in core.trigger_groups_pending_disable:
				core.disable_trigger_group(group)

			core.trigger_groups_pending_disable = []

		backrefs = match.groups()

		player.last_health = player.health
		player.health = int(backrefs[0])
		player.delta_health = player.health - player.last_health
		player.last_mana = player.mana
		player.mana	= int(backrefs[1])
		player.delta_mana = player.mana - player.last_mana

		player.health_percentage = percentage(player.health, player.max_health)
		player.mana_percentage = percentage(player.mana, player.max_mana)

		previous_stats = current_stats
		current_stats = backrefs[2]
		status = backrefs[2]
		ex = ''
		stats = ''
		if status is None:
			player.equilibrium = False
			player.balance = False
			player.defences['cloak'] = 0
			player.defences['blind'] = 0
			player.defences['deaf'] = 0
			player.defences['kelventari'] = 0
		else:
			if 'e' in status:
				player.equilibrium = True
				ex = ex + 'e'
			else:
				player.equilibrium = False
			if 'y' or 'z' in status:
				#balance stuff. Work on this
				if player.combat_class == 'monk':
					if player.leftarm_balance and player.rightarm_balance:
						player.balance = True
					else:
						player.balance = False
				else:
					player.balance = True
				ex = ex + 'x'
			else:
				player.balance = False
			if 'c' in status:
				player.defences['cloak'] = 1
				stats = stats + 'c'
				queues.action_queue.remove_by_name('cloak')
			else:
				player.defences['cloak'] = 0
			if 'b' in status:
				player.defences['blind'] = 1
				stats = stats + 'b'
				queues.herb_queue.remove_by_name('blind')
			else:
				player.defences['blind'] = 0
			if 'd' in status:
				player.defences['deaf'] = 1
				stats = stats + 'd'
				queues.herb_queue.remove_by_name('deaf')
			else:
				player.defences['deaf'] = 0
			if 'k' in status:
				player.defences['kelventari'] = 1
				stats = stats + 'k'
			else:
				if player.defences['kelventari'] != .5:
					player.defences['kelventari'] = 0

		# quick reckless check
		if player.health < player.max_health or player.mana < player.max_mana:
			player.afflictions['reckless'] = False

		# death handling
		if player.health == 0:
			player.dead = True
		else:
			player.dead = False

		# we -might- be dead
		if player.dead == False:
			dead = True
			if player.death_check:
				if player.equilibrium is False:
					dead = False
				elif player.balance is False:
					dead = False
				elif player.defences['cloak'] == 1:
					dead = False
				elif player.defences['blind'] == 1:
					dead = False
				elif player.defences['deaf'] == 1:
					dead = False
				elif player.defences['kola'] == 1:
					dead = False
				if dead:
					player.dead = True

				if player.dead and player.starburst_check:
					hooks.burst.run()
					player.mode = 'starburst'
					player.keepup = player.keepup_starburst
					for defence in player.starburst:
						if player.starburst[defence] is True and player.keepup[defence] is False:
							if player.defences[defence] == 0:
								defences.load_def(defence)
				player.death_check = False
				player.starburst_check = False
		else:
			dead = False

		if player.dead:
			if dead:
				core.echo("You're no daisy. You're no daisy at all!")
			if player.health == 0:
				core.paused = True

			for aff in player.afflictions:
				player.afflictions[aff] = False
			for defence in player.defences:
				player.defences[defence] = 0
			queues.flush_queues()
			player.stunned = False
			player.herb_balance = 1
			player.hmsip_balance = 1
			player.asip_balance = 1
			player.lestagii_balance = 1
			player.herb_balance = 1
			player.free_balance = 1
			player.waiting_for_kelventari = 0
			player.focus_balance = 1
			player.fire_focus = False
			player.ableto_focus = True
			player.tree_balance = 1
			player.writhe_balance = 1
			core.aeon_mode = False
			core.retardation_mode = False
			herbs.reset()
			hooks.death.run()

		now = time.time()

		if len(pfunctions) > 0:
			i = 0
			for function in pfunctions:
				function(pfunction_args[i][0], pfunction_args[i][1], pfunction_args[i][2])
				i += 1

		pfunctions = []
		pfunction_args = []

		# Cure and Affliction Events
		defences.defence_event(now)
		cures.cure_event()
		if core.aeon_mode is False:
			cures.affliction_event(now)
		else:
			aeon_cures.affliction_event()

		cures.lifevision = False # reset lifevision
		cures.temporary_priorities = {}

		# prompt events
		run_events(now)

		# restyle prompt
		new_prompt = format_prompt(ex, stats)

		buffer = []

		if gagging or gagnext:
			if gagnext:
				gagnext = False

			return None
		else:
			return new_prompt

	# Blackout prompt
	else:
		if clean_line[0] == '-':
			player.afflictions['blackout'] = True

			core.enable_trigger_group('blackout_cures')
			core.enable_trigger_group('venoms')

			now = time.time()

			if len(pfunctions) > 0:
				for function in pfunctions:
					pfunctions[function](pfunction_args[function][0], pfunction_args[function][1], pfunction_args[function][2])

			pfunctions = []
			pfunction_args = []

			defences.defence_event(now)
			cures.cure_event()

			if core.aeon_mode is False:
				cures.affliction_event(now)
			else:
				aeon_cures.affliction_event()

			cures.lifevision = False # reset lifevision
			cures.temporary_priorities = {}

			run_events(now)

			buffer = []
			return blackout_prompt()

	return line
示例#16
0
def diag(line, time, backrefs):
	core.enable_trigger_group('start_diagnose')
	return "diag"
示例#17
0
文件: tattoos.py 项目: AKJ/sage
def tattoos_list(line, time, backrefs):
	core.enable_trigger_group('tattoo_list')
	core.write('tattoos')
示例#18
0
def channels(line, time, backrefs):
	core.enable_trigger_group('start_channels')
	return "channels"
示例#19
0
文件: misc.py 项目: AKJ/sage
def stupidity_emote(line, time, backrefs):
	core.disable_trigger_group('emotes')
	core.enable_trigger_group('symptoms')
示例#20
0
文件: events.py 项目: AKJ/sage
def keepup_event(now):
	defences_awaiting = 0
	for defence in player.keepup:
		# defences ignored by keepup event
		if defence not in ('sileris', 'deaf'):
			if player.keepup[defence] and player.defences[defence] == .5:
				if now - defences.def_redundancy_ticks[defence] >= 6:
					defences_awaiting += 1
					player.defences[defence] = 0
					defences.def_redundancy_ticks[defence] = 0

			elif player.keepup[defence] and player.defences[defence] == 0:
				defences_awaiting += 1
				player.defences[defence] = .5
				defences.def_redundancy_ticks[defence] = now
				cmd = defences.defup_actions[defence]
				core.enable_trigger('ondef_' + defence, 'ondef')
				if defence == 'riding':
					core.enable_trigger('failure_mount', 'failures')
					if core.config['vaulting']:
						queues.action_queue.add('riding', 'vault ' + player.mount, cmd[2])
					else:
						queues.action_queue.add('riding', 'mount ' + player.mount, cmd[2])
				if cmd[0] == 'action':
					if queues.action_queue.get_index(defence) == -1:
						if defence in ('air', 'earth', 'fire', 'water', 'spirit'):
							if player.defences['air'] != 1 and \
							player.defences['water'] != 1 and \
							player.defences['fire'] != 1 and \
							player.defences['earth'] != 1:
								queues.action_queue.add('simultaneity', 'simultaneity', 387)
								core.enable_trigger('ondef_earth', 'ondef')
								core.enable_trigger('ondef_water', 'ondef')
								core.enable_trigger('ondef_fire', 'ondef')
								core.enable_trigger('ondef_air', 'ondef')
								core.enable_trigger('ondef_spirit', 'ondef')
						else:
							queues.action_queue.add(defence, cmd[1], cmd[2])
				elif cmd[0] == 'immediate':
					if queues.immediate_queue.get_index(defence) == -1:
						queues.immediate_queue.add(defence, cmd[1], cmd[2])
				elif cmd[0] == 'free':
					if queues.free_queue.get_index(defence) == -1:
						queues.free_queue.add(defence, cmd[1], cmd[2])
				elif cmd[0] == 'herb':
					if queues.herb_queue.get_index(defence) == -1:
						queues.herb_queue.add(defence, cmd[1], cmd[2])
				elif cmd[0] == 'salve':
					if queues.salve_queue.get_index(defence) == -1:
						queues.salve_queue.add(defence, cmd[1], cmd[2])
				elif cmd[0] == 'asip':
					if queues.asip_queue.get_index(defence) == -1:
						queues.asip_queue.add(defence, cmd[1], cmd[2])
				elif cmd[0] == 'smoke':
					if defence == 'rebounding' and player.rebounding_pending is True:
						if now - player.skullcap_lastfire > 9:
							# Something's wrong... rebounding should come up
							# in 8 seconds. We're waiting on it but it hasn't
							# come up yet...
							queues.smoke_queue.remove_by_name(defence)
							queues.smoke_queue.add(defence, cmd[1], cmd[2])
						return

					queues.smoke_queue.remove_by_name(defence)
					queues.smoke_queue.add(defence, cmd[1], cmd[2])
	if defences_awaiting > 0:
		core.enable_trigger_group('defence_redundancy')
	else:
		core.disable_trigger_group('defence_redundancy')