Exemple #1
0
def get_matching_remembered_items(life, matches, no_owner=False, active=True, only_visible=False):
	_matched_items = []
	
	if 'type' in matches and matches['type'] in life['known_items_type_cache']:
		_remembered_items = [life['know_items'][i] for i in life['known_items_type_cache'][matches['type']]]
	else:
		_remembered_items = life['know_items'].values()
	
	for item in _remembered_items:
		_item = ITEMS[item['item']]
		
		if get_item_flag(life, _item, 'ignore'):
			continue
		
		if active and 'offloaded' in item:
			continue
		
		if no_owner and item['last_owned_by']:
			continue
				
		if only_visible and not sight.can_see_position(life, _item['pos']):
			continue
		
		if _item['lock']:
			continue
		
		if 'parent' in _item and _item['parent']:
			continue
		
		if logic.matches(_item, matches):
			_matched_items.append(item['item'])
	
	return _matched_items
Exemple #2
0
def get_alife_in_chunk_matching(chunk_key, matching):
	_life = []
	_chunk = maps.get_chunk(chunk_key)
	
	for alife in [LIFE[l] for l in _chunk['life']]:
		if logic.matches(alife, matching):
			_life.append(alife['id'])
	
	return _life
Exemple #3
0
def get_ranged_combat_rating_of_target(life, life_id, inventory_check=True):
	target = LIFE[life_id]
	_score = 1
	_score_mod = 1
	
	_items = [ITEMS[i] for i in lfe.get_all_visible_items(target) if i in ITEMS and logic.matches(ITEMS[i], {'type': 'gun'})]
	
	if not _items and inventory_check:
		_items = [i for i in lfe.get_all_inventory_items(target) if i['uid'] in ITEMS and logic.matches(i, {'type': 'gun'})]
		_score_mod = .5
	
	for item in _items:
		if bad_numbers.distance(life['pos'], target['pos']) > combat.get_engage_distance(target):
			_score += item['accuracy']/2
		else:
			_score += item['accuracy']
	
	if _score:
		_score += 2*(life['stats']['firearms']/10.0)
	
	return _score*_score_mod
Exemple #4
0
def get_ranged_combat_rating_of_target(life, life_id):
    target = LIFE[life_id]
    _score = 1

    for item in [ITEMS[i] for i in lfe.get_all_visible_items(target) if i in ITEMS]:
        if not logic.matches(item, {"type": "gun"}):
            continue

        if numbers.distance(life["pos"], target["pos"]) > sight.get_vision(life) / 2:
            _score += item["accuracy"] / 2
        else:
            _score += item["accuracy"]

    return _score
Exemple #5
0
def get_matching_remembered_items(life,
                                  matches,
                                  no_owner=False,
                                  active=True,
                                  only_visible=False):
    _matched_items = []

    if 'type' in matches and matches['type'] in life['known_items_type_cache']:
        _remembered_items = [
            life['know_items'][i]
            for i in life['known_items_type_cache'][matches['type']]
        ]
    else:
        _remembered_items = life['know_items'].values()

    for item in _remembered_items:
        _item = ITEMS[item['item']]

        if get_item_flag(life, _item, 'ignore'):
            continue

        if active and 'offloaded' in item:
            continue

        if no_owner and item['last_owned_by']:
            continue

        if only_visible and not sight.can_see_position(life, _item['pos']):
            continue

        if _item['lock']:
            continue

        if 'parent' in _item and _item['parent']:
            continue

        if logic.matches(_item, matches):
            _matched_items.append(item['item'])

    return _matched_items