Exemplo n.º 1
0
def react_to_tension(life, life_id):
    if brain.knows_alife_by_id(life, life_id)['alignment'] in ['hostile']:
        return False

    if life['group'] and not groups.is_leader(
            life, life['group'], life['id']) and groups.get_leader(
                life, life['group']):
        if sight.can_see_target(life, groups.get_leader(
                life, life['group'])) and sight.can_see_target(
                    LIFE[life_id], groups.get_leader(life, life['group'])):
            return False

    _disarm = brain.get_alife_flag(life, life_id, 'disarm')

    if _disarm:
        #For now...
        if not sight.can_see_position(life, LIFE[life_id]['pos']):
            groups.announce(life,
                            life['group'],
                            'attacked_by_hostile',
                            filter_if=lambda life_id: brain.knows_alife_by_id(
                                life, life_id)['last_seen_time'] <= 30,
                            target_id=life_id)

            return False

        for item_uid in lfe.get_all_visible_items(LIFE[life_id]):
            if ITEMS[item_uid]['type'] == 'gun':
                break
        else:
            brain.unflag_alife(life, life_id, 'disarm')
            speech.start_dialog(life, life_id, 'clear_drop_weapon')

            return False

        _time_elapsed = WORLD_INFO['ticks'] - _disarm

        if _time_elapsed > 135 and not speech.has_sent(life, life_id,
                                                       'threaten'):
            speech.start_dialog(life, life_id, 'threaten')
            speech.send(life, life_id, 'threaten')
        elif _time_elapsed > 185:
            speech.start_dialog(life, life_id, 'establish_hostile')
    elif not speech.has_sent(life, life_id, 'confront'):
        speech.start_dialog(life, life_id, 'confront')
        speech.send(life, life_id, 'confront')
Exemplo n.º 2
0
def react_to_tension(life, life_id):
	if brain.knows_alife_by_id(life, life_id)['alignment'] in ['hostile']:
		return False
	
	if life['group'] and not groups.is_leader(life, life['group'], life['id']) and groups.get_leader(life, life['group']):
		if sight.can_see_target(life, groups.get_leader(life, life['group'])) and sight.can_see_target(LIFE[life_id], groups.get_leader(life, life['group'])):
			return False
	
	_disarm = brain.get_alife_flag(life, life_id, 'disarm')
	
	if _disarm:
		#For now...
		if not sight.can_see_position(life, LIFE[life_id]['pos']):
			groups.announce(life,
			                life['group'],
			                'attacked_by_hostile',
			                filter_if=lambda life_id: brain.knows_alife_by_id(life, life_id)['last_seen_time']<=30,
			                target_id=life_id)
			
			return False
		
		for item_uid in lfe.get_all_visible_items(LIFE[life_id]):
			if ITEMS[item_uid]['type'] == 'gun':
				break
		else:
			brain.unflag_alife(life, life_id, 'disarm')
			speech.start_dialog(life, life_id, 'clear_drop_weapon')
			
			return False
		
		_time_elapsed = WORLD_INFO['ticks']-_disarm
		
		if _time_elapsed>135 and not speech.has_sent(life, life_id, 'threaten'):
			speech.start_dialog(life, life_id, 'threaten')
			speech.send(life, life_id, 'threaten')
		elif _time_elapsed>185:
			speech.start_dialog(life, life_id, 'establish_hostile')
	elif not speech.has_sent(life, life_id, 'confront'):
		speech.start_dialog(life, life_id, 'confront')
		speech.send(life, life_id, 'confront')
Exemplo n.º 3
0
def create_question(life, life_id, gist, ignore_if_said_in_last=0, **kwargs):
	_target = brain.knows_alife_by_id(life, life_id)
	_question = {'gist': gist, 'args': kwargs}
	
	if not _target:
		logging.critical('%s does not know %s but is creating questions for them.' % (' '.join(life['name']), ' '.join(LIFE[life_id]['name'])))
		return False
	
	if _question in _target['questions']:
		return False
	
	_sent = speech.has_sent(life, life_id, gist)
	
	if _sent and (WORLD_INFO['ticks']-_sent<ignore_if_said_in_last or ignore_if_said_in_last == -1):
		return False
	
	speech.send(life, life_id, gist)
	_target['questions'].append(_question)
	
	logging.debug('%s created question for %s: %s' % (' '.join(life['name']), ' '.join(LIFE[life_id]['name']), gist))
Exemplo n.º 4
0
def create_question(life, life_id, gist, ignore_if_said_in_last=0, recent_time=0, **kwargs):
	_target = brain.knows_alife_by_id(life, life_id)
	_question = {'gist': gist, 'args': kwargs}
	
	if not _target:
		logging.critical('%s does not know %s but is creating questions for them.' % (' '.join(life['name']), ' '.join(LIFE[life_id]['name'])))
		return False
	
	if _target['time_visible'] < recent_time:
		return False
	
	if _question in _target['questions']:
		return False
	
	_sent = speech.has_sent(life, life_id, gist)
	
	if _sent and (WORLD_INFO['ticks']-_sent<ignore_if_said_in_last or ignore_if_said_in_last == -1):
		return False
	
	speech.send(life, life_id, gist)
	_target['questions'].append(_question)
Exemplo n.º 5
0
def ask_for_help(life, life_id):
    _bleeding_limbs = len(lfe.get_bleeding_limbs(life))

    if not speech.has_sent(life, life_id, 'hurt'):
        speech.start_dialog(life, life_id, 'hurt')
        speech.send(life, life_id, 'hurt')
Exemplo n.º 6
0
def ask_for_help(life, life_id):
	_bleeding_limbs = len(lfe.get_bleeding_limbs(life))
	
	if not speech.has_sent(life, life_id, 'hurt'):
		speech.start_dialog(life, life_id, 'hurt')
		speech.send(life, life_id, 'hurt')