private static string ConvertStatus(ARKDinoDataObject d) { string status = "YOUR_TARGET"; if (d.HasProperty("TamedAggressionLevel")) { int agroLevel = d.GetIntProperty("TamedAggressionLevel"); switch (agroLevel) { case 0: status = "PASSIVE"; break; case 1: status = "NEUTRAL"; break; case 2: status = "AGGRESSIVE"; break; } if (d.GetBoolProperty("bPassiveFlee", 0, false)) { status = "PASSIVE_FLEE"; } } return(status); }
private static DbDino ParseDinoData(DbServer server, string inventoryId, ulong revisionId, byte revisionIndex, int inventoryType, ulong inventoryItemId, string request) { //Decode data as bytes and read byte[] data = new byte[request.Length / 2]; for (int index = 0; index < data.Length; index++) { data[index] = byte.Parse(request.Substring(index * 2, 2), System.Globalization.NumberStyles.HexNumber); } //Now, decode and parse ARKDinoDataObject[] parts = ARKDinoDataTool.ReadData(data); Console.WriteLine(JsonConvert.SerializeObject(parts)); //Get dino part ARKDinoDataObject d = parts[0]; //Convert colors List <string> colors = new List <string>(); for (int i = 0; true; i++) { ByteProperty colorProp = d.GetPropertyByName <ByteProperty>("ColorSetIndices", i); if (colorProp == null) { break; } byte color = colorProp.byteValue; if (color <= 0 || color > ArkStatics.ARK_COLOR_IDS.Length) { colors.Add("#FFFFFF"); } else { colors.Add(ArkStatics.ARK_COLOR_IDS[colorProp.byteValue - 1]); //Look this up in the color table to get the nice HTML value. } } //Get status component ARKDinoDataObject status = d.GetPropertyByName <ObjectProperty>("MyCharacterStatusComponent").localLinkObject; //Read as dino, adding required fields first DbDino dino = new DbDino { revision_id = revisionId, revision_type = revisionIndex, is_cryo = true, cryo_inventory_id = inventoryId, dino_id = Program.GetMultipartID(d.GetPropertyByName <UInt32Property>("DinoID1").value, d.GetPropertyByName <UInt32Property>("DinoID2").value), tribe_id = d.GetPropertyByName <IntProperty>("TargetingTeam").value, tamed_name = d.GetStringProperty("TamedName", 0, ""), classname = Program.TrimArkClassname(d.name), tamer_name = d.GetStringProperty("TamerString", 0, ""), baby_age = d.GetFloatProperty("BabyAge", 0, 1), is_baby = d.GetBoolProperty("bIsBaby", 0, false), next_imprint_time = d.GetDoubleProperty("BabyNextCuddleTime", 0, 0), imprint_quality = d.GetFloatProperty("DinoImprintingQuality", 0, 0), color_indexes = new int[6], experience = status.GetFloatProperty("ExperiencePoints", 0, 0), server_id = server._id, location = new DbLocation(0, 0, 0), is_female = d.GetBoolProperty("bIsFemale", 0, false), level = status.GetIntProperty("BaseCharacterLevel", 0, 0) + status.GetUInt16Property("ExtraCharacterLevel", 0, 0), base_level = status.GetIntProperty("BaseCharacterLevel", 0, 0), is_tamed = true, taming_effectiveness = 1, max_stats = ConvertStatsFloat(status, "MaxStatusValues"), current_stats = ConvertStatsFloat(status, "CurrentStatusValues"), tamed_levelups_applied = ConvertStatsInt(status, "NumberOfLevelUpPointsAppliedTamed"), base_levelups_applied = ConvertStatsInt(status, "NumberOfLevelUpPointsApplied"), status = ConvertStatus(d), cryo_inventory_type = inventoryType, cryo_inventory_itemid = inventoryItemId, experience_points = status.GetFloatProperty("ExperiencePoints", 0, 0) }; return(dino); }