Ejemplo n.º 1
0
def update():
    global X
    global Y
    global LAST_X
    global LAST_Y

    X = numbers.clip(X, X_MIN, X_MAX)
    Y = numbers.clip(Y, Y_MIN, Y_MAX)

    _zone = zones.ZONES[zones.ACTIVE_ZONE]

    display.set_surface_camera("tiles", X, Y)
    display.reset_surface_shaders("tiles")

    if world_action.FADE_VALUE < 255:
        display.apply_surface_shader(
            "tiles", zones.get_active_fader(), constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT
        )

    for shader in _zone["shaders"]:
        display.apply_surface_shader("tiles", shader, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)

    display.blit_surface_viewport("tiles", X, Y, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)

    LAST_X = X
    LAST_Y = Y
Ejemplo n.º 2
0
def draw_item_labels():
	_camera_x, _camera_y = camera.X, camera.Y
	_width = display.get_surface('life')['width']
	_height = display.get_surface('life')['height']
	
	if settings.OBSERVER_MODE:
		_draw_items = entities.get_entity_group('items')
	else:
		_draw_items = [item for _items in PLAYER['ai']['visible_items'].values() for item in _items]
	
	for entity_id in _draw_items:
		if not entity_id in entities.ENTITIES:
			continue
		
		_entity = entities.get_entity(entity_id)
		
		if _entity['stats']['owner']:
			continue
		
		_x, _y = movement.get_position(_entity)
		_x -= _camera_x
		_y -= _camera_y
		
		if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
			continue
		
		_label = _entity['stats']['name']
		_render_x = numbers.clip(_x - len(_label)/2, 0, _width - len(_label))
		_render_y = numbers.clip(_y + 2, 0, _height)
		
		if _render_y == _y:
			_render_y -= 1
		
		display.write_string('ui', _render_x, _render_y, _label)
Ejemplo n.º 3
0
def light(x, y, brightness, r=1., g=1., b=1., light_map=None):
	if '--no-fx' in sys.argv:
		return
	
	if light_map:
		_active_light_maps = zones.get_active_light_maps()
		_light_map = _active_light_maps[light_map]
	
	else:
		_light_map = post_processing.get_light_map()
	
	_width, _height = zones.get_active_size()
	
	for _x, _y in shapes.circle(x, y, brightness):
		if _x < 0 or _x >= _width or _y < 0 or _y >= _height:
			continue
		
		_brightness = 1 - ((numbers.float_distance((x, y), (_x, _y)) - 1.0) / float(brightness))
		_r = numbers.clip(2 * (_brightness * r), 1, 4)
		_g = numbers.clip(2 * (_brightness * g), 1, 4)
		_b = numbers.clip(2 * (_brightness * b), 1, 4)
		
		_min_r = min(_light_map[0][_y, _x], _r)
		_max_r = max(_light_map[0][_y, _x], _r)
		
		_min_g = min([_light_map[1][_y, _x], _g])
		_max_g = max([_light_map[1][_y, _x], _g])
		
		_min_b = min([_light_map[2][_y, _x], _b])
		_max_b = max([_light_map[2][_y, _x], _b])
		
		_light_map[0][_y, _x] = numbers.interp(_min_r, _max_r, .5)
		_light_map[1][_y, _x] = numbers.interp(_min_g, _max_g, .5)
		_light_map[2][_y, _x] = numbers.interp(_min_b, _max_b, .5)
Ejemplo n.º 4
0
def _smoke_shooter_push(entity):
	_x, _y = movement.get_position(entity)
	_direction = movement.get_direction(entity)
	_mod = random.randint(-35, 35)
	_alpha = flags.get_flag(entity, 'alpha')
	
	if _mod < 0:
		_mod = numbers.clip(_mod, -35, -20)
	else:
		_mod = numbers.clip(_mod, 20, 35)
	
	_direction += _mod
	
	_v_x, _v_y = numbers.velocity(_direction, random.uniform(.65, .85))
	
	if not int(round(_x + _v_x)) == int(round(_x)) or not int(round(_y + _v_y)) == int(round(_y)):
		#smoke_cloud(_x + _v_x, _y + _v_y, random.randint(1, 2), start_alpha=_alpha, decay_amount=1.2)
		smoke(_x + _v_x, _y + _v_y, .75, start_amount=_alpha, decay_amount=random.uniform(3.0, 4.0))
	
	_x += _v_x
	_y += _v_y
	
	if (int(round(_x)), int(round(_y))) in zones.get_active_solids({}, no_life=True):
		entities.delete_entity(entity)
		
		return
	
	entities.trigger_event(entity, 'set_direction', direction=_direction)
	entities.trigger_event(entity, 'set_position', x=_x, y=_y)
	entities.trigger_event(entity, 'set_flag', flag='alpha', value=_alpha - .05)
Ejemplo n.º 5
0
def create():
	display.create_surface('background')
	display.create_surface('text')
	display.blit_background('background')
	
	roll()
	
	NOISE = tcod.noise_new(2, h=tcod.NOISE_DEFAULT_HURST, random=tcod.random_new())
	
	for y in range(0, constants.WINDOW_HEIGHT):
		for x in range(0, constants.WINDOW_WIDTH):
			_noise_values = [(ZOOM * x / (constants.WINDOW_WIDTH)),
			                 (ZOOM * y / (constants.WINDOW_HEIGHT))]
			_height = 1 - tcod.noise_get_turbulence(NOISE, _noise_values, tcod.NOISE_SIMPLEX)
			_dist_to_crosshair = 30
			_crosshair_mod = abs((_dist_to_crosshair - 1))
			
			if _height > .4:
				_height = (_height - .4) / .4
				_r, _g, _b = numbers.clip(30 * _height, 20, 255), 50 * _height, numbers.clip(30 * _height, 30, 255)
			
			else:
				_r, _g, _b = 20, 0, 30
			
			_r += 30# * _crosshair_mod
			
			if x < SIDEBAR_WIDTH:
				if y < 7:
					_r = numbers.interp(_r, .0, .4)
					_g = numbers.interp(_g, .0, .4)
					_b = numbers.interp(_b, .0, .4)
					
				elif y < 43:
					_r = numbers.interp(_r, .0, .6)
					_g = numbers.interp(_g, .0, .6)
					_b = numbers.interp(_b, .0, .6)
					
				elif y < constants.WINDOW_HEIGHT:
					_r = numbers.interp(_r, 1, .7)
					_g = numbers.interp(_g, 1, .7)
					_b = numbers.interp(_b, 1, .7)

				else:
					_r = (int(round(_r * 1.0)))
					_g = (int(round(_g * .2)))
					_b = (int(round(_b * .2)))
			
			if x > SIDEBAR_WIDTH + 3 and x < constants.WINDOW_WIDTH - 6:
				if y > 18 and y < 36:
					_r = numbers.interp(_r, 255, .1)
					_g = numbers.interp(_g, 255, .1)
					_b = numbers.interp(_b, 255, .1)
			
			if x > SIDEBAR_WIDTH + 3 and x < constants.WINDOW_WIDTH - 6:
				if y > 10 and y < 16:
					_r = numbers.interp(_r, .0, .4)
					_g = numbers.interp(_g, .0, .4)
					_b = numbers.interp(_b, .0, .4)
			
			display._set_char('background', x, y, ' ', (0, 0, 0), (_r, _g, _b))
Ejemplo n.º 6
0
def draw_life_memory():
	_camera_x, _camera_y = camera.X, camera.Y
	_width = display.get_surface('life')['width']
	_height = display.get_surface('life')['height']
	_draw_life = set()
	_can_see_life = set()
	_last_seen_locations = {}
		
	for squad_id in entities.get_entity_group('squads'):
		_squad = entities.get_entity(squad_id)
		
		if not _squad['faction'] == 'Rogues':
			continue
		
		for member_id in _squad['members']:
			_member = entities.get_entity(member_id)
			_can_see_life.update([i for i in _member['ai']['life_memory'] if _member['ai']['life_memory'][i]['can_see'] and i in entities.ENTITIES])
			_draw_life.update(_member['ai']['targets'] - _member['ai']['visible_life'])
			
			for memory_id in _member['ai']['life_memory'].keys():
				if not member_id in _last_seen_locations and _member['ai']['life_memory'][memory_id]['last_seen_at']:
					_last_seen_locations[memory_id] = _member['ai']['life_memory'][memory_id]['last_seen_at']
	
	_draw_life = list(_draw_life)

	for entity_id in _draw_life:
		if entity_id in _can_see_life or not entity_id in entities.ENTITIES:
			continue
		
		if not entity_id in _last_seen_locations:
			continue
		
		_entity = entities.get_entity(entity_id)
		_x, _y = _last_seen_locations[entity_id]
		_x -= _camera_x
		_y -= _camera_y
		
		if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
			continue
		
		if time.time() % 1 >= .5:
			_char = _entity['tile']['char']
			_fore_color = _entity['tile']['fore_color']
		else:
			_char = '!'
			_fore_color = (255, 0, 0)
		
		_render_x = numbers.clip(_x - len(_char)/2, 0, _width - len(_char) - 1)
		_render_y = numbers.clip(_y, 0, _height)
		
		#if _x - len(_char)/2 < 0 or _x + len(_char)/2 >= _width:
		#	continue
		
		if _render_y == _y:
			_render_y += 2
		
		display.write_string('ui', _render_x, _render_y, _char, fore_color=_fore_color)
