Exemple #1
0
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")
Exemple #2
0
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')
Exemple #3
0
def execute(script, **kvargs):
	for function in script:
		_args = parse_arguments(script[function], **kvargs)
		
		if function == 'CREATE_AND_OWN_ITEM':
			_i = items.create_item(_args[0], position=_args[1])
			life.add_item_to_inventory(kvargs['owner'], _i)
		elif function == 'DELETE':
			items.delete_item(ITEMS[kvargs['item_uid']])
		elif function == 'LIGHT_FOLLOW':
			_item = ITEMS[kvargs['item_uid']]
			
			effects.create_light(items.get_pos(kvargs['item_uid']),
			                     (255, 255, 255),
			                     _item['brightness'],
			                     _item['light_shake'],
			                     follow_item=kvargs['item_uid'])
		elif function == 'LIGHT_FOLLOW_REMOVE':
			_item = ITEMS[kvargs['item_uid']]
			
			effects.delete_light_at(items.get_pos(kvargs['item_uid']))
		elif function == 'TOGGLE_BLOCK':
			_item = ITEMS[kvargs['item_uid']]
			
			if _item['blocking']:
				_item['blocking'] = False
			else:
				_item['blocking'] = True
		else:
			logging.error('Script: \'%s\' is not a valid function.' % function)
Exemple #4
0
def execute(script, **kvargs):
    for function in script:
        _args = parse_arguments(script[function], **kvargs)

        if function == 'CREATE_AND_OWN_ITEM':
            _i = items.create_item(_args[0], position=_args[1])
            life.add_item_to_inventory(kvargs['owner'], _i)
        elif function == 'DELETE':
            items.delete_item(ITEMS[kvargs['item_uid']])
        elif function == 'LIGHT_FOLLOW':
            _item = ITEMS[kvargs['item_uid']]

            effects.create_light(items.get_pos(kvargs['item_uid']),
                                 (255, 255, 255),
                                 _item['brightness'],
                                 _item['light_shake'],
                                 follow_item=kvargs['item_uid'])
        elif function == 'LIGHT_FOLLOW_REMOVE':
            _item = ITEMS[kvargs['item_uid']]

            effects.delete_light_at(items.get_pos(kvargs['item_uid']))
        elif function == 'TOGGLE_BLOCK':
            _item = ITEMS[kvargs['item_uid']]

            if _item['blocking']:
                _item['blocking'] = False
            else:
                _item['blocking'] = True
        else:
            logging.error('Script: \'%s\' is not a valid function.' % function)
Exemple #5
0
def bullet_hit(life, bullet, limb):
    _owner = LIFE[bullet["shot_by"]]
    _actual_limb = lfe.get_limb(life, limb)
    _items_to_check = []

    if "player" in _owner:
        if bullet["aim_at_limb"] == limb:
            _msg = ["The round hits"]
        elif not limb in life["body"]:
            return "The round misses entirely!"
        else:
            _msg = ["The round misses slightly"]
        _detailed = True
    elif "player" in life:
        _msg = ["The round hits"]
    else:
        _msg = ["%s hits %s's %s" % (items.get_name(bullet), life["name"][0], limb)]

    for item_uid in lfe.get_items_attached_to_limb(life, limb):
        _items_to_check.append({"item": item_uid, "visible": True})
        _item = items.get_item_from_uid(item_uid)

        if "storing" in _item:
            for item_in_container_uid in _item["storing"]:
                _chance_of_hitting_item = _item["capacity"] / float(_item["max_capacity"])

                if random.uniform(0, 1) < _chance_of_hitting_item:
                    break

                _items_to_check.append({"item": item_in_container_uid, "visible": False})

    for entry in _items_to_check:
        _item = items.get_item_from_uid(entry["item"])
        _item_damage = get_puncture_value(bullet, _item, target_structure_name=_item["name"])
        _item["thickness"] = numbers.clip(_item["thickness"] - _item_damage, 0, _item["max_thickness"])

        if "material" in _item and not _item["material"] == "cloth":
            _speed_mod = _item_damage
            _can_stop = True

            bullet["speed"] *= _speed_mod
            bullet["velocity"][0] *= _speed_mod
            bullet["velocity"][1] *= _speed_mod
        else:
            _can_stop = False

        if not _item["thickness"]:
            _msg.append(", destroying the %s" % _item["name"])

            if _item["type"] == "explosive":
                items.explode(_item)
            else:
                items.delete_item(_item)
        else:
            if bullet["speed"] <= 1 and _can_stop:
                _msg.append(", lodging itself in %s" % items.get_name(_item))
                _ret_string = own_language(life, _msg)

                if _ret_string.endswith("!"):
                    return _ret_string
                else:
                    return _ret_string + "."
            else:
                if "material" in _item:
                    if _item["material"] == "metal":
                        _msg.append(", puncturing the %s" % _item["name"])
                    else:
                        _msg.append(", ripping through the %s" % _item["name"])

    _damage = get_puncture_value(bullet, _actual_limb, target_structure_name=limb)
    _actual_limb["thickness"] = numbers.clip(_actual_limb["thickness"] - _damage, 0, _actual_limb["max_thickness"])
    _damage_mod = 1 - (_actual_limb["thickness"] / float(_actual_limb["max_thickness"]))

    if limb in life["body"]:
        _msg.append(", " + lfe.add_wound(life, limb, cut=_damage * _damage_mod, impact_velocity=bullet["velocity"]))

    _ret_string = own_language(life, _msg)

    if _ret_string.endswith("!"):
        return _ret_string
    else:
        return _ret_string + "."
