Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
0
def control_zes():
	_zes = get_faction('ZES')
	
	if not 'intro_created' in _zes['flags'] and _zes['members'] and SETTINGS['controlling']:
		_zes = get_faction('ZES')
		_zes['flags']['intro_created'] = True
		_item_uid = weapons.spawn_and_arm('glock', '9x19mm magazine', '9x19mm round', 17)
		_kill_target = get_faction('Bandits')['members'][0]
		_kill_target_direction = numbers.distance(LIFE[_zes['members'][0]]['pos'], LIFE[_kill_target]['pos'])
		_quest_item_uid = lfe.get_inventory_item_matching(LIFE[_kill_target], {'type': 'radio'})
		_mission = missions.create_mission('zes_glock', target=SETTINGS['controlling'],
		                                   item_uid=_item_uid,
		                                   quest_item_uid=_quest_item_uid,
		                                   deliver_target=_zes['members'][0],
		                                   kill_target=_kill_target,
		                                   location=lfe.get_current_chunk_id(LIFE[_kill_target]))
		
		lfe.add_item_to_inventory(LIFE[_zes['members'][0]], _item_uid)
		alife.brain.meet_alife(LIFE[_zes['members'][0]], LIFE[SETTINGS['controlling']])
		alife.memory.create_question(LIFE[_zes['members'][0]],
		                             SETTINGS['controlling'],
		                             'zes_intro',
		                             kill_target_name=' '.join(LIFE[_kill_target]['name']),
		                             kill_target_direction=language.get_real_direction(_kill_target_direction))
		missions.remember_mission(LIFE[_zes['members'][0]], _mission)
		missions.activate_mission(LIFE[_zes['members'][0]], '1')
Beispiel #4
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
Beispiel #5
0
def control_zes():
	_zes = get_faction('ZES')
	
	if not 'intro_created' in _zes['flags'] and _zes['members'] and SETTINGS['controlling']:
		_zes = get_faction('ZES')
		_zes['flags']['intro_created'] = True
		_item_uid = weapons.spawn_and_arm('glock', '9x19mm magazine', '9x19mm round', 17)
		_kill_target = get_faction('Bandits')['members'][0]
		_kill_target_direction = bad_numbers.distance(LIFE[_zes['members'][0]]['pos'], LIFE[_kill_target]['pos'])
		_quest_item_uid = lfe.get_inventory_item_matching(LIFE[_kill_target], {'type': 'radio'})
		_mission = missions.create_mission('zes_glock', target=SETTINGS['controlling'],
		                                   item_uid=_item_uid,
		                                   quest_item_uid=_quest_item_uid,
		                                   deliver_target=_zes['members'][0],
		                                   kill_target=_kill_target,
		                                   location=lfe.get_current_chunk_id(LIFE[_kill_target]))
		
		lfe.add_item_to_inventory(LIFE[_zes['members'][0]], _item_uid)
		alife.brain.meet_alife(LIFE[_zes['members'][0]], LIFE[SETTINGS['controlling']])
		alife.memory.create_question(LIFE[_zes['members'][0]],
		                             SETTINGS['controlling'],
		                             'zes_intro',
		                             kill_target_name=' '.join(LIFE[_kill_target]['name']),
		                             kill_target_direction=language.get_real_direction(_kill_target_direction))
		missions.remember_mission(LIFE[_zes['members'][0]], _mission)
		missions.activate_mission(LIFE[_zes['members'][0]], '1')
Beispiel #6
0
def execute_recipe(life, item, recipe):
    _difficulty = get_recipe_difficulty(life, item, recipe)
    _dice_percentage = bad_numbers.roll(2, 5) / (10.0 + _difficulty)

    if _dice_percentage >= .75:
        _recipe_quality = 'success'
    elif _dice_percentage >= .5:
        _recipe_quality = 'partial_success'
    else:
        _recipe_quality = 'failure'

    if recipe['type'] == 'create_item':
        for create_item in recipe['create_item']:
            if not _recipe_quality in recipe['create_item'][create_item]:
                continue

            for i in range(recipe['create_item'][create_item][_recipe_quality]
                           ['amount']):
                _created_item = items.create_item(create_item)
                lfe.add_item_to_inventory(life, _created_item)

    if _recipe_quality in recipe['strings']:
        gfx.message(recipe['strings'][_recipe_quality])
    else:
        gfx.message('You finish crafting.')
Beispiel #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
Beispiel #8
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
Beispiel #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
Beispiel #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))

    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
Beispiel #11
0
def execute_recipe(life, item, recipe):
	_difficulty = get_recipe_difficulty(life, item, recipe)
	_dice_percentage = numbers.roll(2, 5)/(10.0+_difficulty)
	
	if _dice_percentage >= .75:
		_recipe_quality = 'success'
	elif _dice_percentage >= .5:
		_recipe_quality = 'partial_success'
	else:
		_recipe_quality = 'failure'
	
	if recipe['type'] == 'create_item':
		for create_item in recipe['create_item']:
			if not _recipe_quality in recipe['create_item'][create_item]:
				continue
			
			for i in range(recipe['create_item'][create_item][_recipe_quality]['amount']):
				_created_item = items.create_item(create_item)
				lfe.add_item_to_inventory(life, _created_item)
	
	if _recipe_quality in recipe['strings']:
		gfx.message(recipe['strings'][_recipe_quality])
	else:
		gfx.message('You finish crafting.')
Beispiel #12
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'))
Beispiel #13
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