Ejemplo n.º 7
0
def paint_map(initial=False):
    global SPARK_SIZE, REDRAW_RATE

    if REDRAW_RATE:
        REDRAW_RATE -= 1

        return

    REDRAW_RATE = 0.0

    if initial:
        _x_range = 0, constants.WINDOW_WIDTH
        _y_range = 0, constants.WINDOW_HEIGHT

    else:
        _x_range = 30, 50
        _y_range = 5, 20

    SPARK_SIZE = numbers.clip(SPARK_SIZE + random.uniform(-3, 3), 6.0, 12.0)

    for y in range(_y_range[0], _y_range[1]):
        for x in range(_x_range[0], _x_range[1]):
            _noise_values = [(ZOOM * x / (constants.WINDOW_WIDTH)),
                             (ZOOM * y / (constants.WINDOW_HEIGHT))]
            _height = 1 - tcod.noise_get_turbulence(NOISE, _noise_values,
                                                    tcod.NOISE_SIMPLEX)
            _dist_to_crosshair = numbers.clip(
                (abs(y - 12) *
                 (abs(x - 38))) / (SPARK_SIZE + random.uniform(-3.5, 1)), 0, 1)
            #_height *= _dist_to_crosshair

            _crosshair_mod = abs((_dist_to_crosshair - 1))

            #if not initial and not _crosshair_mod:
            #	continue

            if _height > .4:
                _height = (_height - .4) / .4
                _r, _g, _b = numbers.clip(30 * _height, 20,
                                          255), 50 * _height, numbers.clip(
                                              30 * _height, 30, 255)

            else:
                _r, _g, _b = 20, 0, 30
                #_height = 1 - (_height / .5)
                #_r, _g, _b = 60 * _height, 60 * _height, 100 * _height

            _r += 80 * _crosshair_mod

            display._set_char('background', x, y, ' ', (0, 0, 0), (_r, _g, _b))

    display.blit_background('background')
Ejemplo n.º 8
0
def loop():
    global UNSCRAMBLE_TO, WHITE_VALUE, SUBTITLE_COLOR

    for i in range(len(COMPANY_STRING)):
        if i > UNSCRAMBLE_TO:
            _char = random.choice(COMPANY_STRING)
            _gray_color = int(round(255 * (UNSCRAMBLE_TO / i))) + random.randint(-15, 15)
            _fore_color = (_gray_color, _gray_color, _gray_color)

        else:
            _char = COMPANY_STRING[i]
            _r = numbers.clip(WHITE_VALUE - random.randint(0, 90), 0, 255)
            _g = _r
            _b = _r

            _fore_color = _r, _g, _b

        display.write_char(
            "text",
            (constants.WINDOW_WIDTH / 2) + i - (len(COMPANY_STRING) / 2),
            (constants.WINDOW_HEIGHT / 2) - 1,
            _char,
            fore_color=_fore_color,
        )

    display.write_string(
        "text",
        (constants.WINDOW_WIDTH / 2) - (len(SUBTITLE_TEXT) / 2),
        (constants.WINDOW_HEIGHT / 2) + 1,
        SUBTITLE_TEXT,
        fore_color=(SUBTITLE_COLOR, SUBTITLE_COLOR, SUBTITLE_COLOR),
    )

    if UNSCRAMBLE_TO > 6:
        SUBTITLE_COLOR = numbers.clip(SUBTITLE_COLOR + 2, 0, 255)

    if UNSCRAMBLE_TO > 25:
        WHITE_VALUE -= 2

        SUBTITLE_COLOR = numbers.clip(SUBTITLE_COLOR - 6, 0, 255)

    if UNSCRAMBLE_TO > 38:
        return False

    display.blit_surface("text")

    events.trigger_event("draw")

    UNSCRAMBLE_TO += 0.1

    return True
Ejemplo n.º 9
0
def draw_long_range_life():
	_camera_x, _camera_y = camera.X, camera.Y
	_width = display.get_surface('life')['width']
	_height = display.get_surface('life')['height']
	_draw_life_targets = set()
	
	if settings.OBSERVER_MODE:
		_draw_life = entities.get_entity_group('life')
	else:
		_draw_life = set()
		
		for squad_id in entities.get_entity_group('squads'):
			_squad = entities.get_entity(squad_id)
			
			if not _squad['faction'] == 'Rogues':
				continue
			
			for member_id in _squad['members']:
				_member = entities.get_entity(member_id)
				_draw_life.add(member_id)
				_draw_life.update([i for i in _member['ai']['life_memory'] if _member['ai']['life_memory'][i]['can_see'] and i in entities.ENTITIES])
				_draw_life_targets.update([i for i in _member['ai']['life_memory'] if _member['ai']['life_memory'][i]['can_see'] and _member['ai']['life_memory'][i]['is_target'] and i in entities.ENTITIES])
		
		_draw_life = list(_draw_life)
	
	for entity_id in _draw_life:
		_entity = entities.get_entity(entity_id)
		_x, _y = movement.get_position(_entity)
		_x -= _camera_x
		_y -= _camera_y
		
		if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
			_x = numbers.clip(_x, 0, _width-1)
			_y = numbers.clip(_y, 0, _height-1)
		else:
			continue
		
		if time.time() % 1 >= .5:
			_char = 'X'
		else:
			_char = 'O'
		
		if entity_id in _draw_life_targets:
			_fore_color = (255, 0, 0)
			_back_color = (100, 0, 0)
		else:
			_fore_color = (255, 255, 255)
			_back_color = (100, 100, 100)
		
		display.write_string('ui', _x, _y, _char, fore_color=_fore_color, back_color=_back_color)
Ejemplo n.º 10
0
def generate_shadow_map(width, height, solids, trees, inside):
    global SHADOWS

    SHADOWS = display.create_shader(width, height)
    SHADOWS[0] += 1
    SHADOWS[1] += 1
    SHADOWS[2] += 1

    _taken = set()

    for x, y in solids:
        if (x, y) in trees:
            continue

        for y1 in range(-3, 4):
            for x1 in range(-3, 4):
                if (x + x1,
                        y + y1) in solids or (x + x1, y + y1) in inside or (
                            x + x1, y + y1
                        ) in _taken or x + x1 >= width or y + y1 >= height:
                    continue

                _shadow = numbers.clip(
                    numbers.distance((x, y),
                                     (x + x1, y + y1)) / 5.0, .25, .6) + .25

                if _shadow < SHADOWS[0][y + y1][x + x1]:
                    SHADOWS[0][y + y1][x + x1] = _shadow
                    SHADOWS[1][y + y1][x + x1] = _shadow
                    SHADOWS[2][y + y1][x + x1] = _shadow

    _taken = set()

    for _x, _y in trees.keys():
        _tree_size = float(trees[_x, _y])

        for x, y in shapes.circle(_x, _y, int(_tree_size)):
            if (x, y) in solids or x >= width or y >= height or x < 0 or y < 0:
                continue

            _distance = numbers.float_distance((x, y), (_x, _y)) * 1.25
            _shadow = numbers.clip(1 - ((_distance / _tree_size) + .25), .1,
                                   .9)

            SHADOWS[0][y][x] = numbers.clip(SHADOWS[0][y][x] - _shadow, .45, 1)
            SHADOWS[1][y][x] = numbers.clip(SHADOWS[1][y][x] - _shadow, .45, 1)
            SHADOWS[2][y][x] = numbers.clip(SHADOWS[2][y][x] - _shadow, .45, 1)

    return SHADOWS
Ejemplo n.º 11
0
def paint_map(initial=False):
    global SPARK_SIZE, REDRAW_RATE

    if REDRAW_RATE:
        REDRAW_RATE -= 1

        return

    REDRAW_RATE = 0.0

    if initial:
        _x_range = 0, constants.WINDOW_WIDTH
        _y_range = 0, constants.WINDOW_HEIGHT

    else:
        _x_range = 30, 50
        _y_range = 5, 20

    SPARK_SIZE = numbers.clip(SPARK_SIZE + random.uniform(-3, 3), 6.0, 12.0)

    for y in range(_y_range[0], _y_range[1]):
        for x in range(_x_range[0], _x_range[1]):
            _noise_values = [(ZOOM * x / (constants.WINDOW_WIDTH)), (ZOOM * y / (constants.WINDOW_HEIGHT))]
            _height = 1 - tcod.noise_get_turbulence(NOISE, _noise_values, tcod.NOISE_SIMPLEX)
            _dist_to_crosshair = numbers.clip(
                (abs(y - 12) * (abs(x - 38))) / (SPARK_SIZE + random.uniform(-3.5, 1)), 0, 1
            )
            # _height *= _dist_to_crosshair

            _crosshair_mod = abs((_dist_to_crosshair - 1))

            # if not initial and not _crosshair_mod:
            # 	continue

            if _height > 0.4:
                _height = (_height - 0.4) / 0.4
                _r, _g, _b = numbers.clip(30 * _height, 20, 255), 50 * _height, numbers.clip(30 * _height, 30, 255)

            else:
                _r, _g, _b = 20, 0, 30
                # _height = 1 - (_height / .5)
                # _r, _g, _b = 60 * _height, 60 * _height, 100 * _height

            _r += 80 * _crosshair_mod

            display._set_char("background", x, y, " ", (0, 0, 0), (_r, _g, _b))

    display.blit_background("background")
