Esempio n. 1
0
        public ExportedCreatureControl(string filePath)
        {
            InitializeComponent();
            exportedFile   = filePath;
            creatureValues = ImportExported.importExportedCreature(filePath);

            // check if the values are valid, i.e. if the read file was a creature-file at all.
            if (creatureValues?.Species == null)
            {
                speciesBlueprintPath = creatureValues.speciesBlueprint;
                validValues          = false;
                return;
            }

            groupBox1.Text = $"{creatureValues.name} ({(creatureValues.Species?.name ?? "unknown species")}, Lv {creatureValues.level}), " +
                             $"exported at {Utils.shortTimeDate(creatureValues.domesticatedAt)}. " +
                             $"Filename: {Path.GetFileName(filePath)}";
            Disposed += ExportedCreatureControl_Disposed;

            if (tt == null)
            {
                tt = new ToolTip();
            }
            tt.SetToolTip(btRemoveFile, "Delete the exported game-file");

            validValues = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Set the stat-values to the extractor.
        /// </summary>
        /// <param name="cv"></param>
        /// <param name="setInfoInput"></param>
        private void SetCreatureValuesToExtractor(CreatureValues cv, bool setInfoInput = true)
        {
            // at this point, if the creatureValues has parent-ArkIds, make sure these parent-creatures exist
            if (cv.Mother == null)
            {
                if (creatureCollection.CreatureById(cv.motherGuid, cv.motherArkId, cv.Species, cv.sex, out Creature mother))
                {
                    cv.Mother = mother;
                }
                else if (cv.motherArkId != 0)
                {
                    cv.Mother = new Creature(cv.motherArkId);
                    creatureCollection.creatures.Add(cv.Mother);
                }
            }
            if (cv.Father == null)
            {
                if (creatureCollection.CreatureById(cv.fatherGuid, cv.fatherArkId, cv.Species, cv.sex, out Creature father))
                {
                    cv.Father = father;
                }
                else if (cv.fatherArkId != 0)
                {
                    cv.Father = new Creature(cv.fatherArkId);
                    creatureCollection.creatures.Add(cv.Father);
                }
            }

            ClearAll();
            speciesSelector1.SetSpecies(Values.V.SpeciesByBlueprint(cv.speciesBlueprint));
            for (int s = 0; s < Values.STATS_COUNT; s++)
            {
                statIOs[s].Input = cv.statValues[s];
            }

            if (setInfoInput)
            {
                SetCreatureValuesToInfoInput(cv, creatureInfoInputExtractor);
            }

            numericUpDownLevel.ValueSave          = cv.level;
            numericUpDownLowerTEffBound.ValueSave = (decimal)cv.tamingEffMin * 100;
            numericUpDownUpperTEffBound.ValueSave = (decimal)cv.tamingEffMax * 100;

            if (cv.isBred)
            {
                rbBredExtractor.Checked = true;
            }
            else if (cv.isTamed)
            {
                rbTamedExtractor.Checked = true;
            }
            else
            {
                rbWildExtractor.Checked = true;
            }
            numericUpDownImprintingBonusExtractor.ValueSave = (decimal)cv.imprintingBonus * 100;
        }
Esempio n. 3
0
        private void addCreatureValuesControl(CreatureValues cv)
        {
            ExportedCreatureControl ecc = new ExportedCreatureControl(cv);

            ecc.Dock = DockStyle.Top;
            ecc.CopyValuesToExtractor += CopyValuesToExtractor;
            ecc.CheckGuidInLibrary    += CheckGuidInLibrary;
            ecc.DoCheckGuidInLibrary();
            panel1.Controls.Add(ecc);
        }
Esempio n. 4
0
        public ExportedCreatureControl(string filePath)
        {
            InitializeComponent();
            exportedFile = filePath;
            CreatureValues creatureValues = ImportExported.importExportedCreature(filePath);

            this.creatureValues = creatureValues;
            groupBox1.Text      = creatureValues.name + " (" + creatureValues.species + ", Lv " + creatureValues.level + "), exported at " + Utils.shortTimeDate(creatureValues.domesticatedAt)
                                  + ". Filename: " + Path.GetFileName(filePath);
            Disposed += ExportedCreatureControl_Disposed;
            tt        = new ToolTip();
            tt.SetToolTip(btRemoveFile, "Delete the exported game-file");
        }
 public ExportedCreatureControl(string filePath)
 {
     InitializeComponent();
     exportedFile   = filePath;
     creatureValues = ImportExported.importExportedCreature(filePath);
     groupBox1.Text = $"{creatureValues.name} ({creatureValues.species}, Lv {creatureValues.level}), " +
                      $"exported at {Utils.shortTimeDate(creatureValues.domesticatedAt)}. " +
                      $"Filename: {Path.GetFileName(filePath)}";
     Disposed += ExportedCreatureControl_Disposed;
     if (tt == null)
     {
         tt = new ToolTip();
     }
     tt.SetToolTip(btRemoveFile, "Delete the exported game-file");
 }
        private bool ExtractValuesInExtractor(CreatureValues cv, string filePath, bool autoExtraction)
        {
            SetCreatureValuesToExtractor(cv, false);

            // exported stat-files have values for all stats, so activate all stats the species uses
            SetStatsActiveAccordingToUsage(cv.Species);

            bool creatureExists = IsCreatureAlreadyInLibrary(cv.guid, cv.ARKID, out Creature existingCreature);

            ExtractLevels(autoExtraction: autoExtraction, statInputsHighPrecision: true, existingCreature: existingCreature);
            UpdateParentListInput(creatureInfoInputExtractor); // this function is only used for single-creature extractions, e.g. LastExport
            SetCreatureValuesToInfoInput(cv, creatureInfoInputExtractor);
            creatureInfoInputExtractor.UpdateExistingCreature = creatureExists;
            SetMessageLabelText("Creature of the exported file\n" + filePath);
            return(creatureExists);
        }
        public static CreatureValues importExportedCreature(string filePath)
        {
            CreatureValues cv = new CreatureValues
            {
                domesticatedAt = File.GetLastWriteTime(filePath),
                isTamed        = true,
                tamingEffMax   = 1,
                tamingEffMin   = Properties.Settings.Default.ImportLowerBoundTE
            };

            string[] iniLines        = File.ReadAllLines(filePath);
            string   id              = "";
            int      statIndexIngame = -1;

            // this is the order how the stats appear in the ini-file; field names in the file are localized
            string[] statIndices =
            {
                "Health",
                "Stamina",
                "Torpidity",
                "Oxygen",
                "Food",
                "Water",
                "Temperature",
                "Weight",
                "Melee Damage",
                "Movement Speed",
                "Fortitude",
                "Crafting Skill"
            };
            bool inStatSection = false;

            foreach (string line in iniLines)
            {
                if (line.Contains("[Max Character Status Values]"))
                {
                    inStatSection = true;
                    continue;
                }
                if (line.Contains("="))
                {
                    string parameterName;
                    int    i    = line.IndexOf("=");
                    string text = line.Substring(i + 1);
                    double.TryParse(text, System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowLeadingSign, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out double value);
                    if (inStatSection)
                    {
                        statIndexIngame++;
                        if (statIndexIngame > 11)
                        {
                            inStatSection = false;
                        }
                    }
                    if (inStatSection)
                    {
                        parameterName = statIndices[statIndexIngame];
                    }
                    else
                    {
                        parameterName = line.Substring(0, i);
                        if (parameterName.Contains("DinoAncestorsMale"))
                        {
                            parameterName = "DinoAncestorsMale"; // only the last entry contains the parents
                        }
                    }

                    if (parameterName.Length <= 0)
                    {
                        continue;
                    }
                    switch (parameterName)
                    {
                    case "DinoID1":
                        if (string.IsNullOrEmpty(id))
                        {
                            id = text;
                        }
                        else
                        {
                            cv.ARKID = BuildARKID(text, id);
                            cv.guid  = Utils.ConvertArkIdToGuid(cv.ARKID);
                        }
                        break;

                    case "DinoID2":
                        if (string.IsNullOrEmpty(id))
                        {
                            id = text;
                        }
                        else
                        {
                            cv.ARKID = BuildARKID(id, text);
                            cv.guid  = Utils.ConvertArkIdToGuid(cv.ARKID);
                        }
                        break;

                    case "DinoClass":
                        // despite the property is called DinoClass it contains the complete blueprint-path
                        if (text.Length > 2 && text.Substring(text.Length - 2) == "_C")
                        {
                            text = text.Substring(0, text.Length - 2);     // the last two characters are "_C"
                        }
                        cv.Species = Values.V.SpeciesByBlueprint(text);
                        if (cv.Species == null)
                        {
                            cv.speciesBlueprint = text;     // species is unknown, check the needed mods later
                        }
                        break;

                    //case "DinoNameTag":
                    //    // get name if blueprintpath is not available (in this case a custom values_mod.json should be created, this is just a fallback
                    //    if (cv.Species == null &&
                    //        Values.V.TryGetSpeciesByName(text, out Species species))
                    //    {
                    //        cv.Species = species;
                    //    }
                    //    break;
                    case "bIsFemale":
                        cv.sex = text == "True" ? Sex.Female : Sex.Male;
                        break;

                    case "bIsNeutered":
                        if (text != "False")
                        {
                            cv.flags |= CreatureFlags.Neutered;
                        }
                        break;

                    case "TamerString":
                        if (Properties.Settings.Default.ImportExportUseTamerStringForOwner)
                        {
                            cv.owner = text;
                        }
                        else
                        {
                            cv.tribe = text;
                        }
                        break;

                    case "TamedName":
                        cv.name = text;
                        break;

                    case "ImprinterName":
                        cv.imprinterName = text;
                        if (string.IsNullOrEmpty(cv.owner))
                        {
                            cv.owner = text;
                        }
                        if (!string.IsNullOrWhiteSpace(text))
                        {
                            cv.isBred = true;
                        }
                        break;

                    // todo mutations for mother and father
                    case "RandomMutationsMale":
                        cv.mutationCounterFather = (int)value;
                        break;

                    case "RandomMutationsFemale":
                        cv.mutationCounterMother = (int)value;
                        break;

                    case "BabyAge":
                        if (cv.Species?.breeding != null)
                        {
                            cv.growingUntil = DateTime.Now.AddSeconds((int)(cv.Species.breeding.maturationTimeAdjusted * (1 - value)));
                        }
                        break;

                    case "CharacterLevel":
                        cv.level = (int)value;
                        break;

                    case "DinoImprintingQuality":
                        cv.imprintingBonus = value;
                        if (value > 0)
                        {
                            cv.isBred = true;
                        }
                        break;

                    // Colorization
                    case "ColorSet[0]":
                        cv.colorIDs[0] = ParseColor(text);
                        break;

                    case "ColorSet[1]":
                        cv.colorIDs[1] = ParseColor(text);
                        break;

                    case "ColorSet[2]":
                        cv.colorIDs[2] = ParseColor(text);
                        break;

                    case "ColorSet[3]":
                        cv.colorIDs[3] = ParseColor(text);
                        break;

                    case "ColorSet[4]":
                        cv.colorIDs[4] = ParseColor(text);
                        break;

                    case "ColorSet[5]":
                        cv.colorIDs[5] = ParseColor(text);
                        break;

                    case "Health":
                        cv.statValues[(int)StatNames.Health] = value;
                        break;

                    case "Stamina":
                        cv.statValues[(int)StatNames.Stamina] = value;
                        break;

                    case "Torpidity":
                        cv.statValues[(int)StatNames.Torpidity] = value;
                        break;

                    case "Oxygen":
                        cv.statValues[(int)StatNames.Oxygen] = value;
                        break;

                    case "Food":
                        cv.statValues[(int)StatNames.Food] = value;
                        break;

                    case "Water":
                        cv.statValues[(int)StatNames.Water] = value;
                        break;

                    case "Temperature":
                        cv.statValues[(int)StatNames.Temperature] = value;
                        break;

                    case "Weight":
                        cv.statValues[(int)StatNames.Weight] = value;
                        break;

                    case "Melee Damage":
                        cv.statValues[(int)StatNames.MeleeDamageMultiplier] = 1 + value;
                        break;

                    case "Movement Speed":
                        cv.statValues[(int)StatNames.SpeedMultiplier] = 1 + value;
                        break;

                    case "Fortitude":
                        cv.statValues[(int)StatNames.TemperatureFortitude] = 1 + value;
                        break;

                    case "Crafting Skill":
                        cv.statValues[(int)StatNames.CraftingSpeedMultiplier] = 1 + value;
                        break;

                    case "DinoAncestorsMale":
                        Regex r = new Regex(@"MaleName=([^;]+);MaleDinoID1=([^;]+);MaleDinoID2=([^;]+);FemaleName=([^;]+);FemaleDinoID1=([^;]+);FemaleDinoID2=([^;]+)");
                        Match m = r.Match(text);
                        if (m.Success)
                        {
                            cv.motherArkId = BuildARKID(m.Groups[5].Value, m.Groups[6].Value);
                            cv.fatherArkId = BuildARKID(m.Groups[2].Value, m.Groups[3].Value);
                            cv.isBred      = true;
                        }
                        break;
                    }
                }
            }

            // if parent ArkIds are set, create creature placeholder
            if (cv.motherArkId != 0)
            {
                cv.Mother = new Creature(cv.motherArkId)
                {
                    Species = cv.Species
                };
            }
            if (cv.fatherArkId != 0)
            {
                cv.Father = new Creature(cv.fatherArkId)
                {
                    Species = cv.Species
                };
            }

            // if file was not recognized, return null
            if (string.IsNullOrEmpty(cv.speciesBlueprint))
            {
                return(null);
            }

            return(cv);
        }
        /// <summary>
        /// Tries to converts the library from the 8-stats format to the 12-stats format and the species identification by the blueprintpath.
        /// </summary>
        public static void UpgradeFormatTo12Stats(CreatureCollectionOld ccOld, CreatureCollection ccNew)
        {
            if (ccOld == null)
            {
                return;
            }

            // if library has the old statMultiplier-indices, fix the order
            var newToOldIndices = new int[] { 0, 1, 7, 2, 3, -1, -1, 4, 5, 6, -1, -1 };

            if (ccOld.multipliers != null && ccOld.multipliers.Length == 8)
            {
                /// old order was
                /// HP, Stam, Ox, Fo, We, Dm, Sp, To
                /// new order is
                // 0: Health
                // 1: Stamina / Charge Capacity
                // 2: Torpidity
                // 3: Oxygen / Charge Regeneration
                // 4: Food
                // 5: Water
                // 6: Temperature
                // 7: Weight
                // 8: MeleeDamageMultiplier / Charge Emission Range
                // 9: SpeedMultiplier
                // 10: TemperatureFortitude
                // 11: CraftingSpeedMultiplier

                // imprinting bonus factor default 0.2, 0, 0.2, 0, 0.2, 0.2, 0, 0.2, 0.2, 0.2, 0, 0
                // i.e. stats without imprinting are by default: St, Ox, Te, TF, Cr

                // create new multiplierArray
                var newMultipliers = new double[Values.STATS_COUNT][];
                for (int s = 0; s < Values.STATS_COUNT; s++)
                {
                    newMultipliers[s] = new double[4];
                    if (newToOldIndices[s] >= 0)
                    {
                        for (int si = 0; si < 4; si++)
                        {
                            newMultipliers[s][si] = ccOld.multipliers[newToOldIndices[s]][si];
                        }
                    }
                    else
                    {
                        for (int si = 0; si < 4; si++)
                        {
                            newMultipliers[s][si] = 1;
                        }
                    }
                }
                ccOld.multipliers = newMultipliers;
            }

            ccNew.creatures = new List <Creature>();

            foreach (CreatureOld c in ccOld.creatures)
            {
                Creature newC = new Creature()
                {
                    addedToLibrary    = c.addedToLibrary.Year < 2000 ? default(DateTime?) : c.addedToLibrary,
                    ArkId             = c.ArkId,
                    ArkIdImported     = c.ArkIdImported,
                    colors            = c.colors,
                    cooldownUntil     = c.cooldownUntil.Year < 2000 ? default(DateTime?) : c.cooldownUntil,
                    domesticatedAt    = c.domesticatedAt.Year < 2000 ? default(DateTime?) : c.domesticatedAt,
                    fatherGuid        = c.fatherGuid,
                    flags             = c.flags,
                    generation        = c.generation,
                    growingLeft       = c.growingLeft,
                    growingPaused     = c.growingPaused,
                    growingUntil      = c.growingUntil.Year < 2000 ? default(DateTime?) : c.growingUntil,
                    guid              = c.guid,
                    imprinterName     = c.imprinterName,
                    imprintingBonus   = c.imprintingBonus,
                    isBred            = c.isBred,
                    motherGuid        = c.motherGuid,
                    mutationsMaternal = c.mutationsMaternal,
                    mutationsPaternal = c.mutationsPaternal,
                    name              = c.name,
                    note              = c.note,
                    owner             = c.owner,
                    server            = c.server,
                    sex       = c.sex,
                    Status    = c.status,
                    tags      = c.tags,
                    tamingEff = c.tamingEff,
                    tribe     = c.tribe
                };
                ccNew.creatures.Add(newC);

                if (c.IsPlaceholder)
                {
                    newC.flags |= CreatureFlags.Placeholder;
                }
                if (c.neutered)
                {
                    newC.flags |= CreatureFlags.Neutered;
                }

                // set new species-id
                if (c.Species == null &&
                    !string.IsNullOrEmpty(c.speciesBlueprint))
                {
                    c.Species = Values.V.SpeciesByBlueprint(c.speciesBlueprint);
                }
                if (c.Species == null &&
                    Values.V.TryGetSpeciesByName(c.species, out Species speciesObject))
                {
                    c.Species = speciesObject;
                }

                newC.Species = c.Species;

                // fix statlevel-indices
                newC.levelsWild = Convert8To12(c.levelsWild);
                newC.levelsDom  = Convert8To12(c.levelsDom);
            }

            ccNew.creaturesValues = new List <CreatureValues>();

            foreach (var cvOld in ccOld.creaturesValues)
            {
                var cv = new CreatureValues()
                {
                    ARKID                 = cvOld.ARKID,
                    colorIDs              = cvOld.colorIDs,
                    cooldownUntil         = cvOld.cooldownUntil.Year < 2000 ? default(DateTime?) : cvOld.cooldownUntil,
                    domesticatedAt        = cvOld.domesticatedAt.Year < 2000 ? default(DateTime?) : cvOld.domesticatedAt,
                    fatherArkId           = cvOld.fatherArkId,
                    fatherGuid            = cvOld.fatherGuid,
                    growingUntil          = cvOld.growingUntil.Year < 2000 ? default(DateTime?) : cvOld.growingUntil,
                    guid                  = cvOld.guid,
                    imprinterName         = cvOld.imprinterName,
                    imprintingBonus       = cvOld.imprintingBonus,
                    isBred                = cvOld.isBred,
                    isTamed               = cvOld.isTamed,
                    level                 = cvOld.level,
                    levelsDom             = cvOld.levelsDom,
                    levelsWild            = cvOld.levelsWild,
                    motherArkId           = cvOld.motherArkId,
                    motherGuid            = cvOld.motherGuid,
                    mutationCounterFather = cvOld.mutationCounterFather,
                    mutationCounterMother = cvOld.mutationCounterMother,
                    name                  = cvOld.name,
                    owner                 = cvOld.owner,
                    server                = cvOld.server,
                    sex          = cvOld.sex,
                    speciesName  = cvOld.species,
                    statValues   = cvOld.statValues,
                    tamingEffMax = cvOld.tamingEffMax,
                    tamingEffMin = cvOld.tamingEffMin,
                    tribe        = cvOld.tribe
                };

                if (cvOld.neutered)
                {
                    cv.flags |= CreatureFlags.Neutered;
                }

                if (Values.V.TryGetSpeciesByName(cvOld.species, out Species species))
                {
                    cv.Species = species;
                }

                ccNew.creaturesValues.Add(cv);

                // fix statlevel-indices
                cv.levelsWild = Convert8To12(cvOld.levelsWild);
                cv.levelsDom  = Convert8To12(cvOld.levelsDom);
                cv.statValues = Convert8To12(cvOld.statValues);
            }
        }
        static public CreatureValues importExportedCreature(string filePath)
        {
            CreatureValues cv = new CreatureValues();

            cv.domesticatedAt = File.GetLastWriteTime(filePath);
            cv.isTamed        = true;
            cv.tamingEffMax   = 1;
            string[] iniLines        = File.ReadAllLines(filePath);
            string   id              = "";
            int      statIndexIngame = -1;

            string[] statIndices   = new string[] { "Health", "Stamina", "Torpidity", "Oxygen", "Food", "", "", "Weight", "Melee Damage", "Movement Speed", "", "" }; // this is the order how the stats appear in the ini-file
            bool     inStatSection = false;

            foreach (string line in iniLines)
            {
                if (line.Contains("="))
                {
                    string parameterName;
                    int    i    = line.IndexOf("=");
                    string text = line.Substring(i + 1);
                    double.TryParse(text, System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowLeadingSign, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out double value);
                    if (inStatSection)
                    {
                        statIndexIngame++;
                        if (statIndexIngame > 11)
                        {
                            inStatSection = false;
                        }
                    }
                    if (inStatSection)
                    {
                        parameterName = statIndices[statIndexIngame];
                    }
                    else
                    {
                        parameterName = line.Substring(0, i);
                        if (parameterName.Contains("DinoAncestorsMale"))
                        {
                            parameterName = "DinoAncestorsMale"; // only the last entry contains the parents
                        }
                    }

                    if (parameterName.Length > 0)
                    {
                        switch (parameterName)
                        {
                        // todo ID1, ID2
                        case "DinoID1":
                            if (string.IsNullOrEmpty(id))
                            {
                                id = text;
                            }
                            else
                            {
                                cv.guid = builtGuid(text, id);
                            }
                            break;

                        case "DinoID2":
                            if (string.IsNullOrEmpty(id))
                            {
                                id = text;
                            }
                            else
                            {
                                cv.guid = builtGuid(id, text);
                            }
                            break;

                        case "DinoClass":
                            cv.species = Values.V.speciesNameFromBP(text.Substring(0, text.Length - 2));
                            break;

                        case "bIsFemale":
                            cv.sex = (text == "True" ? Sex.Female : Sex.Male);
                            break;

                        case "bIsNeutered":
                            cv.neutered = (text == "False" ? false : true);
                            break;

                        case "TamerString":
                            cv.owner = text;
                            break;

                        case "TamedName":
                            cv.name = text;
                            break;

                        case "ImprinterName":
                            cv.imprinterName = text;
                            if (string.IsNullOrEmpty(cv.owner))
                            {
                                cv.owner = text;
                            }
                            if (!String.IsNullOrWhiteSpace(text))
                            {
                                cv.isBred = true;     // TODO is this a correct assumption?
                            }
                            break;

                        // todo mutations for mother and father
                        case "RandomMutationsMale":
                            break;

                        case "RandomMutationsFemale":
                            break;

                        case "BabyAge":
                            int speciesIndex = Values.V.speciesIndex(cv.species);
                            if (speciesIndex >= 0 && value >= 0 && value <= 1 && Values.V.species[speciesIndex].breeding != null)
                            {
                                cv.growingUntil = DateTime.Now.AddSeconds((int)(Values.V.species[speciesIndex].breeding.maturationTimeAdjusted * (1 - value)));
                            }
                            break;

                        case "CharacterLevel":
                            cv.level = (int)value;
                            break;

                        case "DinoImprintingQuality":
                            cv.imprintingBonus = value;
                            if (value > 0)
                            {
                                cv.isBred = true;
                            }
                            break;

                        // Colorization
                        case "ColorSet[0]":
                            cv.colorIDs[0] = parseColor(text);
                            break;

                        case "ColorSet[1]":
                            cv.colorIDs[1] = parseColor(text);
                            break;

                        case "ColorSet[2]":
                            cv.colorIDs[2] = parseColor(text);
                            break;

                        case "ColorSet[3]":
                            cv.colorIDs[3] = parseColor(text);
                            break;

                        case "ColorSet[4]":
                            cv.colorIDs[4] = parseColor(text);
                            break;

                        case "ColorSet[5]":
                            cv.colorIDs[5] = parseColor(text);
                            break;

                        case "Health":
                            cv.statValues[0] = value;
                            break;

                        case "Stamina":
                            cv.statValues[1] = value;
                            break;

                        case "Torpidity":
                            cv.statValues[7] = value;
                            break;

                        case "Oxygen":
                            cv.statValues[2] = value;
                            break;

                        case "Food":
                            cv.statValues[3] = value;
                            break;

                        case "Weight":
                            cv.statValues[4] = value;
                            break;

                        case "Melee Damage":
                            cv.statValues[5] = 1 + value;
                            break;

                        case "Movement Speed":
                            cv.statValues[6] = 1 + value;
                            break;

                        case "DinoAncestorsMale":
                            Regex r = new Regex(@"MaleName=([^;]+);MaleDinoID1=([^;]+);MaleDinoID2=([^;]+);FemaleName=([^;]+);FemaleDinoID1=([^;]+);FemaleDinoID2=([^;]+)");
                            Match m = r.Match(text);
                            if (m.Success)
                            {
                                cv.motherGuid = builtGuid(m.Groups[5].Value, m.Groups[6].Value);
                                cv.fatherGuid = builtGuid(m.Groups[2].Value, m.Groups[3].Value);
                                cv.isBred     = true;
                            }
                            break;
                        }
                    }
                }
                else if (line.Contains("[Max Character Status Values]"))
                {
                    inStatSection = true;
                }
            }

            // if parent GUIDs are set, creature placeholder
            if (cv.motherGuid != Guid.Empty)
            {
                cv.Mother         = new Creature();
                cv.Mother.species = cv.species;
                cv.Mother.guid    = cv.motherGuid;
            }
            if (cv.fatherGuid != Guid.Empty)
            {
                cv.Father         = new Creature();
                cv.Father.species = cv.species;
                cv.Father.guid    = cv.fatherGuid;
            }
            return(cv);
        }
Esempio n. 10
0
        public static CreatureValues importExportedCreature(string filePath)
        {
            CreatureValues cv = new CreatureValues
            {
                domesticatedAt = File.GetLastWriteTime(filePath),
                isTamed        = true,
                tamingEffMax   = 1
            };

            string[] iniLines        = File.ReadAllLines(filePath);
            string   id              = "";
            int      statIndexIngame = -1;

            // this is the order how the stats appear in the ini-file; field names in the file are localized
            string[] statIndices =
            {
                "Health",
                "Stamina",
                "Torpidity",
                "Oxygen",
                "Food",
                "Water" /*ignored*/,
                "Temperature" /*ignored*/,
                "Weight",
                "Melee Damage",
                "Movement Speed",
                "Fortitude" /*ignored*/,
                "Crafting Skill"     /*ignored*/
            };
            bool inStatSection = false;

            foreach (string line in iniLines)
            {
                if (line.Contains("="))
                {
                    string parameterName;
                    int    i    = line.IndexOf("=");
                    string text = line.Substring(i + 1);
                    double.TryParse(text, System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowLeadingSign, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out double value);
                    if (inStatSection)
                    {
                        statIndexIngame++;
                        if (statIndexIngame > 11)
                        {
                            inStatSection = false;
                        }
                    }
                    if (inStatSection)
                    {
                        parameterName = statIndices[statIndexIngame];
                    }
                    else
                    {
                        parameterName = line.Substring(0, i);
                        if (parameterName.Contains("DinoAncestorsMale"))
                        {
                            parameterName = "DinoAncestorsMale"; // only the last entry contains the parents
                        }
                    }

                    if (parameterName.Length <= 0)
                    {
                        continue;
                    }
                    switch (parameterName)
                    {
                    case "DinoID1":
                        if (string.IsNullOrEmpty(id))
                        {
                            id = text;
                        }
                        else
                        {
                            cv.ARKID = buildARKID(text, id);
                            cv.guid  = Utils.ConvertArkIdToGuid(cv.ARKID);
                        }
                        break;

                    case "DinoID2":
                        if (string.IsNullOrEmpty(id))
                        {
                            id = text;
                        }
                        else
                        {
                            cv.ARKID = buildARKID(id, text);
                            cv.guid  = Utils.ConvertArkIdToGuid(cv.ARKID);
                        }
                        break;

                    case "DinoClass":
                        if (text.Length > 2 && text.Substring(text.Length - 2) == "_C")
                        {
                            text = text.Substring(0, text.Length - 2);     // the last two characters are "_C"
                        }
                        cv.species = Values.V.speciesNameFromBP(text);
                        break;

                    case "DinoNameTag":
                        // get name if blueprintpath is not available (in this case a custom values_mod.json should be created, this is just a fallback
                        if (string.IsNullOrEmpty(cv.species))
                        {
                            cv.species = Values.V.speciesName(text);
                        }
                        break;

                    case "bIsFemale":
                        cv.sex = text == "True" ? Sex.Female : Sex.Male;
                        break;

                    case "bIsNeutered":
                        cv.neutered = text != "False";
                        break;

                    case "TamerString":
                        cv.tribe = text;
                        break;

                    case "TamedName":
                        cv.name = text;
                        break;

                    case "ImprinterName":
                        cv.imprinterName = text;
                        if (string.IsNullOrEmpty(cv.owner))
                        {
                            cv.owner = text;
                        }
                        if (!string.IsNullOrWhiteSpace(text))
                        {
                            cv.isBred = true;     // TODO is this a correct assumption?
                        }
                        break;

                    // todo mutations for mother and father
                    case "RandomMutationsMale":
                        cv.mutationCounterFather = (int)value;
                        break;

                    case "RandomMutationsFemale":
                        cv.mutationCounterMother = (int)value;
                        break;

                    case "BabyAge":
                        int speciesIndex = Values.V.speciesIndex(cv.species);
                        if (speciesIndex >= 0 && value >= 0 && value <= 1 && Values.V.species[speciesIndex].breeding != null)
                        {
                            cv.growingUntil = DateTime.Now.AddSeconds((int)(Values.V.species[speciesIndex].breeding.maturationTimeAdjusted * (1 - value)));
                        }
                        break;

                    case "CharacterLevel":
                        cv.level = (int)value;
                        break;

                    case "DinoImprintingQuality":
                        cv.imprintingBonus = value;
                        if (value > 0)
                        {
                            cv.isBred = true;
                        }
                        break;

                    // Colorization
                    case "ColorSet[0]":
                        cv.colorIDs[0] = parseColor(text);
                        break;

                    case "ColorSet[1]":
                        cv.colorIDs[1] = parseColor(text);
                        break;

                    case "ColorSet[2]":
                        cv.colorIDs[2] = parseColor(text);
                        break;

                    case "ColorSet[3]":
                        cv.colorIDs[3] = parseColor(text);
                        break;

                    case "ColorSet[4]":
                        cv.colorIDs[4] = parseColor(text);
                        break;

                    case "ColorSet[5]":
                        cv.colorIDs[5] = parseColor(text);
                        break;

                    case "Health":
                        cv.statValues[0] = value;
                        break;

                    case "Stamina":
                        cv.statValues[1] = value;
                        break;

                    case "Torpidity":
                        cv.statValues[7] = value;
                        break;

                    case "Oxygen":
                        cv.statValues[2] = value;
                        break;

                    case "Food":
                        cv.statValues[3] = value;
                        break;

                    case "Weight":
                        cv.statValues[4] = value;
                        break;

                    case "Melee Damage":
                        cv.statValues[5] = 1 + value;
                        break;

                    case "Movement Speed":
                        cv.statValues[6] = 1 + value;
                        break;

                    case "DinoAncestorsMale":
                        Regex r = new Regex(@"MaleName=([^;]+);MaleDinoID1=([^;]+);MaleDinoID2=([^;]+);FemaleName=([^;]+);FemaleDinoID1=([^;]+);FemaleDinoID2=([^;]+)");
                        Match m = r.Match(text);
                        if (m.Success)
                        {
                            cv.motherArkId = buildARKID(m.Groups[5].Value, m.Groups[6].Value);
                            cv.fatherArkId = buildARKID(m.Groups[2].Value, m.Groups[3].Value);
                            cv.isBred      = true;
                        }
                        break;
                    }
                }
                else if (line.Contains("[Max Character Status Values]"))
                {
                    inStatSection = true;
                }
            }

            // if parent ArkIds are set, create creature placeholder
            if (cv.motherArkId != 0)
            {
                cv.Mother = new Creature(cv.motherArkId)
                {
                    species = cv.species
                };
            }
            if (cv.fatherArkId != 0)
            {
                cv.Father = new Creature(cv.fatherArkId)
                {
                    species = cv.species
                };
            }
            return(cv);
        }
 public ExportedCreatureControl(CreatureValues creatureValues)
 {
     InitializeComponent();
     this.creatureValues = creatureValues;
     groupBox1.Text      = creatureValues.name + " (" + creatureValues.species + ", Lv " + creatureValues.level + "), exported at " + Utils.shortTimeDate(creatureValues.domesticatedAt);
 }