Exemple #1
0
import process_operations as po
import module_music

def process_entry(processor, txt_file, entry, index):
  txt_file.write("%s %d %d\r\n" % (entry[1], entry[2], entry[2]|entry[3]))

export = po.make_export(data=module_music.tracks, data_name="music", tag="track",
    header_format="%d\r\n", process_entry=process_entry)
Exemple #2
0
    for i, faction in enumerate(module_factions.factions):
        faction_relations[i][i] = faction[3]
        for relation in faction[4]:
            other_faction = processor.identifier_map.get_id(
                "fac", relation[0]) & 0xffffffff
            faction_relations[other_faction][i] = relation[1]
            faction_relations[i][other_faction] = relation[1]


def process_entry(processor, txt_file, faction, index):
    global faction_relations
    faction_len = len(faction)
    color = faction[6] if faction_len > 6 else 0xaaaaaa
    txt_file.write(
        "fac_%s %s %d %d \r\n" %
        (faction[0], pc.replace_spaces(faction[1]), faction[2], color))
    map(txt_file.write,
        (" %f " % relation for relation in faction_relations[index]))
    ranks = faction[5] if faction_len > 5 else []
    txt_file.write("\r\n%d " % len(ranks))
    map(txt_file.write, (" %s " % pc.replace_spaces(rank) for rank in ranks))
    txt_file.write("\r\n")


export = po.make_export(data=module_factions.factions,
                        data_name="factions",
                        tag="fac",
                        header_format="factionsfile version 1\r\n%d\r\n",
                        process_entry=process_entry,
                        process_list=compile_relations)
import module_game_menus


def process_entry(processor, txt_file, entry, index):
    output_list = [
        "menu_%s %d %s %s" %
        (entry[0], entry[1], pc.replace_spaces(entry[2]), entry[3])
    ]
    output_list.extend(processor.process_block(entry[4], entry[0]))
    output_list.append("%d\r\n" % po.block_len(entry[5]))
    for menu in entry[5]:
        output_list.append(" mno_%s " % menu[0])
        name = "%s: %s" % (entry[0], menu[0])
        output_list.extend(
            processor.process_block(menu[1], name + " conditions"))
        output_list.append(" %s " % pc.replace_spaces(menu[2]))
        output_list.extend(
            processor.process_block(menu[3], name + " consequences"))
        output_list.append(
            " %s " % pc.replace_spaces(menu[4]) if len(menu) > 4 else " . ")
    output_list.append("\r\n")
    txt_file.write("".join(output_list))


export = po.make_export(data=module_game_menus.game_menus,
                        data_name="game_menus",
                        tag="menu",
                        file_name="menus",
                        header_format="menusfile version 1\r\n %d\r\n",
                        process_entry=process_entry)
import process_operations as po
import module_animations

def process_entry(processor, txt_file, entry, index):
  txt_file.write(" %s %d %d  %d\r\n" % (entry[0], entry[1], entry[2], len(entry) - 3))
  for anim in entry[3:]:
    output_list = ["  %f %s %d %d %d " % tuple(anim[0:5])]
    anim_len = len(anim)
    output_list.append("%d " % anim[5] if anim_len > 5 else "0 ")
    output_list.append("%f %f %f  " % anim[6] if anim_len > 6 else "0.0 0.0 0.0 ")
    output_list.append("%f " % anim[7] if anim_len > 7 else "0.0 ")
    output_list.append("\r\n")
    txt_file.write("".join(output_list))

export = po.make_export(data=module_animations.animations, data_name="animations", tag="anim", file_name="actions",
    header_format="%d\r\n", process_entry=process_entry)
import module_generated_scripts


def generate_scripts(processor, unused):
    for script_name, script_generator in module_generated_scripts.__dict__.iteritems():
        if script_name.startswith("generate_"):
            try:
                script_id = processor.process_id(script_name.replace("generate_", "script_"), "script")
                module_scripts.scripts[script_id][1].extend(script_generator())
            except pc.ModuleSystemError as e:
                if not e.entry:
                    e.entry = "generated scripts"
                raise


def process_entry(processor, txt_file, entry, index):
    output_list = ["%s -1\r\n" % entry[0]]
    output_list.extend(processor.process_block(entry[1], entry[0], check_can_fail=True))
    output_list.append("\r\n")
    txt_file.write("".join(output_list))


export = po.make_export(
    data=module_scripts.scripts,
    data_name="scripts",
    tag="script",
    header_format="scriptsfile version 1\r\n%d\r\n",
    process_entry=process_entry,
    process_list=generate_scripts,
)
import process_common as pc
import process_operations as po
import module_parties

def process_list(processor, txt_file):
  party_count = len(module_parties.parties)
  txt_file.write("partiesfile version 1\r\n%d %d\r\n" % (party_count, party_count))

def process_entry(processor, txt_file, entry, index):
  icon_flags = (entry[2][1] if po.block_len(entry[2]) > 1 else 0) | processor.process_id(entry[2][0], "icon") if entry[2] else 0
  menu = processor.process_id(entry[3], "mnu")
  template = processor.process_id(entry[4], "pt")
  faction = processor.process_id(entry[5], "fac")
  pos = entry[9]
  txt_file.write(" 1 %d %d p_%s %s %d %d %d %d %d %d %d %d %d %f %f %f %f %f %f 0.0 %d " % (index, index, entry[0],
      pc.replace_spaces(entry[1]), icon_flags, menu, template, faction, entry[6], entry[6], entry[7], entry[8], entry[8],
      pos[0], pos[1], pos[0], pos[1], pos[0], pos[1], len(entry[10])))
  txt_file.write("".join("%d %d 0 %d " % (processor.process_id(member[0], "trp"), member[1], member[2]) for member in entry[10]))
  txt_file.write("\r\n%f\r\n" % ((3.1415926 / 180.0) * entry[11] if len(entry) > 11 else 0.0))

export = po.make_export(data=module_parties.parties, data_name="parties", tag="p",
    process_list=process_list, process_entry=process_entry)
import process_common as pc
import process_operations as po
import module_party_templates

def process_entry(processor, txt_file, entry, index):
    icon_flags = 0 if not entry[2] else ((entry[2][1] if po.block_len(entry[2]) > 1 else 0) | processor.process_id(entry[2][0], "icon"))
    txt_file.write("pt_%s %s %d %d %d %d " % (entry[0], pc.replace_spaces(entry[1]), icon_flags, entry[3],
        processor.process_id(entry[4], "fac"), entry[5]))
    member_count = po.block_len(entry[6])
    if member_count > 6:
      raise pc.ERROR("party templates can only have a maximum of 6 members")
    members_list = ["%d %d %d %d " % (processor.process_id(troop[0], "trp"), troop[1], troop[2], troop[3] if len(troop) > 3 else 0) for troop in entry[6]]
    members_list.extend("-1 " for i in xrange(6 - member_count))
    members_list.append("\r\n")
    txt_file.write("".join(members_list))