Ejemplo n.º 12
0
def loop():
    global UNSCRAMBLE_TO, WHITE_VALUE, SUBTITLE_COLOR

    for i in range(len(COMPANY_STRING)):
        if i > UNSCRAMBLE_TO:
            _char = random.choice(COMPANY_STRING)
            _gray_color = int(round(
                255 * (UNSCRAMBLE_TO / i))) + random.randint(-15, 15)
            _fore_color = (_gray_color, _gray_color, _gray_color)

        else:
            _char = COMPANY_STRING[i]
            _r = numbers.clip(WHITE_VALUE - random.randint(0, 90), 0, 255)
            _g = _r
            _b = _r

            _fore_color = _r, _g, _b

        display.write_char('text', (constants.WINDOW_WIDTH / 2) + i -
                           (len(COMPANY_STRING) / 2),
                           (constants.WINDOW_HEIGHT / 2) - 1,
                           _char,
                           fore_color=_fore_color)

    display.write_string(
        'text', (constants.WINDOW_WIDTH / 2) - (len(SUBTITLE_TEXT) / 2),
        (constants.WINDOW_HEIGHT / 2) + 1,
        SUBTITLE_TEXT,
        fore_color=(SUBTITLE_COLOR, SUBTITLE_COLOR, SUBTITLE_COLOR))

    if UNSCRAMBLE_TO > 6:
        SUBTITLE_COLOR = numbers.clip(SUBTITLE_COLOR + 2, 0, 255)

    if UNSCRAMBLE_TO > 25:
        WHITE_VALUE -= 2

        SUBTITLE_COLOR = numbers.clip(SUBTITLE_COLOR - 6, 0, 255)

    if UNSCRAMBLE_TO > 38:
        return False

    display.blit_surface('text')

    events.trigger_event('draw')

    UNSCRAMBLE_TO += .1

    return True
Ejemplo n.º 13
0
def create_noise(entity, text, volume, owner_can_hear=False, show_on_sight=False, direction=-1000, callback=None, context_callback=None):
	_x, _y = movement.get_position(entity)
	
	for entity_id in entities.get_entity_group('life'):
		if not owner_can_hear and entity['_id'] == entity_id:
			continue
		
		_target = entities.get_entity(entity_id)
		
		if entity['ai']['faction'] == _target['ai']['faction']:
			continue
		
		#TODO: Hearing stat
		_distance = numbers.distance(movement.get_position(entity), movement.get_position(_target))
		_accuracy = 1 - numbers.clip(_distance / float(volume), 0, 1)
		
		entities.trigger_event(_target,
		                       'heard_noise',
		                       x=_x,
		                       y=_y,
		                       text=text,
		                       direction=direction,
		                       show_on_sight=show_on_sight,
		                       accuracy=_accuracy,
		                       callback=callback,
		                       context_callback=context_callback)
Ejemplo n.º 14
0
def smoke(x, y, amount, start_amount=0.0, decay_amount=1.0):
	_blood = _create(x, y)
	_x, _y = (int(round(x)), int(round(y)))
	_fore_color = random.choice([constants.BLACK_1, constants.BLACK_2, constants.BLACK_3])
	_back_color = random.choice([constants.BLACK_1, constants.BLACK_2, constants.BLACK_3])
	
	amount = numbers.clip(amount + random.uniform(-.1, .1), 0, 1)	
	
	entities.trigger_event(_blood, 'set_char', char=' ')
	flags.register(_blood)
	flags.set_flag(_blood, 'alpha', value=start_amount)
	flags.set_flag(_blood, 'decay', value=decay_amount)
	flags.set_flag(_blood, 'alpha_mode', value=0)
	flags.set_flag(_blood, 'alpha_max', value=amount)
	flags.set_flag(_blood, 'fore_color', value=_fore_color)
	flags.set_flag(_blood, 'back_color', value=_back_color)
	
	_color = list(display.get_color_at('tiles', _x, _y))
	_color[0] = numbers.interp_velocity(_color[0], _fore_color, amount)
	_color[1] = numbers.interp_velocity(_color[1], _back_color, amount)
	
	for c in range(len(_color)):
		for i in range(len(_color)):
			_color[c][i] = int((round(_color[c][i])))
	
	entities.trigger_event(_blood, 'set_fore_color', color=_color[0])
	entities.trigger_event(_blood, 'set_back_color', color=_color[1])
	
	entities.register_event(_blood, 'tick', _tick_smoke)

	return _blood
Ejemplo n.º 15
0
def _explosive_tick(entity):
    _direction = movement.get_direction(entity)

    entities.trigger_event(entity, 'push_tank', direction=_direction)

    _x, _y = movement.get_position(entity)
    _distance = numbers.distance((_x, _y), entity['end_position'])
    _starting_target_distance = numbers.distance(entity['start_position'],
                                                 entity['end_position'])

    if _distance <= entity['accuracy'] * 2.5:
        entity['slow_down'] = True

    if entity['slow_down']:
        entity['speed'] = numbers.clip(entity['speed'] * 1.2, 0, 40)

    if entity['speed'] < 40:
        entities.trigger_event(entity,
                               'create_timer',
                               time=int(round(entity['speed'])),
                               name='movement',
                               exit_callback=_explosive_tick)

    else:
        entities.trigger_event(entity, 'activate_explosive')
Ejemplo n.º 16
0
def _fade_out():
    global FADE_VALUE, NEED_FADE_IN

    FADE_VALUE = numbers.clip(FADE_VALUE - FADE_STEP, 0, 255)

    if not FADE_VALUE:
        NEED_FADE_IN = True
Ejemplo n.º 17
0
def _tick_fire(entity):
	_x, _y = movement.get_position(entity)
	_alpha = flags.get_flag(entity, 'alpha')
	_alpha += random.uniform(-.3, .3)
	_alpha = numbers.clip(_alpha, 0, 1)
	
	if not _alpha:
		#char(_x, _y, numbers.clip(flags.get_flag(entity, 'alpha_max') - random.uniform(.1, .2), 0, 1))
		entities.delete_entity(entity)
		
		return
	
	#entities.trigger_event(entity, 'set_char', char=random.choice(['*', '&', '%']))

	_color = list(display.get_color_at('tiles', _x, _y))
	_color[0] = numbers.interp_velocity(_color[0], random.choice([constants.FIRE_1, constants.FIRE_2, constants.FIRE_3]), _alpha)
	_color[1] = numbers.interp_velocity(_color[1], random.choice([constants.FIRE_1, constants.FIRE_2, constants.FIRE_3]), _alpha)
	
	for c in range(len(_color)):
		for i in range(len(_color)):
			_color[c][i] = int((round(_color[c][i])))
	
	entities.trigger_event(entity, 'set_fore_color', color=_color[0])
	entities.trigger_event(entity, 'set_back_color', color=_color[1])
	entities.trigger_event(entity, 'set_flag', flag='alpha', value=_alpha)
Ejemplo n.º 18
0
def draw_path(entity, x_mod=0, y_mod=0):
	_last_x, _last_y = (0, 0)
	_node_ids = entity['node_grid']['path'][:]
	_action_time_max = 0
	_surface_width = display.get_surface('nodes')['width']
	_surface_height = display.get_surface('nodes')['height']
	
	for node_id in _node_ids:
		_node = entity['node_grid']['nodes'][node_id]
		
		if not _last_x:
			_last_x, _last_y = movement.get_position(entity)
		
		if (_last_x, _last_y) == (_node['node']['x'], _node['node']['y']):
			continue
		
		_node['node']['busy_pos'] = []
		
		if _node['node']['draw_path'] and not _node['node']['path']:
			_path = pathfinding.astar((_last_x, _last_y), (_node['node']['x'], _node['node']['y']), zones.get_active_astar_map(), zones.get_active_weight_map())
			
			if (_node['node']['x'], _node['node']['y']) in _path:
				_path.remove((_node['node']['x'], _node['node']['y']))
			
			_node['node']['path'] = _path
		
		_move_cost = 0
		for pos in _node['node']['path']:
			for node_id in _node_ids:
				_check_node = entity['node_grid']['nodes'][node_id]['node']
				
				if not _check_node['action_time']:
					continue
				
				if (_check_node['x'], _check_node['y']) == pos:
					_action_time_max = _check_node['action_time']
			
			if _action_time_max and _move_cost <= _action_time_max:
				_color_mod = int(round(200*numbers.clip(_move_cost/float(_action_time_max), .75, 1)))
				_color = (_color_mod, 0, 0)
				
				_node['node']['busy_pos'].append(pos)
			
			else:
				_color = (200, 200, 200)
			
			if _action_time_max:
				_move_cost += movement.get_move_cost(entity)
				
				if _move_cost >= _action_time_max:
					_action_time_max = 0
					_move_cost = 0
			
			if pos[0]-x_mod < 0 or pos[1]-y_mod < 0 or pos[0]-x_mod >= _surface_width or pos[1]-y_mod >= _surface_height:
				continue
			
			display.write_char('nodes', pos[0]-x_mod, pos[1]-y_mod, chr(177), fore_color=_color)
		
		if _node['node']['draw_path']:
			_last_x, _last_y = (_node['node']['x'], _node['node']['y'])
Ejemplo n.º 19
0
def _fade_out():
	global FADE_VALUE, NEED_FADE_IN
	
	FADE_VALUE = numbers.clip(FADE_VALUE - FADE_STEP, 0, 255)
	
	if not FADE_VALUE:
		NEED_FADE_IN = True
