Exemplo n.º 1
0
def save_troops(file, troop):
    troop_len = len(troop)
    if troop_len == 11:
        troop[11:11] = [0, 0, 0, 0, 0]
    elif troop_len == 12:
        troop[12:12] = [0, 0, 0, 0]
    elif troop_len == 13:
        troop[13:13] = [0, 0, 0]
    elif troop_len == 14:
        troop[14:14] = [0, 0]
    elif troop_len == 15:
        troop[15:15] = [0]
    if (troop[4] > 0):
        pass
    troop_info = (convert_to_identifier(troop[0]), replace_spaces(troop[1]),
                  replace_spaces(troop[2]), replace_spaces(str(troop[13])),
                  troop[3], troop[4], troop[5], troop[6], troop[14], troop[15])
    file.write("\ntrp_%s %s %s %s %d %d %d %d %d %d\n  " % troop_info)
    inventory_list = troop[7]
    for inventory_item in inventory_list:
        file.write("%d 0 " % inventory_item)
    for i in range(64 - len(inventory_list)):
        file.write("-1 0 ")
    file.write("\n ")
    attrib = troop[8]
    strength = (attrib & 0xff)
    agility = ((attrib >> 8) & 0xff)
    intelligence = ((attrib >> 16) & 0xff)
    charisma = ((attrib >> 24) & 0xff)
    starting_level = (attrib >> level_bits) & level_mask

    file.write(" %d %d %d %d %d\n" %
               (strength, agility, intelligence, charisma, starting_level))
    wp_word = troop[9]
    for wp in range(num_weapon_proficiencies):
        wp_level = wp_word & 0x3FF
        file.write(" %d" % wp_level)
        wp_word = wp_word >> 10
    file.write("\n")

    skill_array = troop[10]
    for i in range(num_skill_words):
        file.write("%d " % ((skill_array >> (i * 32)) & 0xffffffff))
    file.write("\n  ")

    face_keys = [troop[11], troop[12]]

    for fckey in (face_keys):
        word_keys = []
        for word_no in range(4):
            word_keys.append((fckey >> (64 * word_no)) & 0xFFFFFFFFFFFFFFFF)
        for word_no in range(4):
            file.write("%d " % (word_keys[(4 - 1) - word_no]))

    file.write("\n")
Exemplo n.º 2
0
def save_scene(ofile, scene):
  identity = convert_to_identifier(scene[0])
  name = replace_spaces(scene[0])
  ofile.write("scn_%s %s %d %s %s %f %f %f %f %f %s " % (
      identity, name, scene[1], scene[2], scene[3], scene[4][0],
      scene[4][1], scene[5][0], scene[5][1], scene[6], scene[7])
  )
  passages = scene[8]
  ofile.write("\n  %d " % len(passages))
  for passage in passages:
    write_passage(ofile, scenes, passage)
  chest_troops = scene[9]
  ofile.write("\n  %d " % len(chest_troops))
  for chest_troop in chest_troops:
    troop_no = find_troop(troops, chest_troop)
    if (troop_no < 0):
      print("Error unable to find chest-troop: " + chest_troop)
      troop_no = 0
    else:
      pass
    ofile.write(" %d " % troop_no)
  ofile.write("\n")
  if (len(scene) > 10):
    ofile.write(" %s " % scene[10])
  else:
    ofile.write(" 0 ")
  ofile.write("\n")
Exemplo n.º 3
0
def save_mission_template(file, mission_template):
    identity = convert_to_identifier(mission_template[0])
    file.write("mst_%s %s %d %d\n" %
               (identity, identity, mission_template[1], mission_template[2]))
    file.write("%s\n" % replace_spaces(mission_template[3]))
    file.write("%d " % len(mission_template[4]))
    for group in mission_template[4]:
        save_mission_template_group(file, group)
