Exemple #1
0
def _human(x, y, name, is_player, faction):
	_entity = _create_human(x, y, 100, 10, name, has_ai=True, is_player=is_player, faction=faction)

	#entities.register_event(_entity,
	#			'hold_item',
	#			lambda e, item_id: effects.printer(_entity['tile']['x']-camera.X,
	#								_entity['tile']['y']-camera.Y-5,
	#								'+%s' % entities.get_entity(item_id)['stats']['name'],
	#								fore_color=(0, 255, 0),
	#								speed_mod=0.3,
	#								show_mod=1.0,
	#								moving=False,
	#								center=True))
	#entities.register_event(_entity,
	#			'store_item',
	#			lambda e, item_id: effects.printer(_entity['tile']['x']-camera.X,
	#								_entity['tile']['y']-camera.Y-5,
	#								'+%s' % entities.get_entity(item_id)['stats']['name'],
	#								fore_color=(0, 255, 0),
	#								speed_mod=0.3,
	#								show_mod=1.0,
	#								moving=False,
	#								center=True))
	
	if faction == 'Rogues':
		entities.trigger_event(_entity, 'set_flag', flag='is_player', value=is_player)
		
		if is_player:
			entities.register_event(_entity,
				                    'new_target_spotted',
				                    _handle_new_target)
		
		entities.register_event(_entity,
			                    'broadcast',
			                    lambda e, message: effects.message(message))
		entities.register_event(_entity,
			                    'add_mission',
			                    lambda e, mission_id: effects.message('New mission.'))
		entities.register_event(_entity,
			                    'complete_mission',
			                    lambda e, mission_id: effects.message('Mission complete.'))
		entities.register_event(_entity,
			                    'set_rank',
			                    lambda e, rank: not _entity['stats']['rank'] == rank and effects.message('New Rank: %s' % rank))
		
		entities.register_event(_entity, 'heard_noise', handle_player_heard_noise)
		
		entities.register_event(_entity, 'receive_memory', handle_player_received_memory)
		
		entities.register_event(ai_flow.FLOW, 'start_of_turn', lambda e, squad_id: handle_player_start_of_turn(_entity, squad_id))
		entities.register_event(ai_flow.FLOW, 'end_of_turn', lambda e, squad_id: handle_player_end_of_turn(_entity, squad_id))

	return _entity
Exemple #2
0
def fade_in():
    entities.trigger_event(FADER,
                           'create_timer',
                           time=7,
                           repeat=FADE_TICKS,
                           repeat_callback=lambda e: _fade_in(),
                           enter_callback=lambda e: effects.message(
                               'Warehouse', center=True, vert_center=True))
Exemple #3
0
def handle_member_killed(entity, member_id, target_id):
	_member = entities.get_entity(member_id)
	_target = entities.get_entity(target_id)
	_target_faction = _target['ai']['faction']
	
	if _target_faction == _member['ai']['faction']:
		logging.info('Friendly fire resulted in death: %s' % _target_faction)
		
		return
	
	if not _target_faction in entity['enemies']:
		entity['relations'][_target_faction] = 0
		entity['enemies'].append(_target_faction)
		
		logging.info('%s is now hostile to %s: Murder' % (_member['ai']['faction'], _target_faction))
		
		if flags.has_flag(_target, 'is_player') and flags.get_flag(_target, 'is_player'):
			effects.message('%s now see you as hostile.' % _member['ai']['faction'])
Exemple #4
0
def handle_player_start_of_turn(entity, squad_id):
	if ai_squads.get_assigned_squad(entity)['_id'] == squad_id:
		settings.set_tick_mode('strategy')
	
		_squad = entities.get_entity(squad_id)
		
		if not ai_factions.is_enemy(entity, _squad['leader']) and entity['_id'] == _squad['leader']:
			if _squad['meta']['is_squad_combat_ready']:
				_message = random.choice(['Locked and loaded.',
					                      'Nuke \'em!',
					                      'No mercy, boys...'])
			
			elif _squad['meta']['is_squad_overwhelmed']:
				_message = random.choice(['We\'re outnumbered!',
					                      'Fall back!'])
				
			else:
				return
			
			effects.message(_message, time=120, center=True)