Exemple #6
0
def bullet_hit(life, bullet, limb):
	_owner = LIFE[bullet['shot_by']]
	_actual_limb = lfe.get_limb(life, limb)
	
	if 'player' in _owner:
		if bullet['aim_at_limb'] == limb:
			_msg = ['The round hits']
		elif not limb in life['body']:
			return 'The round misses entirely!'
		else:
			_msg = ['The round misses slightly']
		_detailed = True
	else:
		_msg = ['%s shoots' % language.get_name(_owner)]
	
	_items_to_check = []
	for item_uid in lfe.get_items_attached_to_limb(life, limb):
		_items_to_check.append({'item': item_uid, 'visible': True})
		_item = items.get_item_from_uid(item_uid)
		
		if 'storing' in _item:
			for item_in_container_uid in _item['storing']:
				print '*' * 100
				_chance_of_hitting_item = bullet['size']*(_item['capacity']/float(_item['max_capacity']))
				print 'percent chance of hitting item:', 1-_chance_of_hitting_item
				if random.uniform(0, 1)<_chance_of_hitting_item:
					continue
				
				_items_to_check.append({'item': item_in_container_uid, 'visible': False})
		
	for entry in _items_to_check:
		_item = items.get_item_from_uid(entry['item'])
		_item_damage = get_puncture_value(bullet, _item, target_structure_name=_item['name'])
		_item['thickness'] = numbers.clip(_item['thickness']-_item_damage, 0, _item['max_thickness'])
		
		_speed_mod = _item_damage
		bullet['speed'] *= _speed_mod
		bullet['velocity'][0] *= _speed_mod
		bullet['velocity'][1] *= _speed_mod
		
		if not _item['thickness']:
			_msg.append(', destroying the %s' % _item['name'])

			if _item['type'] == 'explosive':
				items.explode(_item)
			else:
				items.delete_item(_item)
		else:
			if bullet['speed']<=1:
				_msg.append(', lodging itself in %s' % items.get_name(_item))
				_ret_string = own_language(life, _msg)
			
				if _ret_string.endswith('!'):
					return _ret_string
				else:
					return _ret_string+'.'
			else:
				if 'material' in _item:
					if _item['material'] == 'metal':
						_msg.append(', puncturing the %s' % _item['name'])
					else:
						_msg.append(', ripping through the %s' % _item['name'])
	
	_damage = get_puncture_value(bullet, _actual_limb, target_structure_name=limb)
	_actual_limb['thickness'] = numbers.clip(_actual_limb['thickness']-_damage, 0, _actual_limb['max_thickness'])
	_damage_mod = 1-(_actual_limb['thickness']/float(_actual_limb['max_thickness']))
	
	if limb in life['body']:
		_msg.append(', '+lfe.add_wound(life, limb, cut=_damage*_damage_mod, impact_velocity=bullet['velocity']))
	
	#return '%s punctures %s (%s)' % (bullet['name'], limb, get_puncture_value(bullet, _actual_limb, target_structure_name=limb))
	_ret_string = own_language(life, _msg)
	
	if _ret_string.endswith('!'):
		return _ret_string
	else:
		return _ret_string+'.'
