public DroppedItem(GameObject droppedItem, GameObjectContainer container) { className = droppedItem.ClassName; CreatureData structureData = ArkDataManager.GetStructure(droppedItem.ClassString); type = structureData != null ? structureData.Name : droppedItem.ClassString; location = droppedItem.Location; myItem = droppedItem.GetPropertyValue <ObjectReference, GameObject>("MyItem", map: reference => container[reference]); droppedByName = droppedItem.GetPropertyValue <string>("DroppedByName", defaultValue: string.Empty); targetingTeam = droppedItem.GetPropertyValue <int>("TargetingTeam"); originalCreationTime = droppedItem.GetPropertyValue <double>("OriginalCreationTime"); initialLifeSpan = droppedItem.GetPropertyValue <float>("InitialLifeSpan", defaultValue: float.PositiveInfinity); }
public Structure(GameObject structure, GameObjectContainer saveFile) { id = structure.Names[0].ToString(); className = structure.ClassName; CreatureData structureData = ArkDataManager.GetStructure(className.ToString()); type = structureData != null ? structureData.Name : className.ToString(); location = structure.Location; inventory = structure.GetPropertyValue <ObjectReference, GameObject>("MyInventoryComponent", map: reference => saveFile[reference]); containerActivated = structure.GetPropertyValue <bool>("bContainerActivated"); owningPlayerId = structure.GetPropertyValue <int>("OwningPlayerID"); owningPlayerName = structure.GetPropertyValue <string>("OwningPlayerName", defaultValue: string.Empty); ArkArrayObjectReference linkedStructuresReferences = structure.GetPropertyValue <ArkArrayObjectReference>("LinkedStructures"); if (linkedStructuresReferences != null) { linkedStructures = new int[linkedStructuresReferences.Count]; int index = 0; foreach (ObjectReference objectReference in linkedStructuresReferences) { linkedStructures[index++] = objectReference.ObjectId; } } placedOnFloorStructure = structure.GetPropertyValue <ObjectReference>("PlacedOnFloorStructure")?.ObjectId ?? -1; ownerName = structure.GetPropertyValue <string>("OwnerName", defaultValue: string.Empty); boxName = structure.GetPropertyValue <string>("BoxName", defaultValue: string.Empty); bedName = structure.GetPropertyValue <string>("BedName", defaultValue: string.Empty); maxHealth = structure.GetPropertyValue <float>("MaxHealth"); health = structure.GetPropertyValue <float>("Health", defaultValue: maxHealth); targetingTeam = structure.GetPropertyValue <int>("TargetingTeam"); }
protected void listImpl(Func <GameObject, bool> filter, IEnumerable <string> args) { List <string> argsList = args.ToList(); if (showCommandHelp(argsList)) { return; } if (!withoutIndex) { ArkDataManager.LoadData(GlobalOptions.Language); } string savePath = argsList.Count > 0 ? argsList[0] : Path.Combine(GlobalOptions.ArkToolsConfiguration.BasePath, GlobalOptions.ArkToolsConfiguration.ArkSavegameFilename); outputDirectory = argsList.Count > 1 ? argsList[1] : Path.Combine(GlobalOptions.ArkToolsConfiguration.BasePath, GlobalOptions.ArkToolsConfiguration.CreaturesPath); Stopwatch stopwatch = new Stopwatch(GlobalOptions.UseStopWatch); // Load everything that is not an item and either has a parent or components // Drawback: includes structures and players arkSavegame = new ArkSavegame().ReadBinary <ArkSavegame>(savePath, readingOptions .WithDataFiles(false) .WithEmbeddedData(false) .WithDataFilesObjectMap(false) .WithObjectFilter(o => !o.IsItem && (o.Parent != null || o.Components.Any())) .WithBuildComponentTree(true)); stopwatch.Stop("Reading"); writeAnimalLists(filter); stopwatch.Stop("Dumping"); stopwatch.Print(); }
private void writeAnimalLists(Func <GameObject, bool> filter) { if (arkSavegame.HibernationEntries.Any()) { List <GameObject> combinedObjects = arkSavegame.Objects; foreach (HibernationEntry entry in arkSavegame.HibernationEntries) { ObjectCollector collector = new ObjectCollector(entry, 1); combinedObjects.AddRange(collector.Remap(combinedObjects.Count)); } container = new GameObjectContainer(combinedObjects); } else { container = arkSavegame; } IEnumerable <GameObject> objectStream = container.Where(o => o.IsCreature()); if (filter != null) { objectStream = objectStream.Where(filter); } if (!untameable) { IEnumerable <string> untameableClasses = GlobalOptions.ArkToolsConfiguration.UntameableClasses?.Split(",").Select(s => s.Trim()) ?? Enumerable.Empty <string>(); objectStream = objectStream.Where(gameObject => !gameObject.GetPropertyValue <bool>("bForceDisablingTaming")); objectStream = objectStream.Where(gameObject => !untameableClasses.Contains(gameObject.ClassString)); } if (cleanFolder) { foreach (string path in Directory.EnumerateFiles(outputDirectory, "*.json")) { File.Delete(path); } } Dictionary <string, List <GameObject> > dinoLists = objectStream.GroupBy(o => o.ClassString) .ToDictionary(grouping => grouping.Key, grouping => grouping.ToList()); if (!withoutIndex) { Dictionary <string, string> classNames = readClassNames(); //Func<string, string> fetchName = key => ArkDataManager.GetCreature(key)?.Name ?? key; //foreach (string dinoClass in dinoLists.Keys.Where(dinoClass => !classNames.ContainsKey(dinoClass) || classNames[dinoClass] == null)) { foreach (string dinoClass in dinoLists.Keys.Where(dinoClass => !classNames.TryGetValue(dinoClass, out string value) || value == null)) { //string name = fetchName(dinoClass); string name = ArkDataManager.GetCreature(dinoClass)?.Name ?? dinoClass; if (name != null) { classNames.Add(dinoClass, name); } } writeClassNames(classNames); foreach (string s in classNames.Keys.Where(s => !dinoLists.ContainsKey(s))) { writeEmpty(s); } } foreach (KeyValuePair <string, List <GameObject> > dinoList in dinoLists) { writeList(dinoList); } }
protected override void RunCommand(IEnumerable <string> args) { List <string> argsList = args.ToList(); if (showCommandHelp(argsList)) { return; } string clusterDirectory = argsList[0]; string outputDirectory = argsList[1]; ArkDataManager.LoadData(GlobalOptions.Language); List <Action> tasks = GlobalOptions.Parallel ? new List <Action>() : null; Stopwatch stopwatch = new Stopwatch(GlobalOptions.UseStopWatch); foreach (string path in Directory.EnumerateFiles(clusterDirectory)) { Action task = () => { try { ArkCloudInventory cloudInventory = new ArkCloudInventory().ReadBinary <ArkCloudInventory>(path, ReadingOptions.Create()); CustomDataContext context = new CustomDataContext { ObjectContainer = cloudInventory }; IPropertyContainer arkData = cloudInventory.InventoryData.GetPropertyValue <IPropertyContainer>("MyArkData"); CommonFunctions.WriteJson(Path.Combine(outputDirectory, path + ".json"), (generator, writingOptions) => { generator.WriteStartObject(); ArkArrayStruct tamedDinosData = arkData.GetPropertyValue <ArkArrayStruct>("ArkTamedDinosData"); if (tamedDinosData != null && tamedDinosData.Any()) { generator.WriteArrayFieldStart("creatures"); foreach (IStruct dinoStruct in tamedDinosData) { IPropertyContainer dino = (IPropertyContainer)dinoStruct; ArkContainer container = null; if (cloudInventory.InventoryVersion == 1) { ArkArrayUInt8 byteData = dino.GetPropertyValue <ArkArrayUInt8>("DinoData"); container = new ArkContainer(byteData); } else if (cloudInventory.InventoryVersion == 3) { ArkArrayInt8 byteData = dino.GetPropertyValue <ArkArrayInt8>("DinoData"); container = new ArkContainer(byteData); } ObjectReference dinoClass = dino.GetPropertyValue <ObjectReference>("DinoClass"); // Skip "BlueprintGeneratedClass " = 24 chars string dinoClassName = dinoClass.ObjectString.ToString().Substring(24); generator.WriteStartObject(); generator.WriteField("type", ArkDataManager.HasCreatureByPath(dinoClassName) ? ArkDataManager.GetCreatureByPath(dinoClassName).Name : dinoClassName); // NPE for unknown versions Creature creature = new Creature(container.Objects[0], container); generator.WriteObjectFieldStart("data"); creature.writeAllProperties(generator, context, writeAllFields); generator.WriteEndObject(); generator.WriteEndObject(); } generator.WriteEndArray(); } ArkArrayStruct arkItems = arkData.GetPropertyValue <ArkArrayStruct>("ArkItems"); if (arkItems != null) { List <Item> items = new List <Item>(); foreach (IStruct itemStruct in arkItems) { IPropertyContainer item = (IPropertyContainer)itemStruct; IPropertyContainer netItem = item.GetPropertyValue <IPropertyContainer>("ArkTributeItem"); items.Add(new Item(netItem)); } if (items.Any()) { generator.WritePropertyName("items"); Inventory.writeInventoryLong(generator, context, items, writeAllFields); } } generator.WriteEndObject(); }, writingOptions); } catch (Exception ex) { Console.Error.WriteLine("Found potentially corrupt cluster data: " + path); if (GlobalOptions.Verbose) { Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); } } }; if (tasks != null) { tasks.Add(task); } else { task(); } } if (tasks != null) { Parallel.ForEach(tasks, task => task()); } stopwatch.Stop("Loading cluster data and writing info"); stopwatch.Print(); }
protected override void RunCommand(IEnumerable <string> args) { List <string> argsList = args.ToList(); if (showCommandHelp(argsList)) { return; } ArkDataManager.LoadData(GlobalOptions.Language); Stopwatch stopwatch = new Stopwatch(GlobalOptions.UseStopWatch); bool mapNeeded = !string.IsNullOrEmpty(inventory) || positions; if (!GlobalOptions.Quiet && mapNeeded) { Console.WriteLine("Need to load map, this may take some time..."); } string saveGame = argsList.Count > 0 ? argsList[0] : Path.Combine(GlobalOptions.ArkToolsConfiguration.BasePath, GlobalOptions.ArkToolsConfiguration.ArkSavegameFilename); string outputDirectory = argsList.Count > 1 ? argsList[1] : Path.Combine(GlobalOptions.ArkToolsConfiguration.BasePath, GlobalOptions.ArkToolsConfiguration.PlayersPath); string saveDir = Path.GetDirectoryName(saveGame); CustomDataContext context = new CustomDataContext(); if (mapNeeded) { ArkSavegame mapSave = new ArkSavegame().ReadBinary <ArkSavegame>(saveGame, ReadingOptions.Create().WithBuildComponentTree(true)); context.ObjectContainer = mapSave; context.Savegame = mapSave; context.MapData = LatLonCalculator.ForSave(mapSave); stopwatch.Stop("Loading map data"); } Dictionary <int, Tribe> tribes = new Dictionary <int, Tribe>(); List <Action> tasks = GlobalOptions.Parallel ? new List <Action>() : null; foreach (string path in Directory.EnumerateFiles(saveDir).Where(path => profilePattern.IsMatch(Path.GetFileName(path)))) { if (maxAge.HasValue) { DateTimeOffset fileTime = File.GetLastWriteTimeUtc(path); if (fileTime < DateTimeOffset.UtcNow.AddSeconds(-maxAge.Value)) { continue; } } Action task = () => { try { Player player = new Player(path, context, ReadingOptions.Create()); long playerId = player.playerDataId; string playerFileName; if (naming == "steamid" || string.IsNullOrWhiteSpace(naming)) { playerFileName = player.uniqueId.NetId + ".json"; } else if (naming == "playerid") { playerFileName = playerId + ".json"; } else { throw new Exception("Invalid value for parameter naming."); } if (player.tribeId != 0) { if (!tribes.ContainsKey(player.tribeId)) { string tribePath = Path.Combine(saveDir, player.tribeId + ".arktribe"); if (File.Exists(tribePath)) { try { tribes[player.tribeId] = new Tribe(tribePath, ReadingOptions.Create()); } catch (Exception ex) { // Either the header didn't match or one of the properties is missing Console.Error.WriteLine("Found potentially corrupt ArkTribe: " + tribePath); if (GlobalOptions.Verbose) { Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); } } } } } string playerPath = Path.Combine(outputDirectory, playerFileName); void writePlayer(JsonTextWriter writer, WritingOptions options) { writer.WriteStartObject(); // Player data player.WriteAllProperties(writer, context, writeAllFields, noPrivacy); // Inventory if (!string.IsNullOrEmpty(inventory)) { player.WriteInventory(writer, context, writeAllFields, inventory.ToLowerInvariant() != "long"); } // Tribe if (player.tribeId != 0 && tribes.TryGetValue(player.tribeId, out Tribe tribe)) { writer.WriteField("tribeName", tribe.tribeName); if (writeAllFields || tribe.ownerPlayerDataId == playerId) { writer.WriteField("tribeOwner", tribe.ownerPlayerDataId == playerId); } if (writeAllFields || tribe.tribeAdmins.Contains((int)playerId)) { writer.WriteField("tribeAdmin", tribe.tribeAdmins.Contains((int)playerId)); } } writer.WriteEndObject(); } CommonFunctions.WriteJson(playerPath, writePlayer, writingOptions); } catch (Exception ex) when(!Debugger.IsAttached) { Console.Error.WriteLine("Found potentially corrupt ArkProfile: " + path); if (GlobalOptions.Verbose) { Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); } } }; if (tasks != null) { tasks.Add(task); } else { task(); } } if (tasks != null) { Parallel.ForEach(tasks, task => task()); } stopwatch.Stop("Loading profiles and writing info"); stopwatch.Print(); }
protected override void RunCommand(IEnumerable <string> args) { List <string> argsList = args.ToList(); if (showCommandHelp(argsList)) { return; } bool itemsLong = withItems == "long"; bool inventoryLong = withInventory == "long"; bool tamedLong = tamed == "long"; bool structuresLong = withStructures == "long"; Stopwatch stopwatch = new Stopwatch(GlobalOptions.UseStopWatch); bool mapNeeded = withItems != null || tamed != null || withStructures != null || withInventory != null; if (!GlobalOptions.Quiet && mapNeeded) { Console.WriteLine("Need to load map, this may take some time..."); } string saveGame = argsList.Count > 0 ? argsList[0] : Path.Combine(GlobalOptions.ArkToolsConfiguration.BasePath, GlobalOptions.ArkToolsConfiguration.ArkSavegameFilename); string outputDirectory = argsList.Count > 1 ? argsList[1] : Path.Combine(GlobalOptions.ArkToolsConfiguration.BasePath, GlobalOptions.ArkToolsConfiguration.TribesPath); string saveDir = Path.GetDirectoryName(saveGame); Dictionary <int, HashSet <TribeBase> > baseMap; CustomDataContext context = new CustomDataContext(); if (mapNeeded) { ArkDataManager.LoadData(GlobalOptions.Language); ArkSavegame mapSave = new ArkSavegame().ReadBinary <ArkSavegame>(saveGame, ReadingOptions.Create().WithBuildComponentTree(true)); context.Savegame = mapSave; context.MapData = LatLonCalculator.ForSave(context.Savegame); stopwatch.Stop("Loading map data"); if (withBases) { baseMap = new Dictionary <int, HashSet <TribeBase> >(); foreach (GameObject gameObject in mapSave) { // Skip items and stuff without a location if (gameObject.IsItem || gameObject.Location == null) { continue; } string signText = gameObject.GetPropertyValue <string>("SignText"); long? targetingTeam = gameObject.GetPropertyValue <long?>("TargetingTeam"); if (signText != null && targetingTeam != null) { // Might be a 'Base' sign MatchCollection matcher = basePattern.Matches(signText); if (matcher.Any()) { // Found a base sign, add it to the set, automatically replacing duplicates int tribeId = (int)targetingTeam; LocationData location = gameObject.Location; string baseName = matcher[1].Value; float size = float.Parse(matcher[2].Value); TribeBase tribeBase = new TribeBase(baseName, location.X, location.Y, location.Z, size); if (!baseMap.ContainsKey(tribeId)) { baseMap[tribeId] = new HashSet <TribeBase>(); } baseMap[tribeId].Add(tribeBase); } } } stopwatch.Stop("Collecting bases"); } else { baseMap = null; } if (mapSave.HibernationEntries.Any() && tamed != null) { List <GameObject> combinedObjects = context.Savegame.Objects.ToList(); foreach (HibernationEntry entry in context.Savegame.HibernationEntries) { ObjectCollector collector = new ObjectCollector(entry, 1); combinedObjects.AddRange(collector.Remap(combinedObjects.Count)); } context.ObjectContainer = new GameObjectContainer(combinedObjects); } else { context.ObjectContainer = mapSave; } } else { baseMap = null; } List <Action> tasks = GlobalOptions.Parallel ? new List <Action>() : null; void mapWriter(JsonTextWriter generator, int tribeId) { if (!mapNeeded) { return; } List <GameObject> structures = new List <GameObject>(); List <GameObject> creatures = new List <GameObject>(); List <Item> items = new List <Item>(); List <Item> blueprints = new List <Item>(); List <DroppedItem> droppedItems = new List <DroppedItem>(); // Apparently there is a behavior in ARK causing certain structures to exist twice within a save HashSet <ArkName> processedList = new HashSet <ArkName>(); // Bases HashSet <TribeBase> bases = withBases ? baseMap[tribeId] : null; foreach (GameObject gameObject in context.ObjectContainer) { if (gameObject.IsItem) { continue; } int targetingTeam = gameObject.GetPropertyValue <int>("TargetingTeam", defaultValue: -1); if (targetingTeam == -1) { continue; } TeamType teamType = TeamTypes.ForTeam(targetingTeam); if (tribeId == -1 && teamType != TeamType.Player) { continue; } if (tribeId == 0 && teamType != TeamType.NonPlayer) { continue; } if (tribeId > 0 && tribeId != targetingTeam) { continue; } // Determine base if we have bases TribeBase tribeBase; if (bases != null && gameObject.Location != null) { TribeBase matchedBase = null; foreach (TribeBase potentialBase in bases) { if (potentialBase.InsideBounds(gameObject.Location)) { matchedBase = potentialBase; break; } } tribeBase = matchedBase; } else { tribeBase = null; } if (gameObject.IsCreature()) { if (!processedList.Contains(gameObject.Names[0])) { if (tribeBase != null) { tribeBase.Creatures.Add(gameObject); } else { creatures.Add(gameObject); } processedList.Add(gameObject.Names[0]); } else { // Duped Creature continue; } } else if (!gameObject.IsPlayer() && !gameObject.IsWeapon() && !gameObject.IsDroppedItem()) { // LinkedPlayerDataID: Players ain't structures // AssociatedPrimalItem: Items equipped by sleeping players // MyItem: dropped item if (!processedList.Contains(gameObject.Names[0])) { if (tribeBase != null) { tribeBase.Structures.Add(gameObject); } else { structures.Add(gameObject); } processedList.Add(gameObject.Names[0]); } else { // Duped Structure continue; } } else { if (!processedList.Contains(gameObject.Names[0])) { processedList.Add(gameObject.Names[0]); } else { // Duped Player or dropped Item or weapon continue; } } void itemHandler(ObjectReference itemReference) { GameObject item = itemReference.GetObject(context.Savegame); if (item != null && !Item.isDefaultItem(item)) { if (processedList.Contains(item.Names[0])) { // happens for players having items in their quick bar return; } processedList.Add(item.Names[0]); if (item.HasAnyProperty("bIsBlueprint")) { if (tribeBase != null) { tribeBase.Blueprints.Add(new Item(item)); } else { blueprints.Add(new Item(item)); } } else { if (tribeBase != null) { tribeBase.Items.Add(new Item(item)); } else { items.Add(new Item(item)); } } } } void droppedItemHandler(GameObject droppedItemObject) { DroppedItem droppedItem = new DroppedItem(droppedItemObject, context.Savegame); if (tribeBase != null) { tribeBase.DroppedItems.Add(droppedItem); } else { droppedItems.Add(droppedItem); } } if (withItems != null && withInventory == null) { foreach (GameObject inventory in gameObject.Components.Values) { if (!inventory.IsInventory()) { continue; } List <ObjectReference> inventoryItems = inventory.GetPropertyValue <IArkArray, ArkArrayObjectReference>("InventoryItems"); foreach (ObjectReference itemReference in inventoryItems ?? Enumerable.Empty <ObjectReference>()) { itemHandler(itemReference); } List <ObjectReference> equippedItems = inventory.GetPropertyValue <IArkArray, ArkArrayObjectReference>("EquippedItems"); foreach (ObjectReference itemReference in equippedItems ?? Enumerable.Empty <ObjectReference>()) { itemHandler(itemReference); } } } ObjectReference myItem = gameObject.GetPropertyValue <ObjectReference>("MyItem"); if (myItem != null) { if (withItems != null && withInventory == null) { itemHandler(myItem); } else if (withInventory != null) { droppedItemHandler(gameObject); } } } void writeStructures(IEnumerable <GameObject> structList) { if (withStructures == null) { return; } generator.WriteArrayFieldStart("structures"); if (structuresLong) { foreach (GameObject structureObject in structList) { Structure structure = new Structure(structureObject, context.Savegame); generator.WriteStartObject(); structure.writeAllProperties(generator, context, writeAllFields); if (withInventory != null) { structure.writeInventory(generator, context, writeAllFields, !inventoryLong); } generator.WriteEndObject(); } } else { Dictionary <ArkName, long> structMap = structList.GroupBy(o => o.ClassName).ToDictionary(objects => objects.Key, objects => objects.LongCount()); foreach (KeyValuePair <ArkName, long> entry in structMap.OrderByDescending(pair => pair.Value)) { generator.WriteStartObject(); string name = entry.Key.ToString(); if (ArkDataManager.HasStructure(name)) { name = ArkDataManager.GetStructure(name).Name; } generator.WriteField("name", name); generator.WriteField("count", entry.Value); generator.WriteEndObject(); } } generator.WriteEndArray(); } void writeCreatures(List <GameObject> creaList) { if (tamed == null) { return; } generator.WriteArrayFieldStart("tamed"); if (tamedLong) { foreach (GameObject creatureObject in creaList) { Creature creature = new Creature(creatureObject, context.Savegame); generator.WriteStartObject(); creature.writeAllProperties(generator, context, writeAllFields); if (withInventory != null) { creature.writeInventory(generator, context, writeAllFields, !inventoryLong); } generator.WriteEndObject(); } } else { Dictionary <ArkName, long> creaMap = creaList.GroupBy(o => o.ClassName).ToDictionary(objects => objects.Key, objects => objects.LongCount()); foreach (KeyValuePair <ArkName, long> entry in creaMap.OrderByDescending(pair => pair.Value)) { generator.WriteStartObject(); string name = entry.Key.ToString(); if (ArkDataManager.HasCreature(name)) { name = ArkDataManager.GetCreature(name).Name; } generator.WriteField("name", name); generator.WriteField("count", entry.Value); generator.WriteEndObject(); } } generator.WriteEndArray(); } void writeDroppedItems(List <DroppedItem> droppedList) { if (withInventory == null) { return; } generator.WriteArrayFieldStart("droppedItems"); foreach (DroppedItem droppedItem in droppedList) { generator.WriteStartObject(); droppedItem.writeAllProperties(generator, context, writeAllFields); droppedItem.writeInventory(generator, context, writeAllFields, !inventoryLong); generator.WriteEndObject(); } generator.WriteEndArray(); } if (withBases && bases != null) { generator.WriteArrayFieldStart("bases"); foreach (TribeBase tribeBase in bases) { generator.WriteStartObject(); generator.WriteField("name", tribeBase.Name); generator.WriteField("x", tribeBase.X); generator.WriteField("y", tribeBase.Y); generator.WriteField("z", tribeBase.Z); generator.WriteField("lat", context.MapData.CalculateLat(tribeBase.Y)); generator.WriteField("lon", context.MapData.CalculateLon(tribeBase.X)); generator.WriteField("radius", tribeBase.Size); writeCreatures(tribeBase.Creatures); writeStructures(tribeBase.Structures); writeDroppedItems(tribeBase.DroppedItems); if (itemsLong) { generator.WritePropertyName("items"); Inventory.writeInventoryLong(generator, context, tribeBase.Items, writeAllFields); generator.WritePropertyName("blueprints"); Inventory.writeInventoryLong(generator, context, tribeBase.Blueprints, writeAllFields); } else { generator.WritePropertyName("items"); Inventory.writeInventorySummary(generator, tribeBase.Items); generator.WritePropertyName("blueprints"); Inventory.writeInventorySummary(generator, tribeBase.Blueprints); } generator.WriteEndObject(); } generator.WriteStartObject(); } writeCreatures(creatures); writeStructures(structures); writeDroppedItems(droppedItems); if (itemsLong) { generator.WritePropertyName("items"); Inventory.writeInventoryLong(generator, context, items, writeAllFields); generator.WritePropertyName("blueprints"); Inventory.writeInventoryLong(generator, context, blueprints, writeAllFields); } else { generator.WritePropertyName("items"); Inventory.writeInventorySummary(generator, items); generator.WritePropertyName("blueprints"); Inventory.writeInventorySummary(generator, blueprints); } if (withBases && bases != null) { generator.WriteEndObject(); generator.WriteEndArray(); } } foreach (string path in Directory.EnumerateFiles(saveDir).Where(path => tribePattern.IsMatch(path))) { Action task = () => { try { Tribe tribe = new Tribe(path, ReadingOptions.Create()); string tribeFileName = tribe.tribeId + ".json"; string tribePath = Path.Combine(outputDirectory, tribeFileName); CommonFunctions.WriteJson(tribePath, (generator, writingOptions) => { generator.WriteStartObject(); tribe.writeAllProperties(generator, context, writeAllFields); mapWriter(generator, tribe.tribeId); generator.WriteEndObject(); }, writingOptions); } catch (Exception ex) { Console.Error.WriteLine("Found potentially corrupt ArkTribe: " + path); if (GlobalOptions.Verbose) { Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); } } }; if (tasks != null) { tasks.Add(task); } else { task(); } } if (tasks != null) { Parallel.ForEach(tasks, task => task()); } if (tribeless) { string tribePath = Path.Combine(outputDirectory, "tribeless.json"); CommonFunctions.WriteJson(tribePath, (generator, writingOptions) => { generator.WriteStartObject(); mapWriter(generator, -1); generator.WriteEndObject(); }, writingOptions); } if (nonPlayers) { string tribePath = Path.Combine(outputDirectory, "non-players.json"); CommonFunctions.WriteJson(tribePath, (generator, writingOptions) => { generator.WriteStartObject(); mapWriter(generator, 0); generator.WriteEndObject(); }, writingOptions); } stopwatch.Stop("Loading tribes and writing info"); stopwatch.Print(); }
public Creature(GameObject creature, GameObjectContainer container) { className = creature.ClassName; CreatureData creatureData = ArkDataManager.GetCreature(creature.ClassString); type = creatureData != null ? creatureData.Name : creature.ClassString; location = creature.Location; int dinoID1 = creature.GetPropertyValue <int>("DinoID1"); int dinoID2 = creature.GetPropertyValue <int>("DinoID2"); dinoId = (long)dinoID1 << 32 | (dinoID2 & 0xFFFFFFFFL); targetingTeam = creature.GetPropertyValue <int>("TargetingTeam"); tamed = targetingTeam < 0 || targetingTeam >= 50000; owningPlayerId = creature.GetPropertyValue <int>("OwningPlayerID"); isFemale = creature.IsFemale(); for (int i = 0; i < 6; i++) { colorSetIndices[i] = creature.GetPropertyValue <ArkByteValue>("ColorSetIndices", i)?.ByteValue ?? 0; } tamedAtTime = creature.GetPropertyValue <double>("TamedAtTime"); tribeName = creature.GetPropertyValue <string>("TribeName", defaultValue: string.Empty); tamerstring = creature.GetPropertyValue <string>("Tamerstring", defaultValue: string.Empty); owningPlayerName = creature.GetPropertyValue <string>("OwningPlayerName", defaultValue: string.Empty); tamedName = creature.GetPropertyValue <string>("TamedName", defaultValue: string.Empty); imprinterName = creature.GetPropertyValue <string>("ImprinterName", defaultValue: string.Empty); // Not all ancestors are saved. Only those ancestor information // are available which are displayed ingame in the UI. ArkArrayStruct ancestors = creature.GetPropertyValue <IArkArray, ArkArrayStruct>("DinoAncestors"); if (ancestors != null) { // traverse female ancestor line foreach (IStruct value in ancestors) { StructPropertyList propertyList = (StructPropertyList)value; int fatherID1 = propertyList.GetPropertyValue <int>("MaleDinoID1"); int fatherID2 = propertyList.GetPropertyValue <int>("MaleDinoID2"); int motherID1 = propertyList.GetPropertyValue <int>("FemaleDinoID1"); int motherID2 = propertyList.GetPropertyValue <int>("FemaleDinoID2"); AncestorLineEntry entry = new AncestorLineEntry { MaleName = propertyList.GetPropertyValue <string>("MaleName", defaultValue: string.Empty), MaleId = (long)fatherID1 << 32 | (fatherID2 & 0xFFFFFFFFL), FemaleName = propertyList.GetPropertyValue <string>("FemaleName", defaultValue: string.Empty), FemaleId = (long)motherID1 << 32 | (motherID2 & 0xFFFFFFFFL) }; femaleAncestors.Add(entry); } } ancestors = creature.GetPropertyValue <IArkArray, ArkArrayStruct>("DinoAncestorsMale"); if (ancestors != null) { // traverse male ancestor line foreach (IStruct value in ancestors) { StructPropertyList propertyList = (StructPropertyList)value; int fatherID1 = propertyList.GetPropertyValue <int>("MaleDinoID1"); int fatherID2 = propertyList.GetPropertyValue <int>("MaleDinoID2"); int motherID1 = propertyList.GetPropertyValue <int>("FemaleDinoID1"); int motherID2 = propertyList.GetPropertyValue <int>("FemaleDinoID2"); AncestorLineEntry entry = new AncestorLineEntry { MaleName = propertyList.GetPropertyValue <string>("MaleName", defaultValue: string.Empty), MaleId = (long)fatherID1 << 32 | (fatherID2 & 0xFFFFFFFFL), FemaleName = propertyList.GetPropertyValue <string>("FemaleName", defaultValue: string.Empty), FemaleId = (long)motherID1 << 32 | (motherID2 & 0xFFFFFFFFL) }; maleAncestors.Add(entry); } } wildRandomScale = creature.GetPropertyValue <float>("WildRandomScale", defaultValue: 1F); isWakingTame = creature.GetPropertyValue <bool>("bIsWakingTame"); isSleeping = creature.GetPropertyValue <bool>("bIsSleeping"); requiredTameAffinity = creature.GetPropertyValue <float>("RequiredTameAffinity"); currentTameAffinity = creature.GetPropertyValue <float>("CurrentTameAffinity"); tamedIneffectivenessModifier = creature.GetPropertyValue <float>("TameIneffectivenessModifier"); tamedFollowTarget = creature.GetPropertyValue <ObjectReference>("TamedFollowTarget")?.ObjectId ?? -1; tamingTeamID = creature.GetPropertyValue <int>("TamingTeamID"); tamedOnServerName = creature.GetPropertyValue <string>("TamedOnServerName", defaultValue: string.Empty); uploadedFromServerName = creature.GetPropertyValue <string>("UploadedFromServerName", defaultValue: string.Empty); tamedAggressionLevel = creature.GetPropertyValue <int>("TamedAggressionLevel"); matingProgress = creature.GetPropertyValue <float>("MatingProgress"); lastEnterStasisTime = creature.GetPropertyValue <double>("LastEnterStasisTime"); status = creature.GetPropertyValue <ObjectReference, GameObject>("MyCharacterStatusComponent", map: reference => container[reference]); inventory = creature.GetPropertyValue <ObjectReference, GameObject>("MyInventoryComponent", map: reference => container[reference]); if (status != null && status.ClassString.StartsWith("DinoCharacterStatusComponent_")) { baseCharacterLevel = status.GetPropertyValue <int>("BaseCharacterLevel", defaultValue: 1); for (int index = 0; index < AttributeNames.Instance.Count; index++) { numberOfLevelUpPointsApplied[index] = status.GetPropertyValue <ArkByteValue>("NumberOfLevelUpPointsApplied", index)?.ByteValue ?? 0; } extraCharacterLevel = status.GetPropertyValue <short>("ExtraCharacterLevel"); for (int index = 0; index < AttributeNames.Instance.Count; index++) { numberOfLevelUpPointsAppliedTamed[index] = status.GetPropertyValue <ArkByteValue>("NumberOfLevelUpPointsAppliedTamed", index)?.ByteValue ?? 0; } allowLevelUps = status.GetPropertyValue <bool>("bAllowLevelUps"); experiencePoints = status.GetPropertyValue <float>("ExperiencePoints"); dinoImprintingQuality = status.GetPropertyValue <float>("DinoImprintingQuality"); tamedIneffectivenessModifier = status.GetPropertyValue <float>("TamedIneffectivenessModifier", defaultValue: tamedIneffectivenessModifier); } }
/** * From ArkSavegame */ public Item(GameObject item) { className = item.ClassName; ItemData itemData = ArkDataManager.GetItem(className.ToString()); type = itemData != null ? itemData.Name : className.ToString(); blueprintGeneratedClass = itemData != null ? itemData.BlueprintGeneratedClass : null; canEquip = item.GetPropertyValue <bool>("bAllowEquppingItem", defaultValue: true); canSlot = item.GetPropertyValue <bool>("bCanSlot", defaultValue: true); isEngram = item.GetPropertyValue <bool>("bIsEngram"); isBlueprint = item.GetPropertyValue <bool>("bIsBlueprint"); canRemove = item.GetPropertyValue <bool>("bAllowRemovalFromInventory", defaultValue: true); canRemoveFromCluster = true; isHidden = item.GetPropertyValue <bool>("bHideFromInventoryDisplay"); //quantity = Math.Max(1, item.findPropertyValue<Number>("ItemQuantity").map(Number.intValue).orElse(1)); quantity = Math.Max(1, item.GetPropertyValue <int>("ItemQuantity", defaultValue: 1)); customName = item.GetPropertyValue <string>("CustomItemName", defaultValue: string.Empty); customDescription = item.GetPropertyValue <string>("CustomItemDescription", defaultValue: string.Empty); durability = item.GetPropertyValue <float>("SavedDurability"); rating = item.GetPropertyValue <float>("ItemRating"); quality = item.GetPropertyValue <ArkByteValue>("ItemQualityIndex")?.ByteValue ?? 0; nextSpoilingTime = item.GetPropertyValue <double>("NextSpoilingTime"); lastSpoilingTime = item.GetPropertyValue <double>("LastSpoilingTime"); for (int i = 0; i < ItemStatDefinitions.Instance.Count; i++) { itemStatValues[i] = item.GetPropertyValue <short>("ItemStatValues", i); } for (int i = 0; i < itemColors.Length; i++) { itemColors[i] = item.GetPropertyValue <short>("ItemColorID", i); } for (int i = 0; i < preSkinItemColors.Length; i++) { preSkinItemColors[i] = item.GetPropertyValue <short>("PreSkinItemColorID", i); } for (int i = 0; i < eggLevelups.Length; i++) { eggLevelups[i] = item.GetPropertyValue <ArkByteValue>("EggNumberOfLevelUpPointsApplied", i)?.ByteValue ?? 0; } for (int i = 0; i < eggColors.Length; i++) { eggColors[i] = item.GetPropertyValue <ArkByteValue>("EggColorSetIndices", i)?.ByteValue ?? 0; } crafterCharacterName = item.GetPropertyValue <string>("CrafterCharacterName", defaultValue: string.Empty); crafterTribeName = item.GetPropertyValue <string>("CrafterTribeName", defaultValue: string.Empty); craftedSkillBonus = item.GetPropertyValue <float>("CraftedSkillBonus"); }
/** * From JSON / ModificationFile */ public Item(JToken node) { className = ArkName.From(node.Value <string>("className")); ItemData itemData = ArkDataManager.GetItem(className.ToString()); type = itemData != null ? itemData.Name : className.ToString(); blueprintGeneratedClass = "BlueprintGeneratedClass " + node.Value <string>("blueprintGeneratedClass"); canEquip = node.Value <bool?>("canEquip") ?? true; canSlot = node.Value <bool?>("canSlot") ?? true; isEngram = node.Value <bool>("isEngram"); isBlueprint = node.Value <bool>("isBlueprint"); canRemove = node.Value <bool?>("canRemove") ?? true; canRemoveFromCluster = node.Value <bool?>("canRemoveFromCluster") ?? true; isHidden = node.Value <bool>("isHidden"); quantity = Math.Max(1, node.Value <int?>("quantity") ?? 1); customName = node.Value <string>("customName"); customDescription = node.Value <string>("customDescription"); durability = node.Value <float>("durability"); rating = node.Value <float>("rating"); quality = node.Value <byte>("quality"); nextSpoilingTime = node.Value <double>("nextSpoilingTime"); lastSpoilingTime = node.Value <double>("lastSpoilingTime"); for (int i = 0; i < itemStatValues.Length; i++) { itemStatValues[i] = node.Value <short>("itemStatsValue_" + i); } for (int i = 0; i < itemColors.Length; i++) { itemColors[i] = node.Value <short>("itemColor_" + i); } for (int i = 0; i < preSkinItemColors.Length; i++) { preSkinItemColors[i] = node.Value <short>("preSkinItemColor_" + i); } for (int i = 0; i < eggLevelups.Length; i++) { eggLevelups[i] = node.Value <byte>("eggLevelup_" + i); } for (int i = 0; i < eggColors.Length; i++) { eggColors[i] = node.Value <byte>("eggColor_" + i); } crafterCharacterName = node.Value <string>("crafterCharacterName"); crafterTribeName = node.Value <string>("crafterTribeName"); craftedSkillBonus = node.Value <float>("craftedSkillBonus"); uploadOffset = node.Value <int>("uploadOffset"); }
/** * From cluster storage */ public Item(IPropertyContainer item) { blueprintGeneratedClass = item.GetPropertyValue <ObjectReference>("ItemArchetype").ObjectString.ToString(); className = ArkName.From(blueprintGeneratedClass.Substring(blueprintGeneratedClass.LastIndexOf('.') + 1)); ItemData itemData = ArkDataManager.GetItem(className.ToString()); type = itemData != null ? itemData.Name : className.ToString(); canEquip = true; canSlot = item.GetPropertyValue <bool>("bIsSlot", defaultValue: true); isEngram = item.GetPropertyValue <bool>("bIsEngram"); isBlueprint = item.GetPropertyValue <bool>("bIsBlueprint"); canRemove = item.GetPropertyValue <bool>("bAllowRemovalFromInventory", defaultValue: true); canRemoveFromCluster = item.GetPropertyValue <bool>("bAllowRemovalFromSteamInventory", defaultValue: true); isHidden = item.GetPropertyValue <bool>("bHideFromInventoryDisplay"); //quantity = Math.Max(1, item.findPropertyValue<Number>("ItemQuantity").map(Number::intValue).orElse(1)); quantity = Math.Max(1, item.GetPropertyValue <int>("ItemQuantity", defaultValue: 1)); customName = item.GetPropertyValue <string>("CustomItemName", defaultValue: string.Empty); customDescription = item.GetPropertyValue <string>("CustomItemDescription", defaultValue: string.Empty); durability = item.GetPropertyValue <float>("ItemDurability"); rating = item.GetPropertyValue <float>("ItemRating"); quality = item.GetPropertyValue <ArkByteValue>("ItemQualityIndex")?.ByteValue ?? 0; nextSpoilingTime = item.GetPropertyValue <double>("NextSpoilingTime"); lastSpoilingTime = item.GetPropertyValue <double>("LastSpoilingTime"); for (int i = 0; i < itemStatValues.Length; i++) { itemStatValues[i] = item.GetPropertyValue <short>("ItemStatValues", i); } for (int i = 0; i < itemColors.Length; i++) { itemColors[i] = item.GetPropertyValue <short>("ItemColorID", i); } for (int i = 0; i < preSkinItemColors.Length; i++) { preSkinItemColors[i] = item.GetPropertyValue <short>("PreSkinItemColorID", i); } for (int i = 0; i < eggLevelups.Length; i++) { eggLevelups[i] = item.GetPropertyValue <ArkByteValue>("EggNumberOfLevelUpPointsApplied", i)?.ByteValue ?? 0; } for (int i = 0; i < eggColors.Length; i++) { eggColors[i] = item.GetPropertyValue <ArkByteValue>("EggColorSetIndices", i)?.ByteValue ?? 0; } crafterCharacterName = item.GetPropertyValue <string>("CrafterCharacterName", defaultValue: string.Empty); crafterTribeName = item.GetPropertyValue <string>("CrafterTribeName", defaultValue: string.Empty); craftedSkillBonus = item.GetPropertyValue <float>("CraftedSkillBonus"); }