Ejemplo n.º 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')
Ejemplo n.º 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")
Ejemplo n.º 3
0
def get_spawn_point(randomize=False, zone_entry_point=False):
	if zone_entry_point:
		_pos = [random.randint(150, 250), random.randint(850, 900), 2]
		
		return spawns.get_spawn_point_around(_pos, area=100)
	
	if WORLD_INFO['reference_map']['roads'] and not randomize:
		_entry_road_keys = []
		for road in WORLD_INFO['reference_map']['roads']:
			for chunk_key in alife.references.get_reference(road):
				_pos = WORLD_INFO['chunk_map'][chunk_key]['pos']
				
				if len(mapgen.get_neighbors_of_type(WORLD_INFO, chunk_key, 'any')) <= 3:
					_entry_road_keys.append(chunk_key)
		
		if _entry_road_keys:
			
			_spawn_pos = random.choice(WORLD_INFO['chunk_map'][random.choice(_entry_road_keys)]['ground'])
			
			return [_spawn_pos[0], _spawn_pos[1], 2]

	_start_seed = random.randint(0, 3)
	
	if not _start_seed:
		_spawn = (random.randint(0, MAP_SIZE[0]-1), 0, 2)
	elif _start_seed == 1:
		_spawn = (MAP_SIZE[0]-1, random.randint(0, MAP_SIZE[1]-1), 2)
	elif _start_seed == 2:
		_spawn = (random.randint(0, MAP_SIZE[0]-1), MAP_SIZE[1]-1, 2)
	else:
		_spawn = (0, random.randint(0, MAP_SIZE[1]-1), 2)
	
	return _spawn
Ejemplo n.º 4
0
def intrigue_player(situation):
	_player = LIFE[SETTINGS['controlling']]
	_event_number = 0#random.randint(0, 1)
	
	#0: Cache drop (mid-game only: faction ordered)
	#1: Heli crash site (military)
	#2: Weather balloon (radio, PDA info: forecast)
	
	if _event_number == 1:
		_crash_pos = spawns.get_spawn_point_around(_player['pos'], area=150, min_area=90)
		
		events.create_heli_crash(_crash_pos, [])
		events.attract_tracked_alife_to(_crash_pos)
		core.record_dangerous_event(6)
	else:
		_land_pos = spawns.get_spawn_point_around(_player['pos'], area=160, min_area=90)
		_storage_items = [{'item': 'AK-74', 'rarity': 0.6},
		                  {'item': '5.45x39mm round', 'rarity': 0.6},
		                  {'item': '5.45x39mm round', 'rarity': 0.6},
		                  {'item': '5.45x39mm round', 'rarity': 0.6},
		                  {'item': '5.45x39mm round', 'rarity': 0.6},
		                  {'item': '5.45x39mm round', 'rarity': 0.6},
		                  {'item': '5.45x39mm round', 'rarity': 0.6},
		                  {'item': '5.45x39mm round', 'rarity': 0.6},
		                  {'item': '5.45x39mm magazine', 'rarity': 0.75}]
		_storage = [{'item': 'military crate', 'rarity': 1.0, 'spawn_list': _storage_items}]
		
		if situation['armed']:
			_group = spawns.generate_group('bandit', amount=3, spawn_chunks=[spawns.get_spawn_point_around(_land_pos, area=140, min_area=80, chunk_key=True)])
			
			for ai in _group:
				alife.brain.meet_alife(ai, _player)
				alife.stats.establish_hostile(ai, _player['id'])
			
			core.record_encounter(3, life_ids=[l['id'] for l in _group])
			events.attract_tracked_alife_to(_land_pos)
		
		events.create_cache_drop(_land_pos, _storage)
		
		core.record_dangerous_event(3)
Ejemplo n.º 5
0
def help_player(situation):
	_player = LIFE[SETTINGS['controlling']]
	
	if not situation['armed']:
		_spawn_pos = spawns.get_spawn_point_around(_player['pos'], min_area=50, area=125)
		_group = spawns.generate_group('bandit', amount=1, spawn_chunks=[alife.chunks.get_chunk_key_at(_spawn_pos)])
		
		lfe.add_wound(_group[0], random.choice(['head', 'stomach']), cut=4, pain=5)
		
		for i in range(8):
			events.sound('radio static', 'something', _spawn_pos, 130, 180*i)
		
		core.record_intervention(3)
