Exemplo n.º 1
0
    def extract(self, proxy: UEProxyStructure) -> Any:
        species: PrimalDinoCharacter = cast(PrimalDinoCharacter, proxy)

        asset: UAsset = proxy.get_source().asset
        assert asset.assetname and asset.default_class
        modid: Optional[str] = self.manager.loader.get_mod_id(asset.assetname)
        overrides = get_overrides_for_species(asset.assetname, modid)

        if _should_skip_species(species, overrides):
            return None

        try:
            dcsc = gather_dcsc_properties(species.get_source())
        except AssetLoadException as ex:
            logger.warning(
                f'Gathering properties failed for {asset.assetname}: %s',
                str(ex))
            return None

        name = str(species.DescriptiveName[0])

        variants = get_variants_from_assetname(
            asset.assetname, overrides) | get_variants_from_species(
                species, overrides)
        if variants:
            if should_skip_from_variants(variants, overrides):
                return None

            name = adjust_name_from_variants(name, variants, overrides)

        out = Species(bp=asset.default_class.fullname)
        out.name = name
        out.dinoNameTag = species.DinoNameTag[0]
        out.customTag = species.CustomTag[0]
        out.targetingTeamName = species.TargetingTeamNameOverride[0]
        out.mass = species.CharacterMovement[0].Mass[0]
        out.dragWeight = species.DragWeight[0]

        if variants:
            out.variants = tuple(sorted(variants))

        out.flags = gather_flags(species, OUTPUT_FLAGS)

        out.levelCaps = convert_level_data(species, dcsc)
        out.cloning = gather_cloning_data(species)

        out.falling = FallingData(
            dmgMult=species.FallDamageMultiplier[0],
            maxSpeed=species.MaxFallSpeed[0],
        )

        movement = gather_movement_data(species, dcsc)
        out.movementW = movement.movementW
        out.movementD = movement.movementD
        out.staminaRates = movement.staminaRates
        out.attack = gather_attack_data(species)

        return out
Exemplo n.º 2
0
    def extract(self, proxy: UEProxyStructure) -> Any:
        species: PrimalDinoCharacter = cast(PrimalDinoCharacter, proxy)

        asset: UAsset = proxy.get_source().asset
        assert asset.assetname and asset.default_class
        modid: Optional[str] = self.manager.loader.get_mod_id(asset.assetname)
        overrides = get_overrides_for_species(asset.assetname, modid)

        if _should_skip_species(species, overrides):
            return None

        name = str(species.DescriptiveName[0])

        variants = get_variants_from_assetname(
            asset.assetname, overrides) | get_variants_from_species(species)
        if variants:
            if should_skip_from_variants(variants, overrides):
                return None

            name = adjust_name_from_variants(name, variants, overrides)

        results: Dict[str, Any] = dict(
            name=name,
            blueprintPath=asset.default_class.fullname,
            dinoNameTag=species.DinoNameTag[0],
            customTag=species.CustomTag[0],
            targetingTeamName=species.TargetingTeamNameOverride[0],
            mass=species.CharacterMovement[0].Mass[0],
            dragWeight=species.DragWeight[0],
        )

        if variants:
            results['variants'] = tuple(sorted(variants))

        results['flags'] = _gather_flags(species)

        results['falling'] = dict(
            dmgMult=species.FallDamageMultiplier[0],
            maxSpeed=species.MaxFallSpeed[0],
        )

        results.update(gather_movement_data(species))
        results.update(gather_attack_data(species))

        return results
