コード例 #1
0
def is_item_base_class(item: PrimalItem) -> bool:
    item_name = item.get('DescriptiveNameBase', 0, None)
    icon_texture = item.get('ItemIcon', 0, None)
    icon_material = item.get('ItemIconMaterialParent', 0, None)

    if not item_name or (not icon_texture and not icon_material):
        return True
    return False
コード例 #2
0
def _get_pretty_item_type(item: PrimalItem) -> str:
    itemType = item.get('MyItemType', 0, None)
    value = itemType.get_enum_value_name()
    if value == 'MiscConsumable':
        consumableType = item.get('MyConsumableType', 0, None)
        return value + '/' + consumableType.get_enum_value_name()
    elif value == 'Equipment':
        equipmentType = item.get('MyEquipmentType', 0, None)
        return value + '/' + equipmentType.get_enum_value_name()
    return value
コード例 #3
0
def convert_egg_values(item: PrimalItem) -> Dict[str, Any]:
    v = dict()

    dino_class = item.get('EggDinoClassToSpawn', 0, None)
    if dino_class:
        v['dinoClass'] = dino_class
        v['temperature'] = (item.EggMinTemperature[0], item.EggMaxTemperature[0])

    hud_mic_ref = item.get('ItemIconMaterialParent', 0, None)
    if hud_mic_ref:
        hud_mic = item.get_source().asset.loader.load_related(hud_mic_ref)
        hud_mic = hud_mic.default_export
        hud_colors = gather_hud_color_data(hud_mic)
        if hud_colors:
            v['hudColorisation'] = hud_colors

    return v
コード例 #4
0
ファイル: egg.py プロジェクト: arkutils/Purlovia
def convert_egg_values(item: PrimalItem) -> Optional[EggData]:
    dino_class = item.get('EggDinoClassToSpawn', 0, None)
    if not dino_class or not dino_class.value or not dino_class.value.value:
        return None

    return EggData(
        dinoClass=dino_class.value.value.format_for_json(),
        temperature=MinMaxRange(min=item.EggMinTemperature[0],
                                max=item.EggMaxTemperature[0]),
    )
コード例 #5
0
ファイル: egg.py プロジェクト: TigerMehMat/Purlovia
def convert_egg_values(item: PrimalItem) -> Dict[str, Any]:
    v = dict()

    dino_class = item.get('EggDinoClassToSpawn', 0, None)
    if dino_class:
        v['dinoClass'] = dino_class
        v['temperature'] = (item.EggMinTemperature[0], item.EggMaxTemperature[0])

    hud_mic_ref = item.get('ItemIconMaterialParent', 0, None)
    if hud_mic_ref and hud_mic_ref.value and hud_mic_ref.value.value:
        try:
            hud_mic = item.get_source().asset.loader.load_related(hud_mic_ref)
            hud_mic = hud_mic.default_export
            hud_colors = gather_hud_color_data(hud_mic)
            if hud_colors:
                v['hudColorisation'] = hud_colors
        except AssetLoadException:
            logger.warning(f'Failure while gathering color data from {hud_mic_ref.value.value.fullname}', exc_info=True)

    return v