Ejemplo n.º 6
0
def get_spawn_point(randomize=False, zone_entry_point=False):
    if zone_entry_point:
        _pos = [random.randint(150, 250), random.randint(850, 900), 2]

        return spawns.get_spawn_point_around(_pos, area=100)

    if WORLD_INFO['reference_map']['roads'] and not randomize:
        _entry_road_keys = []
        for road in WORLD_INFO['reference_map']['roads']:
            for chunk_key in alife.references.get_reference(road):
                _pos = WORLD_INFO['chunk_map'][chunk_key]['pos']

                if len(
                        mapgen.get_neighbors_of_type(WORLD_INFO, chunk_key,
                                                     'any')) <= 3:
                    _entry_road_keys.append(chunk_key)

        if _entry_road_keys:

            _spawn_pos = random.choice(WORLD_INFO['chunk_map'][random.choice(
                _entry_road_keys)]['ground'])

            return [_spawn_pos[0], _spawn_pos[1], 2]

    _start_seed = random.randint(0, 3)

    if not _start_seed:
        _spawn = (random.randint(0, MAP_SIZE[0] - 1), 0, 2)
    elif _start_seed == 1:
        _spawn = (MAP_SIZE[0] - 1, random.randint(0, MAP_SIZE[1] - 1), 2)
    elif _start_seed == 2:
        _spawn = (random.randint(0, MAP_SIZE[0] - 1), MAP_SIZE[1] - 1, 2)
    else:
        _spawn = (0, random.randint(0, MAP_SIZE[1] - 1), 2)

    return _spawn