Ejemplo n.º 20
0
def create_noise(entity,
                 text,
                 volume,
                 owner_can_hear=False,
                 show_on_sight=False,
                 direction=-1000,
                 callback=None,
                 context_callback=None):
    _x, _y = movement.get_position(entity)

    for entity_id in entities.get_entity_group('life'):
        if not owner_can_hear and entity['_id'] == entity_id:
            continue

        _target = entities.get_entity(entity_id)

        if entity['ai']['faction'] == _target['ai']['faction']:
            continue

        #TODO: Hearing stat
        _distance = numbers.distance(movement.get_position(entity),
                                     movement.get_position(_target))
        _accuracy = 1 - numbers.clip(_distance / float(volume), 0, 1)

        entities.trigger_event(_target,
                               'heard_noise',
                               x=_x,
                               y=_y,
                               text=text,
                               direction=direction,
                               show_on_sight=show_on_sight,
                               accuracy=_accuracy,
                               callback=callback,
                               context_callback=context_callback)
Ejemplo n.º 21
0
def hit(entity, projectile, damage_mod=1.0):
    _accuracy = random.uniform(.7, 1)
    _hit_map = []

    for limb_name in entity['skeleton']['limbs']:
        _limb = entity['skeleton']['limbs'][limb_name]

        for i in range(int(round(_limb['health'] * _limb['accuracy']))):
            _hit_map.append(limb_name)

    _limb_name = random.choice(_hit_map)
    _limb = entity['skeleton']['limbs'][_limb_name]
    _damage = int(
        round((projectile['damage'] * _accuracy) * (numbers.clip(
            (1 - _limb['accuracy']), 0.25, .6) + .4)))
    _damage = int(round(_damage * damage_mod))
    _limb['health'] -= _damage
    _x, _y = movement.get_position(entity)
    _x += int(round(random.uniform(-1, 1)))
    _y += int(round(random.uniform(-1, 1)))
    _mod = _limb['health'] / float(_limb['max_health'])

    #effects.explosion(_x, _y, 6)

    if not (_x, _y) in zones.get_active_solids(entity,
                                               ignore_calling_entity=True):
        #effects.blood(_x, _y)
        effects.blood_splatter(
            _x, _y,
            movement.get_direction(projectile) + random.randint(-5, 5))
        entities.trigger_event(entity,
                               'animate',
                               animation=['X', '@@'],
                               repeat=4 * int(round((1 - _mod))),
                               delay=20 * _mod)

    if _limb['health'] <= 0:
        if _limb['critical']:
            if projectile['owner'] in entities.ENTITIES:
                entities.trigger_event(entities.get_entity(
                    projectile['owner']),
                                       'log_kill',
                                       target_id=entity['_id'])
                entities.trigger_event(entity,
                                       'killed_by',
                                       target_id=projectile['owner'])

            #entity['stats']['grave'] = {'':}
            entities.delete_entity(entity)
    else:
        if projectile['owner'] in entities.ENTITIES:
            entities.trigger_event(entities.get_entity(projectile['owner']),
                                   'did_damage',
                                   target_id=entity['_id'],
                                   damage=_damage)

        entities.trigger_event(entity,
                               'damage',
                               limb=_limb_name,
                               damage=_damage)
Ejemplo n.º 22
0
def explosive(entity, x, y, tx, ty, speed, accuracy, damage):
	_entity = _create(x, y, 'Explosive', '.', 0, 'bullet')
	_entity['owner'] = entity['_id']
	_entity['start_position'] = (x, y)
	_entity['end_position'] = (tx, ty)
	_entity['speed'] = speed
	_entity['damage'] = damage
	_toss_distance = numbers.distance(_entity['start_position'], _entity['end_position'])
	_entity['accuracy'] = numbers.clip(random.randint(int(round(accuracy * .25)), accuracy), 0, 100) - (accuracy * (1 - (_toss_distance / 20.0)))
	_entity['slow_down'] = False
	_direction_mod = random.uniform(-accuracy, accuracy) * 2
	
	entities.create_event(_entity, 'explode')
	entities.create_event(_entity, 'activate_explosive')
	entities.register_event(_entity, 'explode', frag_grenade_explode)
	entities.register_event(_entity, 'explode', entities.delete_entity)
	entities.register_event(_entity, 'activate_explosive', lambda e: entities.trigger_event(e, 'create_timer', time=90, exit_callback=lambda ee: entities.trigger_event(ee, 'explode')))
	entities.register_event(_entity, 'check_next_position', check_next_position)
	
	entities.add_entity_to_group(_entity, 'bullets')
	timers.register(_entity)
	
	entities.trigger_event(_entity, 'set_direction', direction=numbers.direction_to((x, y), (tx, ty)) + _direction_mod)
	entities.trigger_event(_entity, 'create_timer', time=speed, enter_callback=_explosive_tick, name='movement')
	entities.register_event(_entity, 'position_changed', lambda e, **kwargs: check_for_collisions(e))
	
	if not '--no-fx' in sys.argv:
		entities.register_event(_entity, 'position_changed', lambda e, x, y, **kwargs: _bullet_effects(e, x, y))
	
	entities.register_event(_entity, 'collision_with_entity', lambda e, **kwargs: entities.trigger_event(e, 'activate_explosive'))
	entities.register_event(_entity, 'collision_with_entity', lambda e, **kwargs: _explosive_stop_dumb_hack(e))
	entities.register_event(_entity, 'collision_with_solid', lambda e: timers.stop_timer(e, 'movement'))
	entities.register_event(_entity, 'collision_with_solid', _explosive_stop_dumb_hack)
	entities.register_event(_entity, 'collision_with_solid', lambda e: entities.trigger_event(e, 'activate_explosive'))
Ejemplo n.º 23
0
def get_stat_mod(entity, stat, subtract=False):
    for limb_name in entity['skeleton']['limbs']:
        _limb = entity['skeleton']['limbs'][limb_name]

        if stat in _limb['stat_mod']:
            _mod = _limb['health'] / float(_limb['max_health'])

            if subtract:
                entity['stats'][stat] *= numbers.clip(
                    1 - (1 - _mod), 1 - _limb['stat_mod'][stat], 1)

            else:
                entity['stats'][stat] *= numbers.clip(
                    1 + (1 - _mod), 1, 1 + _limb['stat_mod'][stat])

    return int(round(entity['stats'][stat]))
Ejemplo n.º 24
0
def _reload_weapon(entity, weapon_id, ammo_id):
    _weapon = entities.get_entity(weapon_id)
    _ammo = entities.get_entity(ammo_id)
    _weapon_ammo = flags.get_flag(_weapon, 'ammo')
    _weapon_ammo_max = flags.get_flag(_weapon, 'ammo_max')
    _ammo_count = flags.get_flag(_ammo, 'ammo')

    if _weapon_ammo == _weapon_ammo_max:
        return

    _need_ammo = numbers.clip(_weapon_ammo_max - _weapon_ammo, 1, _ammo_count)
    _ammo_count -= _need_ammo

    entities.trigger_event(_weapon,
                           'set_flag',
                           flag='ammo',
                           value=_weapon_ammo + _need_ammo)

    if _ammo_count:
        entities.trigger_event(_ammo,
                               'set_flag',
                               flag='ammo',
                               value=_ammo_count)
    else:
        entities.delete_entity(_ammo)
Ejemplo n.º 25
0
def explosive(entity, x, y, tx, ty, speed, accuracy, damage):
    _entity = _create(x, y, 'Explosive', '.', 0, 'bullet')
    _entity['owner'] = entity['_id']
    _entity['start_position'] = (x, y)
    _entity['end_position'] = (tx, ty)
    _entity['speed'] = speed
    _entity['damage'] = damage
    _toss_distance = numbers.distance(_entity['start_position'],
                                      _entity['end_position'])
    _entity['accuracy'] = numbers.clip(
        random.randint(int(round(accuracy * .25)), accuracy), 0,
        100) - (accuracy * (1 - (_toss_distance / 20.0)))
    _entity['slow_down'] = False
    _direction_mod = random.uniform(-accuracy, accuracy) * 2

    entities.create_event(_entity, 'explode')
    entities.create_event(_entity, 'activate_explosive')
    entities.register_event(_entity, 'explode', frag_grenade_explode)
    entities.register_event(_entity, 'explode', entities.delete_entity)
    entities.register_event(
        _entity, 'activate_explosive', lambda e: entities.trigger_event(
            e,
            'create_timer',
            time=90,
            exit_callback=lambda ee: entities.trigger_event(ee, 'explode')))
    entities.register_event(_entity, 'check_next_position',
                            check_next_position)

    entities.add_entity_to_group(_entity, 'bullets')
    timers.register(_entity)

    entities.trigger_event(_entity,
                           'set_direction',
                           direction=numbers.direction_to(
                               (x, y), (tx, ty)) + _direction_mod)
    entities.trigger_event(_entity,
                           'create_timer',
                           time=speed,
                           enter_callback=_explosive_tick,
                           name='movement')
    entities.register_event(_entity, 'position_changed',
                            lambda e, **kwargs: check_for_collisions(e))

    if not '--no-fx' in sys.argv:
        entities.register_event(
            _entity, 'position_changed',
            lambda e, x, y, **kwargs: _bullet_effects(e, x, y))

    entities.register_event(
        _entity, 'collision_with_entity',
        lambda e, **kwargs: entities.trigger_event(e, 'activate_explosive'))
    entities.register_event(_entity, 'collision_with_entity',
                            lambda e, **kwargs: _explosive_stop_dumb_hack(e))
    entities.register_event(_entity, 'collision_with_solid',
                            lambda e: timers.stop_timer(e, 'movement'))
    entities.register_event(_entity, 'collision_with_solid',
                            _explosive_stop_dumb_hack)
    entities.register_event(
        _entity, 'collision_with_solid',
        lambda e: entities.trigger_event(e, 'activate_explosive'))
