def generate_world(source_map, dynamic_spawns='Sparse', wildlife_spawns='Sparse', simulate_ticks=1000, combat_test=False, save=True, thread=True): WORLD_INFO['inittime'] = time.time() WORLD_INFO['start_age'] = simulate_ticks WORLD_INFO['dynamic_spawns'] = dynamic_spawns WORLD_INFO['wildlife_spawns'] = wildlife_spawns WORLD_INFO['real_time_of_day'] = int(round(WORLD_INFO['length_of_day']*.10)) WORLD_INFO['seed'] = time.time() WORLD_INFO['combat_test'] = combat_test WORLD_INFO['title'] = 'Operation %s' % language.generate_scheme_title().title() random.seed(WORLD_INFO['seed']) if WORLD_INFO['dynamic_spawns'] == 'Sparse': WORLD_INFO['dynamic_spawn_interval'] = [350, (1000, 1200)] elif WORLD_INFO['dynamic_spawns'] == 'Medium': WORLD_INFO['dynamic_spawn_interval'] = [350, (800, 999)] elif WORLD_INFO['dynamic_spawns'] == 'Heavy': WORLD_INFO['dynamic_spawn_interval'] = [350, (600, 799)] else: WORLD_INFO['dynamic_spawn_interval'] = [-1, (600, 799)] if WORLD_INFO['wildlife_spawns'] == 'Sparse': WORLD_INFO['wildlife_spawn_interval'] = [2500, (770, 990)] elif WORLD_INFO['wildlife_spawns'] == 'Medium': WORLD_INFO['wildlife_spawn_interval'] = [2500, (550, 700)] elif WORLD_INFO['wildlife_spawns'] == 'Heavy': WORLD_INFO['wildlife_spawn_interval'] = [2500, (250, 445)] else: WORLD_INFO['wildlife_spawn_interval'] = [-1, (250, 445)] weather.change_weather() create_region_spawns() randomize_item_spawns() lfe.focus_on(create_player()) alife.camps.create_all_camps() if thread: tcod.console_rect(0,0,0,WINDOW_SIZE[0],WINDOW_SIZE[1],True,flag=tcod.BKGND_DEFAULT) _r = Runner(simulate_ticks) _r.start() while _r.running: draw_world_stats() if not SETTINGS['running']: return False else: simulate_life(simulate_ticks) WORLD_INFO['id'] = 0 if save: WORLD_INFO['id'] = profiles.create_world() save_world(create=True) logging.info('World generation complete (took %.2fs)' % (time.time()-WORLD_INFO['inittime']))
def tick_world(): WORLD_INFO['ticks'] += 1 alfe.groups.get_group_relationships() if WORLD_INFO['real_time_of_day'] < WORLD_INFO['length_of_day']: WORLD_INFO['real_time_of_day'] += WORLD_INFO['time_scale'] else: WORLD_INFO['real_time_of_day'] = 0 WORLD_INFO['day'] += 1 weather.change_weather() if WORLD_INFO['real_time_of_day'] >= WORLD_INFO[ 'length_of_day'] - 22.00 or WORLD_INFO[ 'real_time_of_day'] <= WORLD_INFO['length_of_day'] * .15: if WORLD_INFO['time_of_day'] == 'day': gfx.message('Night falls.') WORLD_INFO['time_of_day'] = 'night' else: if WORLD_INFO['time_of_day'] == 'night': gfx.message('The sun rises.') WORLD_INFO['time_of_day'] = 'day' if WORLD_INFO['dynamic_spawn_interval'][0] > 0: WORLD_INFO['dynamic_spawn_interval'][0] -= 1 elif not WORLD_INFO['dynamic_spawn_interval'][0]: spawns.generate_life(random.choice(['loner', 'bandit'])) WORLD_INFO['dynamic_spawn_interval'][0] = random.randint( WORLD_INFO['dynamic_spawn_interval'][1][0], WORLD_INFO['dynamic_spawn_interval'][1][1]) logging.info('Reset life spawn clock: %s' % WORLD_INFO['dynamic_spawn_interval'][0]) if WORLD_INFO['wildlife_spawn_interval'][0] > 0: WORLD_INFO['wildlife_spawn_interval'][0] -= 1 elif not WORLD_INFO['wildlife_spawn_interval'][0]: worldgen.generate_wildlife() WORLD_INFO['wildlife_spawn_interval'][0] = random.randint( WORLD_INFO['wildlife_spawn_interval'][1][0], WORLD_INFO['wildlife_spawn_interval'][1][1]) logging.info('Reset wildlife spawn clock: %s' % WORLD_INFO['wildlife_spawn_interval'][0]) #situations.form_scheme() #situations.execute_scheme() alfe.factions.direct() core.evaluate_overwatch_mood() cache.scan_cache()
def tick_world(): WORLD_INFO['ticks'] += 1 alfe.groups.get_group_relationships() if WORLD_INFO['real_time_of_day'] < WORLD_INFO['length_of_day']: WORLD_INFO['real_time_of_day'] += WORLD_INFO['time_scale'] else: WORLD_INFO['real_time_of_day'] = 0 WORLD_INFO['day'] += 1 weather.change_weather() if WORLD_INFO['real_time_of_day']>=WORLD_INFO['length_of_day']-22.00 or WORLD_INFO['real_time_of_day']<=WORLD_INFO['length_of_day']*.15: if WORLD_INFO['time_of_day'] == 'day': gfx.message('Night falls.') WORLD_INFO['time_of_day'] = 'night' else: if WORLD_INFO['time_of_day'] == 'night': gfx.message('The sun rises.') WORLD_INFO['time_of_day'] = 'day' if WORLD_INFO['dynamic_spawn_interval'][0]>0: WORLD_INFO['dynamic_spawn_interval'][0] -= 1 elif not WORLD_INFO['dynamic_spawn_interval'][0]: spawns.generate_life(random.choice(['loner', 'bandit'])) WORLD_INFO['dynamic_spawn_interval'][0] = random.randint(WORLD_INFO['dynamic_spawn_interval'][1][0], WORLD_INFO['dynamic_spawn_interval'][1][1]) logging.info('Reset life spawn clock: %s' % WORLD_INFO['dynamic_spawn_interval'][0]) if WORLD_INFO['wildlife_spawn_interval'][0]>0: WORLD_INFO['wildlife_spawn_interval'][0] -= 1 elif not WORLD_INFO['wildlife_spawn_interval'][0]: worldgen.generate_wildlife() WORLD_INFO['wildlife_spawn_interval'][0] = random.randint(WORLD_INFO['wildlife_spawn_interval'][1][0], WORLD_INFO['wildlife_spawn_interval'][1][1]) logging.info('Reset wildlife spawn clock: %s' % WORLD_INFO['wildlife_spawn_interval'][0]) situations.form_scheme() situations.execute_scheme() artifacts.tick_fields() alfe.factions.direct() core.evaluate_overwatch_mood() cache.scan_cache()
def generate_world(source_map, dynamic_spawns='Sparse', wildlife_spawns='Sparse', simulate_ticks=1000, combat_test=False, save=True, thread=True): WORLD_INFO['inittime'] = time.time() WORLD_INFO['start_age'] = simulate_ticks WORLD_INFO['dynamic_spawns'] = dynamic_spawns WORLD_INFO['wildlife_spawns'] = wildlife_spawns WORLD_INFO['real_time_of_day'] = int( round(WORLD_INFO['length_of_day'] * .10)) WORLD_INFO['seed'] = time.time() WORLD_INFO['combat_test'] = combat_test WORLD_INFO['title'] = 'Operation %s' % language.generate_scheme_title( ).title() random.seed(WORLD_INFO['seed']) if WORLD_INFO['dynamic_spawns'] == 'Sparse': WORLD_INFO['dynamic_spawn_interval'] = [350, (1000, 1200)] elif WORLD_INFO['dynamic_spawns'] == 'Medium': WORLD_INFO['dynamic_spawn_interval'] = [350, (800, 999)] elif WORLD_INFO['dynamic_spawns'] == 'Heavy': WORLD_INFO['dynamic_spawn_interval'] = [350, (600, 799)] else: WORLD_INFO['dynamic_spawn_interval'] = [-1, (600, 799)] if WORLD_INFO['wildlife_spawns'] == 'Sparse': WORLD_INFO['wildlife_spawn_interval'] = [2500, (770, 990)] elif WORLD_INFO['wildlife_spawns'] == 'Medium': WORLD_INFO['wildlife_spawn_interval'] = [2500, (550, 700)] elif WORLD_INFO['wildlife_spawns'] == 'Heavy': WORLD_INFO['wildlife_spawn_interval'] = [2500, (250, 445)] else: WORLD_INFO['wildlife_spawn_interval'] = [-1, (250, 445)] weather.change_weather() create_region_spawns() randomize_item_spawns() lfe.focus_on(create_player()) alife.camps.create_all_camps() if thread: tcod.console_rect(0, 0, 0, WINDOW_SIZE[0], WINDOW_SIZE[1], True, flag=tcod.BKGND_DEFAULT) _r = Runner(simulate_ticks) _r.start() while _r.running: draw_world_stats() if not SETTINGS['running']: return False else: simulate_life(simulate_ticks) WORLD_INFO['id'] = 0 if save: WORLD_INFO['id'] = profiles.create_world() save_world(create=True) logging.info('World generation complete (took %.2fs)' % (time.time() - WORLD_INFO['inittime']))
def post_setup_world(): items.reload_all_items() weather.change_weather() maps.create_position_maps() WORLD_INFO['real_time_of_day'] = WORLD_INFO['length_of_day']/2
def post_setup_world(): items.reload_all_items() weather.change_weather() maps.create_position_maps() WORLD_INFO['real_time_of_day'] = WORLD_INFO['length_of_day'] / 2
def weather(): weather.change_weather()