export = po.make_export(data=module_party_templates.party_templates, data_name="party_templates", tag="pt",
    header_format="partytemplatesfile version 1\r\n%d\r\n", process_entry=process_entry)
Exemple #8
0
import process_common as pc
import process_operations as po
import module_meshes


def process_entry(processor, txt_file, entry, index):
    txt_file.write("mesh_%s %d %s %f %f %f %f %f %f %f %f %f\r\n" %
                   (entry[0:2] +
                    (pc.replace_spaces(entry[2]), ) + entry[3:12]))


export = po.make_export(data=module_meshes.meshes,
                        data_name="meshes",
                        tag="mesh",
                        header_format="%d\r\n",
                        process_entry=process_entry)
import process_common as pc
import process_operations as po
import module_strings
import module_generated_strings

def generate_strings(processor, unused):
  for name, generator in module_generated_strings.__dict__.iteritems():
    if name.startswith("generate_"):
      try:
        string_id = processor.process_id(name.replace("generate_", "str_"), "str")
        entry = module_strings.strings[string_id]
        module_strings.strings[string_id] = (entry[0], generator(entry[1], processor))
      except pc.ModuleSystemError as e:
        if not e.entry:
          e.entry = "generated strings"
        raise

def process_entry(processor, txt_file, entry, index):
  txt_file.write("str_%s %s\r\n" % (entry[0], pc.replace_spaces(entry[1])))

export = po.make_export(data=module_strings.strings, data_name="strings", tag="str",
    header_format="stringsfile version 1\r\n%d\r\n", process_entry=process_entry, process_list=generate_strings)
import process_common as pc
import process_operations as po
from header_items import *
import module_items

def process_entry(processor, txt_file, item, index):
  visible_name = pc.replace_spaces(item[1])
  item_meshes = item[2]
  output_list = [" itm_%s %s %s %d " % (item[0], visible_name, visible_name, po.block_len(item_meshes))]
  output_list.extend([" %s %d " % mesh_imod for mesh_imod in item_meshes])
  stats = item[6]
  output_list.append(" %d %d %d %d %f %d %d %d %d %d %d %d %d %d %d %d %d\r\n" % (item[3], item[4], item[5], item[7],
      get_weight(stats), get_abundance(stats), get_head_armor(stats), get_body_armor(stats), get_leg_armor(stats),
      get_difficulty(stats), get_hit_points(stats), get_speed_rating(stats), get_missile_speed(stats),
      get_weapon_length(stats), get_max_ammo(stats), get_thrust_damage(stats), get_swing_damage(stats)))
  item_len = len(item)
  if item_len > 9:
    output_list.append(" %d\r\n" % po.block_len(item[9]))
    output_list.extend([" %d" % processor.process_id(item_faction, "fac") for item_faction in item[9]])
    output_list.append("\r\n")
  else:
    output_list.append(" 0\r\n")
  txt_file.write("".join(output_list))
  triggers = item[8] if item_len > 8 else []
  triggers = processor.process_triggers(triggers, item[0])
  triggers.append("\r\n")
  txt_file.write("".join(triggers))

export = po.make_export(data=module_items.items, data_name="items", tag="itm", file_name="item_kinds1",
    header_format="itemsfile version 3\r\n%d\r\n", process_entry=process_entry)
import process_operations as po
import module_map_icons

def process_entry(processor, txt_file, entry, index):
  entry_len = len(entry)
  output_list = ["%s %d %s %f %d " % (entry[0], entry[1], entry[2], entry[3], processor.process_id(entry[4], "snd"))]
  triggers = []
  if entry_len >= 8:
    output_list.append("%f %f %f " % entry[5:8])
    if entry_len > 8:
      triggers = entry[8]
  else:
    output_list.append("0 0 0 ")
    if entry_len > 5:
      triggers = entry[5]
  output_list.extend(processor.process_triggers(triggers, entry[0]))
  output_list.append("\r\n\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_map_icons.map_icons, data_name="map_icons", tag="icon",
    header_format="map_icons_file version 1\r\n%d\r\n", process_entry=process_entry)
Exemple #12
0
import process_operations as po
import module_particle_systems


def process_entry(processor, txt_file, entry, index):
    output_list = [
        "psys_%s %d %s  %d %f %f %f %f %f \r\n" %
        (entry[0], entry[1], entry[2], entry[3], entry[4], entry[5], entry[6],
         entry[7], entry[8])
    ]
    output_list.extend("%f %f   %f %f\r\n" % (bt, bm, ft, fm)
                       for (bt,
                            bm), (ft,
                                  fm) in zip(entry[9:18:2], entry[10:19:2]))
    output_list.extend("%f %f %f   " % e for e in entry[19:21])
    entry_len = len(entry)
    output_list.append("%f \r\n" % entry[21])
    output_list.append("%f " % entry[22] if entry_len > 22 else "0.0 ")
    output_list.append("%f " % entry[23] if entry_len > 23 else "0.0 ")
    output_list.append("\r\n")
    txt_file.write("".join(output_list))


export = po.make_export(
    data=module_particle_systems.particle_systems,
    data_name="particle_systems",
    tag="psys",
    header_format="particle_systemsfile version 1\r\n%d\r\n",
    process_entry=process_entry)
import process_operations as po
from header_triggers import *
import module_mission_templates

def process_entry(processor, txt_file, entry, index):
  spawn_records = entry[4]
  output_list = ["mst_%s %s %d  %d\r\n%s \r\n\r\n%d " % (entry[0], entry[0], entry[1], entry[2],
      pc.replace_spaces(entry[3]), po.block_len(spawn_records))]
  for spawn_record in spawn_records:
    item_override_len = po.block_len(spawn_record[5])
    if item_override_len > 8:
      pc.ERROR("the maximum number of spawn item overrides is 8")
    output_list.append("%d %d %d %d %d %d  "% (spawn_record[0:5] + (item_override_len,)))
    output_list.extend("%d " % processor.process_id(item, "itm") for item in spawn_record[5])
    output_list.append("\r\n")
  output_list.append("%d\r\n" % po.block_len(entry[5]))
  txt_file.write("".join(output_list))
  for i, trigger in enumerate(entry[5]):
    txt_file.write("%f %f %f " % trigger[0:3])
    if trigger[0] < 0.0:
      name = "%s: %s" % (entry[0], get_trigger_name(trigger[0]))
    else:
      name = "%s: trigger #%d" % (entry[0], i)
    txt_file.write("".join(processor.process_block(trigger[3], name + " conditions")))
    txt_file.write("".join(processor.process_block(trigger[4], name + " consequences")))
    txt_file.write("\r\n")
  txt_file.write("\r\n\r\n")

