def has_threat_in_combat_range(life): _engage_distance = combat.get_engage_distance(life) for target_id in judgement.get_threats(life): _target = brain.knows_alife_by_id(life, target_id) if numbers.distance(life['pos'], _target['last_seen_at']) <= _engage_distance: return True return False
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