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")
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)
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")
def save_script(file, script): identity = convert_to_identifier(script[0]) block = script[1] if isinstance(block, list): file.write("%s -1\n" % identity) else: file.write("%s %f\n" % (identity, script[1])) block = script[2] save_statement_block(file, identity, 0, block) file.write("\n")
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")
def create_auto_id2(dialog, auto_ids): text = dialog[3] token_ipt = convert_to_identifier(dialog[1]) token_opt = convert_to_identifier(dialog[4]) done = 0 auto_id = "dlga_" + token_ipt + ":" + token_opt done = 0 if auto_id not in auto_ids: done = 1 else: if auto_ids[auto_id] == text: done = 1 if not done: number = 1 new_auto_id = auto_id + "." + str(number) while new_auto_id in auto_ids: number += 1 new_auto_id = auto_id + "." + str(number) auto_id = new_auto_id auto_ids[auto_id] = text return auto_id
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")
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)
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))
def write_id_file(self, item, index): item_id = convert_to_identifier(item[0]) self.id_file.write("%s%s = %d\n" % (self.id_prefix, item_id, index))