export = po.make_export(data=module_mission_templates.mission_templates, data_name="mission_templates", tag="mt",
    header_format="missionsfile version 1\r\n %d\r\n", process_entry=process_entry)
        " %d %d %d %d %f %d %d %d %d %d %d %d %d %d %d %d %d\r\n" %
        (item[3], item[4], item[5], item[7], get_weight(stats),
         get_abundance(stats), get_head_armor(stats), get_body_armor(stats),
         get_leg_armor(stats), get_difficulty(stats), get_hit_points(stats),
         get_speed_rating(stats), get_missile_speed(stats),
         get_weapon_length(stats), get_max_ammo(stats),
         get_thrust_damage(stats), get_swing_damage(stats)))
    item_len = len(item)
    if item_len > 9:
        output_list.append(" %d\r\n" % po.block_len(item[9]))
        output_list.extend([
            " %d" % processor.process_id(item_faction, "fac")
            for item_faction in item[9]
        ])
        output_list.append("\r\n")
    else:
        output_list.append(" 0\r\n")
    txt_file.write("".join(output_list))
    triggers = item[8] if item_len > 8 else []
    triggers = processor.process_triggers(triggers, item[0])
    triggers.append("\r\n")
    txt_file.write("".join(triggers))


export = po.make_export(data=module_items.items,
                        data_name="items",
                        tag="itm",
                        file_name="item_kinds1",
                        header_format="itemsfile version 3\r\n%d\r\n",
                        process_entry=process_entry)
Exemple #15
0
import process_common as pc
import process_operations as po
import module_info_pages


def process_entry(processor, txt_file, entry, index):
    txt_file.write(
        "ip_%s %s %s\r\n" %
        (entry[0], pc.replace_spaces(entry[1]), pc.replace_spaces(entry[2])))


export = po.make_export(data=module_info_pages.info_pages,
                        data_name="info_pages",
                        tag="info",
                        header_format="infopagesfile version 1\r\n%d\r\n",
                        process_entry=process_entry)
Exemple #16
0
import process_common as pc
import process_operations as po
import module_party_templates


def process_entry(processor, txt_file, entry, index):
    icon_flags = 0 if not entry[2] else (
        (entry[2][1] if po.block_len(entry[2]) > 1 else 0)
        | processor.process_id(entry[2][0], "icon"))
    txt_file.write("pt_%s %s %d %d %d %d " %
                   (entry[0], pc.replace_spaces(entry[1]), icon_flags,
                    entry[3], processor.process_id(entry[4], "fac"), entry[5]))
    member_count = po.block_len(entry[6])
    if member_count > 6:
        raise pc.ERROR("party templates can only have a maximum of 6 members")
    members_list = [
        "%d %d %d %d " % (processor.process_id(troop[0], "trp"), troop[1],
                          troop[2], troop[3] if len(troop) > 3 else 0)
        for troop in entry[6]
    ]
    members_list.extend("-1 " for i in xrange(6 - member_count))
    members_list.append("\r\n")
    txt_file.write("".join(members_list))


export = po.make_export(data=module_party_templates.party_templates,
                        data_name="party_templates",
                        tag="pt",
                        header_format="partytemplatesfile version 1\r\n%d\r\n",
                        process_entry=process_entry)
import process_operations as po
import module_tableau_materials

def process_entry(processor, txt_file, entry, index):
  output_list = ["tab_%s %d %s %d %d %d %d %d %d" % entry[0:9]]
  output_list.extend(processor.process_block(entry[9], entry[0]))
  output_list.append("\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_tableau_materials.tableaus, data_name="tableau_materials",
    tag="tableau", header_format="%d\r\n", process_entry=process_entry)
    for face in face_textures:
        hair_textures = face[2]
        hair_colors = face[3] if len(face) > 3 else []
        output_list.append(" %s %d %d %d " % (face[0], face[1], po.block_len(hair_textures), po.block_len(hair_colors)))
        output_list.extend(" %s " % e for e in hair_textures)
        output_list.extend(" %d " % e for e in hair_colors)
    voices = entry[12]
    output_list.append("\r\n %d " % po.block_len(voices))
    output_list.extend(" %d %s " % e for e in voices)
    output_list.append("\r\n %s %f \r\n" % (entry[13], entry[14]))
    entry_len = len(entry)
    blood_1 = processor.process_id(entry[15], "psys") if entry_len > 15 else 0
    blood_2 = processor.process_id(entry[16], "psys") if entry_len > 16 else 0
    constraints = entry[17] if entry_len > 17 else []
    output_list.append("%d %d\r\n%d\r\n" % (blood_1, blood_2, po.block_len(constraints)))
    for constraint in constraints:
        output_list.append("\r\n%f %d %d " % (constraint[0], constraint[1], len(constraint) - 2))
        output_list.extend(" %f %d" % e for e in constraint[2:])
    output_list.append("\r\n")
    txt_file.write("".join(output_list))


export = po.make_export(
    data=module_skins.skins,
    data_name="skins",
    tag="skin",
    header_format="skins_file version 1\r\n%d\r\n",
    process_entry=process_entry,
    process_list=check_count,
)
import process_common as pc
import process_operations as po
import module_factions

faction_relations = []

def compile_relations(processor, txt_file):
  global faction_relations
  factions_len = len(module_factions.factions)
  faction_relations = [[0.0 for j in xrange(factions_len)] for i in xrange(factions_len)]
  for i, faction in enumerate(module_factions.factions):
    faction_relations[i][i] = faction[3]
    for relation in faction[4]:
      other_faction = processor.identifier_map.get_id("fac", relation[0]) & 0xffffffff
      faction_relations[other_faction][i] = relation[1]
      faction_relations[i][other_faction] = relation[1]

def process_entry(processor, txt_file, faction, index):
  global faction_relations
  faction_len = len(faction)
  color = faction[6] if faction_len > 6 else 0xaaaaaa
  txt_file.write("fac_%s %s %d %d \r\n" % (faction[0], pc.replace_spaces(faction[1]), faction[2], color))
  map(txt_file.write, (" %f " % relation for relation in faction_relations[index]))
  ranks = faction[5] if faction_len > 5 else []
  txt_file.write("\r\n%d " % len(ranks))
  map(txt_file.write, (" %s " % pc.replace_spaces(rank) for rank in ranks))
  txt_file.write("\r\n")

export = po.make_export(data=module_factions.factions, data_name="factions", tag="fac",
    header_format="factionsfile version 1\r\n%d\r\n", process_entry=process_entry, process_list=compile_relations)
Exemple #20
0

def process_entry(processor, txt_file, entry, index):
    icon_flags = (entry[2][1]
                  if po.block_len(entry[2]) > 1 else 0) | processor.process_id(
                      entry[2][0], "icon") if entry[2] else 0
    menu = processor.process_id(entry[3], "mnu")
    template = processor.process_id(entry[4], "pt")
    faction = processor.process_id(entry[5], "fac")
    pos = entry[9]
    txt_file.write(
        " 1 %d %d p_%s %s %d %d %d %d %d %d %d %d %d %f %f %f %f %f %f 0.0 %d "
        %
        (index, index, entry[0], pc.replace_spaces(entry[1]), icon_flags, menu,
         template, faction, entry[6], entry[6], entry[7], entry[8], entry[8],
         pos[0], pos[1], pos[0], pos[1], pos[0], pos[1], len(entry[10])))
    txt_file.write(
        "".join("%d %d 0 %d " %
                (processor.process_id(member[0], "trp"), member[1], member[2])
                for member in entry[10]))
    txt_file.write(
        "\r\n%f\r\n" %
        ((3.1415926 / 180.0) * entry[11] if len(entry) > 11 else 0.0))


