static void Main(string[] args) { Console.WriteLine("Loading..."); ArkImports.ImportContent("imports\\"); ArkWorld world = new ArkWorld("save\\", "Extinction", @"C:\Program Files (x86)\Steam\steamapps\common\ARK\ShooterGame\SavedV\Config\WindowsServer\", null, true); Console.WriteLine("World loaded."); RunTestNamed(world, "Blake", "Yutyrannus", 2300.8f, 3091.2f, 4200f, 644.8f); RunTestNamed(world, "Kato", "Rock Drake", 2268.8f, 1578.4f, 3120f, 642.8f); Console.WriteLine("Tests completed."); Console.ReadLine(); }
public ArkDinosaur(ArkWorld world, DotArkGameObject orig) : base(world, orig) { //Grab the data and save it here. //Get the other components of this dinosaur. HighLevelArkGameObjectRef statusComponent = GetGameObjectRef("MyCharacterStatusComponent"); //Check if this dinosaur is tamed. isTamed = CheckIfValueExists("TamedName") && CheckIfValueExists("TribeName") && CheckIfValueExists("TargetingTeam"); //Grab the values that will exist on both tamed and untamed dinosaurs. isFemale = GetBooleanProperty("bIsFemale"); //Convert the colors into a byte array and hex. var colorAttrib = GetPropertiesByName("ColorSetIndices"); //Get all of the color properties from the dinosaur. These are indexes in the color table. colors = new byte[colorAttrib.Length]; //Initialize the array for storing the indexes. These will be saved to the file. colors_hex = new string[colorAttrib.Length]; //Initialize the array for reading nice HTML color values. for (int i = 0; i < colors.Length; i++) //For each color region this dinosaur has. Each "ColorSetIndices" value is a color region. { colors[i] = ((ByteProperty)colorAttrib[i]).byteValue; //Get the index in the color table by getting the byte value out of the property //Validate that the color is in range byte color = colors[i]; if (color <= 0 || color > ArkColorIds.ARK_COLOR_IDS.Length) { colors_hex[i] = "#FFF"; } else { colors_hex[i] = ArkColorIds.ARK_COLOR_IDS[colors[i] - 1]; //Look this up in the color table to get the nice HTML value. } } //Read the dinosaur ID by combining the the bytes of the two UInt32 values. byte[] buf = new byte[8]; BitConverter.GetBytes(GetUInt32Property("DinoID1")).CopyTo(buf, 0); BitConverter.GetBytes(GetUInt32Property("DinoID2")).CopyTo(buf, 4); //Convert this to a ulong dinosaurId = BitConverter.ToUInt64(buf, 0); //Read in levels currentStats = ArkDinosaurStats.ReadStats(statusComponent, "CurrentStatusValues", false); baseLevelupsApplied = ArkDinosaurStats.ReadStats(statusComponent, "NumberOfLevelUpPointsApplied", true); baseLevel = 1; if (statusComponent.CheckIfValueExists("BaseCharacterLevel")) { baseLevel = statusComponent.GetInt32Property("BaseCharacterLevel"); } level = baseLevel; //Now, convert attributes that only exist on tamed dinosaurs. isInTribe = isTamed; if (isTamed) { tamedName = GetStringProperty("TamedName"); tribeId = GetInt32Property("TargetingTeam"); tamerName = GetStringProperty("TribeName"); tamedLevelupsApplied = ArkDinosaurStats.ReadStats(statusComponent, "NumberOfLevelUpPointsAppliedTamed", true); if (statusComponent.CheckIfValueExists("ExtraCharacterLevel")) { level += statusComponent.GetUInt16Property("ExtraCharacterLevel"); } if (statusComponent.HasProperty("ExperiencePoints")) { experience = statusComponent.GetFloatProperty("ExperiencePoints"); } else { experience = 0; } isBaby = GetBooleanProperty("bIsBaby"); if (isBaby) { babyAge = GetFloatProperty("BabyAge"); nextImprintTime = -1; if (HasProperty("BabyNextCuddleTime")) { nextImprintTime = GetDoubleProperty("BabyNextCuddleTime"); } if (statusComponent.HasProperty("DinoImprintingQuality")) { imprintQuality = statusComponent.GetFloatProperty("DinoImprintingQuality"); } else { imprintQuality = 0; } } } //Get the dino entry data dino_entry = ArkImports.GetDinoDataByClassname(classname.classname); isInit = true; }
/// <summary> /// Convert the map from a low-level object to a high-level object. /// </summary> /// <param name="savePath">The path to the folder housing the game data.</param> /// <param name="mapFileName">The name of the map file. For example, "Extinction" if you would like to load "Extinction.ark".</param> /// <param name="overrideMapData">Override the map data.</param> public ArkWorld(string savePath, string mapFileName, string configPath, ArkMapData overrideMapData = null, bool loadOnlyKnown = false) { //Read the config files configSettings = new ArkConfigSettings(); configSettings.ReadFromFile(File.ReadAllLines(configPath + "Game.ini")); configSettings.ReadFromFile(File.ReadAllLines(configPath + "GameUserSettings.ini")); //Open the .ark file now. string arkFileLocaton = Path.Combine(savePath, mapFileName + ".ark"); var arkFile = ArkSaveEditor.Deserializer.ArkSaveDeserializer.OpenDotArk(arkFileLocaton); //Loop through all .arkprofile files here and add them to the player list. string[] saveFilePaths = Directory.GetFiles(savePath); foreach (string profilePathname in saveFilePaths) { try { if (profilePathname.ToLower().EndsWith(".arkprofile")) { //This is an ARK profile. Open it. players.Add(ArkPlayerProfile.ReadFromFile(profilePathname)); } if (profilePathname.ToLower().EndsWith(".arktribe")) { //This is an ARK tribe. Open it. tribes.Add(new ArkTribeProfile(profilePathname, this)); } } catch (Exception ex) { Console.WriteLine($"Failed to load an Ark tribe or player at {profilePathname.Substring(savePath.Length)}. It will be skipped. This could result in errors!"); Console.WriteLine($"Error debug data: {ex.Message} - {ex.StackTrace}"); } } //Check to see if we have imported data. This will crash if we have not. if (ArkImports.dino_entries == null) { throw new Exception("Missing ArkImports.dino_entries! You should run ArkImports.ImportContent() to import the content."); } if (ArkImports.item_entries == null) { throw new Exception("Missing ArkImports.item_entries! You should run ArkImports.ImportContent() to import the content."); } if (ArkImports.world_settings == null) { throw new Exception("Missing ArkImports.world_settings! You should run ArkImports.ImportContent() to import the content."); } //Set our sources first sources = arkFile.gameObjects; //Do some analysis to find objects for (int i = 0; i < sources.Count; i++) { var g = sources[i]; string classname = g.classname.classname; bool known = false; //Check if this is a dinosaur by matching the classname. if (Enum.TryParse <DinoClasses>(classname, out DinoClasses dinoClass)) { //This is a dinosaur. dinos.Add(new ArkDinosaur(this, this.sources[i])); known = true; } //Check if this is a player if (classname == "PlayerPawnTest_Male_C" || classname == "PlayerPawnTest_Female_C") { //This is a player. playerCharacters.Add(new ArkPlayer(this, this.sources[i])); known = true; } //Check if this is a structure StructureDisplayMetadata metadata = ArkImports.GetStructureDisplayMetadataByClassname(classname); if (metadata != null) { //This is a structure. structures.Add(new ArkStructure(this, this.sources[i], metadata)); known = true; } } //Get the other metadata map = arkFile.meta.binaryDataNames[0]; gameTime = arkFile.gameTime; //If we got the override map data, set it. Else, auto detect if (overrideMapData == null) { //Autodetect if (ArkMapDataTable.arkmaps.ContainsKey(map)) { mapinfo = ArkMapDataTable.arkmaps[map]; } else { throw new Exception($"Ark map, '{map}', could not be found in the ArkMapDataTable. Please provide an override map data in the constructor for the ArkWorld."); } } else { mapinfo = overrideMapData; } }