def _spread(noise): for alife in LIFE.values(): if alife['dead']: continue _can_see = False if sight.can_see_position(alife, noise['pos']): _can_see = True _dist = bad_numbers.distance(noise['pos'], alife['pos']) if _dist>noise['volume']: continue update_targets_around_noise(alife, noise) _direction_to = bad_numbers.direction_to(alife['pos'], noise['pos']) _direction_string = language.get_real_direction(_direction_to) #TODO: Check walls between positions #TODO: Add memory if not _can_see or not noise['skip_on_visual']: if _dist >=noise['volume']/2: if 'player' in alife: gfx.message(random.choice(FAR_TEXT).replace('@t', noise['text'][1]).replace('@d', _direction_string), style='sound') else: if 'player' in alife: gfx.message(random.choice(FAR_TEXT).replace('@t', noise['text'][0]).replace('@d', _direction_string), style='sound')
def create_cache_drop(pos, spawn_list): _player = LIFE[SETTINGS['controlling']] _pos = spawns.get_spawn_point_around(pos, area=10) _direction = language.get_real_direction( numbers.direction_to(_player['pos'], _pos)) for container in spawn_list: if not container['rarity'] > random.uniform(0, 1.0): continue _c = items.create_item(container['item'], position=[_pos[0], _pos[1], 2]) for _inside_item in container['spawn_list']: if _inside_item['rarity'] <= random.uniform(0, 1.0): continue _i = items.create_item(_inside_item['item'], position=[_pos[0], _pos[1], 2]) if not items.can_store_item_in(_i, _c): items.delete_item(_i) continue items.store_item_in(_i, _c) effects.create_smoker(_pos, 300, color=tcod.orange) gfx.message('You see something parachuting to the ground to the %s.' % _direction, style='event')
def create_cache_drop(pos, spawn_list): _player = LIFE[SETTINGS["controlling"]] _pos = spawns.get_spawn_point_around(pos, area=10) _direction = language.get_real_direction(numbers.direction_to(_player["pos"], _pos)) for container in spawn_list: if not container["rarity"] > random.uniform(0, 1.0): continue _c = items.create_item(container["item"], position=[_pos[0], _pos[1], 2]) for _inside_item in container["spawn_list"]: if _inside_item["rarity"] <= random.uniform(0, 1.0): continue _i = items.create_item(_inside_item["item"], position=[_pos[0], _pos[1], 2]) if not items.can_store_item_in(_i, _c): items.delete_item(_i) continue items.store_item_in(_i, _c) effects.create_smoker(_pos, 300, color=tcod.orange) gfx.message("You see something parachuting to the ground to the %s." % _direction, style="event")
def control_zes(): _zes = get_faction('ZES') if not 'intro_created' in _zes['flags'] and _zes['members'] and SETTINGS['controlling']: _zes = get_faction('ZES') _zes['flags']['intro_created'] = True _item_uid = weapons.spawn_and_arm('glock', '9x19mm magazine', '9x19mm round', 17) _kill_target = get_faction('Bandits')['members'][0] _kill_target_direction = numbers.distance(LIFE[_zes['members'][0]]['pos'], LIFE[_kill_target]['pos']) _quest_item_uid = lfe.get_inventory_item_matching(LIFE[_kill_target], {'type': 'radio'}) _mission = missions.create_mission('zes_glock', target=SETTINGS['controlling'], item_uid=_item_uid, quest_item_uid=_quest_item_uid, deliver_target=_zes['members'][0], kill_target=_kill_target, location=lfe.get_current_chunk_id(LIFE[_kill_target])) lfe.add_item_to_inventory(LIFE[_zes['members'][0]], _item_uid) alife.brain.meet_alife(LIFE[_zes['members'][0]], LIFE[SETTINGS['controlling']]) alife.memory.create_question(LIFE[_zes['members'][0]], SETTINGS['controlling'], 'zes_intro', kill_target_name=' '.join(LIFE[_kill_target]['name']), kill_target_direction=language.get_real_direction(_kill_target_direction)) missions.remember_mission(LIFE[_zes['members'][0]], _mission) missions.activate_mission(LIFE[_zes['members'][0]], '1')
def control_zes(): _zes = get_faction('ZES') if not 'intro_created' in _zes['flags'] and _zes['members'] and SETTINGS['controlling']: _zes = get_faction('ZES') _zes['flags']['intro_created'] = True _item_uid = weapons.spawn_and_arm('glock', '9x19mm magazine', '9x19mm round', 17) _kill_target = get_faction('Bandits')['members'][0] _kill_target_direction = bad_numbers.distance(LIFE[_zes['members'][0]]['pos'], LIFE[_kill_target]['pos']) _quest_item_uid = lfe.get_inventory_item_matching(LIFE[_kill_target], {'type': 'radio'}) _mission = missions.create_mission('zes_glock', target=SETTINGS['controlling'], item_uid=_item_uid, quest_item_uid=_quest_item_uid, deliver_target=_zes['members'][0], kill_target=_kill_target, location=lfe.get_current_chunk_id(LIFE[_kill_target])) lfe.add_item_to_inventory(LIFE[_zes['members'][0]], _item_uid) alife.brain.meet_alife(LIFE[_zes['members'][0]], LIFE[SETTINGS['controlling']]) alife.memory.create_question(LIFE[_zes['members'][0]], SETTINGS['controlling'], 'zes_intro', kill_target_name=' '.join(LIFE[_kill_target]['name']), kill_target_direction=language.get_real_direction(_kill_target_direction)) missions.remember_mission(LIFE[_zes['members'][0]], _mission) missions.activate_mission(LIFE[_zes['members'][0]], '1')
def form_scheme(force=False): if (WORLD_INFO['scheme'] or (WORLD_INFO['ticks']-WORLD_INFO['last_scheme_time'])<200) and not force or not SETTINGS['controlling']: return False _overwatch_mood = WORLD_INFO['overwatch']['mood'] core.handle_tracked_alife() if _overwatch_mood == 'rest': return False _player_situation = core.get_player_situation() if _overwatch_mood == 'hurt': if hurt_player(_player_situation): WORLD_INFO['last_scheme_time'] = WORLD_INFO['ticks'] return True elif _overwatch_mood == 'intrigue': if intrigue_player(_player_situation): WORLD_INFO['last_scheme_time'] = WORLD_INFO['ticks'] return True elif _overwatch_mood == 'help': if help_player(_player_situation): WORLD_INFO['last_scheme_time'] = WORLD_INFO['ticks'] return True #if _player_situation['armed']: _i = random.randint(0, 3)+10 if _i == 1: _military_group_leader = get_group_leader_with_motive('military') _bandit_group_leader = get_group_leader_with_motive('crime', online=False) #TODO: Actual bandit camp location if _military_group_leader and _bandit_group_leader: _bandit_group_location = lfe.get_current_chunk_id(LIFE[_bandit_group_leader]) order_group(LIFE[_military_group_leader], LIFE[_military_group_leader]['group'], STAGE_RAIDING, 30, chunk_key=_bandit_group_location) alife.groups.discover_group(LIFE[_military_group_leader], LIFE[_bandit_group_leader]['group']) alife.groups.declare_group_hostile(LIFE[_military_group_leader], LIFE[_military_group_leader]['group'], LIFE[_bandit_group_leader]['group']) elif _i == 2: _spawn_pos = spawns.get_spawn_in_ref('farms') _real_direction = language.get_real_direction(numbers.direction_to((MAP_SIZE[0]/2, MAP_SIZE[1]/2), _spawn_pos)) spawn_life('loner', _spawn_pos, 35, injuries={'llowerleg': {'cut': 1}}) _messages = [{'text': 'Hello? Can anyone hear me?'}, {'text': 'Bandits robbed me and left me to bleed out...'}, {'text': 'I\'m by a farm to the %s.' % _real_direction}, {'text': 'They might still be around. Please hurry!'}] events.broadcast(_messages, 40) elif 1 == 1: _bandit_group_leader = core.get_group_leader_with_motive('crime', online=True) _military_group_leader = core.get_group_leader_with_motive('military', online=False) if _military_group_leader and _bandit_group_leader: _bandit_group_location = lfe.get_current_chunk_id(LIFE[_bandit_group_leader]) _military_group_location = lfe.get_current_chunk_id(LIFE[_military_group_leader]) order_group(LIFE[_bandit_group_leader], LIFE[_bandit_group_leader]['group'], STAGE_RAIDING, 500, chunk_key=_military_group_location) alife.groups.discover_group(LIFE[_bandit_group_leader], LIFE[_military_group_leader]['group']) alife.groups.declare_group_hostile(LIFE[_bandit_group_leader], LIFE[_bandit_group_leader]['group'], LIFE[_military_group_leader]['group']) _real_direction = language.get_real_direction(numbers.direction_to((MAP_SIZE[0]/2, MAP_SIZE[1]/2), alife.chunks.get_chunk(_military_group_location)['pos'])) _messages = [{'text': 'Attention all neutral and bandit squads.'}, {'text': 'We finally got solid contact on military in the %s compound.' % _real_direction}, {'text': 'We\'re located near coords %s and heading out soon.' % (', '.join(_bandit_group_location.split(',')))}] events.broadcast(_messages, 40)
def hurt_player(situation): _player = LIFE[SETTINGS['controlling']] if situation['group']: if situation['armed']: _bandit_group_leader = get_group_leader_with_motive('crime', online=True) _military_group_leader = get_group_leader_with_motive('military', online=False) if not _military_group_leader: _military_group_leader = spawns.generate_group('soldier', amount=3, spawn_chunks=[spawns.get_spawn_in_ref('outposts', chunk_key=True)])[0] if not _bandit_group_leader: _chunk_key = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_military_group_leader['pos'], area=150, min_area=100)) _bandit_group_leader = spawns.generate_group('bandit', amount=5, spawn_chunks=[_chunk_key])[0] _bandit_group_location = lfe.get_current_chunk_id(_bandit_group_leader) _military_group_location = lfe.get_current_chunk_id(_military_group_leader) order_group(_bandit_group_leader, _bandit_group_leader['group'], STAGE_RAIDING, 500, chunk_key=_military_group_location) alife.groups.discover_group(_bandit_group_leader, _military_group_leader['group']) alife.groups.declare_group_hostile(_bandit_group_leader, _bandit_group_leader['group'], _military_group_leader['group']) _real_direction = language.get_real_direction(numbers.direction_to((MAP_SIZE[0]/2, MAP_SIZE[1]/2), alife.chunks.get_chunk(_military_group_location)['pos'])) _messages = [{'text': 'Attention all neutral and bandit squads.'}, {'text': 'We finally got solid contact on military in the %s compound.' % _real_direction}, {'text': 'We\'re located near coords %s and heading out soon.' % (', '.join(_bandit_group_location.split(',')))}] events.broadcast(_messages, 40) core.record_encounter(len(alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members'])) _player_group_leader = LIFE[alife.groups.get_leader(_player, situation['group'])] for friendly_member in alife.groups.get_group(_player_group_leader, situation['group'])['members']: for hostile_member in alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members']: _target = alife.brain.meet_alife(LIFE[friendly_member], LIFE[hostile_member]) _target['last_seen_time'] = 1 _target['escaped'] = 1 _target['last_seen_at'] = LIFE[hostile_member]['pos'][:] alife.stats.establish_hostile(LIFE[friendly_member], hostile_member) for hostile_member in alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members']: for friendly_member in alife.groups.get_group(_player_group_leader, situation['group'])['members']: _target = alife.brain.meet_alife(LIFE[hostile_member], LIFE[friendly_member]) _target['last_seen_time'] = 1 _target['escaped'] = 1 _target['last_seen_at'] = LIFE[friendly_member]['pos'][:] alife.stats.establish_hostile(LIFE[hostile_member], friendly_member) return True elif situation['armed']: _town_chunk_keys = [] for ref in WORLD_INFO['refs']['towns']: _town_chunk_keys.extend(ref) _nearest_town_chunk_key = alife.chunks.get_nearest_chunk_in_list(_player['pos'], _town_chunk_keys) _town_chunk = alife.chunks.get_chunk(_nearest_town_chunk_key) _distance_to_nearst_town = numbers.distance(_player['pos'], _town_chunk['pos']) _spawn_distance = 15*WORLD_INFO['chunk_size'] if len(situation['online_alife']) == len(situation['trusted_online_alife']): if _distance_to_nearst_town<=50: _group_spawn_velocity = numbers.velocity(numbers.direction_to(_player['pos'], _town_chunk['pos']), _spawn_distance+(50-numbers.clip(_distance_to_nearst_town, 0, 50))) _group_spawn_pos = [int(round(_player['pos'][0]+_group_spawn_velocity[0])), int(round(_player['pos'][1]+_group_spawn_velocity[1]))] _group_spawn_pos[0] = numbers.clip(_group_spawn_pos[0], 0, MAP_SIZE[0]) _group_spawn_pos[1] = numbers.clip(_group_spawn_pos[1], 0, MAP_SIZE[1]) _group_spawn_chunk_key = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_group_spawn_pos, area=30)) _alife = spawns.generate_group('bandit', amount=2, spawn_chunks=[_group_spawn_chunk_key]) for ai in _alife: alife.brain.meet_alife(ai, _player) alife.stats.establish_hostile(ai, _player['id']) core.record_encounter(2, life_ids=[i['id'] for i in _alife]) if random.randint(0, 1) or 1: _spawn_chunk_key = spawns.get_spawn_point_around(_group_spawn_pos, area=90, min_area=60, chunk_key=True) _other_group = spawns.generate_group('loner', amount=1, spawn_chunks=[_spawn_chunk_key]) for ai in _other_group: for ai2 in _alife: _target = alife.brain.meet_alife(ai, ai2) _target['last_seen_time'] = 1 _target['escaped'] = 1 _target['last_seen_at'] = ai2['pos'][:] alife.stats.establish_hostile(ai, ai2['id']) for ai2 in _alife: for ai in _other_group: _target = alife.brain.meet_alife(ai2, ai) _target['last_seen_time'] = 1 _target['escaped'] = 1 _target['last_seen_at'] = ai['pos'][:] alife.stats.establish_hostile(ai2, ai['id']) _messages = [{'text': 'I\'m pinned down in the village!'}, {'text': 'Anyone nearby?'}] events.broadcast(_messages, 0) return True elif 1==2: _spawn_chunk_key = spawns.get_spawn_point_around(_player['pos'], min_area=125, area=200, chunk_key=True) _group = spawns.generate_group('loner', amount=1, spawn_chunks=[_spawn_chunk_key]) core.record_encounter(1, life_ids=[l['id'] for l in _group]) for ai in _group: events.attract_tracked_alife_to(spawns.get_spawn_point_around(_player['pos'], min_area=10, area=100)) return False