Ejemplo n.º 7
0
def hurt_player(situation):
	_player = LIFE[SETTINGS['controlling']]
	
	if situation['group']:
		if situation['armed']:
			_bandit_group_leader = get_group_leader_with_motive('crime', online=True)
			_military_group_leader = get_group_leader_with_motive('military', online=False)
			
			if not _military_group_leader:
				_military_group_leader = spawns.generate_group('soldier', amount=3, spawn_chunks=[spawns.get_spawn_in_ref('outposts', chunk_key=True)])[0]
			
			if not _bandit_group_leader:
				_chunk_key = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_military_group_leader['pos'], area=150, min_area=100))
				_bandit_group_leader = spawns.generate_group('bandit', amount=5, spawn_chunks=[_chunk_key])[0]
			
			_bandit_group_location = lfe.get_current_chunk_id(_bandit_group_leader)
			_military_group_location = lfe.get_current_chunk_id(_military_group_leader)
			order_group(_bandit_group_leader, _bandit_group_leader['group'], STAGE_RAIDING, 500, chunk_key=_military_group_location)
			alife.groups.discover_group(_bandit_group_leader, _military_group_leader['group'])
			alife.groups.declare_group_hostile(_bandit_group_leader, _bandit_group_leader['group'], _military_group_leader['group'])

			_real_direction = language.get_real_direction(numbers.direction_to((MAP_SIZE[0]/2, MAP_SIZE[1]/2), alife.chunks.get_chunk(_military_group_location)['pos']))
		
			_messages = [{'text': 'Attention all neutral and bandit squads.'},
		                 {'text': 'We finally got solid contact on military in the %s compound.' % _real_direction},
		                 {'text': 'We\'re located near coords %s and heading out soon.' % (', '.join(_bandit_group_location.split(',')))}]
			events.broadcast(_messages, 40)
			core.record_encounter(len(alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members']))
			
			_player_group_leader = LIFE[alife.groups.get_leader(_player, situation['group'])]
			
			for friendly_member in alife.groups.get_group(_player_group_leader, situation['group'])['members']:
				for hostile_member in alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members']:
					_target = alife.brain.meet_alife(LIFE[friendly_member], LIFE[hostile_member])
					_target['last_seen_time'] = 1
					_target['escaped'] = 1
					_target['last_seen_at'] = LIFE[hostile_member]['pos'][:]
					alife.stats.establish_hostile(LIFE[friendly_member], hostile_member)
			
			for hostile_member in alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members']:		
				for friendly_member in alife.groups.get_group(_player_group_leader, situation['group'])['members']:
					_target = alife.brain.meet_alife(LIFE[hostile_member], LIFE[friendly_member])
					_target['last_seen_time'] = 1
					_target['escaped'] = 1
					_target['last_seen_at'] = LIFE[friendly_member]['pos'][:]
					alife.stats.establish_hostile(LIFE[hostile_member], friendly_member)
			
			return True
	elif situation['armed']:
		_town_chunk_keys = []
		for ref in WORLD_INFO['refs']['towns']:
			_town_chunk_keys.extend(ref)
		
		_nearest_town_chunk_key = alife.chunks.get_nearest_chunk_in_list(_player['pos'], _town_chunk_keys)
		_town_chunk = alife.chunks.get_chunk(_nearest_town_chunk_key)
		_distance_to_nearst_town = numbers.distance(_player['pos'], _town_chunk['pos'])
		_spawn_distance = 15*WORLD_INFO['chunk_size']
		
		if len(situation['online_alife']) == len(situation['trusted_online_alife']):
			if _distance_to_nearst_town<=50:
				_group_spawn_velocity = numbers.velocity(numbers.direction_to(_player['pos'], _town_chunk['pos']), _spawn_distance+(50-numbers.clip(_distance_to_nearst_town, 0, 50)))
				_group_spawn_pos = [int(round(_player['pos'][0]+_group_spawn_velocity[0])), int(round(_player['pos'][1]+_group_spawn_velocity[1]))]
				_group_spawn_pos[0] = numbers.clip(_group_spawn_pos[0], 0, MAP_SIZE[0])
				_group_spawn_pos[1] = numbers.clip(_group_spawn_pos[1], 0, MAP_SIZE[1])
				_group_spawn_chunk_key = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_group_spawn_pos, area=30))
				
				_alife = spawns.generate_group('bandit', amount=2, spawn_chunks=[_group_spawn_chunk_key])
				
				for ai in _alife:
					alife.brain.meet_alife(ai, _player)
					alife.stats.establish_hostile(ai, _player['id'])
				
				core.record_encounter(2, life_ids=[i['id'] for i in _alife])
			
				if random.randint(0, 1) or 1:
					_spawn_chunk_key = spawns.get_spawn_point_around(_group_spawn_pos, area=90, min_area=60, chunk_key=True)
					_other_group = spawns.generate_group('loner', amount=1, spawn_chunks=[_spawn_chunk_key])
					
					for ai in _other_group:
						for ai2 in _alife:
							_target = alife.brain.meet_alife(ai, ai2)
							_target['last_seen_time'] = 1
							_target['escaped'] = 1
							_target['last_seen_at'] = ai2['pos'][:]
							
							alife.stats.establish_hostile(ai, ai2['id'])
					
					for ai2 in _alife:
						for ai in _other_group:
							_target = alife.brain.meet_alife(ai2, ai)
							_target['last_seen_time'] = 1
							_target['escaped'] = 1
							_target['last_seen_at'] = ai['pos'][:]
							
							alife.stats.establish_hostile(ai2, ai['id'])
					
					_messages = [{'text': 'I\'m pinned down in the village!'},
					             {'text': 'Anyone nearby?'}]
					events.broadcast(_messages, 0)
				
				return True
	elif 1==2:
		_spawn_chunk_key = spawns.get_spawn_point_around(_player['pos'], min_area=125, area=200, chunk_key=True)
		_group = spawns.generate_group('loner', amount=1, spawn_chunks=[_spawn_chunk_key])
		
		core.record_encounter(1, life_ids=[l['id'] for l in _group])
		
		for ai in _group:
			events.attract_tracked_alife_to(spawns.get_spawn_point_around(_player['pos'], min_area=10, area=100))
			
	return False
Ejemplo n.º 8
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'))