Exemplo n.º 4
0
def save_skin(ofile, skin):
    skin_name = skin[0]
    skin_flags = skin[1]
    body_name = skin[2]
    calf_name = skin[3]
    hand_name = skin[4]

    head_mesh = skin[5]
    face_keys = skin[6]
    hair_meshes = skin[7]
    beard_meshes = skin[8]
    hair_textures = skin[9]
    beard_textures = skin[10]
    face_textures = skin[11]
    voices = skin[12]
    skeleton_name = skin[13]
    scale = skin[14]

    blood_particles_1 = 0
    blood_particles_2 = 0
    constraints = []
    if len(skin) > 15:
        blood_particles_1 = skin[15]
    if len(skin) > 16:
        blood_particles_2 = skin[16]
    if len(skin) > 17:
        constraints = skin[17]

    ofile.write("%s %d\n %s %s %s\n" %
                (skin_name, skin_flags, body_name, calf_name, hand_name))
    ofile.write(" %s %d " % (head_mesh, len(face_keys)))
    for face_key in face_keys:
        skin_info = (convert_to_identifier(face_key[4]), face_key[0],
                     face_key[1], face_key[2], face_key[3],
                     replace_spaces(face_key[4]))
        ofile.write("skinkey_%s %d %d %f %f %s " % skin_info)
    ofile.write("\n%d\n" % len(hair_meshes))
    for mesh_name in hair_meshes:
        ofile.write(" %s " % mesh_name)
    ofile.write("\n %d\n" % len(beard_meshes))
    for bmn in beard_meshes:
        ofile.write("  %s\n" % bmn)
    ofile.write("\n")
    write_textures(ofile, hair_textures)
    write_textures(ofile, beard_textures)
    write_face_tex(ofile, face_textures)
    write_voices(ofile, voices)
    ofile.write(" %s %f " % (skeleton_name, scale))
    ofile.write("\n%d %d\n" % (blood_particles_1, blood_particles_2))
    ofile.write("%d\n" % (len(constraints)))
    for constraint in constraints:
        ofile.write("\n%f %d %d " % (constraint[0], constraint[1],
                                     (len(constraint) - 2)))
        for i_pair in range(len(constraint)):
            if i_pair > 1:
                ofile.write(" %f %d" %
                            (constraint[i_pair][0], constraint[i_pair][1]))
    ofile.write("\n")
Exemplo n.º 5
0
def save_game_menu(ofile, game_menu):
  ofile.write("menu_%s %d %s %s" % (
    game_menu[0], game_menu[1], replace_spaces(game_menu[2]), game_menu[3])
  )
  save_statement_block(ofile, 0, 1, game_menu[4])
  menu_items = game_menu[5]
  ofile.write("%d\n" % (len(menu_items)))
  for menu_item in menu_items:
    save_game_menu_item(ofile, menu_item)
  ofile.write("\n")
Exemplo n.º 6
0
def save_dialog(file, dialog, input_state, output_state):
    dialog_id = create_auto_id2(dialog, auto_ids)
    file.write("%s %d %d " % (dialog_id, dialog[0], input_state))
    save_statement_block(file, 0, 1, dialog[2])
    file.write("%s " % replace_spaces(dialog[3]))
    if (len(dialog[3]) == 0):
        file.write("NO_TEXT ")
    file.write(" %d " % output_state)
    save_statement_block(file, 0, 1, dialog[5])
    if (len(dialog) > 6):
        file.write("%s " % dialog[6])
    else:
        file.write("NO_VOICEOVER ")
    file.write("\n")
Exemplo n.º 7
0
def write_face_tex(ofile, tex_set):
    ofile.write(" %d " % len(tex_set))
    for tex in tex_set:
        color = tex[1]
        hair_mats = tex[2]
        hair_colors = []
        if len(tex) > 3:
            hair_colors = tex[3]
        ofile.write(" %s %d %d %d " %
                    (tex[0], color, len(hair_mats), len(hair_colors)))
        for hair_mat in hair_mats:
            ofile.write(" %s " % (replace_spaces(hair_mat)))
        for hair_color in hair_colors:
            ofile.write(" %d " % (hair_color))
    ofile.write("\n")
Exemplo n.º 8
0
def save_party_template(file, template):
    identity = convert_to_identifier(template[0])
    name = replace_spaces(template[1])
    file.write(
        "pt_%s %s %d %d %d %d " %
        (identity, name, template[2], template[3], template[4], template[5]))
    members = template[6]
    if (len(members) > 6):
        print("Error! NUMBER OF TEMPLATE MEMBERS EXCEEDS 6 " + template[0])
        members = members[0:6]
    for member in members:
        save_party_template_troop(file, member)
    for i in range(6 - len(members)):
        save_party_template_troop(file, 0)
    file.write("\n")
