Ejemplo n.º 1
0
def generate_wildlife():
	_spawn = get_spawn_point()
	_group_members = []
	
	for i in range(3):
		_alife = life.create_life('dog', map=WORLD_INFO['map'], position=[_spawn[0], _spawn[1], 2])
		
		if not _group_members:
			_alife['stats']['is_leader'] = True
			_group = alife.groups.create_group(_alife)
		
		_group_members.append(_alife)
	
	for m1 in _group_members:
		if m1['id'] == _group_members[0]['id']:
			continue
		
		alife.groups.discover_group(m1, _group)
		alife.groups.add_member(_group_members[0], _group, m1['id'])
		alife.groups.add_member(m1, _group, m1['id'])
		m1['group'] = _group
		alife.groups.set_leader(m1, _group, _group_members[0]['id'])
	
	for m1 in _group_members:
		for m2 in _group_members:
			if m1 == m2:
				continue
			
			alife.stats.establish_trust(m1, m2['id'])
	
	alife.speech.inform_of_group_members(_group_members[0], None, _group)
Ejemplo n.º 2
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
Ejemplo n.º 3
0
def generate_wildlife():
    _spawn = get_spawn_point()
    _group_members = []

    for i in range(3):
        _alife = life.create_life('dog',
                                  map=WORLD_INFO['map'],
                                  position=[_spawn[0], _spawn[1], 2])

        if not _group_members:
            _alife['stats']['is_leader'] = True
            _group = alife.groups.create_group(_alife)

        _group_members.append(_alife)

    for m1 in _group_members:
        if m1['id'] == _group_members[0]['id']:
            continue

        alife.groups.discover_group(m1, _group)
        alife.groups.add_member(_group_members[0], _group, m1['id'])
        alife.groups.add_member(m1, _group, m1['id'])
        m1['group'] = _group
        alife.groups.set_leader(m1, _group, _group_members[0]['id'])

    for m1 in _group_members:
        for m2 in _group_members:
            if m1 == m2:
                continue

            alife.stats.establish_trust(m1, m2['id'])

    alife.speech.inform_of_group_members(_group_members[0], None, _group)
Ejemplo n.º 4
0
    def game_actions(self, old_life):
        life = []

        neighbors = get_neighbors(old_life)
        new_life = create_life(old_life, neighbors)

        for coordinate in new_life:
            life.append(Cell(coordinate))

        return life
Ejemplo n.º 5
0
    def game_actions(self, old_life):
        life = []

        neighbors = get_neighbors(old_life)
        new_life = create_life(old_life, neighbors)

        for coordinate in new_life:
            life.append(Cell(coordinate))

        return life
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 8
0
def create_player():
	PLAYER = life.create_life('human',
		name=['Tester','Toaster'],
		position=get_spawn_point(zone_entry_point=True))
	PLAYER['stats'].update(historygen.create_background(life))
	PLAYER['player'] = True
	
	for item in BASE_ITEMS:
		life.add_item_to_inventory(PLAYER, items.create_item(item))

	SETTINGS['controlling'] = PLAYER['id']
	
	_zes_leader = alife.factions.get_faction('ZES')['members'][0]
	_m = missions.create_mission('locate_target', target=_zes_leader)
	_m_id = missions.remember_mission(PLAYER, _m)
	
	missions.change_task_description(PLAYER, _m_id, 1, 'Find ZES outpost, talk to %s' % ' '.join(LIFE[_zes_leader]['name']))
	alife.factions.add_member('Loners', SETTINGS['controlling'])
	lfe.focus_on(LIFE[SETTINGS['controlling']])
	
	return PLAYER
Ejemplo n.º 9
0
def create_player():
    PLAYER = life.create_life('human',
                              name=['Tester', 'Toaster'],
                              position=get_spawn_point(zone_entry_point=True))
    PLAYER['stats'].update(historygen.create_background(life))
    PLAYER['player'] = True

    for item in BASE_ITEMS:
        life.add_item_to_inventory(PLAYER, items.create_item(item))

    SETTINGS['controlling'] = PLAYER['id']

    _zes_leader = alife.factions.get_faction('ZES')['members'][0]
    _m = missions.create_mission('locate_target', target=_zes_leader)
    _m_id = missions.remember_mission(PLAYER, _m)

    missions.change_task_description(
        PLAYER, _m_id, 1,
        'Find ZES outpost, talk to %s' % ' '.join(LIFE[_zes_leader]['name']))
    alife.factions.add_member('Loners', SETTINGS['controlling'])
    lfe.focus_on(LIFE[SETTINGS['controlling']])

    return PLAYER
