Beispiel #1
0
def read_ench(d):
    res = {}
    res['NAME'] = PREFIX + 'en_' + d[0]
    res.update(schema.decode_plaintext(d[1].split(), 'ENDT'))
    res['ENDT'] = {}
    schema.record_repack_schema(res)
    res['ENAM'] = []
    for x in d[2:]:
        res['ENAM'].append(spellgen.build_ENAM(x, None, False)['data'])
    return res
Beispiel #2
0
def process_mgefs():

    icon_dir = os.path.abspath('output/icons')
    if not os.path.exists(icon_dir):
        os.makedirs(icon_dir)

    idata.index_data['mgef_to_school'] = {}
    for name, mgef in esm.records_original['MGEF'].iteritems():
        mgef['icon_base'] = os.path.abspath(
            'data/icons/' + mgef['ITEX'][0:-1].lower().strip(NULL).replace(
                '.tga', '.dds').replace('\\', '/'))
        index = idata.get(name, 'magic_effects')
        mgef.update(schema.decode_subrecord(mgef['MEDT'], 'MEDT'))
        mgef['name'] = name
        idata.index_data['mgef_to_school'][index] = mgef['school']
        if mgef['school'] not in reference_icons:
            reference_icons[mgef['school']] = mgef['icon_base']

    input_dir = os.path.abspath('content/magic_effects')
    input_files = ut.get_file_list(input_dir)

    mgefs_new = {}
    for f in input_files:
        data = ut.read_newline_sep(f)
        for d in data:
            name = d[0]
            if name not in esm.records_original['MGEF']:
                continue
            else:
                mgefs_new[name] = esm.records_original['MGEF'][name]
            mgef = mgefs_new[name]
            school_old = mgef['school']
            if len(d) > 1:
                mgef.update(schema.decode_plaintext(d[1:], 'MEDT'))
            schema.encode_all_subrecords(mgef)

            if config.options.getboolean('settings', 'regenerate_spell_icons'):
                if school_old != mgef['school']:
                    mgef['ITEX'] = make_new_icon(mgef)

    output_names = ['spellmod', 'everything']
    outputs.update({'MGEF': mgefs_new}, output_names)
Beispiel #3
0
input_dir = os.path.abspath("content/item_types")
input_files = ut.get_file_list(input_dir)
item_types = {}

for f in input_files:
    data = ut.read_newline_sep(f)
    rec_type = (os.path.basename(f)).split('_')[0]
    item_types[rec_type] = {}
    for d in data:
        schemename = rec_type + '_type'
        t = {}
        name = ut.reductions(d[0])
        if rec_type == 'WEAP': d = d[1:]

        if (len(d) > 1):
            t = schema.decode_plaintext(d, schemename)
        item_types[rec_type][name] = t

#ITEM_CLASSES = ['ARMO', 'WEAP']
ITEM_CLASSES = ['WEAP']
MAPPING_TYPES = ['MODL']
type_mappings = {}
recs = {}
for item_class in ITEM_CLASSES:
    recs[item_class] = {}
    for item_name, item in esm.records_original[item_class].iteritems():
        if 'FNAM' in item:
            recs[item_class][item_name] = item

for item_class in ITEM_CLASSES:
    itypes = item_types[item_class]
Beispiel #4
0
from parameters import *
import utility as ut
import index_data as idata
import esm

import struct
import os
import schema

input_dir = os.path.abspath("content/materials")
input_files = ut.get_file_list(input_dir)

materials = {}

for f in input_files:
    data = ut.read_newline_sep(f)
    material_type = (os.path.basename(f)).split('_')[1]  # WEAP, ARMO, etc?
    materials[material_type] = {}
    for d in data:

        schemename = 'material_' + material_type
        mat = {}
        if (len(d) > 1):
            mat = schema.decode_plaintext(d[1:], schemename)
        if material_type == 'WEAP' and 'weapon_flags' not in mat:
            mat['weapon_flags'] = 0
        materials[material_type][d[0]] = mat
Beispiel #5
0
def read_attack_types():
    data = ut.read_newline_sep(os.path.abspath('data/spell_attack_types'))
    for d in data:
        attack_types[idata.complete_key(
            d[0],
            'magic_effects')] = schema.decode_plaintext(d[1:], 'spell_attack')
Beispiel #6
0
def build_ENAM(d, spell_rec, autobuild):
    res = {}
    d = d.split()

    res['skill'] = -1
    res['attribute'] = -1
    if spell_rec:
        res['name'] = spell_rec['FNAM']
        res['cost'] = spell_rec['cost']

    params = ['range', 'magic_effect', 'skill', 'attribute']
    number_data = []
    for x in d:
        number = ut.is_numeric(x)
        if number:
            number_data.append(x)
        else:
            for p in params:
                #val = idata.try_subkeys(d, p+'s')
                val = idata.complete_key(x, p + 's')
                if val:
                    res[p] = val
                    break

    try:
        res['magic_effect']
    except KeyError:
        print "magic_effect key error in " + spell_rec['FNAM']

    if 'range' not in res:
        if res['magic_effect'] in attack_types:
            res['range'] = 1  #touch
        else:
            res['range'] = 0  #self

    if autobuild:
        res.update(
            schema.decode_plaintext(number_data, 'ENAM_subdata_autobuild'))
        if 'efficiency' not in res: res['efficiency'] = 1.0
        if 'variability' not in res: res['variability'] = 0.0
        if not 'duration' in res: res['duration'] = 0
        if not 'area' in res: res['area'] = 0
        calc_mag(res)
    else:
        res.update(schema.decode_plaintext(number_data, 'ENAM_subdata'))

    if not 'min' in res: res['min'] = 1
    if not 'max' in res: res['max'] = res['min']
    if not 'duration' in res: res['duration'] = 0
    if not 'area' in res: res['area'] = 0

    if spell_rec:
        for flag in spell_rec['flags']:
            if 'buff' in flag:
                res['duration'] = 1
        spell_rec['duration'] = res['duration']

    res['mag'] = 0.5 * (res['min'] + res['max'])
    res['school'] = idata.get(idata.get(res['magic_effect'], 'magic_effects'),
                              'mgef_to_school')

    res['data'] = schema.encode_subrecord(res, 'ENAM')
    return res