/// <summary>
        /// Calculates the max stats for a dinosaur. REQUIRES YOU TO RUN ArkSaveEditor.ArkImports.ImportContent() BEFORE THIS!
        /// </summary>
        /// <returns></returns>
        public ArkDinosaurStats GetMaxStats()
        {
            ArkDinoEntry     d                   = dino_entry;
            ArkWorldSettings settings            = ArkImports.world_settings;
            float            tamingEffectiveness = 0.5f;
            float            imprintingBonus     = 0f;

            if (d == null)
            {
                return(null);
            }

            return(new ArkDinosaurStats
            {
                health = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.Health, baseLevelupsApplied.health, tamingEffectiveness, tamedLevelupsApplied.health, imprintingBonus, settings, world.configSettings, isTamed),
                stamina = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.Stamina, baseLevelupsApplied.stamina, tamingEffectiveness, tamedLevelupsApplied.stamina, imprintingBonus, settings, world.configSettings, isTamed),
                unknown1 = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.Torpidity, baseLevelupsApplied.unknown1, tamingEffectiveness, tamedLevelupsApplied.unknown1, imprintingBonus, settings, world.configSettings, isTamed),
                oxygen = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.Oxygen, baseLevelupsApplied.oxygen, tamingEffectiveness, tamedLevelupsApplied.oxygen, imprintingBonus, settings, world.configSettings, isTamed),
                food = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.Food, baseLevelupsApplied.food, tamingEffectiveness, tamedLevelupsApplied.food, imprintingBonus, settings, world.configSettings, isTamed),
                water = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.Water, baseLevelupsApplied.water, tamingEffectiveness, tamedLevelupsApplied.water, imprintingBonus, settings, world.configSettings, isTamed),
                inventoryWeight = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.Weight, baseLevelupsApplied.inventoryWeight, tamingEffectiveness, tamedLevelupsApplied.inventoryWeight, imprintingBonus, settings, world.configSettings, isTamed),
                meleeDamageMult = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.MeleeDamage, baseLevelupsApplied.meleeDamageMult, tamingEffectiveness, tamedLevelupsApplied.meleeDamageMult, imprintingBonus, settings, world.configSettings, isTamed),
                movementSpeedMult = (float)ArkStatsCalculator.CalculateStat(d, DinoStatTypeIndex.Speed, baseLevelupsApplied.movementSpeedMult, tamingEffectiveness, tamedLevelupsApplied.movementSpeedMult, imprintingBonus, settings, world.configSettings, isTamed),
            });
        }
        public static bool ImportContentFromPackage(Stream package, VerifyPackageMetadata verify = null)
        {
            //Open package as ZIP
            using (ZipArchive zip = new ZipArchive(package, ZipArchiveMode.Read, true))
            {
                //Read package metadata first
                PrimalDataPackageMetadata metadata = PackageReaderHelper <PrimalDataPackageMetadata>(zip, "metadata.json");

                //If requested, verify that we can read this
                if (verify != null)
                {
                    if (!verify(metadata))
                    {
                        return(false);
                    }
                }

                //Now, read other parts
                packageMetadata          = metadata;
                dino_entries             = PackageReaderHelper <List <ArkDinoEntry> >(zip, "dinos.json");
                item_entries             = PackageReaderHelper <List <ArkItemEntry> >(zip, "items.json");
                world_settings           = PackageReaderHelper <ArkWorldSettings>(zip, "world_settings.json");
                classHierachy            = PackageReaderHelper <ImportedClassHierarchyFile>(zip, "classes.json");
                structureDisplayMetadata = PackageReaderHelper <List <StructureDisplayMetadata> >(zip, "structure_metadata.json");
            }

            return(true);
        }
 public static void ImportContent(string path)
 {
     //Deserialize all of these assets.
     packageMetadata          = JsonConvert.DeserializeObject <PrimalDataPackageMetadata>(File.ReadAllText(path + "metadata.json"));
     dino_entries             = JsonConvert.DeserializeObject <List <ArkDinoEntry> >(File.ReadAllText(path + "dinos.json"));
     item_entries             = JsonConvert.DeserializeObject <List <ArkItemEntry> >(File.ReadAllText(path + "items.json"));
     world_settings           = JsonConvert.DeserializeObject <ArkWorldSettings>(File.ReadAllText(path + "world_settings.json"));
     classHierachy            = JsonConvert.DeserializeObject <ImportedClassHierarchyFile>(File.ReadAllText(path + "classes.json"));
     structureDisplayMetadata = JsonConvert.DeserializeObject <List <StructureDisplayMetadata> >(File.ReadAllText(path + "structure_metadata.json"));
 }
Example #4
0
        public static double CalculateStat(ArkDinoEntry dino_entry, DinoStatTypeIndex stat, float levelWild, float tamingEff, float levelDom, float imprintingBonus, ArkWorldSettings world, ArkConfigSettings settings, bool isTamed)
        {
            // if stat is generally available but level is set to -1 (== unknown), return -1 (== unknown)
            if (levelWild < 0 && dino_entry != null && dino_entry.increasePerWildLevel[stat] != 0)
            {
                return(-1);
            }
            if (dino_entry != null)
            {
                Dictionary <DinoStatTypeIndex, ArkBreedingStat> stats = dino_entry.GetBreedingStats(settings);
                double add = 0, domMult = 1, imprintingM = 1, tamedBaseHP = 1;
                if (isTamed)
                {
                    add = stats[stat].AddWhenTamed;
                    double domMultAffinity = stats[stat].MultAffinity;
                    // the multiplicative bonus is only multiplied with the TE if it is positive (i.e. negative boni won't get less bad if the TE is low)
                    if (domMultAffinity >= 0)
                    {
                        domMultAffinity *= tamingEff;
                    }
                    domMult = (tamingEff >= 0 ? (1 + domMultAffinity) : 1) * (1 + levelDom * stats[stat].IncPerTamedLevel);
                    if (imprintingBonus > 0 &&
                        stat != DinoStatTypeIndex.Stamina &&
                        stat != DinoStatTypeIndex.Oxygen &&
                        stat != DinoStatTypeIndex.Temperature &&
                        (stat != DinoStatTypeIndex.Speed /*|| species.NoImprintingForSpeed == false*/) &&
                        stat != DinoStatTypeIndex.TemperatureFortitude &&
                        stat != DinoStatTypeIndex.CraftingSpeed
                        )
                    {
                        imprintingM = 1 + 0.2 * imprintingBonus * settings.BabyImprintingStatScaleMultiplier; // TODO 0.2 is not always true
                    }
                    if (stat == 0)
                    {
                        tamedBaseHP = (float)dino_entry.statusComponent.tamedBaseHealthMultiplier;
                    }
                }
                //double result = Math.Round((species.stats[stat].BaseValue * tamedBaseHP * (1 + species.stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) * domMult, Utils.precision(stat), MidpointRounding.AwayFromZero);
                // double is too precise and results in wrong values due to rounding. float results in better values, probably ARK uses float as well.
                // or rounding first to a precision of 7, then use the rounding of the precision
                //double resultt = Math.Round((species.stats[stat].BaseValue * tamedBaseHP * (1 + species.stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) * domMult, 7);
                //resultt = Math.Round(resultt, Utils.precision(stat), MidpointRounding.AwayFromZero);

                // adding an epsilon to handle rounding-errors
                double result = Math.Round((stats[stat].BaseValue * tamedBaseHP *
                                            (1 + stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) *
                                           domMult + roundupDelta, precision(stat), MidpointRounding.AwayFromZero);

                return(result >= 0 ? result : 0);
            }
            return(0);
        }