Exemple #1
0
def generate_life(life_class, amount=1, spawn_chunks=[]):
	_life_species = LIFE_CLASSES[life_class]['species']
	_spawn_list = []
	
	if spawn_chunks:
		_chunk_key = random.choice(spawn_chunks)
		_spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
	else:
		_spawn = worldgen.get_spawn_point()
	
	for i in range(amount):
		if spawn_chunks:
			_chunk_key = random.choice(spawn_chunks)
			_spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
		
		_alife = life.create_life(_life_species, map=WORLD_INFO['map'], position=[_spawn[0], _spawn[1], 2])
		
		for item in LIFE_CLASSES[life_class]['items']:
			print item
			for i in range(item.values()[0]):
				life.add_item_to_inventory(_alife, items.create_item(item.keys()[0]))
		
		for stat in LIFE_CLASSES[life_class]['stats']:
			_alife['stats'][stat] = LIFE_CLASSES[life_class]['stats'][stat]
		
		for goal in LIFE_CLASSES[life_class]['banned_goals']:
			alife.planner.remove_goal(_alife, goal)
		
		_spawn_list.append(_alife)
		
	return _spawn_list
Exemple #2
0
def generate_life(life_class,
                  amount=1,
                  position=None,
                  faction=None,
                  spawn_chunks=[]):
    _life_species = LIFE_CLASSES[life_class]['species']
    _spawn_list = []

    if not faction:
        faction = LIFE_CLASSES[life_class]['faction']

    if position:
        _spawn = position[:]

        if not len(_spawn) == 3:
            _spawn.append(2)

    elif spawn_chunks:
        _chunk_key = random.choice(spawn_chunks)
        _spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
    else:
        _spawn = worldgen.get_spawn_point()

    for i in range(amount):
        if spawn_chunks:
            _chunk_key = random.choice(spawn_chunks)
            _spawn = random.choice(
                alife.chunks.get_chunk(_chunk_key)['ground'])

        _alife = life.create_life(_life_species,
                                  position=[_spawn[0], _spawn[1], 2])

        if faction:
            alife.factions.add_member(faction, _alife['id'])

        for item in LIFE_CLASSES[life_class]['items']:
            for i in range(item['amount']):
                if 'equip' in item and item['equip']:
                    _equip = True
                else:
                    _equip = False

                life.add_item_to_inventory(_alife,
                                           items.create_item(item['item']),
                                           equip=_equip)

        for stat in LIFE_CLASSES[life_class]['stats']:
            _alife['stats'][stat] = LIFE_CLASSES[life_class]['stats'][stat]

        for goal in LIFE_CLASSES[life_class]['banned_goals']:
            alife.planner.remove_goal(_alife, goal)

        _spawn_list.append(_alife)

    return _spawn_list
Exemple #3
0
def generate_life(life_class, amount=1, position=None, faction=None, spawn_chunks=[]):
	_life_species = LIFE_CLASSES[life_class]['species']
	_spawn_list = []
	
	if not faction:
		faction = LIFE_CLASSES[life_class]['faction']
	
	if position:
		_spawn = position[:]
		
		if not len(_spawn) == 3:
			_spawn.append(2)
		
	elif spawn_chunks:
		_chunk_key = random.choice(spawn_chunks)
		_spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
	else:
		_spawn = worldgen.get_spawn_point()
	
	for i in range(amount):
		if spawn_chunks:
			_chunk_key = random.choice(spawn_chunks)
			_spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
		
		_alife = life.create_life(_life_species, position=[_spawn[0], _spawn[1], 2])
		
		if faction:
			alife.factions.add_member(faction, _alife['id'])
		
		for item in LIFE_CLASSES[life_class]['items']:
			for i in range(item['amount']):
				if 'equip' in item and item['equip']:
					_equip = True
				else:
					_equip = False
				
				life.add_item_to_inventory(_alife, items.create_item(item['item']), equip=_equip)
		
		for stat in LIFE_CLASSES[life_class]['stats']:
			_alife['stats'][stat] = LIFE_CLASSES[life_class]['stats'][stat]
		
		for goal in LIFE_CLASSES[life_class]['banned_goals']:
			alife.planner.remove_goal(_alife, goal)
		
		_spawn_list.append(_alife)
		
	return _spawn_list