export = po.make_export(data=module_parties.parties,
                        data_name="parties",
                        tag="p",
                        process_list=process_list,
                        process_entry=process_entry)
import process_common as pc
import process_operations as po
from header_troops import *
from header_skills import *
import module_troops

def process_entry(processor, txt_file, troop, index):
  troop.extend(0 for i in xrange(16 - len(troop)))
  image = "0" if troop[13] == 0 else pc.replace_spaces(str(troop[13]))
  scene_entry = 0 if not troop[4] else processor.process_id(troop[4][0], "scn") | troop[4][1]
  output_list = ["\r\ntrp_%s %s %s %s %d %d %d %d %d %d\r\n  " % (troop[0], pc.replace_spaces(troop[1]), pc.replace_spaces(troop[2]),
      image, troop[3], scene_entry, troop[5], processor.process_id(troop[6], "fac"), troop[14], troop[15])]
  output_list.extend("%d 0 " % processor.process_id(i, "itm") for i in troop[7])
  output_list.extend("-1 0 " for i in xrange(64 - len(troop[7])))
  output_list.append("\r\n ")
  output_list.append(" %d %d %d %d %d\r\n" % tuple((troop[8] >> (i * 8)) & 0xff for i in xrange(5)))
  output_list.append(" %d %d %d %d %d %d %d\r\n" % tuple((troop[9] >> (i * 10)) & 0x3ff for i in xrange(num_weapon_proficiencies)))
  output_list.append("%d %d %d %d %d %d \r\n  " % tuple((troop[10] >> (i * 32)) & 0xffffffff for i in xrange(num_skill_words)))
  output_list.extend("%d %d %d %d " % tuple((face_key >> (64 * i)) & 0xffffffffffffffff for i in reversed(xrange(4))) for face_key in troop[11:13])
  output_list.append("\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_troops.troops, data_name="troops", tag="trp",
    header_format="troopsfile version 2\r\n%d ", process_entry=process_entry)
import process_common as pc
import process_operations as po
import module_info_pages

def process_entry(processor, txt_file, entry, index):
  txt_file.write("ip_%s %s %s\r\n" % (entry[0], pc.replace_spaces(entry[1]), pc.replace_spaces(entry[2])))

export = po.make_export(data=module_info_pages.info_pages, data_name="info_pages", tag="info",
    header_format="infopagesfile version 1\r\n%d\r\n", process_entry=process_entry)
  ("gray_stone",gtf_has_color,"stone_a",4.0,"none",(0.7,0.7,0.7)),
  ("brown_stone",gtf_has_color,"patch_rock",2,"none",(0.7,0.7,0.7)),
  ("turf",gtf_overlay|gtf_has_color,"grassy_ground",3.3,"ground_earth_under_grass",(0.42,0.59,0.17)),
  ("steppe",gtf_overlay|gtf_dusty|gtf_has_color,"ground_steppe",3.0,"ground_earth_under_steppe",(0.85,0.73,0.36)),
  ("snow",gtf_overlay|gtf_has_color,"snow",5.2,"none",(1.4,1.4,1.4)),
  ("earth",gtf_overlay|gtf_dusty|gtf_has_color,"ground_earth",4.5,"none",(0.7,0.5,0.23)),
  ("desert",gtf_overlay|gtf_dusty|gtf_has_color,"ground_desert", 2.5,"none",(1.4,1.2,0.4)),
  ("forest",gtf_overlay|gtf_has_color,"ground_forest",4.2,"ground_forest_under_grass",(0.6,0.42,0.28)),
  ("pebbles",gtf_overlay|gtf_has_color,"pebbles",4.1,"none",(0.7,0.7,0.7)),
  ("village",gtf_overlay|gtf_has_color,"ground_village",7.0,"none",(1.0,0.9,0.59)),
  ("path",gtf_overlay|gtf_dusty|gtf_has_color,"ground_path",6.0,"none",(0.93,0.68,0.34)),
]

import process_operations as po

def save_python_header(processor, txt_file):
  if not processor.write_id:
    return
  with open("header_ground_types.py", "w") as py_file:
    for i, entry in enumerate(ground_specs):
      py_file.write("ground_%s = %d\n" % (entry[0], i))

def process_entry(processor, txt_file, entry, index):
  txt_file.write(" %s %d %s %f %s" % entry[0:5])
  if entry[1] & gtf_has_color and po.block_len(entry[5]) >= 3:
    txt_file.write(" %f %f %f" % entry[5])
  txt_file.write("\r\n")

export = po.make_export(data=ground_specs, data_name="ground_specs", file_name="Data/ground_specs",
    process_entry=process_entry, process_list=save_python_header)
import process_operations as po
import module_tableau_materials


def process_entry(processor, txt_file, entry, index):
    output_list = ["tab_%s %d %s %d %d %d %d %d %d" % entry[0:9]]
    output_list.extend(processor.process_block(entry[9], entry[0]))
    output_list.append("\r\n")
    txt_file.write("".join(output_list))


export = po.make_export(data=module_tableau_materials.tableaus,
                        data_name="tableau_materials",
                        tag="tableau",
                        header_format="%d\r\n",
                        process_entry=process_entry)