Ejemplo n.º 26
0
def draw_life_labels():
    _camera_x, _camera_y = camera.X, camera.Y
    _width = display.get_surface('life')['width']
    _height = display.get_surface('life')['height']

    if settings.OBSERVER_MODE:
        _draw_life = entities.get_entity_group('life')
    else:
        _draw_life = [
            i for i in PLAYER['ai']['life_memory']
            if PLAYER['ai']['life_memory'][i]['can_see']
        ]

        if PLAYER['_id'] in entities.ENTITIES:
            _draw_life.append(PLAYER['_id'])

    for entity_id in _draw_life:
        _entity = entities.get_entity(entity_id)
        _x, _y = movement.get_position(_entity)
        _x -= _camera_x
        _y -= _camera_y

        if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
            continue

        _back_color = None

        if settings.OBSERVER_MODE:
            _label = _entity['ai']['current_action']
        else:
            _label = life.get_status_string(_entity)

            if not PLAYER['_id'] == entity_id and PLAYER['ai']['life_memory'][
                    entity_id]['mission_related'] and time.time() % 1 >= .5:
                _back_color = (200, 0, 0)

        _render_x = numbers.clip(_x - len(_label) / 2, 0, _width - len(_label))
        _render_y = numbers.clip(_y - 2, 0, _height)

        if _render_y == _y:
            _render_y += 2

        display.write_string('ui',
                             _render_x,
                             _render_y,
                             _label,
                             back_color=_back_color)
Ejemplo n.º 27
0
def update_position_maps(squad):
	_t = time.time()
	
	_coverage_positions = squad['coverage_positions']
	_known_targets = squad['known_targets']
	_known_squads = squad['known_squads']
	_known_targets_left_to_check = _known_targets.copy()
	_score_map = {pos: {'coverage': 0, 'vantage': 100, 'member_coverage': 0, 'danger': 0, 'targets': [], 'owned': False} for pos in _coverage_positions}
	
	for faction_name, squad_id in _known_squads:
		if not squad_id in ai_factions.FACTIONS[faction_name]['squads']:
			continue
		
		_squad = entities.get_entity(ai_factions.FACTIONS[faction_name]['squads'][squad_id])
		_member_set = set(_squad['members'])
		_check_members = _known_targets_left_to_check & _member_set
		_known_targets_left_to_check = _known_targets_left_to_check - _member_set
		
		for target_id in list(_check_members):
			_target_position = movement.get_position_via_id(target_id)
			_closest_member = {'distance': 0, 'member_id': None}
			
			for member_id in squad['members']:
				_member_position = movement.get_position_via_id(member_id)
				_distance = numbers.clip(numbers.distance(_target_position, _member_position), 0, 60)
				
				if not _closest_member['member_id'] or _distance < _closest_member['distance']:
					_closest_member['distance'] = _distance
					_closest_member['member_id'] = member_id
			
			_target_coverage_map = _squad['member_position_maps'][target_id]
			_overlap_positions = _coverage_positions & _target_coverage_map
			_cover_positions = _coverage_positions - _target_coverage_map
			
			if not _closest_member['member_id']:
				logging.warning('Couldn\'t find closest member for target during squad positioning.')
				
				continue
			
			_closest_member_pos = movement.get_position_via_id(_closest_member['member_id'])
			
			for pos in _overlap_positions:
				_distance = numbers.distance(_closest_member_pos, pos)
				
				if _distance < _score_map[pos]['vantage']:
					_score_map[pos]['vantage'] = _distance
				
				#_score_map[pos]['danger'] = 60 - _distance
				_score_map[pos]['targets'].append(target_id)
			
			for pos in _cover_positions:
				_distance = numbers.distance(_closest_member_pos, pos)
								
				if _distance > _score_map[pos]['coverage']:
					_score_map[pos]['coverage'] = _distance
				
				_score_map[pos]['danger'] = 60 - _distance
	
	squad['position_map_scores'] = _score_map
Ejemplo n.º 28
0
def add_respect(entity, target_id):
	_target = entities.get_entity(target_id)
	_respect = entity['stats']['respect']
	_target_respect = _target['stats']['respect']
	
	if _respect >= _target_respect:
		_target_respect *= 1 - numbers.clip((_respect - _target_respect) / 10.0, 0, 1)
	
	entities.trigger_event(entity, 'set_respect', respect = entity['stats']['respect'] + int(round(_target_respect)))
Ejemplo n.º 29
0
def generate_shadow_map(width, height, solids, trees, inside):
	global SHADOWS
	
	SHADOWS = display.create_shader(width, height)
	SHADOWS[0] += 1
	SHADOWS[1] += 1
	SHADOWS[2] += 1
	
	_taken = set()
	
	for x, y in solids:
		if (x, y) in trees:
			continue
		
		for y1 in range(-3, 4):
			for x1 in range(-3, 4):
				if (x+x1, y+y1) in solids or (x+x1, y+y1) in inside or (x+x1, y+y1) in _taken or x+x1 >= width or y+y1 >= height:
					continue
				
				_shadow = numbers.clip(numbers.distance((x, y), (x+x1, y+y1))/5.0, .25, .6) + .25
			
				if _shadow < SHADOWS[0][y+y1][x+x1]:
					SHADOWS[0][y+y1][x+x1] = _shadow
					SHADOWS[1][y+y1][x+x1] = _shadow
					SHADOWS[2][y+y1][x+x1] = _shadow
	
	_taken = set()
	
	for _x, _y in trees.keys():
		_tree_size = float(trees[_x, _y])
		
		for x, y in shapes.circle(_x, _y, int(_tree_size)):
			if (x, y) in solids or x >= width or y >= height or x < 0 or y <0:
				continue
			
			_distance = numbers.float_distance((x, y), (_x, _y))*1.25
			_shadow = numbers.clip(1 - ((_distance / _tree_size) + .25), .1, .9)
			
			SHADOWS[0][y][x] = numbers.clip(SHADOWS[0][y][x]-_shadow, .45, 1)
			SHADOWS[1][y][x] = numbers.clip(SHADOWS[1][y][x]-_shadow, .45, 1)
			SHADOWS[2][y][x] = numbers.clip(SHADOWS[2][y][x]-_shadow, .45, 1)
	
	return SHADOWS
Ejemplo n.º 30
0
def _bullet_effects(entity, x, y):
	_distance = numbers.distance((x, y), entity['start_position'])
	_target_distance = numbers.distance((x, y), entity['end_position']) + numbers.clip(10 - _distance, 0, 10) 
	_x, _y = movement.get_position(entity)
	_mod = (0.6 - (_distance / 35.0)) + random.uniform(-.1, .1)
	_alpha = numbers.clip(_mod, 0, 1)
	_crash_dist = 60 - (entity['speed'] * 2)
	
	if _alpha > 0:
		effects.vapor(x, y, start_alpha=_alpha)
	
	if _target_distance < 30:
		_size = int(round(2 * (1 - (1 * numbers.clip(numbers.clip(_target_distance, 0, 100)/60.0, 0, 1))))) + random.randint(1, 2)
		
		if _distance > _crash_dist:
			_size = int(round(_size * (_crash_dist/float(_distance))))
		
		if _size > 1:
			effects.light(_x, _y, _size, r=1.3, g=1.3, b=1.3)
Ejemplo n.º 31
0
def explosion(x, y, size):
	_solids = zones.get_active_solids({}, no_life=True)
	
	for pos in shapes.circle_smooth(x, y, size + .1, 0.05):
		_c_mod = 1 - (numbers.float_distance((x, y), pos) / size)
		_c_mod_clip = numbers.clip(1 - numbers.float_distance((x, y), pos) / size, random.uniform(.3, .45), 1)
		
		if pos in _solids or set(shapes.line((x, y), (int(round(pos[0])), int(round(pos[1]))))) & _solids:
			continue
		
		smoke(pos[0], pos[1], _c_mod_clip)
		
		if random.uniform(0, 1) < numbers.clip(_c_mod, 0, .75) and not pos in _solids:
			fire(pos[0], pos[1], _c_mod)
	
	for i in range(random.randint(2 * size, 3*size)):
		smoke_shooter(x, y, random.randint(0, 359))
	
	light(x, y, random.randint(7, 9), r=2.5, g=1.5, b=1.5)
	light(x, y, random.randint(13, 15), r=1.3, g=1.3, b=1.3)
Ejemplo n.º 32
0
def _fade_out():
	global FADE_VALUE
	
	FADE_VALUE = numbers.clip(FADE_VALUE - FADE_STEP, 0, 255)
	
	_fader = zones.get_active_fader()
	_fader[0] = _fader[0].clip(0, 0)
	_fader[0] += FADE_VALUE / 255.0
	_fader[1] = _fader[1].clip(0, 0)
	_fader[1] += FADE_VALUE / 255.0
	_fader[2] = _fader[2].clip(0, 0)
	_fader[2] += FADE_VALUE / 255.0
Ejemplo n.º 33
0
def _fade_out():
    global FADE_VALUE

    FADE_VALUE = numbers.clip(FADE_VALUE - FADE_STEP, 0, 255)

    _fader = zones.get_active_fader()
    _fader[0] = _fader[0].clip(0, 0)
    _fader[0] += FADE_VALUE / 255.0
    _fader[1] = _fader[1].clip(0, 0)
    _fader[1] += FADE_VALUE / 255.0
    _fader[2] = _fader[2].clip(0, 0)
    _fader[2] += FADE_VALUE / 255.0
