Пример #1
0
def melee_combat(life, targets):
	_target = get_closest_target(life, targets)
	
	if not _target:
		logging.error('No target for melee combat.')
		return False
	
	if sight.can_see_position(life, _target['last_seen_at'], block_check=True, strict=True):
		_can_see = sight.can_see_position(life, _target['life']['pos'], get_path=True)
		
		if _can_see:
			if len(_can_see)>1:
				movement.find_target(life, _target['life']['id'], distance=1, follow=True)
			else:
				melee.fight(life, _target['life']['id'])
		else:
			lfe.memory(life,'lost sight of %s' % (' '.join(_target['life']['name'])), target=_target['life']['id'])
			
			_target['escaped'] = 1
			
			for send_to in judgement.get_trusted(life):
				speech.communicate(life,
			        'target_missing',
			        target=_target['life']['id'],
			        matches=[send_to])
	else:
		return False
Пример #2
0
def melee_combat(life, targets):
	_target = get_closest_target(life, targets)
	
	if not _target:
		logging.error('No target for melee combat.')
		return False
	
	if sight.can_see_position(life, _target['last_seen_at'], block_check=True, strict=True):
		_can_see = sight.can_see_position(life, _target['life']['pos'], get_path=True)
		
		if _can_see:
			if len(_can_see)>1:
				movement.find_target(life, _target['life']['id'], distance=1, follow=True)
			else:
				melee.fight(life, _target['life']['id'])
		else:
			lfe.memory(life,'lost sight of %s' % (' '.join(_target['life']['name'])), target=_target['life']['id'])
			
			_target['escaped'] = 1
			
			for send_to in judgement.get_trusted(life):
				speech.communicate(life,
			        'target_missing',
			        target=_target['life']['id'],
			        matches=[send_to])
	else:
		return False
Пример #3
0
def tick(life):
	_guard = judgement.get_target_to_guard(life)
	
	if _guard:
		return movement.find_target(life, _guard, follow=False, distance=sight.get_vision(life)*.25, call=False)
	
	return movement.find_target(life, judgement.get_target_to_follow(life), follow=True, call=False)
Пример #4
0
def tick(life):
    _guard = judgement.get_target_to_guard(life)

    if _guard:
        return movement.find_target(life,
                                    _guard,
                                    follow=False,
                                    distance=sight.get_vision(life) * .25,
                                    call=False)

    return movement.find_target(life,
                                judgement.get_target_to_follow(life),
                                follow=True,
                                call=False)
Пример #5
0
def get_closest_target(life, targets):
	if targets:
		_target_positions, _zones = get_target_positions_and_zones(life, targets)
	else:
		#TODO: Dude, what?
		movement.find_target(life, targets, call=False)
		return False
	
	_targets_too_far = []
	_closest_target = {'target_id': None, 'score': 9999}
	for t in [brain.knows_alife_by_id(life, t_id) for t_id in targets]:
		_distance = numbers.distance(life['pos'], t['last_seen_at'])
		
		#NOTE: Hardcoding this for optimization reasons.
		if _distance>=100:
			targets.remove(t['life']['id'])
			_targets_too_far.append(t['life']['id'])
		
		if _distance < _closest_target['score']:
			_closest_target['score'] = _distance
			_closest_target['target_id'] = t['life']['id']
	
	if not _targets_too_far:
		_path_to_nearest = zones.dijkstra_map(life['pos'], _target_positions, _zones)
		
		if not _path_to_nearest:
			_path_to_nearest = [life['pos'][:]]
		
		if not _path_to_nearest:
			logging.error('%s lost known/visible target.' % ' '.join(life['name']))
			
			return False
		
		_target_pos = list(_path_to_nearest[len(_path_to_nearest)-1])
		#else:
		#	_target_pos = life['pos'][:]
		#	_target_positions.append(_target_pos)
		
		target = None
		
		if _target_pos in _target_positions:
			for _target in [brain.knows_alife_by_id(life, t) for t in targets]:
				if _target_pos == _target['last_seen_at']:
					target = _target
					break
	else:
		print 'THIS IS MUCH QUICKER!!!' * 10
		target = brain.knows_alife_by_id(life, _closest_target['target_id'])
	
	return target
Пример #6
0
def tick(life, alife_seen, alife_not_seen, targets_seen, targets_not_seen,
         source_map):
    _target = judgement.get_target_to_guard(life)

    movement.find_target(life, _target, call=False)
Пример #7
0
def tick(life, alife_seen, alife_not_seen, targets_seen, targets_not_seen, source_map):
	_target = judgement.get_target_to_guard(life)
	
	movement.find_target(life, _target, call=False)