Exemplo n.º 3
0
def values_for_species(asset: UAsset,
                       props: PriorityPropDict,
                       proxy: PrimalDinoCharacter,
                       allFields=False,
                       fullStats=True,
                       includeColor=True,
                       includeBreeding=True,
                       includeImmobilize=True,
                       includeDamageMults=True,
                       includeTaming=True):
    assert asset.loader

    # Having no name or tag is an indication that this is an intermediate class, not a spawnable species
    name = stat_value(props, 'DescriptiveName', 0, None) or stat_value(
        props, 'DinoNameTag', 0, None)
    if not name:
        logger.debug(
            f"Species {asset.assetname} has no DescriptiveName or DinoNameTag - skipping"
        )
        return

    # Also consider anything that doesn't override any base status value as non-spawnable
    if not any(
            stat_value(props, 'MaxStatusValues', n, None) is not None
            for n in ARK_STAT_INDEXES):
        logger.debug(
            f"Species {asset.assetname} has no overridden stats - skipping")
        return

    assert asset.assetname and asset.default_export and asset.default_class and asset.default_class.fullname

    modid: str = asset.loader.get_mod_id(asset.assetname)
    overrides = get_overrides_for_species(asset.assetname, modid)

    if get_overrides_for_species(asset.assetname, modid).skip_export:
        return

    bp: str = asset.default_class.fullname
    if bp.endswith('_C'):
        bp = bp[:-2]

    # Replace names to match ASB's hardcoding of specific species
    name = overrides.descriptive_name or name

    # Variant information
    variants = get_variants_from_assetname(
        asset.assetname, overrides) | get_variants_from_species(proxy)
    if variants:
        if should_skip_from_variants(variants, overrides):
            return
        name = adjust_name_from_variants(name, variants, overrides)

    species = dict(name=name, blueprintPath=bp)
    if variants:
        species['variants'] = tuple(sorted(variants))

    # Stat data
    statsField = 'fullStatsRaw' if fullStats else 'statsRaw'
    statIndexes = ARK_STAT_INDEXES if fullStats else ASB_STAT_INDEXES
    species[statsField] = gather_stat_data(props, statIndexes)

    # Set imprint multipliers
    stat_imprint_mults: List[float] = list()
    for ark_index in statIndexes:
        imprint_mult = stat_value(props, 'DinoMaxStatAddMultiplierImprinting',
                                  ark_index, IMPRINT_VALUES)
        stat_imprint_mults.append(imprint_mult)
    if stat_imprint_mults != list(IMPRINT_VALUES):
        species['statImprintMult'] = stat_imprint_mults

    if includeImmobilize:
        # ImmobilizedBy format data
        immobilization_data = None
        try:
            immobilization_data = gather_immobilization_data(
                props, asset.loader)
        except (AssetNotFound, ModNotFound) as ex:
            logger.warning(
                f'Failure while gathering immobilization data for {asset.assetname}:\n\t{ex}'
            )
        if immobilization_data is not None:
            species['immobilizedBy'] = immobilization_data

    if includeBreeding:
        # Breeding data
        if stat_value(props, 'bCanHaveBaby', 0,
                      False):  # TODO: Consider always including this data
            breeding_data = None
            try:
                breeding_data = gather_breeding_data(props, asset.loader)
            except (AssetNotFound, ModNotFound) as ex:
                logger.warning(
                    f'Failure while gathering breeding data for {asset.assetname}:\n\t{ex}'
                )
            if breeding_data:
                species['breeding'] = breeding_data

    if includeColor:
        # Color data
        if stat_value(props, 'bUseColorization', False):
            colors = None
            try:
                colors = gather_color_data(asset, props, overrides)
            except (AssetNotFound, ModNotFound) as ex:
                logger.warning(
                    f'Failure while gathering color data for {asset.assetname}:\n\t{ex}'
                )
            if colors is not None:
                species['colors'] = colors

    if includeTaming:
        # Taming data
        if stat_value(
                props, 'bCanBeTamed', True
        ) or True:  # ASB currently requires all species to have taming data
            taming = None
            try:
                taming = gather_taming_data(props)
            except (AssetNotFound, ModNotFound) as ex:
                logger.warning(
                    f'Failure while gathering taming data for {asset.assetname}:\n\t{ex}'
                )
            if taming:
                species['taming'] = taming

    if includeDamageMults:
        # Bone damage multipliers
        dmg_mults = None
        try:
            dmg_mults = gather_damage_mults(props)
        except (AssetNotFound, ModNotFound) as ex:
            logger.warning(
                f'Failure while gathering bone damage data for {asset.assetname}:\n\t{ex}'
            )
        if dmg_mults:
            species['boneDamageAdjusters'] = dmg_mults

    # Misc data
    noSpeedImprint = (stat_value(props, 'DinoMaxStatAddMultiplierImprinting',
                                 9, IMPRINT_VALUES) == 0)
    usesOxyWild = stat_value(props, 'bCanSuffocate', 0, True)
    usesOxyTamed = stat_value(props, 'bCanSuffocateIfTamed', 0, usesOxyWild)
    forceOxy = stat_value(props, 'bForceGainOxygen', 0, False)
    doesntUseOxygen = not (usesOxyTamed or forceOxy)
    ETBHM = stat_value(props, 'ExtraTamedBaseHealthMultiplier', 0, 1)
    TBHM = stat_value(props, 'TamedBaseHealthMultiplier', 0, 1) * ETBHM

    displayed_stats: int = 0

    for i in statIndexes:
        use_stat = not stat_value(props, 'DontUseValue', i, DONTUSESTAT_VALUES)
        if use_stat and not (i == 3 and doesntUseOxygen):
            displayed_stats |= (1 << i)

    if allFields or TBHM != 1: species['TamedBaseHealthMultiplier'] = cd(TBHM)
    if allFields or noSpeedImprint:
        species['NoImprintingForSpeed'] = noSpeedImprint
    if allFields or doesntUseOxygen:
        species['doesNotUseOxygen'] = doesntUseOxygen
    if allFields or displayed_stats:
        species['displayedStats'] = displayed_stats

    return species