Ejemplo n.º 34
0
def draw_life_labels():
	_camera_x, _camera_y = camera.X, camera.Y
	_width = display.get_surface('life')['width']
	_height = display.get_surface('life')['height']
	
	if settings.OBSERVER_MODE:
		_draw_life = entities.get_entity_group('life')
	else:
		_draw_life = [i for i in PLAYER['ai']['life_memory'] if PLAYER['ai']['life_memory'][i]['can_see']]
		
		if PLAYER['_id'] in entities.ENTITIES:
			_draw_life.append(PLAYER['_id'])
	
	for entity_id in _draw_life:
		_entity = entities.get_entity(entity_id)
		_x, _y = movement.get_position(_entity)
		_x -= _camera_x
		_y -= _camera_y
		
		if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
			continue
		
		_back_color = None
		
		if settings.OBSERVER_MODE:
			_label = _entity['ai']['current_action']
		else:
			_label = life.get_status_string(_entity)
			
			if not PLAYER['_id'] == entity_id and PLAYER['ai']['life_memory'][entity_id]['mission_related'] and time.time() % 1 >= .5:
				_back_color = (200, 0, 0)
		
		_render_x = numbers.clip(_x - len(_label)/2, 0, _width - len(_label))
		_render_y = numbers.clip(_y - 2, 0, _height)
		
		if _render_y == _y:
			_render_y += 2
		
		display.write_string('ui', _render_x, _render_y, _label, back_color=_back_color)
Ejemplo n.º 35
0
def _bullet_effects(entity, x, y):
    _distance = numbers.distance((x, y), entity['start_position'])
    _target_distance = numbers.distance(
        (x, y), entity['end_position']) + numbers.clip(10 - _distance, 0, 10)
    _x, _y = movement.get_position(entity)
    _mod = (0.6 - (_distance / 35.0)) + random.uniform(-.1, .1)
    _alpha = numbers.clip(_mod, 0, 1)
    _crash_dist = 60 - (entity['speed'] * 2)

    if _alpha > 0:
        effects.vapor(x, y, start_alpha=_alpha)

    if _target_distance < 30:
        _size = int(
            round(2 * (1 - (1 * numbers.clip(
                numbers.clip(_target_distance, 0, 100) / 60.0, 0, 1))))
        ) + random.randint(1, 2)

        if _distance > _crash_dist:
            _size = int(round(_size * (_crash_dist / float(_distance))))

        if _size > 1:
            effects.light(_x, _y, _size, r=1.3, g=1.3, b=1.3)
Ejemplo n.º 36
0
def draw_item_labels():
    _camera_x, _camera_y = camera.X, camera.Y
    _width = display.get_surface('life')['width']
    _height = display.get_surface('life')['height']

    if settings.OBSERVER_MODE:
        _draw_items = entities.get_entity_group('items')
    else:
        _draw_items = [
            item for _items in PLAYER['ai']['visible_items'].values()
            for item in _items
        ]

    for entity_id in _draw_items:
        if not entity_id in entities.ENTITIES:
            continue

        _entity = entities.get_entity(entity_id)

        if _entity['stats']['owner']:
            continue

        _x, _y = movement.get_position(_entity)
        _x -= _camera_x
        _y -= _camera_y

        if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
            continue

        _label = _entity['stats']['name']
        _render_x = numbers.clip(_x - len(_label) / 2, 0, _width - len(_label))
        _render_y = numbers.clip(_y + 2, 0, _height)

        if _render_y == _y:
            _render_y -= 1

        display.write_string('ui', _render_x, _render_y, _label)
Ejemplo n.º 37
0
def update():
	global X
	global Y	
	global LAST_X
	global LAST_Y
	
	X = numbers.clip(X, X_MIN, X_MAX)
	Y = numbers.clip(Y, Y_MIN, Y_MAX)
	
	_zone = zones.ZONES[zones.ACTIVE_ZONE]
	
	display.set_surface_camera('tiles', X, Y)
	display.reset_surface_shaders('tiles')
	
	if world_action.FADE_VALUE < 255:
		display.apply_surface_shader('tiles', zones.get_active_fader(), constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)
	
	for shader in _zone['shaders']:
		display.apply_surface_shader('tiles', shader, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)
	
	display.blit_surface_viewport('tiles', X, Y, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)
	
	LAST_X = X
	LAST_Y = Y