Ejemplo n.º 10
0
def create_player():
	PLAYER = life.create_life('human',
		name=['Tester','Toaster'],
		position=get_spawn_point(zone_entry_point=True))
	PLAYER['stats'].update(historygen.create_background(life))
	PLAYER['player'] = True
	
	for item in BASE_ITEMS:
		life.add_item_to_inventory(PLAYER, items.create_item(item))
	
	life.add_item_to_inventory(PLAYER, items.create_item('glock'))
	life.add_item_to_inventory(PLAYER, items.create_item('9x19mm magazine'))
	life.add_item_to_inventory(PLAYER, items.create_item('electric lantern'))
	life.add_item_to_inventory(PLAYER, items.create_item('aspirin'))
	
	for i in range(17):
		life.add_item_to_inventory(PLAYER, items.create_item('9x19mm round'))

	SETTINGS['controlling'] = PLAYER['id']
	
	lfe.focus_on(LIFE[SETTINGS['controlling']])
	
	return PLAYER
Ejemplo n.º 11
0
def create_intro_story():
	_i = 2#random.randint(0, 2)
	_player = LIFE[SETTINGS['controlling']]
	
	WORLD_INFO['last_scheme_time'] = WORLD_INFO['ticks']
	
	if _i == 1:
		#events.broadcast([{'text': 'You wake up from a deep sleep.'},
		#           {'text': 'You don\'t remember anything.', 'change_only': True}], 0, glitch=True)
		
		_spawn_items = ['leather backpack', 'M9', '9x19mm magazine']
		
		for i in range(14):
			_spawn_items.append('9x19mm round')
		
		for item_name in _spawn_items:
			lfe.add_item_to_inventory(_player, items.create_item(item_name))
		
		lfe.set_pos(_player, spawns.get_spawn_in_ref('farms'))
		
		#Dead dude
		_dead_guy = lfe.create_life('human', position=spawns.get_spawn_point_around(_player['pos']))
		_dead_guy['dead'] = True
		
		if _player['pos'] == _dead_guy['pos']:
			lfe.set_pos(_dead_guy, [_dead_guy['pos'][0], _dead_guy['pos'][1], _dead_guy['pos'][2]+1])
		
		for i in range(random.randint(15, 20)):
			effects.create_splatter('blood', spawns.get_spawn_point_around(_dead_guy['pos'], area=2), intensity=8)
		
		#Group nearby
		_bandit_group_spawn_chunk = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_player['pos'], min_area=60, area=90))
		_bandit_group = spawns.generate_group('bandit', amount=3, spawn_chunks=[_bandit_group_spawn_chunk])
		
		_friendly_group_spawn_chunk = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_player['pos'], min_area=10, area=20))
		_friendly_group = spawns.generate_group('loner_riflemen', amount=2, spawn_chunks=[_friendly_group_spawn_chunk])
		
		for ai in _bandit_group:
			_target = alife.brain.meet_alife(ai, _player)
			_target['last_seen_time'] = 1
			_target['escaped'] = 1
			_target['last_seen_at'] = _player['pos'][:]
			
			alife.stats.establish_hostile(ai, _player['id'])
			alife.stats.establish_hostile(_player, ai['id'])
			
			for target in _friendly_group:
				_target = alife.brain.meet_alife(ai, target)
				_target['last_seen_time'] = 1
				_target['escaped'] = 1
				_target['last_seen_at'] = target['pos'][:]
				alife.stats.establish_hostile(ai, target['id'])
				
				_group_target = alife.brain.meet_alife(target, ai)
				_group_target['last_seen_time'] = 1
				_group_target['escaped'] = 1
				_group_target['last_seen_at'] = ai['pos'][:]
				alife.stats.establish_hostile(target, ai['id'])
		
		#Wounded running away
		_wounded_guy = _friendly_group[0]
		
		if _wounded_guy['pos'] == _dead_guy['pos']:
			_wounded_guy['pos'][0] -= 1
		
		alife.brain.meet_alife(_wounded_guy, _player)['alignment'] = 'trust'
		alife.brain.meet_alife(_player, _wounded_guy)['alignment'] = 'trust'
		
		#alife.speech.start_dialog(_wounded_guy, _player['id'], 'incoming_targets', force=True)
		alife.memory.create_question(_wounded_guy, _player['id'], 'incoming_targets')
		alife.memory.create_question(_wounded_guy, _player['id'], 'incoming_targets_follow', group_id=_wounded_guy['group'])
	
	elif _i == 2:
		lfe.set_pos(_player, spawns.get_spawn_in_ref('farms'))