Пример #1
0
def rain(size):
    _running_time = WORLD_INFO['real_time_of_day'] - WORLD_INFO[
        'real_time_of_day'] / (WORLD_INFO['length_of_day'] /
                               len(WORLD_INFO['weather']['colors'])) * (
                                   WORLD_INFO['length_of_day'] /
                                   len(WORLD_INFO['weather']['colors']))

    _rate = .009

    for i in range(0, int(round(_running_time * _rate))):
        _x = random.randint(0, size[0] - 1)
        _y = random.randint(0, size[1] - 1)
        _skip = False

        if not alife.sight.is_in_fov(LIFE[SETTINGS['controlling']],
                                     (CAMERA_POS[0] + _x, CAMERA_POS[1] + _y)):
            continue

        for z in range(LIFE[SETTINGS['controlling']]['pos'][2] + 1,
                       MAP_SIZE[2]):
            if maps.is_solid((CAMERA_POS[0] + _x, CAMERA_POS[1] + _y, z)):
                _skip = True
                break

        if _skip:
            continue

        REFRESH_POSITIONS.append((_x, _y))

        gfx.tint_tile(_x, _y, tcod.blue, random.uniform(0.1, 0.6))

    #"Wind"
    if logic.can_tick():
        for i in range(random.randint(1, 4)):
            _x = random.randint(0, size[0] - 1)
            _y = random.randint(0, size[1] - 1)
            _skip = False

            if not alife.sight.is_in_fov(
                    LIFE[SETTINGS['controlling']],
                (CAMERA_POS[0] + _x, CAMERA_POS[1] + _y)):
                continue

            for z in range(LIFE[SETTINGS['controlling']]['pos'][2] + 1,
                           MAP_SIZE[2]):
                if maps.is_solid((CAMERA_POS[0] + _x, CAMERA_POS[1] + _y, z)):
                    _skip = True
                    break

            if _skip:
                continue

            effects.create_smoke((CAMERA_POS[0] + _x, CAMERA_POS[1] + _y),
                                 color=tcod.white,
                                 grow=0.1,
                                 decay=0.03,
                                 direction=195,
                                 speed=random.uniform(0.35, 0.8),
                                 max_opacity=.3)
Пример #2
0
def rain(size):
	_running_time = WORLD_INFO['real_time_of_day'] - WORLD_INFO['real_time_of_day']/(WORLD_INFO['length_of_day']/len(WORLD_INFO['weather']['colors']))*(WORLD_INFO['length_of_day']/len(WORLD_INFO['weather']['colors']))
	
	_rate = .009
	
	for i in range(0, int(round(_running_time*_rate))):
		_x = random.randint(0, size[0]-1)
		_y = random.randint(0, size[1]-1)
		_skip = False
		
		if not alife.sight.is_in_fov(LIFE[SETTINGS['controlling']], (CAMERA_POS[0]+_x, CAMERA_POS[1]+_y)):
			continue
		
		for z in range(LIFE[SETTINGS['controlling']]['pos'][2]+1, MAP_SIZE[2]):
			if maps.is_solid((CAMERA_POS[0]+_x, CAMERA_POS[1]+_y, z)):
				_skip = True
				break
		
		if _skip:
			continue
		
		REFRESH_POSITIONS.append((_x, _y))
		
		gfx.tint_tile(_x, _y, tcod.blue, random.uniform(0.1, 0.6))
	
	#"Wind"
	if logic.can_tick():
		for i in range(random.randint(1, 4)):
			_x = random.randint(0, size[0]-1)
			_y = random.randint(0, size[1]-1)
			_skip = False
			
			if not alife.sight.is_in_fov(LIFE[SETTINGS['controlling']], (CAMERA_POS[0]+_x, CAMERA_POS[1]+_y)):
				continue
			
			for z in range(LIFE[SETTINGS['controlling']]['pos'][2]+1, MAP_SIZE[2]):
				if maps.is_solid((CAMERA_POS[0]+_x, CAMERA_POS[1]+_y, z)):
					_skip = True
					break
		
			if _skip:
				continue
			
			effects.create_smoke((CAMERA_POS[0]+_x, CAMERA_POS[1]+_y), color=tcod.white, grow=0.1, decay=0.03, direction=195, speed=random.uniform(0.35, 0.8), max_opacity=.3)
