Exemplo n.º 1
0
def generate_resp_script(file, allow_dings):
    """Write the responses section into a file."""
    use_dings = allow_dings

    config = ConfigFile('resp_voice.cfg', root='bee2')
    file.write("BEE2_RESPONSES <- {\n")
    for section in QUOTE_DATA.find_key('CoopResponses', []):
        if not section.has_children() and section.name == 'use_dings':
            # Allow overriding specifically for the response script
            use_dings = utils.conv_bool(section.value, allow_dings)
            continue

        voice_attr = RESP_HAS_NAMES.get(section.name, '')
        if voice_attr and not map_attr[voice_attr]:
            continue
            # This response catagory isn't present

        section_data = ['\t{} = [\n'.format(section.name)]
        for index, line in enumerate(section):
            if not config.getboolean(section.name, "line_" + str(index), True):
                # It's disabled!
                continue
            section_data.append(
                '\t\tCreateSceneEntity("{}"),\n'.format(line['choreo'])
            )
        if len(section_data) != 1:
            for line in section_data:
                file.write(line)
            file.write('\t],\n')
    file.write('}\n')

    file.write('BEE2_PLAY_DING = {};\n'.format(
        'true' if use_dings else 'false'
    ))
Exemplo n.º 2
0
def generate_resp_script(file, allow_dings):
    """Write the responses section into a file."""
    use_dings = allow_dings

    config = ConfigFile('resp_voice.cfg', root='bee2')
    file.write("BEE2_RESPONSES <- {\n")
    for section in QUOTE_DATA.find_key('CoopResponses', []):
        if not section.has_children() and section.name == 'use_dings':
            # Allow overriding specifically for the response script
            use_dings = srctools.conv_bool(section.value, allow_dings)
            continue

        voice_attr = RESP_HAS_NAMES.get(section.name, '')
        if voice_attr and not map_attr[voice_attr]:
            continue
            # This response catagory isn't present

        section_data = ['\t{} = [\n'.format(section.name)]
        for index, line in enumerate(section):
            if not config.getboolean(section.name, "line_" + str(index), True):
                # It's disabled!
                continue
            section_data.append('\t\tCreateSceneEntity("{}"),\n'.format(
                line['choreo']))
        if len(section_data) != 1:
            for line in section_data:
                file.write(line)
            file.write('\t],\n')
    file.write('}\n')

    file.write(
        'BEE2_PLAY_DING = {};\n'.format('true' if use_dings else 'false'))
Exemplo n.º 3
0
def generate_resp_script(file):
    """Write the responses section into a file."""
    config = ConfigFile('resp_voice.cfg', root='bee2')
    file.write("BEE2_RESPONSES <- {\n")
    for section in QUOTE_DATA.find_key('CoopResponses', []):
        section_data = ['\t{} = [\n'.format(section.name)]
        for index, line in enumerate(section):
            if not config.getboolean(section.name, "line_" + str(index), True):
                # It's disabled!
                continue
            section_data.append(
                '\t\tCreateSceneEntity("{}"),\n'.format(line['choreo'])
            )
        if len(section_data) != 1:
            for line in section_data:
                file.write(line)
            file.write('\t],\n')
    file.write('}\n')
Exemplo n.º 4
0
def encode_coop_responses(vmf: VMF, pos: Vec, allow_dings: bool,
                          voice_attrs: dict) -> None:
    """Write the coop responses information into the map."""
    config = ConfigFile('bee2/resp_voice.cfg', in_conf_folder=False)
    response_block = QUOTE_DATA.find_key('CoopResponses', [])

    # Pass in whether to include dings or not.
    vmf.create_ent(
        'comp_scriptvar_setter',
        origin=pos,
        target='@glados',
        variable='BEE2_PLAY_DING',
        mode='const',
        # Allow overriding specifically for the response script.
        const=response_block.bool('use_dings', allow_dings),
    )

    for section in response_block:
        if not section.has_children():
            continue

        voice_attr = RESP_HAS_NAMES.get(section.name, '')
        if voice_attr and not voice_attrs[voice_attr]:
            # This response category isn't present.
            continue

        # Use a custom entity to encode our information.
        ent = vmf.create_ent(
            'bee2_coop_response',
            origin=pos,
            type=section.name,
        )

        # section_data = []
        for index, line in enumerate(section):
            if not config.getboolean(section.name, "line_" + str(index), True):
                # It's disabled!
                continue
            ent[f'choreo{index:02}'] = line['choreo']