def get_manufacturers(baldef_name, data):
    manufs = set()
    baldef = data.get_struct_by_full_object(baldef_name)
    if 'Manufacturers' in baldef:
        for manuf in baldef['Manufacturers']:
            manufs.add(Data.get_attr_obj(manuf['Manufacturer']))
    elif 'BaseDefinition' in baldef:
        basedef_full = baldef['BaseDefinition']
        if basedef_full != 'None':
            manufs |= get_manufacturers(
                Data.get_attr_obj(baldef['BaseDefinition']), data)
    return manufs
Ejemplo n.º 2
0
def title_from_partdef(data, partlist):
    for part_def in partlist['WeightedParts']:
        part = data.get_struct_attr_obj_real(part_def, 'Part')
        if part:
            if 'TitleList' in part:
                for title_def in part['TitleList']:
                    title = data.get_struct_by_full_object(
                        Data.get_attr_obj(title_def))
                    print(title['PartName'])
        else:
            raise Exception('No definitions!')
Ejemplo n.º 3
0
def get_names(data, partdef, attr_name, get_customs=False):
    names = set()
    customs = set()
    if attr_name in partdef and partdef[attr_name] != '':
        for namepart_full in partdef[attr_name]:
            namepart_name = Data.get_attr_obj(namepart_full)
            namepart = data.get_struct_by_full_object(namepart_name)
            if 'PartName' in namepart and namepart['PartName'] != '':
                names.add(namepart['PartName'])
            if get_customs:
                customs |= get_presentations(data, namepart)
    if get_customs:
        return (list(names), list(customs))
    else:
        return list(names)
Ejemplo n.º 4
0
def process_part_list_inner(df, wp, caids, label):
    """
    Given a struct `wp` which contains the attribute 'WeightedParts`, and
    a dict `caids` which contains the processed `ConsolidatedAttributeInitData`
    data, process the part list and write to `df`
    """

    attr_parts = []
    for part in wp['WeightedParts']:
        part_name = Data.get_attr_obj(part['Part']).split('.')[-1]
        try:
            if caids[int(part['MinGameStageIndex'])] >= 100:
                print('')
                print('Skipping 100+ MinGameStageIndex in {} {}'.format(
                    partlist_name, label))
                continue
        except KeyError:
            # This happens at least in GD_Anemone_Weapons.Rocket_Launcher.RL_Maliwan_5_Pyrophobia
            # ... we don't understand BVA, and the mingamestageindex happens to point to a
            # CAID which has one of those.  It's the only one in there, though, and this
            # check is less important anyway, so whatever.  Ignore it.
            print('Couldn\'t get MinGameStageIndex for {} {}'.format(
                partlist_name, label))
            pass
        if 'Manufacturers' not in part or not part['Manufacturers'] or part[
                'Manufacturers'] == '':
            attr_parts.append((part_name, 100))
        elif part['Manufacturers'][0]['Manufacturer'] is None or part[
                'Manufacturers'][0]['Manufacturer'] == 'None':
            attr_parts.append(
                (part_name, caids[int(part['DefaultWeightIndex'])]))
        else:
            print('')
            raise Exception('Have not implemented Manufacturer yet...')

    total_weight = sum([p[1] for p in attr_parts])
    for (part, weight) in attr_parts:
        df.writerow({
            'game': game,
            'balance': baldef_name,
            'parttype': label,
            'part': part,
            'ind_weight': weight,
            'total_weight': total_weight,
            'pct': round(weight / total_weight * 100, 1),
        })
Ejemplo n.º 5
0
def get_presentations(data, base_obj):
    customs = set()
    if 'CustomPresentations' in base_obj and base_obj[
            'CustomPresentations'] != '':
        for cp_full in base_obj['CustomPresentations']:
            cp_name = Data.get_attr_obj(cp_full)
            cp = data.get_struct_by_full_object(cp_name)
            if 'NoConstraintText' in cp and cp['NoConstraintText'] != '':
                customs.add((cp_name, cp['NoConstraintText']))
            if 'Description' in cp and cp['Description'] != '':
                # Have to work around a deficiency in our data processing
                # (should probably just check for `type(foo) == dict` and solve it more generally, eh?)
                if cp['Description'] == {'E ': ' mc^(OMG)/wtf'}:
                    customs.add((cp_name, 'E = mc^(OMG)/wtf'))
                elif cp['Description'] == {'5+7+1': 'Zero'}:
                    customs.add((cp_name, '5+7+1=Zero'))
                else:
                    customs.add((cp_name, cp['Description']))
    return customs