Exemple #25
0
  ("skybox_cloud_1", sf_day|sf_clouds_1, 179.0, 52.0, 0.85, "pfx_sunny", (1.39*1.32,1.39*1.21,1.39*1.08), (0.0,0.0,0.0), (0.96*16.0/255,0.96*23.5/255,0.96*44.5/255), (300, 0xFF8CA2AD)),
  ("skybox_cloud_1", sf_day|sf_clouds_1|sf_HDR, 179.0, 52.0, 0.85, "pfx_sunny", (1.39*1.32,1.39*1.21,1.39*1.08), (0.0,0.0,0.0), (0.86*16.0/255,0.86*23.5/255,0.86*44.5/255), (300, 0xFF8CA2AD)),

  ("skybox_night_1", sf_night|sf_clouds_1, 152.0, 38.0, 0.0, "pfx_night", (1.0*17.0/255,1.0*21.0/255,1.0*27.0/255),(0.0,0.0,0.0), (0.9*5.0/255,0.9*5.0/255,0.9*15.0/255), (500, 0xFF152035)),
  ("skybox_night_1", sf_night|sf_clouds_1|sf_HDR, 152.0, 38.0, 0.0, "pfx_night", (1.0*17.0/255,1.0*21.0/255,1.0*27.0/255),(0.0,0.0,0.0), (0.9*5.0/255,0.9*5.0/255,0.9*15.0/255), (500, 0xFF152035)),
  ("skybox_night_2", sf_night|sf_clouds_3, 152.0, 38.0, 0.0, "pfx_night", (1.0*17.0/255,1.0*21.0/255,1.0*27.0/255),(0.0,0.0,0.0), (0.9*5.0/255,0.9*5.0/255,0.9*15.0/255), (500, 0xFF152035)),
  ("skybox_night_2", sf_night|sf_clouds_3|sf_HDR, 152.0, 38.0, 0.0, "pfx_night", (1.0*17.0/255,1.0*21.0/255,1.0*27.0/255),(0.0,0.0,0.0), (0.9*5.0/255,0.9*5.0/255,0.9*15.0/255), (500, 0xFF152035)),

  ("skybox_sunset_1", sf_dawn|sf_clouds_1, 180.0, 9.146, 0.7, "pfx_sunset", (230.0/220,120.0/220,37.0/220),(0.0,0.0,0.0), (14.5/210,21.0/210,40.0/210), (150, 0xFF897262)),
  ("skybox_sunset_1", sf_dawn|sf_clouds_1|sf_HDR, 180.0, 9.146, 0.7, "pfx_sunset", (230.0/220,120.0/220,37.0/220),(0.0,0.0,0.0), (14.5/210,21.0/210,40.0/210), (150, 0xFF897262)),

  ("skybox_cloud_2", sf_day|sf_clouds_2, 180.0, 19.17, 0.4, "pfx_cloudy", (0.8*0.9,0.8*0.85,0.8*0.75),(0.0,0.0,0.0), (0.8*40.0/255,0.8*46.5/255,0.8*77.0/255), (120, 0xFF607090)),
  ("skybox_cloud_2", sf_day|sf_clouds_2|sf_HDR, 180.0, 19.17, 0.4, "pfx_cloudy", (0.8*0.9,0.85*0.8,0.8*0.75),(0.0,0.0,0.0), (0.8*40.0/255,0.8*46.5/255,0.8*77.0/255), (120, 0xFF607090)),
  ("skybox_cloud_2", sf_day|sf_clouds_3|sf_no_shadows, 180.0, 19.17, 0.4, "pfx_overcast", (0.4,0.35,0.31),(0.0,0.0,0.0), (50.0/255,60.0/255,103.0/255), (120, 0xFF607090)),
  ("skybox_cloud_2", sf_day|sf_clouds_3|sf_no_shadows|sf_HDR, 180.0, 19.17, 0.4, "pfx_overcast", (0.4,0.35,0.31),(0.0,0.0,0.0), (50.0/255,60.0/255,103.0/255), (120, 0xFF607090)),

  ("skybox_clearday", sf_day|sf_clouds_0, 179.0, 80.0, 0.95, "pfx_sunny", (0.99*1.32,0.99*1.21,0.99*1.08), (0.0,0.0,0.0), (0.96*16.0/255,0.96*23.5/255,0.96*44.5/255), (300, 0xFF8CA2AD)),
  ("skybox_clearday", sf_day|sf_clouds_0|sf_HDR, 179.0, 80.0, 0.95, "pfx_sunny", (0.99*1.32,0.99*1.21,0.99*1.08), (0.0,0.0,0.0), (0.86*16.0/255,0.86*23.5/255,0.86*44.5/255), (300, 0xFF8CA2AD)),
]
import process_operations as po

def process_entry(processor, txt_file, entry, index):
  txt_file.write("%s %d %f %f %f %s\r\n" % entry[0:6])
  txt_file.write(" %f %f %f " % entry[6])
  txt_file.write(" %f %f %f " % entry[7])
  txt_file.write(" %f %f %f " % entry[8])
  txt_file.write(" %f %d\r\n" % entry[9])

export = po.make_export(data=skyboxes, data_name="skyboxes", file_name="Data/skyboxes",
    header_format="%d\r\n", process_entry=process_entry)
import process_operations as po
from header_triggers import *
import module_mission_templates

def process_entry(processor, txt_file, entry, index):
  spawn_records = entry[4]
  output_list = ["mst_%s %s %d  %d\r\n%s \r\n\r\n%d " % (entry[0], entry[0], entry[1], entry[2],
      pc.replace_spaces(entry[3]), po.block_len(spawn_records))]
  for spawn_record in spawn_records:
    item_override_len = po.block_len(spawn_record[5])
    if item_override_len > 8:
      pc.ERROR("the maximum number of spawn item overrides is 8")
    output_list.append("%d %d %d %d %d %d  "% (spawn_record[0:5] + (item_override_len,)))
    output_list.extend("%d " % processor.process_id(item, "itm") for item in spawn_record[5])
    output_list.append("\r\n")
  output_list.append("%d\r\n" % po.block_len(entry[5]))
  txt_file.write("".join(output_list))
  for i, trigger in enumerate(entry[5]):
    txt_file.write("%f %f %f " % trigger[0:3])
    if trigger[0] < 0.0:
      name = "%s: %s" % (entry[0], get_trigger_name(trigger[0]))
    else:
      name = "%s: trigger #%d" % (entry[0], i)
    txt_file.write("".join(processor.process_block(trigger[3], name + " conditions")))
    txt_file.write("".join(processor.process_block(trigger[4], name + " consequences")))
    txt_file.write("\r\n")
  txt_file.write("\r\n\r\n")

export = po.make_export(data=module_mission_templates.mission_templates, data_name="mission_templates", tag="mt",
    header_format="missionsfile version 1\r\n %d\r\n", process_entry=process_entry)
import process_operations as po
import module_triggers


def process_entry(processor, txt_file, entry, index):
    output_list = ["%f %f %f " % entry[0:3]]
    name = "#%d" % index
    output_list.extend(processor.process_block(entry[3], name + " conditions"))
    output_list.extend(processor.process_block(entry[4], name + " consequences"))
    output_list.append("\r\n")
    txt_file.write("".join(output_list))


export = po.make_export(
    data=module_triggers.triggers,
    data_name="triggers",
    header_format="triggersfile version 1\r\n%d\r\n",
    process_entry=process_entry,
)
import process_common as pc
import process_operations as po
import module_scenes


def process_entry(processor, txt_file, entry, index):
    passages = entry[8]
    txt_file.write("scn_%s %s %d %s %s %f %f %f %f %f %s \r\n  %d " %
                   (entry[0], pc.replace_spaces(entry[0]), entry[1], entry[2],
                    entry[3], entry[4][0], entry[4][1], entry[5][0],
                    entry[5][1], entry[6], entry[7], po.block_len(passages)))
    output_list = [
        " %d " % (100000 if p == "exit" else
                  0 if p == "" else processor.identifier_map.get_id("scn", p))
        for p in passages
    ]
    chest_troops = entry[9]
    output_list.append("\r\n  %d " % po.block_len(chest_troops))
    output_list.extend(" %d " % processor.identifier_map.get_id("trp", troop)
                       for troop in chest_troops)
    output_list.append("\r\n %s \r\n" %
                       entry[10] if len(entry) > 10 else "\r\n 0 \r\n")
    txt_file.write("".join(output_list))