Ejemplo n.º 38
0
def post_process_clouds(width, height, passes, noise, inside):
	global CLOUD_X, CLOUD_Y
	
	_clouds = numpy.zeros((height, width))
	_clouds += 1.6
	_zoom = 2.0
	_clouds_x = (display.get_surface('tiles')['start_x']*.016)+CLOUD_X
	_clouds_y = (display.get_surface('tiles')['start_y']*.016)+(CLOUD_X * -.5)
	_size = 100.0
	_sunlight = SUNLIGHT
	
	if settings.TICK_MODE == 'normal':
		CLOUD_X -= numbers.clip(.003 * (settings.PLAN_TICK_RATE * .75), .003, 1)
	
	#HUGE decrease in FPS when using workers
	'''_worker = workers.counter_2d(width,
Ejemplo n.º 39
0
def _get_item(entity, item_id, hold=False, weight=None):
	_item = entities.get_entity(item_id)
	_x, _y = movement.get_position(_item)
	_distance = numbers.distance(movement.get_position(entity), (_x, _y))
	
	if weight:
		ai.set_meta_weight(entity, weight, 10*numbers.clip(_distance/30.0, 0, 1))
	
	if _distance:
		movement.walk_to_position(entity, _x, _y, zones.get_active_astar_map(), zones.get_active_weight_map(), smp=True)
	
	else:
		if hold:
			life.get_and_hold_item(entity, item_id)
		else:
			life.get_and_store_item(entity, item_id)
Ejemplo n.º 40
0
def _post_process_clouds(x, y, clouds, zoom, clouds_x, clouds_y, size, sunlight, noise, inside):
	_noise_values = [(zoom * x / (constants.MAP_VIEW_WIDTH)) + clouds_x,
	                 (zoom * y / (constants.MAP_VIEW_HEIGHT)) + clouds_y]
	_shade = tcod.noise_get_turbulence(noise, _noise_values, tcod.NOISE_SIMPLEX)
	_shade_mod = numbers.clip(abs(_shade), sunlight, 1)
	
	#TODO: Inside lighting
	#if not (camera.X+x, camera.Y+y) in inside:
	clouds[y][x] -= _shade_mod
	clouds[y][x] *= SHADOWS[camera.Y+y][camera.X+x].clip(SUNLIGHT-.5, 1)
	#else:
	#	clouds[y][x] *= SHADOWS[camera.Y+y][camera.X+x] #TODO: Inside lighting here
	
	#TODO: Future
	#clouds *= LIGHTS[camera.Y:camera.Y+y, camera.X:camera.X+x]
	
	clouds[y][x] *= LIGHTS[camera.Y+y, camera.X+x]
Ejemplo n.º 41
0
def post_process_clouds(width, height, passes, noise, inside):
    global CLOUD_X, CLOUD_Y

    _clouds = numpy.zeros((height, width))
    _clouds += 1.6
    _zoom = 2.0
    _clouds_x = (display.get_surface('tiles')['start_x'] * .016) + CLOUD_X
    _clouds_y = (display.get_surface('tiles')['start_y'] * .016) + (CLOUD_X *
                                                                    -.5)
    _size = 100.0
    _sunlight = SUNLIGHT

    if settings.TICK_MODE == 'normal':
        CLOUD_X -= numbers.clip(.003 * (settings.PLAN_TICK_RATE * .75), .003,
                                1)

    #HUGE decrease in FPS when using workers
    '''_worker = workers.counter_2d(width,
Ejemplo n.º 42
0
def _reload_weapon(entity, weapon_id, ammo_id):
	_weapon = entities.get_entity(weapon_id)
	_ammo = entities.get_entity(ammo_id)
	_weapon_ammo = flags.get_flag(_weapon, 'ammo')
	_weapon_ammo_max = flags.get_flag(_weapon, 'ammo_max')
	_ammo_count = flags.get_flag(_ammo, 'ammo')

	if _weapon_ammo == _weapon_ammo_max:
		return

	_need_ammo = numbers.clip(_weapon_ammo_max - _weapon_ammo, 1, _ammo_count)
	_ammo_count -= _need_ammo

	entities.trigger_event(_weapon, 'set_flag', flag='ammo', value=_weapon_ammo + _need_ammo)

	if _ammo_count:
		entities.trigger_event(_ammo, 'set_flag', flag='ammo', value=_ammo_count)
	else:
		entities.delete_entity(_ammo)
Ejemplo n.º 43
0
def _post_process_clouds(x, y, clouds, zoom, clouds_x, clouds_y, size,
                         sunlight, noise, inside):
    _noise_values = [(zoom * x / (constants.MAP_VIEW_WIDTH)) + clouds_x,
                     (zoom * y / (constants.MAP_VIEW_HEIGHT)) + clouds_y]
    _shade = tcod.noise_get_turbulence(noise, _noise_values,
                                       tcod.NOISE_SIMPLEX)
    _shade_mod = numbers.clip(abs(_shade), sunlight, 1)

    #TODO: Inside lighting
    #if not (camera.X+x, camera.Y+y) in inside:
    clouds[y][x] -= _shade_mod
    clouds[y][x] *= SHADOWS[camera.Y + y][camera.X + x].clip(SUNLIGHT - .5, 1)
    #else:
    #	clouds[y][x] *= SHADOWS[camera.Y+y][camera.X+x] #TODO: Inside lighting here

    #TODO: Future
    #clouds *= LIGHTS[camera.Y:camera.Y+y, camera.X:camera.X+x]

    clouds[y][x] *= LIGHTS[camera.Y + y, camera.X + x]
Ejemplo n.º 44
0
def _explosive_tick(entity):
	_direction = movement.get_direction(entity)
	
	entities.trigger_event(entity, 'push_tank', direction=_direction)
	
	_x, _y = movement.get_position(entity)
	_distance = numbers.distance((_x, _y), entity['end_position'])
	_starting_target_distance = numbers.distance(entity['start_position'], entity['end_position'])
	
	if _distance <= entity['accuracy'] * 2.5:
		entity['slow_down'] = True
	
	if entity['slow_down']:
		entity['speed'] = numbers.clip(entity['speed'] * 1.2, 0, 40)	
	
	if entity['speed'] < 40:
		entities.trigger_event(entity, 'create_timer', time=int(round(entity['speed'])), name='movement', exit_callback=_explosive_tick)
	
	else:
		entities.trigger_event(entity, 'activate_explosive')
Ejemplo n.º 45
0
def _tick_smoke(entity):
	_x, _y = movement.get_position(entity)
	_alpha = flags.get_flag(entity, 'alpha')
	_alpha_mode = flags.get_flag(entity, 'alpha_mode')
	_alpha_max = flags.get_flag(entity, 'alpha_max')
	_fore_color = flags.get_flag(entity, 'fore_color')
	_back_color = flags.get_flag(entity, 'back_color')
	_decay_mod = flags.get_flag(entity, 'decay')
	
	if _alpha_mode:
		_alpha -= random.uniform(.001 * _decay_mod, .005 * _decay_mod)
		
		if _alpha <= 0:
			display._set_char('tiles', _x, _y, ' ', (0, 0, 0), None)
			entities.delete_entity(entity)
			
			return
	
	else:
		_alpha += random.uniform(.01, .05)
		
		if _alpha > _alpha_max:
			_alpha_mode = 1
	
	_alpha = numbers.clip(_alpha, 0, 1)
	
	#entities.trigger_event(entity, 'set_char', char=random.choice(['*', '&', '%']))

	_color = list(display.get_color_at('tiles', _x, _y))
	_color[0] = numbers.interp_velocity(_color[0], _fore_color, _alpha)
	_color[1] = numbers.interp_velocity(_color[1], _back_color, _alpha)
	
	for c in range(len(_color)):
		for i in range(len(_color)):
			_color[c][i] = int((round(_color[c][i])))
	
	entities.trigger_event(entity, 'set_fore_color', color=_color[0])
	entities.trigger_event(entity, 'set_back_color', color=_color[1])
	
	entities.trigger_event(entity, 'set_flag', flag='alpha', value=_alpha)
	entities.trigger_event(entity, 'set_flag', flag='alpha_mode', value=_alpha_mode)
Ejemplo n.º 46
0
def _get_item(entity, item_id, hold=False, weight=None):
    _item = entities.get_entity(item_id)
    _x, _y = movement.get_position(_item)
    _distance = numbers.distance(movement.get_position(entity), (_x, _y))

    if weight:
        ai.set_meta_weight(entity, weight,
                           10 * numbers.clip(_distance / 30.0, 0, 1))

    if _distance:
        movement.walk_to_position(entity,
                                  _x,
                                  _y,
                                  zones.get_active_astar_map(),
                                  zones.get_active_weight_map(),
                                  smp=True)

    else:
        if hold:
            life.get_and_hold_item(entity, item_id)
        else:
            life.get_and_store_item(entity, item_id)
Ejemplo n.º 47
0
def handle_input():
    global MENU_ITEM_SELECTED

    events.trigger_event('input')

    if controls.get_input_ord_pressed(constants.KEY_ESCAPE):
        return False

    if controls.get_input_char_pressed('s'):
        MENU_ITEM_SELECTED += 1

    elif controls.get_input_char_pressed('w'):
        MENU_ITEM_SELECTED -= 1

    MENU_ITEM_SELECTED = numbers.clip(MENU_ITEM_SELECTED, 0, 2)

    if controls.get_input_char_pressed('\r'):
        return False

    if controls.get_input_char_pressed('k'):
        display.screenshot('screenshot-%s.bmp' % time.time())

    return True
Ejemplo n.º 48
0
def handle_input():
    global MENU_ITEM_SELECTED

    events.trigger_event("input")

    if controls.get_input_ord_pressed(constants.KEY_ESCAPE):
        return False

    if controls.get_input_char_pressed("s"):
        MENU_ITEM_SELECTED += 1

    elif controls.get_input_char_pressed("w"):
        MENU_ITEM_SELECTED -= 1

    MENU_ITEM_SELECTED = numbers.clip(MENU_ITEM_SELECTED, 0, 2)

    if controls.get_input_char_pressed("\r"):
        return False

    if controls.get_input_char_pressed("k"):
        display.screenshot("screenshot-%s.bmp" % time.time())

    return True
Ejemplo n.º 49
0
def generate(width, height):
	_weight_map, _tile_map, _solids, _node_grid = mapgen.create_map(width, height)
	_zoom = .95
	_noise = tcod.noise_new(3)
	_low_grass = 25
	_fsl = {}
	_building_space = set()
	_walls = set()
	_possible_trees = set()
	_river_start_x = random.randint(int(round(width * .35)), int(round(width * .65)))
	_river_start_y = 0#random.randint(int(round(height * .15)), int(round(height * .85)))
	_x = _river_start_x
	_y = _river_start_y
	_px, _py = _river_start_x, _river_start_y
	_river_direction = 270
	_turn_rate = random.randint(-1, 1)
	_river_tiles = set()
	_river_size = random.randint(7, 10)
	_ground_tiles = set()
	_possible_camps = set()
	
	while 1:
		for i in range(4, 10):
			for __x, __y in shapes.circle(_x, _y, _river_size):
				if __x < 0 or __y < 0 or __x >= width or __y >= height or (__x, __y) in _solids:
					continue
				
				_river_tiles.add((__x, __y))
				_tile = tiles.swamp_water(__x, __y)
				_tile_map[__y][__x] = _tile
				_weight_map[__y][__x] = _tile['w']
			
			_river_direction += _turn_rate
			_xv, _yv = numbers.velocity(_river_direction, 1)
			_px += _xv
			_py += _yv
			_x = int(round(_px))
			_y = int(round(_py))
			
			if _x < 0 or _y < 0 or _x >= width or _y >= height or (_x, _y) in _solids:
				break
		
		if _x < 0 or _y < 0 or _x >= width or _y >= height:
			break
		
		_turn_rate = random.uniform(-2.5, 2.5)
		_river_size = numbers.clip(_river_size + random.randint(-1, 1), 7, 10)
	
	for y in range(height):
		for x in range(width):
			if (x, y) in _river_tiles:
				continue
			
			_tile = tiles.grass(x, y)
			_tile_map[y][x] = _tile
			_weight_map[y][x] = _tile['w']
			
			_ground_tiles.add((x, y))
	
	tcod.noise_set_type(_noise, tcod.NOISE_WAVELET)
	
	for y in range(height):
		for x in range(width):
			if (x, y) in _river_tiles:
				continue
			
			_noise_values = [(_zoom * x / (constants.MAP_VIEW_WIDTH)),
					         (_zoom * y / (constants.MAP_VIEW_HEIGHT))]
			_noise_value = 100 * tcod.noise_get_turbulence(_noise, _noise_values, tcod.NOISE_WAVELET)
			
			if _low_grass <= _noise_value <= 100:
				_tile = tiles.tall_grass(x, y)
				
				if _noise_value >= 40:
					if not x < width * .15 and not x > width * .85 and not y < height * .15 and not y > height * .85:
						_possible_camps.add((x, y))
				
				if random.uniform(0, 1) > .5:
					_possible_trees.add((x, y))
			
			elif _noise_value >= _low_grass - 10 and 10 * random.uniform(0, 1) > _low_grass-_noise_value:
				_tile = tiles.grass(x, y)
			
			else:
				_tile = tiles.rock(x, y)
				_solids.add((x, y))
			
			_tile_map[y][x] = _tile
			_weight_map[y][x] = _tile['w']
	
	_trees = {}
	_tree_plots = _possible_trees - _solids - _river_tiles
	_used_trees = random.sample(_tree_plots, numbers.clip(int(round((width * height) * .002)), 0, len(_tree_plots)))
	
	for x, y in _used_trees:
		_size = random.randint(1, 3)
		
		for _x, _y in shapes.circle(x, y, _size):
			if _x < 0 or _y < 0 or _x >= width or _y >= height or (_x, _y) in _solids:
				break
			
			_tile = tiles.tree(_x, _y)
			_weight_map[_y][_x] = _tile['w']
			_tile_map[_y][_x] = _tile
			_trees[_x, _y] = random.uniform(2, 3.5) * _size
			
			_solids.add((_x, _y))
	
	_ground_tiles = _ground_tiles - _solids
	_plot_pole_x, _plot_pole_y = width/2, height/2
	_bushes = random.sample(_ground_tiles, numbers.clip(int(round((width * height) * .0003)), 0, len(_ground_tiles)))
	_camps = set()
	
	while len(_possible_camps):
		_camp_1 = random.choice(list(_possible_camps))
		_possible_camps.remove(_camp_1)
		_camps.add(_camp_1)
		
		for camp_2 in _possible_camps.copy():
			_dist = numbers.distance(_camp_1, camp_2)
			
			if _dist <= 250:
				_possible_camps.remove(camp_2)
	
	for x, y in _bushes:
		_walker_x = x
		_walker_y = y
		_last_dir = -2, -2
		
		for i in range(random.randint(10, 15)):
			_tile = tiles.tree(_walker_x, _walker_y)
			_weight_map[_walker_y][_walker_x] = _tile['w']
			_tile_map[_walker_y][_walker_x] =_tile
			
			_dir = random.randint(-1, 1), random.randint(-1, 1)
			_n_x = _walker_x + _dir[0]
			_n_y = _walker_y + _dir[1]

			if _n_x < 0 or _n_y < 0 or _n_x >= width or _n_y >= height or (_n_x, _n_y) in _solids:
				break
			
			_last_dir = _dir[0] * -1, _dir[0] * -1
			_walker_x = _n_x
			_walker_y = _n_y
	
	_camp_info = {}
	
	for c_x, c_y in _camps:
		_building_walls = random.sample(['north', 'south', 'east', 'west'], random.randint(2, 3))
		_broken_walls = random.sample(_building_walls, numbers.clip(random.randint(0, 3), 0, len(_building_walls)))
		_camp = {'center': (c_x, c_y)}
		_camp_ground = []
		
		for y in range(-10, 10+1):
			for x in range(-10, 10+1):
				_x = x + c_x
				_y = y + c_y
				
				if (_x, _y) in _solids or (_x, _y) in _river_tiles:
					continue
				
				if (x == -10 and 'west' in _building_walls) or (y == -10 and 'north' in _building_walls) or (x == 10 and 'east' in _building_walls) or (y == 10 and 'south' in _building_walls):
					if x == -10 and 'west' in _building_walls and 'west' in _broken_walls and random.uniform(0, 1) > .75:
						continue
					
					if x == 10 and 'east' in _building_walls and 'east' in _broken_walls and random.uniform(0, 1) > .75:
						continue
					
					if y == -10 and 'north' in _building_walls and 'north' in _broken_walls and random.uniform(0, 1) > .75:
						continue
					
					if y == 10 and 'south' in _building_walls and 'south' in _broken_walls and random.uniform(0, 1) > .75:
						continue
					
					_tile = tiles.wooden_fence(_x, _y)
					_weight_map[_y][_x] = _tile['w']
					_tile_map[_y][_x] = _tile
					_solids.add((_x, _y))
				
				elif (x > -10 and x <= 10) and (y > -10 and y <= 10):
					_camp_ground.append((_x, _y))
		
		_camp['ground'] = _camp_ground[:]
		_camp_info[c_x, c_y] = _camp
	
	mapgen.build_node_grid(_node_grid, _solids)
	
	for c_x, c_y in _camps:
		mapgen.add_plot_pole(c_x, c_y, 40, _solids)
	
	_fsl = {'Terrorists': {'bases': 1, 'squads': 0, 'trader': False, 'type': life.human_runner}}
	#        #'Militia': {'bases': 0, 'squads': 1, 'trader': False, 'type': life.human_bandit},
	#        'Wild Dogs': {'bases': 0, 'squads': 1, 'trader': False, 'type': life.wild_dog}}
	
	return width, height, _node_grid, mapgen.NODE_SETS.copy(), _weight_map, _tile_map, _solids, _fsl, _trees, _building_space - _walls
Ejemplo n.º 50
0
def tick():
    global FADE_ALPHA

    FADE_ALPHA = numbers.clip(FADE_ALPHA + .01, 0, 1)
Ejemplo n.º 51
0
def draw():
    #Title
    _i = 0
    _dst_x = 9999

    for c in TEXT[0]:
        _alpha = numbers.clip(
            FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1)
        _dx = ((constants.WINDOW_WIDTH / 2) - (len(''.join(TEXT)) / 2)) + _i

        if _dx < _dst_x:
            _dst_x = _dx

    _batch = display.create_batch(len(TEXT[0]), 1, _dst_x, 12)

    _i = 0
    for c in TEXT[0]:
        _alpha = numbers.clip(
            FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1)

        display.write_char_batch(
            _batch,
            ((constants.WINDOW_WIDTH / 2) - (len(''.join(TEXT)) / 2)) + _i,
            12,
            c,
            fore_color=(200 * _alpha, 200 * _alpha, 200 * _alpha))

        _i += 1

    display.draw_batch(_batch, 'text')

    _i = 0
    for c in TEXT[1]:
        _alpha = numbers.clip(
            FADE_ALPHA * numbers.clip(18 - _i, 0, 18) / SPARK_SIZE, 0, 1)
        display.write_char('text', ((constants.WINDOW_WIDTH / 2) -
                                    (len(TEXT[1]) / 2)) + _i,
                           13,
                           c.upper(),
                           fore_color=(200 * _alpha, 60 * _alpha, 80 * _alpha))

        _i += 1

    #Menu
    _i = 0
    for item in [('Continue', False), ('New', True), ('Quit', True)]:
        if item[1]:
            _fore_color = (200 * FADE_ALPHA, 200 * FADE_ALPHA,
                           200 * FADE_ALPHA)

        else:
            _fore_color = (100 * FADE_ALPHA, 100 * FADE_ALPHA,
                           100 * FADE_ALPHA)

        if MENU_ITEM_SELECTED == _i:
            _text = '> %s <' % item[0]

        else:
            _text = item[0]

        display.write_string('text',
                             (constants.WINDOW_WIDTH / 2) - (len(_text) / 2),
                             18 + _i,
                             _text,
                             fore_color=_fore_color)

        _i += 1

    paint_map()

    display.blit_surface_viewport('background', 0, 0, constants.MAP_VIEW_WIDTH,
                                  constants.MAP_VIEW_HEIGHT)
    display.blit_surface('text')
Ejemplo n.º 52
0
def tick(entity):
    entity['stats']['pain'] = numbers.clip(entity['stats']['pain'] * .98, 0,
                                           1000)
Ejemplo n.º 53
0
def activate(zone_id):
    global ACTIVE_ZONE

    ACTIVE_ZONE = zone_id

    _zone = ZONES[zone_id]
    _noise = tcod.noise_new(2)

    logging.info('Bringing zone \'%s\' online...' % _zone['name'])

    _zone['astar_map'] = pathfinding.setup(_zone['width'], _zone['height'],
                                           _zone['solids'])
    _zone['los_map'] = mapgen.generate_los_map(_zone['width'], _zone['height'],
                                               _zone['solids'])

    display.create_surface('tiles',
                           width=_zone['width'],
                           height=_zone['height'])

    maps.render_map(_zone['tile_map'], _zone['width'], _zone['height'])

    post_processing.start()

    events.register_event('logic', post_processing.tick_sun)

    _static_lighting = display.create_shader(_zone['width'],
                                             _zone['height'],
                                             start_offset=1)
    _zone['shaders'].append(
        post_processing.generate_shadow_map(_zone['width'], _zone['height'],
                                            _zone['solids'], _zone['trees'],
                                            _zone['inside']))
    _zone['shaders'].append(
        post_processing.generate_light_map(_zone['width'], _zone['height'],
                                           _zone['solids'], _zone['trees']))
    _zone['light_maps']['static_lighting'] = _static_lighting
    _zone['shaders'].append(_static_lighting)

    _noise = tcod.noise_new(3)
    _zoom = 2.0
    _zone['fader'] = display.create_shader(_zone['width'], _zone['height'])
    _shader = display.create_shader(_zone['width'], _zone['height'])

    for y in range(0, _zone['height']):
        for x in range(0, _zone['width']):
            if (x, y) in _zone['inside']:
                _height = .75
            else:
                _noise_values = [(_zoom * x / _zone['width']),
                                 (_zoom * y / _zone['height'])]
                _height = .35 + numbers.clip(
                    tcod.noise_get_turbulence(_noise, _noise_values,
                                              tcod.NOISE_SIMPLEX), .35, 1)

            _shader[0][y, x] = 1.3 * _height
            _shader[1][y, x] = 1.3 * _height
            _shader[2][y, x] = 1.1 * _height

    _zone['shaders'].append(_shader)

    for light in _zone['lights']:
        effects.light(light[0],
                      light[1],
                      light[2],
                      r=light[3],
                      g=light[4],
                      b=light[5],
                      light_map='static_lighting')

    #if not '--no-fx' in sys.argv:
    #	post_processing.run(time=8,
    #		                repeat=-1,
    #		                repeat_callback=lambda _: post_processing.post_process_clouds(constants.MAP_VIEW_WIDTH,
    #		                                                                              constants.MAP_VIEW_HEIGHT,
    #		                                                                              8,
    #		                                                                              _noise,
    #		                                                                              _zone['inside']))
    post_processing.run(
        time=0,
        repeat=-1,
        repeat_callback=lambda _: post_processing.post_process_lights())
    #post_processing.run(time=0,
    #                    repeat=-1,
    #                    repeat_callback=lambda _: post_processing.sunlight())

    camera.set_limits(0, 0, _zone['width'] - constants.MAP_VIEW_WIDTH,
                      _zone['height'] - constants.MAP_VIEW_HEIGHT)

    logging.info('Zone \'%s\' is online' % _zone['name'])