Exemplo n.º 9
0
def write_item(ofile, item):
    identity = convert_to_identifier(item[0])
    name = replace_spaces(item[1])
    status = get_item_status(item)
    variations_info = reduce(variations_reducer, item[2], "")
    info = (item[3], item[4], item[5], item[7]) + status
    ofile.write("itm_%s %s %s %d %s " %
                (identity, name, name, len(item[2]), variations_info))
    ofile.write("%d %d %d %d %f %d %d %d %d %d %d %d %d %d %d %d %d\n" % info)
    if (len(item) > 9):
        factions_info = reduce(factions_reducer, item[9], "")
        ofile.write("%d \n%s \n" % (len(item[9]), factions_info))
    else:
        ofile.write("0 \n")
    triggers = item[8] if len(item) > 8 else []
    save_simple_triggers(ofile, triggers)
Exemplo n.º 10
0
def save_party(file, party, index):
    identity = convert_to_identifier(party[0])
    name = replace_spaces(party[1])
    file.write("1 %d %d p_%s %s %d " %
               (index, index, identity, name, party[2]))
    menu_no = 0
    menu_param = party[3]
    if isinstance(menu_param, str):
        menu_no = find_object(game_menus, menu_param)
        if (menu_no < 0):
            print("Error: Unable to find menu-id :" + menu_param)
    else:
        menu_no = menu_param
    file.write("%d " % (menu_no))

    file.write("%d %d %d %d %d " %
               (party[4], party[5], party[6], party[6], party[7]))
    ai_behavior_object = 0
    ai_param = party[8]
    if isinstance(ai_param, str):
        ai_behavior_object = find_object(parties, ai_param)
        if (ai_behavior_object < 0):
            print("Error: Unable to find party-id :" + ai_param)
    else:
        ai_behavior_object = ai_param
    file.write("%d %d " % (ai_behavior_object, ai_behavior_object))
    position = party[9]
    default_behavior_location = position
    file.write("%f %f " %
               (default_behavior_location[0], default_behavior_location[1]))
    file.write("%f %f " %
               (default_behavior_location[0], default_behavior_location[1]))
    file.write("%f %f 0.0 " % position)
    member_list = party[10]
    file.write("%d " % len(member_list))
    for member in member_list:
        file.write("%d %d 0 %d " % (member[0], member[1], member[2]))
    bearing = 0.0
    if (len(party) > 11):
        bearing = (3.1415926 / 180.0) * party[11]
    file.write("\n%f\n" % (bearing))
Exemplo n.º 11
0
def insert_quick_string_with_auto_id(sentence):
    index = 0
    text = convert_to_identifier_with_no_lowercase(sentence)
    sentence = replace_spaces(sentence)
    done = 0
    i = 20
    lt = len(text)
    if (i > lt):
        i = lt
    auto_id = "qstr_" + text[0:i]
    done = 0
    index = search_quick_string_keys(auto_id)
    if index >= 0 and (quick_strings[index][1] == sentence):
        done = 1
    while (i <= lt) and not done:
        auto_id = "qstr_" + text[0:i]
        index = search_quick_string_keys(auto_id)
        if index >= 0:
            if quick_strings[index][1] == sentence:
                done = 1
            else:
                i += 1
        else:
            done = 1
            index = len(quick_strings)
            quick_strings.append([auto_id, sentence])
    if not done:
        number = 1
        new_auto_id = auto_id + str(number)
        while search_quick_string_keys(new_auto_id):
            number += 1
            new_auto_id = auto_id + str(number)
        auto_id = new_auto_id
        index = len(quick_strings)
        quick_strings.append([auto_id, sentence])
    return index
Exemplo n.º 12
0
def save_quest(file, quest):
    file.write("qst_%s %s %d %s\n" % (quest[0], replace_spaces(
        quest[1]), quest[2], replace_spaces(quest[3])))
Exemplo n.º 13
0
 def write_export_file(self, info_page):
     title = replace_spaces(info_page[1])
     content = replace_spaces(info_page[2])
     self.export_file.write("ip_%s %s %s\n" %
                            (info_page[0], title, content))