Exemple #5
0
def handle_player_start_of_turn(entity, squad_id):
    if ai_squads.get_assigned_squad(entity)['_id'] == squad_id:
        settings.set_tick_mode('strategy')

        _squad = entities.get_entity(squad_id)

        if not ai_factions.is_enemy(
                entity,
                _squad['leader']) and entity['_id'] == _squad['leader']:
            if _squad['meta']['is_squad_combat_ready']:
                _message = random.choice(
                    ['Locked and loaded.', 'Nuke \'em!', 'No mercy, boys...'])

            elif _squad['meta']['is_squad_overwhelmed']:
                _message = random.choice(['We\'re outnumbered!', 'Fall back!'])

            else:
                return

            effects.message(_message, time=120, center=True)
Exemple #6
0
def handle_member_killed(entity, member_id, target_id):
    _member = entities.get_entity(member_id)
    _target = entities.get_entity(target_id)
    _target_faction = _target['ai']['faction']

    if _target_faction == _member['ai']['faction']:
        logging.info('Friendly fire resulted in death: %s' % _target_faction)

        return

    if not _target_faction in entity['enemies']:
        entity['relations'][_target_faction] = 0
        entity['enemies'].append(_target_faction)

        logging.info('%s is now hostile to %s: Murder' %
                     (_member['ai']['faction'], _target_faction))

        if flags.has_flag(_target, 'is_player') and flags.get_flag(
                _target, 'is_player'):
            effects.message('%s now see you as hostile.' %
                            _member['ai']['faction'])
Exemple #7
0
def fade_in():
	entities.trigger_event(FADER, 'create_timer', time=7, repeat=FADE_TICKS,
	                       repeat_callback=lambda e: _fade_in(),
	                       enter_callback=lambda e: effects.message('Warehouse', center=True, vert_center=True))
Exemple #8
0
def _human(x, y, name, is_player, faction):
    _entity = _create_human(x,
                            y,
                            100,
                            10,
                            name,
                            has_ai=True,
                            is_player=is_player,
                            faction=faction)

    #entities.register_event(_entity,
    #			'hold_item',
    #			lambda e, item_id: effects.printer(_entity['tile']['x']-camera.X,
    #								_entity['tile']['y']-camera.Y-5,
    #								'+%s' % entities.get_entity(item_id)['stats']['name'],
    #								fore_color=(0, 255, 0),
    #								speed_mod=0.3,
    #								show_mod=1.0,
    #								moving=False,
    #								center=True))
    #entities.register_event(_entity,
    #			'store_item',
    #			lambda e, item_id: effects.printer(_entity['tile']['x']-camera.X,
    #								_entity['tile']['y']-camera.Y-5,
    #								'+%s' % entities.get_entity(item_id)['stats']['name'],
    #								fore_color=(0, 255, 0),
    #								speed_mod=0.3,
    #								show_mod=1.0,
    #								moving=False,
    #								center=True))

    if faction == 'Rogues':
        entities.trigger_event(_entity,
                               'set_flag',
                               flag='is_player',
                               value=is_player)

        if is_player:
            entities.register_event(_entity, 'new_target_spotted',
                                    _handle_new_target)

        entities.register_event(_entity, 'broadcast',
                                lambda e, message: effects.message(message))
        entities.register_event(
            _entity, 'add_mission',
            lambda e, mission_id: effects.message('New mission.'))
        entities.register_event(
            _entity, 'complete_mission',
            lambda e, mission_id: effects.message('Mission complete.'))
        entities.register_event(
            _entity, 'set_rank', lambda e, rank: not _entity['stats']['rank']
            == rank and effects.message('New Rank: %s' % rank))

        entities.register_event(_entity, 'heard_noise',
                                handle_player_heard_noise)

        entities.register_event(_entity, 'receive_memory',
                                handle_player_received_memory)

        entities.register_event(
            ai_flow.FLOW, 'start_of_turn',
            lambda e, squad_id: handle_player_start_of_turn(_entity, squad_id))
        entities.register_event(
            ai_flow.FLOW, 'end_of_turn',
            lambda e, squad_id: handle_player_end_of_turn(_entity, squad_id))

    return _entity