export = po.make_export(data=module_scenes.scenes,
                        data_name="scenes",
                        tag="scn",
                        header_format="scenesfile version 1\r\n %d\r\n",
                        process_entry=process_entry)
    if not processor.write_id:
        return
    with open("ID_flora_kinds.py", "w") as py_file:
        for i, flora_kind in enumerate(flora_kinds):
            name = flora_kind[0]
            x1 = (2**i) | flora_mask
            x2 = ((2**i) | low_flora_mask) << 64
            py_file.write("%s_1 = 0x%x\n%s_2 = 0x%x\n%s_3 = 0x%x\n" %
                          (name, x1, name, x2, name, x1 | x2))


def process_entry(processor, txt_file, entry, index):
    flags = entry[1] & dword_mask
    txt_file.write("%s %d %d\r\n" % (entry[0], flags, po.block_len(entry[2])))
    for mesh in entry[2]:
        txt_file.write(" %s  %s\r\n" %
                       (mesh[0], mesh[1] if len(mesh) > 1 else 0))
        # If this fails make sure that you have entered the alternative tree definition. Not functional in Warband.
        if flags & (fkf_tree | fkf_speedtree):
            txt_file.write(" %s %s\r\n" % (mesh[2][0], mesh[2][1]))
    if flags & fkf_has_colony_props:
        txt_file.write(" %s %s\r\n" % (entry[3], entry[4]))


export = po.make_export(data=flora_kinds,
                        data_name="flora_kinds",
                        file_name="Data/flora_kinds",
                        header_format="%d\r\n",
                        process_entry=process_entry,
                        process_list=save_python_header)
import process_operations as po
import module_map_icons


def process_entry(processor, txt_file, entry, index):
    entry_len = len(entry)
    output_list = [
        "%s %d %s %f %d " % (entry[0], entry[1], entry[2], entry[3],
                             processor.process_id(entry[4], "snd"))
    ]
    triggers = []
    if entry_len >= 8:
        output_list.append("%f %f %f " % entry[5:8])
        if entry_len > 8:
            triggers = entry[8]
    else:
        output_list.append("0 0 0 ")
        if entry_len > 5:
            triggers = entry[5]
    output_list.extend(processor.process_triggers(triggers, entry[0]))
    output_list.append("\r\n\r\n")
    txt_file.write("".join(output_list))


export = po.make_export(data=module_map_icons.map_icons,
                        data_name="map_icons",
                        tag="icon",
                        header_format="map_icons_file version 1\r\n%d\r\n",
                        process_entry=process_entry)
import process_operations as po
import module_sounds

def process_sounds(processor, txt_file):
  unique_sound_files = {}
  sound_files_list = []
  sounds_list = []
  last_sound_no = 0
  for sound in module_sounds.sounds:
    sound_flags = sound[1]
    sound_files = sound[2]
    sounds_list.append("snd_%s %d %d " % (sound[0], sound[1], len(sound_files)))
    for sound_file in sound_files:
      if isinstance(sound_file, str):
        flags = 0
      else:
        flags = sound_file[1]
        sound_file = sound_file[0]
      sound_no = unique_sound_files.setdefault(sound_file, last_sound_no)
      if sound_no == last_sound_no:
        last_sound_no += 1
        sound_files_list.append(" %s %d\r\n" % (sound_file, sound_flags))
      sounds_list.append("%d %d " % (sound_no, flags))
    sounds_list.append("\r\n")
  txt_file.write("soundsfile version 3\r\n%d\r\n" % len(sound_files_list))
  txt_file.write("".join(sound_files_list))
  txt_file.write("%d\r\n" % len(module_sounds.sounds))
  txt_file.write("".join(sounds_list))

export = po.make_export(data=module_sounds.sounds, data_name="sounds", tag="snd", process_list=process_sounds)
Exemple #32
0
import process_operations as po
import module_presentations

def process_entry(processor, txt_file, entry, index):
  output_list = ["prsnt_%s %d %d " % (entry[0], entry[1], processor.process_id(entry[2], "mesh"))]
  output_list.extend(processor.process_triggers(entry[3], entry[0]))
  output_list.append("\r\n\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_presentations.presentations, data_name="presentations", tag="prsnt",
    header_format="presentationsfile version 1\r\n %d\r\n", process_entry=process_entry)
  ("skybox_cloud_1", sf_day|sf_clouds_1|sf_HDR, 179.0, 52.0, 0.85, "pfx_sunny", (1.39*1.32,1.39*1.21,1.39*1.08), (0.0,0.0,0.0), (0.86*16.0/255,0.86*23.5/255,0.86*44.5/255), (300, 0xFF8CA2AD)),

  ("skybox_night_1", sf_night|sf_clouds_1, 152.0, 38.0, 0.0, "pfx_night", (1.0*17.0/255,1.0*21.0/255,1.0*27.0/255),(0.0,0.0,0.0), (0.9*5.0/255,0.9*5.0/255,0.9*15.0/255), (500, 0xFF152035)),
  ("skybox_night_1", sf_night|sf_clouds_1|sf_HDR, 152.0, 38.0, 0.0, "pfx_night", (1.0*17.0/255,1.0*21.0/255,1.0*27.0/255),(0.0,0.0,0.0), (0.9*5.0/255,0.9*5.0/255,0.9*15.0/255), (500, 0xFF152035)),
  ("skybox_night_2", sf_night|sf_clouds_3, 152.0, 38.0, 0.0, "pfx_night", (1.0*17.0/255,1.0*21.0/255,1.0*27.0/255),(0.0,0.0,0.0), (0.9*5.0/255,0.9*5.0/255,0.9*15.0/255), (500, 0xFF152035)),
  ("skybox_night_2", sf_night|sf_clouds_3|sf_HDR, 152.0, 38.0, 0.0, "pfx_night", (1.0*17.0/255,1.0*21.0/255,1.0*27.0/255),(0.0,0.0,0.0), (0.9*5.0/255,0.9*5.0/255,0.9*15.0/255), (500, 0xFF152035)),

  ("skybox_sunset_1", sf_dawn|sf_clouds_1, 180.0, 9.146, 0.7, "pfx_sunset", (230.0/220,120.0/220,37.0/220),(0.0,0.0,0.0), (14.5/210,21.0/210,40.0/210), (150, 0xFF897262)),
  ("skybox_sunset_1", sf_dawn|sf_clouds_1|sf_HDR, 180.0, 9.146, 0.7, "pfx_sunset", (230.0/220,120.0/220,37.0/220),(0.0,0.0,0.0), (14.5/210,21.0/210,40.0/210), (150, 0xFF897262)),

  ("skybox_cloud_2", sf_day|sf_clouds_2, 180.0, 19.17, 0.4, "pfx_cloudy", (0.8*0.9,0.8*0.85,0.8*0.75),(0.0,0.0,0.0), (0.8*40.0/255,0.8*46.5/255,0.8*77.0/255), (120, 0xFF607090)),
  ("skybox_cloud_2", sf_day|sf_clouds_2|sf_HDR, 180.0, 19.17, 0.4, "pfx_cloudy", (0.8*0.9,0.85*0.8,0.8*0.75),(0.0,0.0,0.0), (0.8*40.0/255,0.8*46.5/255,0.8*77.0/255), (120, 0xFF607090)),
  ("skybox_cloud_2", sf_day|sf_clouds_3|sf_no_shadows, 180.0, 19.17, 0.4, "pfx_overcast", (0.4,0.35,0.31),(0.0,0.0,0.0), (50.0/255,60.0/255,103.0/255), (120, 0xFF607090)),
  ("skybox_cloud_2", sf_day|sf_clouds_3|sf_no_shadows|sf_HDR, 180.0, 19.17, 0.4, "pfx_overcast", (0.4,0.35,0.31),(0.0,0.0,0.0), (50.0/255,60.0/255,103.0/255), (120, 0xFF607090)),

  ("skybox_clearday", sf_day|sf_clouds_0, 179.0, 80.0, 0.95, "pfx_sunny", (0.99*1.32,0.99*1.21,0.99*1.08), (0.0,0.0,0.0), (0.96*16.0/255,0.96*23.5/255,0.96*44.5/255), (300, 0xFF8CA2AD)),
  ("skybox_clearday", sf_day|sf_clouds_0|sf_HDR, 179.0, 80.0, 0.95, "pfx_sunny", (0.99*1.32,0.99*1.21,0.99*1.08), (0.0,0.0,0.0), (0.86*16.0/255,0.86*23.5/255,0.86*44.5/255), (300, 0xFF8CA2AD)),
]