Пример #3
0
def fire(life, target, limb=None):
    #TODO: Don't breathe this!
    weapon = get_weapon_to_fire(life)

    if not weapon:
        return False

    _aim_with_limb = None
    for hand in life['hands']:
        if weapon['uid'] in lfe.get_limb(life, hand)['holding']:
            _aim_with_limb = hand

    _ooa = False
    _feed_uid = get_feed(weapon)

    if not _feed_uid:
        if 'player' in life:
            gfx.message('The weapon is unloaded.')

        _ooa = True
        return False

    _feed = items.get_item_from_uid(_feed_uid)

    if not _feed or (_feed and not _feed['rounds']):
        if 'player' in life:
            gfx.message('*Click* (You are out of ammo.)')

        _ooa = True
        return False

    _bullet_deviation = (1 - weapon['accuracy']) + life['recoil']
    _deviation_mod = SETTINGS['aim_difficulty'] * (1 - (
        (life['stats']['firearms'] / 10.0) * SETTINGS['firearms_skill_mod']))
    _direction_deviation = (_bullet_deviation *
                            SETTINGS['aim_difficulty']) * _deviation_mod

    life['recoil'] = bad_numbers.clip(
        life['recoil'] + (weapon['recoil'] * get_stance_recoil_mod(life)), 0.0,
        1.0)

    _bullet_direction = bad_numbers.direction_to(life['pos'], target) + (
        random.uniform(-_direction_deviation, _direction_deviation))

    alife.noise.create(life['pos'],
                       120,
                       '%s fire' % weapon['name'],
                       'something discharge',
                       target=life['id'])

    #TODO: Clean this up...
    _bullet = items.get_item_from_uid(_feed['rounds'].pop())
    _bullet['pos'] = life['pos'][:]
    _bullet['start_pos'] = life['pos'][:]
    _bullet['owner'] = None
    _bullet['shot_by'] = life['id']
    _bullet['aim_at_limb'] = limb

    items.add_to_chunk(_bullet)

    if gfx.position_is_in_frame(life['pos']) or 'player' in life:
        effects.create_light(life['pos'], tcod.yellow, 7, 1, fade=3.2)
        effects.create_light(_bullet['pos'],
                             tcod.yellow,
                             7,
                             .9,
                             fade=.65,
                             follow_item=_bullet['uid'])
        effects.create_smoke_cloud(life['pos'], 3, color=tcod.light_gray)
        effects.create_smoke(life['pos'], color=tcod.yellow)

    _bullet['accuracy'] = int(
        round(get_accuracy(life, weapon['uid'], limb=_aim_with_limb)))

    print 'ACCURACY', _bullet['accuracy']

    del _bullet['parent']
    items.move(_bullet, _bullet_direction, _bullet['max_speed'])
    _bullet['start_velocity'] = _bullet['velocity'][:]
    items.tick_item(_bullet)

    for _life in [LIFE[i] for i in LIFE]:
        if _life['pos'][0] == target[0] and _life['pos'][1] == target[1]:
            life['aim_at'] = _life['id']
            break

    if len(lfe.find_action(life, matches=[{'action': 'shoot'}])) == 1:
        life['firing'] = None
Пример #4
0
def fire(life, target, limb=None):
	#TODO: Don't breathe this!
	weapon = get_weapon_to_fire(life)
	
	if not weapon:
		return False
	
	_aim_with_limb = None
	for hand in life['hands']:
		if weapon['uid'] in lfe.get_limb(life, hand)['holding']:
			_aim_with_limb = hand
	
	_ooa = False
	_feed_uid = get_feed(weapon)
	
	if not _feed_uid:
		if 'player' in life:
			gfx.message('The weapon is unloaded.')
		
		_ooa = True
		return False
	
	_feed = items.get_item_from_uid(_feed_uid)
	
	if not _feed or (_feed and not _feed['rounds']):
		if 'player' in life:
			gfx.message('*Click* (You are out of ammo.)')
		
		_ooa = True
		return False
	
	direction = numbers.direction_to(life['pos'],target)+(random.uniform(-life['recoil'], life['recoil']))
	
	alife.noise.create(life['pos'], 120, '%s fire' % weapon['name'], 'something discharge')
	
	#TODO: Clean this up...
	_bullet = items.get_item_from_uid(_feed['rounds'].pop())
	_bullet['pos'] = life['pos'][:]
	_bullet['start_pos'] = life['pos'][:]
	_bullet['owner'] = None
	_bullet['shot_by'] = life['id']
	_bullet['aim_at_limb'] = limb
	
	life['recoil'] += _bullet['recoil']*(weapon['recoil']*get_stance_recoil_mod(life))
	
	items.add_to_chunk(_bullet)
	
	if gfx.position_is_in_frame(life['pos']):
		effects.create_light(life['pos'], tcod.yellow, 7, 1, fade=3.5)
		effects.create_light(_bullet['pos'], tcod.yellow, 7, 1, fade=0.65, follow_item=_bullet['uid'])
		effects.create_smoke_cloud(life['pos'], 3, color=tcod.light_gray)
		effects.create_smoke(life['pos'], color=tcod.yellow)
	
	_bullet['accuracy'] = int(round(get_accuracy(life, weapon['uid'], limb=_aim_with_limb)))
	del _bullet['parent']
	items.move(_bullet, direction, _bullet['max_speed'])
	_bullet['start_velocity'] = _bullet['velocity'][:]
	items.tick_item(_bullet)
	
	for _life in [LIFE[i] for i in LIFE]:
		if _life['pos'][0] == target[0] and _life['pos'][1] == target[1]:
			life['aim_at'] = _life['id']
			break
	
	if len(lfe.find_action(life, matches=[{'action': 'shoot'}])) == 1:
		life['firing'] = None