示例#1
0
    def check_chunks(self, force=False):
        if not force and WORLD_INFO["ticks"] - self.last_checked < self.check_every:
            return False

        self.last_checked = WORLD_INFO["ticks"]

        for life in [l for l in LIFE.values() if l["online"]]:
            _x_min = numbers.clip(life["pos"][0] - MAP_WINDOW_SIZE[0], 0, MAP_SIZE[0] - 1 - MAP_WINDOW_SIZE[0])
            _y_min = numbers.clip(life["pos"][1] - MAP_WINDOW_SIZE[1], 0, MAP_SIZE[1] - 1 - MAP_WINDOW_SIZE[1])
            _x_max = numbers.clip(life["pos"][0] + MAP_WINDOW_SIZE[0], 0, MAP_SIZE[0] - 1)
            _y_max = numbers.clip(life["pos"][1] + MAP_WINDOW_SIZE[1], 0, MAP_SIZE[1] - 1)
            _refresh = False

            for y in range(_y_min, _y_max, WORLD_INFO["chunk_size"]):
                for x in range(_x_min, _x_max, WORLD_INFO["chunk_size"]):
                    maps.load_cluster_at_position_if_needed((x, y))

                    SETTINGS["loading"] = True

                    if "player" in life:
                        _refresh = True

            if _refresh:
                gfx.refresh_view("map")

        SETTINGS["loading"] = False
示例#2
0
	def check_chunks(self, force=False):
		if not force and WORLD_INFO['ticks']-self.last_checked<self.check_every:
			return False
		
		self.last_checked = WORLD_INFO['ticks']
		
		for life in [l for l in LIFE.values() if l['online']]:
			_x_min = bad_numbers.clip(life['pos'][0]-MAP_WINDOW_SIZE[0], 0, MAP_SIZE[0]-1-MAP_WINDOW_SIZE[0])
			_y_min = bad_numbers.clip(life['pos'][1]-MAP_WINDOW_SIZE[1], 0, MAP_SIZE[1]-1-MAP_WINDOW_SIZE[1])
			_x_max = bad_numbers.clip(life['pos'][0]+MAP_WINDOW_SIZE[0], 0, MAP_SIZE[0]-1)
			_y_max = bad_numbers.clip(life['pos'][1]+MAP_WINDOW_SIZE[1], 0, MAP_SIZE[1]-1)
			_refresh = False
			
			for y in range(_y_min, _y_max, WORLD_INFO['chunk_size']):
				for x in range(_x_min, _x_max, WORLD_INFO['chunk_size']):
					maps.load_cluster_at_position_if_needed((x, y))
					
					SETTINGS['loading'] = True
					
					if 'player' in life:
						_refresh = True
			
			if _refresh:
				gfx.refresh_view('map')
		
		SETTINGS['loading'] = False
示例#3
0
def get_player_situation():
	if not SETTINGS['controlling']:
		return False
	
	_life = LIFE[SETTINGS['controlling']]
	
	_situation = {}
	_situation['armed'] = alife.combat.has_potentially_usable_weapon(_life)
	_situation['friends'] = len([l for l in _life['know'].values() if l['alignment'] in ['trust', 'feign_trust']])
	_situation['group'] = _life['group']
	_situation['online_alife'] = [l for l in LIFE.values() if l['online'] and not l['dead'] and not l['id'] == _life['id']]
	_situation['trusted_online_alife'] = [l for l in _situation['online_alife'] if alife.judgement.can_trust(_life, l['id'])]
	_situation['has_radio'] = len(lfe.get_all_inventory_items(_life, matches=[{'type': 'radio'}]))>0
	_situation['weapons'] = alife.combat.get_weapons(_life)
	_situation['equipped_gear'] = lfe.get_all_equipped_items(_life)	
	_active_factions = set()
	_enemy_factions = set()
	
	for life in _situation['online_alife']:
		if not life['faction'] in _active_factions:
			_active_factions.add(life['faction'])
		
		if alife.factions.is_enemy(_life, life['id']) and not life['faction'] in _enemy_factions:
			_enemy_factions.add(life['faction'])
	
	_situation['active_factions'] = list(_active_factions)
	_situation['friendly_factions'] = list(_enemy_factions-_active_factions)
	_situation['active_factions'] = list(_active_factions)
	_situation['enemy_factions'] = list(_enemy_factions)
	
	return _situation
示例#4
0
def get_group_leader_with_motive(group_motive, online=False):
	for life in LIFE.values():
		if not (life['online'] or not online) or not life['group'] or not alife.groups.is_leader(life, life['group'], life['id']) or SETTINGS['controlling'] == life['id']:
			continue
		
		if alife.groups.get_motive(life, life['group']) == group_motive:
			return life['id']
	
	return None