import process_operations as po

def process_entry(processor, txt_file, entry, index):
  txt_file.write("%s %d %f %f %f %s\r\n" % entry[0:6])
  txt_file.write(" %f %f %f " % entry[6])
  txt_file.write(" %f %f %f " % entry[7])
  txt_file.write(" %f %f %f " % entry[8])
  txt_file.write(" %f %d\r\n" % entry[9])

export = po.make_export(data=skyboxes, data_name="skyboxes", file_name="Data/skyboxes",
    header_format="%d\r\n", process_entry=process_entry)
import process_common as pc
import process_operations as po
import module_skills


def process_entry(processor, txt_file, entry, index):
    txt_file.write(
        "skl_%s %s %d %d %s\r\n" % (entry[0], pc.replace_spaces(
            entry[1]), entry[2], entry[3], pc.replace_spaces(entry[4])))


export = po.make_export(data=module_skills.skills,
                        data_name="skills",
                        tag="skl",
                        header_format="%d\r\n",
                        process_entry=process_entry)
Exemple #35
0
import process_operations as po
import module_postfx

def process_entry(processor, txt_file, entry, index):
  output_list = ["pfx_%s %d %d" % entry[0:3]]
  output_list.extend("  %f %f %f %f" % tuple(e) for e in entry[3:6])
  output_list.append("\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_postfx.postfx_params, data_name="postfx", tag="pfx",
    header_format="postfx_paramsfile version 1\r\n%d\r\n", process_entry=process_entry)

def generate_scripts(processor, unused):
    for script_name, script_generator in module_generated_scripts.__dict__.iteritems(
    ):
        if script_name.startswith("generate_"):
            try:
                script_id = processor.process_id(
                    script_name.replace("generate_", "script_"), "script")
                module_scripts.scripts[script_id][1].extend(script_generator())
            except pc.ModuleSystemError as e:
                if not e.entry:
                    e.entry = "generated scripts"
                raise


def process_entry(processor, txt_file, entry, index):
    output_list = ["%s -1\r\n" % entry[0]]
    output_list.extend(
        processor.process_block(entry[1], entry[0], check_can_fail=True))
    output_list.append("\r\n")
    txt_file.write("".join(output_list))


export = po.make_export(data=module_scripts.scripts,
                        data_name="scripts",
                        tag="script",
                        header_format="scriptsfile version 1\r\n%d\r\n",
                        process_entry=process_entry,
                        process_list=generate_scripts)
import process_operations as po
import module_particle_systems

def process_entry(processor, txt_file, entry, index):
  output_list = ["psys_%s %d %s  %d %f %f %f %f %f \r\n" % (entry[0], entry[1], entry[2],
      entry[3], entry[4], entry[5], entry[6], entry[7], entry[8])]
  output_list.extend("%f %f   %f %f\r\n" % (bt, bm, ft, fm) for (bt, bm), (ft, fm) in zip(entry[9:18:2], entry[10:19:2]))
  output_list.extend("%f %f %f   " % e for e in entry[19:21])
  entry_len = len(entry)
  output_list.append("%f \r\n" % entry[21])
  output_list.append("%f " % entry[22] if entry_len > 22 else "0.0 ")
  output_list.append("%f " % entry[23] if entry_len > 23 else "0.0 ")
  output_list.append("\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_particle_systems.particle_systems, data_name="particle_systems", tag="psys",
    header_format="particle_systemsfile version 1\r\n%d\r\n", process_entry=process_entry)
Exemple #38
0
                                                                      0.7)),
    ("village", gtf_overlay | gtf_has_color, "ground_village", 7.0, "none",
     (1.0, 0.9, 0.59)),
    ("path", gtf_overlay | gtf_dusty | gtf_has_color, "ground_path", 6.0,
     "none", (0.93, 0.68, 0.34)),
]

import process_operations as po


def save_python_header(processor, txt_file):
    if not processor.write_id:
        return
    with open("header_ground_types.py", "w") as py_file:
        for i, entry in enumerate(ground_specs):
            py_file.write("ground_%s = %d\n" % (entry[0], i))


def process_entry(processor, txt_file, entry, index):
    txt_file.write(" %s %d %s %f %s" % entry[0:5])
    if entry[1] & gtf_has_color and po.block_len(entry[5]) >= 3:
        txt_file.write(" %f %f %f" % entry[5])
    txt_file.write("\r\n")


export = po.make_export(data=ground_specs,
                        data_name="ground_specs",
                        file_name="Data/ground_specs",
                        process_entry=process_entry,
                        process_list=save_python_header)
import process_common as pc
import process_operations as po
import module_game_menus

def process_entry(processor, txt_file, entry, index):
  output_list = ["menu_%s %d %s %s" % (entry[0], entry[1], pc.replace_spaces(entry[2]), entry[3])]
  output_list.extend(processor.process_block(entry[4], entry[0]))
  output_list.append("%d\r\n" % po.block_len(entry[5]))
  for menu in entry[5]:
    output_list.append(" mno_%s " % menu[0])
    name = "%s: %s" % (entry[0], menu[0])
    output_list.extend(processor.process_block(menu[1], name + " conditions"))
    output_list.append(" %s " % pc.replace_spaces(menu[2]))
    output_list.extend(processor.process_block(menu[3], name + " consequences"))
    output_list.append(" %s " % pc.replace_spaces(menu[4]) if len(menu) > 4 else " . ")
  output_list.append("\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_game_menus.game_menus, data_name="game_menus", tag="menu", file_name="menus",
    header_format="menusfile version 1\r\n %d\r\n", process_entry=process_entry)
      break
  else:
    text_list.append(text)
  return name