Ejemplo n.º 6
0
def print_title(bal_name):
    try:
        bal_struct = data.get_struct_by_full_object(bal_name)
        if 'ItemName' in bal_struct:
            top_level = 'ItemName'
        elif 'RuntimePartListCollection' in bal_struct:
            top_level = 'RuntimePartListCollection'
        elif 'PartListCollection' in bal_struct:
            top_level = 'PartListCollection'
        else:
            raise Exception('Unknown top-level attribute')

        if bal_struct[top_level] == 'None':
            # This should match on shields

            if 'InventoryDefinition' in bal_struct:
                inv_def = data.get_struct_attr_obj_real(
                    bal_struct, 'InventoryDefinition')
                if 'TitleList' in inv_def:
                    for title_def in inv_def['TitleList']:
                        title = data.get_struct_by_full_object(
                            Data.get_attr_obj(title_def))
                        print(title['PartName'])
                else:
                    for partlist_name in [
                            'AlphaParts', 'BetaParts', 'GammaParts',
                            'DeltaParts'
                    ]:
                        if partlist_name in inv_def and inv_def[
                                partlist_name] != 'None':
                            partlist = data.get_struct_attr_obj_real(
                                inv_def, partlist_name)
                            title_from_partdef(data, partlist)
                #elif 'AlphaParts' in inv_def:
                #    #print(inv_def)
                #    #title_from_partdef(data, inv_def, 'AlphaParts')
                #else:
                #    raise Exception('No mid-level attribute found')
            else:
                raise Exception('Exhausted possible top-level attributes')

        else:
            # This should match on weapons, relics, and grenade mods

            if top_level == 'ItemName':
                # This'll match on relics
                print(bal_struct['ItemName'])

            else:
                # Weapons and grenade mods
                partlist = data.get_struct_attr_obj_real(bal_struct, top_level)
                if 'BarrelPartData' in partlist:
                    to_get = 'BarrelPartData'
                elif 'AlphaPartData' in partlist:
                    to_get = 'AlphaPartData'
                else:
                    raise Exception('No understood part type found')
                title_from_partdef(data, partlist[to_get])

    except Exception as e:
        (ex_type, ex_val, ex_tb) = sys.exc_info()
        print('Error getting title: {}: {}'.format(ex_type.__name__, e))
        print('')
        traceback.print_exception(*sys.exc_info(), file=sys.stderr)
Ejemplo n.º 7
0
 def add_to_asv_dict(cur_dict, asv_list, pt):
     for asv in asv_list:
         name = Data.get_attr_obj(asv['Attribute'])
         cur_dict[name] = Weight(asv['BaseValue'], pt).value
     return cur_dict
Ejemplo n.º 8
0
            data.append(self.phaselock_time)
        data.extend(self.fire.get_data())
        data.extend(self.corrosive.get_data())
        data.extend(self.shock.get_data())
        data.extend(self.slag.get_data())
        return data

startvals = {}
ret_list = []
shown_header = False
writer = csv.writer(sys.stdout)
for pawnbal_name in sorted(data.get_all_by_type('AIPawnBalanceDefinition')):
    pawnbal = data.get_struct_by_full_object(pawnbal_name)
    if 'PlayThroughs' in pawnbal:
        aipawn = data.get_struct_attr_obj_real(pawnbal, 'AIPawnArchetype')
        allegiance = Data.get_attr_obj(aipawn['Allegiance'])
        if allegiance not in friendly_allegiances:
            aiclass_name = Data.get_attr_obj(aipawn['AIClass'])
            aiclass = data.get_struct_attr_obj_real(aipawn, 'AIClass')

            # Loop through all playthroughs to gather stats
            pawn_stats = []
            for (idx, pt) in enumerate(pawnbal['PlayThroughs']):
                display_name = get_display_name(pt['DisplayName'])
                pawn_stats.append(AttributeSet(display_name, pawnbal_name, idx+1, pawnbal, aiclass))

            # Loop through playthroughs one more time to combine any playthroughs
            # which have identical data (this could probably be done in the
            # previous loop, but eh.)
            report_stats=[pawn_stats[0]]
            for idx in range(1, len(pawn_stats)):
Ejemplo n.º 9
0
# used until updating BL2 CDH for DLC5...

import sys
from ftexplorer.data import Data

pools = {}

data = Data('BL2')
for baldef_name in data.get_all_by_type('AIPawnBalanceDefinition'):
    baldef = data.get_struct_by_full_object(baldef_name)

    if 'PlayThroughs' in baldef and baldef['PlayThroughs'] != 'None' and baldef['PlayThroughs'] != '':
        for pt in baldef['PlayThroughs']:
            if 'CustomItemPoolList' in pt and pt['CustomItemPoolList'] != 'None' and pt['CustomItemPoolList'] != '':
                for pool in pt['CustomItemPoolList']:
                    pool_name = Data.get_attr_obj(pool['ItemPool'])
                    if pool_name not in pools:
                        pools[pool_name] = set()
                    pools[pool_name].add(baldef_name)

    if 'DefaultItemPoolList' in baldef and baldef['DefaultItemPoolList'] != 'None' and baldef['DefaultItemPoolList'] != '':
        for pool in baldef['DefaultItemPoolList']:
            pool_name = Data.get_attr_obj(pool['ItemPool'])
            if pool_name not in pools:
                pools[pool_name] = set()
            pools[pool_name].add(baldef_name)

for pool_name, baldefs in sorted(pools.items()):
    print(pool_name)
    for baldef in sorted(baldefs):
        print('    {}'.format(baldef))