Exemple #7
0
def bullet_hit(life, bullet, limb):
	_owner = LIFE[bullet['shot_by']]
	_actual_limb = lfe.get_limb(life, limb)
	_items_to_check = []
	_msg = []
	
	#if 'player' in _owner:
	#	if bullet['aim_at_limb'] == limb:
	#		_hit = True
	#		_msg = ['The round hits']
	#	elif not limb in life['body']:
	#		return 'The round misses entirely!'
	#	else:
	#		_msg = ['The round misses slightly']
	#	_detailed = True
	#
	#elif 'player' in life:
	#	_msg = ['The round hits']
	#else:
	#	_msg = ['%s hits %s\'s %s' % (items.get_name(bullet), life['name'][0], limb)]
	
	for item_uid in lfe.get_items_attached_to_limb(life, limb):
		_items_to_check.append({'item': item_uid, 'visible': True})
		_item = items.get_item_from_uid(item_uid)
		
		if 'storing' in _item:
			for item_in_container_uid in _item['storing']:
				_chance_of_hitting_item = _item['capacity']/float(_item['max_capacity'])
				
				if random.uniform(0, 1)<_chance_of_hitting_item:
					break
				
				_items_to_check.append({'item': item_in_container_uid, 'visible': False})
		
	for entry in _items_to_check:
		_item = items.get_item_from_uid(entry['item'])
		_item_damage = get_puncture_value(bullet, _item, target_structure_name=_item['name'])
		_item['thickness'] = bad_numbers.clip(_item['thickness']-_item_damage, 0, _item['max_thickness'])
		
		if 'material' in _item and not _item['material'] == 'cloth':
			_speed_mod = _item_damage
			_can_stop = True
			
			bullet['speed'] *= _speed_mod
			bullet['velocity'][0] *= _speed_mod
			bullet['velocity'][1] *= _speed_mod
		else:
			_can_stop = False
		
		if not _item['thickness']:
			if _item['uid'] in lfe.get_all_visible_items(life):
				if 'player' in _owner:
					_msg.append('%s\'s %s is destroyed!' % (' '.join(life['name']), _item['name']))

			if _item['type'] == 'explosive':
				items.explode(_item)
			else:
				items.delete_item(_item)
		#else:
		#	if bullet['speed']<=1 and _can_stop:
		#		#if 'player' in _owner:
		#		#	_msg.append(', lodging itself in %s' % items.get_name(_item))
		#		#_ret_string = own_language(life, _msg)
		#	
		#		if _ret_string.endswith('!'):
		#			return _ret_string
		#		else:
		#			return _ret_string+'.'
		#	#else:
		#	#	if 'material' in _item:
		#	#		if _item['material'] == 'metal':
		#	#			_msg.append(', puncturing the %s' % _item['name'])
		#	#		else:
		#	#			_msg.append(', ripping through the %s' % _item['name'])
	
	_damage = get_puncture_value(bullet, _actual_limb, target_structure_name=limb)
	_actual_limb['thickness'] = bad_numbers.clip(_actual_limb['thickness']-_damage, 0, _actual_limb['max_thickness'])

	if not _actual_limb['thickness']:
		lfe.sever_limb(life, limb, (0, 0, 0))
	
	_damage_mod = 1-(_actual_limb['thickness']/float(_actual_limb['max_thickness']))
	
	if limb in life['body']:
		_msg.append(lfe.add_wound(life, limb, cut=_damage*_damage_mod, impact_velocity=bullet['velocity']))
	
	#_ret_string = own_language(life, _msg)
	
	return ' '.join(_msg)