Exemplo n.º 4
0
def values_for_species(asset: UAsset,
                       proxy: PrimalDinoCharacter) -> Optional[Dict[str, Any]]:
    assert asset.loader and asset.default_export and asset.default_class and asset.default_class.fullname

    char_props: PrimalDinoCharacter = ue.gathering.gather_properties(
        asset.default_export)
    dcsc_props: PrimalDinoStatusComponent = ark.gathering.gather_dcsc_properties(
        asset.default_export)
    dcsc_alt_props: PrimalDinoStatusComponent = ark.gathering.gather_dcsc_properties(
        asset.default_export, alt=True)

    # Having no name or tag is an indication that this is an intermediate class, not a spawnable species
    name = (str(char_props.DescriptiveName[0])
            or str(char_props.DinoNameTag[0])).strip()
    if not name:
        logger.debug(
            f"Species {asset.assetname} has no DescriptiveName or DinoNameTag - skipping"
        )
        return None

    # Also consider anything that doesn't override any base status value as non-spawnable
    if not any(
            dcsc_props.has_override('MaxStatusValues', n)
            for n in ARK_STAT_INDEXES):
        logger.debug(
            f"Species {asset.assetname} has no overridden stats - skipping")
        return None

    assert asset.assetname and asset.default_export and asset.default_class and asset.default_class.fullname

    modid: str = asset.loader.get_mod_id(asset.assetname) or ''
    overrides = get_overrides_for_species(asset.assetname, modid)

    if overrides.skip_export:
        return None

    bp: str = asset.default_class.fullname
    if bp.endswith('_C'):
        bp = bp[:-2]

    # Replace names to match ASB's hardcoding of specific species
    name = overrides.descriptive_name or name

    # Variant information
    variants = get_variants_from_assetname(
        asset.assetname, overrides) | get_variants_from_species(
            proxy, overrides)
    if variants:
        if should_skip_from_variants(variants, overrides):
            return None
        name = adjust_name_from_variants(name, variants, overrides)

    species: Dict[str, Any] = dict(name=name, blueprintPath=bp)
    if variants:
        species['variants'] = tuple(sorted(variants))

    # Stat data
    is_flyer = bool(char_props.bIsFlyerDino[0])
    if is_flyer:
        species['isFlyer'] = True
    normal_stats = gather_stat_data(dcsc_props, dcsc_props, is_flyer,
                                    ARK_STAT_INDEXES)
    alt_stats = gather_stat_data(dcsc_alt_props, dcsc_props, is_flyer,
                                 ARK_STAT_INDEXES)
    alt_stats = reduce_alt_stats(normal_stats, alt_stats)
    species['fullStatsRaw'] = normal_stats
    if alt_stats:
        species['altBaseStats'] = alt_stats

    # Set imprint multipliers
    stat_imprint_mults: List[float] = list()
    unique_mults = False
    for stat_index in ARK_STAT_INDEXES:
        imprint_mult = dcsc_props.DinoMaxStatAddMultiplierImprinting[
            stat_index]
        stat_imprint_mults.append(imprint_mult.rounded_value)

        # TODO: Optimize: Too many property look ups
        if DCSC_DEFAULTS.DinoMaxStatAddMultiplierImprinting[
                stat_index] != imprint_mult:
            unique_mults = True

    if unique_mults:
        species['statImprintMult'] = stat_imprint_mults

    # ImmobilizedBy format data
    immobilization_data = None
    try:
        immobilization_data = gather_immobilization_data(
            char_props, asset.loader)
    except (AssetNotFound, ModNotFound) as ex:
        logger.warning(
            f'Failure while gathering immobilization data for {asset.assetname}:\n\t{ex}'
        )
    if immobilization_data is not None:
        species['immobilizedBy'] = immobilization_data

    if not char_props.bUsesGender[0]:
        species['noGender'] = True

    # Breeding data
    if char_props.bCanHaveBaby[0]:  # TODO: Consider always including this data
        breeding_data = None
        try:
            breeding_data = gather_breeding_data(char_props, asset.loader)
        except (AssetNotFound, ModNotFound) as ex:
            logger.warning(
                f'Failure while gathering breeding data for {asset.assetname}:\n\t{ex}'
            )
        if breeding_data:
            species['breeding'] = breeding_data

    # Color data
    if char_props.bUseColorization[0]:
        colors = None
        try:
            colors = gather_color_data(char_props, overrides)
        except (AssetNotFound, ModNotFound) as ex:
            logger.warning(
                f'Failure while gathering color data for {asset.assetname}:\n\t{ex}'
            )
        if colors is not None:
            species['colors'] = colors

    # Taming data
    if char_props.bCanBeTamed[
            0] or True:  # ASB currently requires all species to have taming data
        taming = None
        try:
            taming = gather_taming_data(char_props, dcsc_props, overrides)
        except (AssetNotFound, ModNotFound) as ex:
            logger.warning(
                f'Failure while gathering taming data for {asset.assetname}:\n\t{ex}'
            )
        if taming:
            species['taming'] = taming

    # Bone damage multipliers
    dmg_mults = None
    try:
        dmg_mults = gather_damage_mults(char_props)
    except (AssetNotFound, ModNotFound) as ex:
        logger.warning(
            f'Failure while gathering bone damage data for {asset.assetname}:\n\t{ex}'
        )
    if dmg_mults:
        species['boneDamageAdjusters'] = dmg_mults

    # Misc data
    usesOxyWild = dcsc_props.bCanSuffocate[0]
    usesOxyTamed = True if usesOxyWild else dcsc_props.bCanSuffocateIfTamed[0]
    forceOxy = dcsc_props.bForceGainOxygen[0]
    doesntUseOxygen = not (usesOxyTamed or forceOxy)

    ETBHM = char_props.ExtraTamedBaseHealthMultiplier[0]
    TBHM = dcsc_props.TamedBaseHealthMultiplier[0] * ETBHM

    displayed_stats: int = 0

    for i in ARK_STAT_INDEXES:
        use_stat = not dcsc_props.DontUseValue[i]
        if use_stat and not (i == 3 and doesntUseOxygen):
            displayed_stats |= (1 << i)

    species['TamedBaseHealthMultiplier'] = cf(TBHM)
    species['displayedStats'] = displayed_stats

    stat_name_overrides = get_stat_name_overrides(dcsc_props)
    if stat_name_overrides:
        species['statNames'] = stat_name_overrides

    return species