def process_entry(processor, txt_file, entry, index):
  name = get_dialog_name(entry[start_state_pos], entry[end_state_pos], entry[text_pos])
  trp_pt = entry[speaker_pos]
  flags = entry[flags_pos]
  speaker = 0
  if flags & other:
    speaker = processor.process_id(trp_pt[1], "trp") << other_bits
    flags ^= other
    trp_pt = trp_pt[0]
  if flags & party_tpl:
    speaker |= processor.process_id(trp_pt, "pt")
  else:
    speaker |= processor.process_id(trp_pt, "trp")
  speaker |= flags
  output_list = ["%s %d %d " % (name, speaker, start_states[index])]
  output_list.extend(processor.process_block(entry[conditions_pos], "%s conditions" % name))
  output_list.append("%s " % pc.replace_spaces(entry[text_pos]) if entry[text_pos] else "NO_TEXT ")
  output_list.append(" %d " % end_states[index])
  output_list.extend(processor.process_block(entry[consequences_pos], "%s consequences" % name))
  output_list.append("%s " % entry[voice_pos] if len(entry) > voice_pos else "NO_VOICEOVER ")
  output_list.append("\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_dialogs.dialogs, data_name="dialogs", file_name="conversation",
    header_format="dialogsfile version 2\r\n%d\r\n", process_entry=process_entry, process_list=compile_dialog_states)
import process_common as pc
import process_operations as po
import module_meshes

def process_entry(processor, txt_file, entry, index):
  txt_file.write("mesh_%s %d %s %f %f %f %f %f %f %f %f %f\r\n" % (entry[0:2] +
      (pc.replace_spaces(entry[2]),) + entry[3:12]))

export = po.make_export(data=module_meshes.meshes, data_name="meshes", tag="mesh",
    header_format="%d\r\n", process_entry=process_entry)
Exemple #42
0
import process_common as pc
import process_operations as po
import module_quests


def process_entry(processor, txt_file, entry, index):
    txt_file.write("qst_%s %s %d %s \r\n" %
                   (entry[0], pc.replace_spaces(
                       entry[1]), entry[2], pc.replace_spaces(entry[3])))


export = po.make_export(data=module_quests.quests,
                        data_name="quests",
                        tag="qst",
                        header_format="questsfile version 1\r\n%d\r\n",
                        process_entry=process_entry)
]

import process_operations as po

flora_mask = 0x80000000000000000000000000000000
low_flora_mask =             0x8000000000000000

def save_python_header(processor, txt_file):
  if not processor.write_id:
    return
  with open("ID_flora_kinds.py", "w") as py_file:
    for i, flora_kind in enumerate(flora_kinds):
      name = flora_kind[0]
      x1 = (2 ** i) | flora_mask
      x2 = ((2 ** i) | low_flora_mask) << 64
      py_file.write("%s_1 = 0x%x\n%s_2 = 0x%x\n%s_3 = 0x%x\n" % (name, x1, name, x2, name, x1|x2))

def process_entry(processor, txt_file, entry, index):
  flags = entry[1] & dword_mask
  txt_file.write("%s %d %d\r\n" % (entry[0], flags, po.block_len(entry[2])))
  for mesh in entry[2]:
    txt_file.write(" %s  %s\r\n" % (mesh[0], mesh[1] if len(mesh) > 1 else 0))
    # If this fails make sure that you have entered the alternative tree definition. Not functional in Warband.
    if flags & (fkf_tree|fkf_speedtree):
      txt_file.write(" %s %s\r\n" % (mesh[2][0], mesh[2][1]))
  if flags & fkf_has_colony_props:
    txt_file.write(" %s %s\r\n" % (entry[3], entry[4]))

export = po.make_export(data=flora_kinds, data_name="flora_kinds", file_name="Data/flora_kinds",
    header_format="%d\r\n", process_entry=process_entry, process_list=save_python_header)
import process_operations as po
import module_simple_triggers

def process_entry(processor, txt_file, entry, index):
  output_list = ["%f " % entry[0]]
  output_list.extend(processor.process_block(entry[1], "#%d" % index))
  output_list.append("\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_simple_triggers.simple_triggers, data_name="simple_triggers",
    header_format="simple_triggers_file version 1\r\n%d\r\n", process_entry=process_entry)
import process_common as pc
import process_operations as po
import module_skills

def process_entry(processor, txt_file, entry, index):
  txt_file.write("skl_%s %s %d %d %s\r\n" % (entry[0], pc.replace_spaces(entry[1]), entry[2], entry[3], pc.replace_spaces(entry[4])))

export = po.make_export(data=module_skills.skills, data_name="skills", tag="skl",
    header_format="%d\r\n", process_entry=process_entry)
import process_operations as po
from header_scene_props import *
import module_scene_props

def process_entry(processor, txt_file, entry, index):
  output_list = ["spr_%s %d %d %s %s " % (entry[0], entry[1], get_spr_hit_points(entry[1]), entry[2], entry[3])]
  output_list.extend(processor.process_triggers(entry[4], entry[0]))
  output_list.append("\r\n\r\n")
  txt_file.write("".join(output_list))

export = po.make_export(data=module_scene_props.scene_props, data_name="scene_props", tag="spr",
    header_format="scene_propsfile version 1\r\n %d\r\n", process_entry=process_entry)
import process_common as pc
import process_operations as po
import module_strings
import module_generated_strings

def generate_strings(processor, unused):
  for name, generator in module_generated_strings.__dict__.iteritems():
    if name.startswith("generate_"):
      try:
        string_id = processor.process_id(name.replace("generate_", "str_"), "str")
        entry = module_strings.strings[string_id]
        module_strings.strings[string_id] = (entry[0], generator(entry[1], processor))
      except pc.ModuleSystemError as e:
        if not e.entry:
          e.entry = "generated strings"
        raise

def process_entry(processor, txt_file, entry, index):
  txt_file.write("str_%s %s\r\n" % (entry[0], pc.replace_spaces(entry[1])))

export = po.make_export(data=module_strings.strings, data_name="strings", tag="str",
    header_format="stringsfile version 1\r\n%d\r\n", process_entry=process_entry, process_list=generate_strings)
import process_common as pc
import process_operations as po
import module_quests

def process_entry(processor, txt_file, entry, index):
  txt_file.write("qst_%s %s %d %s \r\n" % (entry[0], pc.replace_spaces(entry[1]), entry[2], pc.replace_spaces(entry[3])))

export = po.make_export(data=module_quests.quests, data_name="quests", tag="qst",
    header_format="questsfile version 1\r\n%d\r\n", process_entry=process_entry)