コード例 #6
0
ファイル: crafting.py プロジェクト: LiungArkeanda/Purlovia
def convert_crafting_values(item: PrimalItem) -> Dict[str, Any]:
    if item.bCraftDontActuallyGiveItem[0]:
        product_count: Union[int, IntProperty] = 0
    else:
        if item.CraftingGivesItemQuantityOverride[0].value >= 1:
            product_count = item.CraftingGiveItemCount[0]
        else:
            product_count = item.ItemQuantity[0]

    v: Dict[str, Any] = dict(crafting=dict(
        xp=item.BaseCraftingXP[0],
        bpCraftTime=item.BlueprintTimeToCraft[0],
        minLevelReq=item.CraftingMinLevelRequirement[0],
        productCount=product_count,
        skillQualityMult=(item.CraftingSkillQualityMultiplierMin[0],
                          item.CraftingSkillQualityMultiplierMax[0]),
    ))

    recipe = item.get('BaseCraftingResourceRequirements', 0, None)
    if recipe and recipe.values:
        v['crafting']['recipe'] = [
            v for v in (convert_recipe_entry(entry.as_dict())
                        for entry in recipe.values) if v
        ]

    if item.bAllowRepair[0]:
        v['repair'] = dict(
            xp=item.BaseRepairingXP[0],
            time=item.TimeForFullRepair[0],
            resourceMult=item.RepairResourceRequirementMultiplier[0],
        )
        if item.bOverrideRepairingRequirements[0]:
            recipe = item.get('OverrideRepairingRequirements', 0, None)
            if recipe and recipe.values:
                v['repair']['recipe'] = [
                    v for v in (convert_recipe_entry(entry.as_dict())
                                for entry in recipe.values) if v
                ]

    return v
コード例 #7
0
def get_item_name(item: PrimalItem) -> Optional[str]:
    item_name = item.get('DescriptiveNameBase', fallback=None)
    if not item_name:
        return None

    out = str(item_name)

    # The game adds the Skin suffix to the item's name if bIsItemSkin is true. This only happens when the name is
    # not overridden by any other dynamic feature, like scripts or the rarity system (that preseeds quality and
    # other stats), and it's probably safer for us to export the CDO name in these cases.
    if item.bIsItemSkin[0] and not item.bUseBPGetItemName[0] and not item.bUseItemStats[0]:
        out += ' Skin'

    return out
コード例 #8
0
def convert_crafting_values(
    item: PrimalItem,
    has_durability: bool = False
) -> Tuple[Optional[CraftingData], Optional[RepairData]]:
    recipe = item.get('BaseCraftingResourceRequirements', 0, None)
    if not recipe:
        return (None, None)

    # Crafted item number
    if item.bCraftDontActuallyGiveItem[0]:
        product_count: Union[int, IntProperty] = 0
    elif item.CraftingGiveItemCount[0] >= 1:
        product_count = item.CraftingGiveItemCount[0]
    elif item.CraftingGivesItemQuantityOverride[0] >= 1:
        product_count = item.CraftingGivesItemQuantityOverride[0]
    else:
        product_count = item.ItemQuantity[0]

    crafting = CraftingData(
        xp=item.BaseCraftingXP[0],
        time=item.BlueprintTimeToCraft[0],
        levelReq=item.CraftingMinLevelRequirement[0],
        productCount=int(product_count),
        skillQualityMult=MinMaxRange(
            min=item.CraftingSkillQualityMultiplierMin[0],
            max=item.CraftingSkillQualityMultiplierMax[0]),
        recipe=list(convert_recipe_entries(recipe.values)),
    )

    # Do not export crafting info if recipe consists only of nulls.
    if not crafting.recipe:
        return (None, None)

    # Durability repair info
    repair = None
    if item.bAllowRepair[0] and has_durability:
        repair = RepairData(
            xp=item.BaseRepairingXP[0],
            time=item.TimeForFullRepair[0],
            recipe=[],
        )

        if item.bOverrideRepairingRequirements[0]:
            recipe = item.get('OverrideRepairingRequirements', 0, None)
            if not recipe or not recipe.values:
                # Override to no ingredients, skip repair.
                repair = None
            else:
                # Convert the repair requirements list.
                repair.recipe = list(convert_recipe_entries(recipe.values))

                # Do not export repair info if the overrides lead to no valid ingredients
                if not repair.recipe:
                    repair = None
        else:
            # Copy crafting ingredients and scale their quantities by the repair multiplier.
            qty_mult = item.RepairResourceRequirementMultiplier[0]
            if qty_mult != 1.0:
                for ingredient in crafting.recipe:
                    ingredient_copy = ingredient.copy()
                    ingredient_copy.qty = clean_float(ingredient_copy.qty *
                                                      qty_mult)
                    repair.recipe.append(ingredient_copy)

    return (crafting, repair)