public void ApplyPatterns() { var files = _manager.GetAllFileEntries(); foreach (var entry in files) { if (_files.Contains(entry)) { continue; } foreach (var pattern in _patterns) { if (new Regex(pattern, RegexOptions.IgnoreCase).Match(entry.FullName).Success) { _files.Add(entry); var file = _manager.ReadFile(entry.FullName).Uncompress(); var inibin = Inibin.DeserializeInibin(file, entry.FullName); foreach (var kvp in inibin.Content) { if (!_hashes.Contains(kvp.Key)) { _hashes.Add(kvp.Key); } } } } } }
static void ExtractSpellData(ArchiveFileManager manager, string hashSourcesPath) { var data = File.ReadAllText(hashSourcesPath); var hashSourceCollection = JsonConvert.DeserializeObject <LeagueHashSourceCollection>(data); var hashCollection = new LeagueHashCollection(hashSourceCollection); var itemHashes = new HashSet <uint>(); //From Data/Spells/NAME.inibin or Data/Shared/NAME.inibin or Data/Characters/CHARACTER/CHARACTER.inibin (no subdirectories) var itemFiles = manager.GetMatchFileEntries(@"Data(|\/Characters\/([^\/]+)|\/Shared)\/Spells\/([^\/]+)\.inibin"); foreach (var entry in itemFiles) { if (!entry.FullName.Contains(".inibin")) { continue; } if (entry.FullName.Contains(".lua")) { continue; } var file = manager.ReadFile(entry.FullName).Uncompress(); var inibin = Inibin.DeserializeInibin(file, entry.FullName); foreach (var kvp in inibin.Content) { if (itemHashes.Contains(kvp.Key)) { continue; } itemHashes.Add(kvp.Key); } } var mapping = new LeagueHashCollection(); foreach (var hash in itemHashes) { if (!hashCollection.Hashes.ContainsKey(hash)) { continue; } mapping.Hashes.Add(hash, hashCollection.Hashes[hash]); } var result = new LeagueHashCollection(); foreach (var hash in mapping.Hashes) { var sectionFilterer = new SectionFilterer(hash.Value); sectionFilterer.ApplyFilter(new FilterPlaintextSections()); sectionFilterer.ApplyFilter(new FilterDuplicateSections()); sectionFilterer.ApplyFilter(new FilterPlaintextKeys()); result.Hashes.Add(hash.Key, sectionFilterer.CurrentSections); } var conflictResolver = new ConflictResolver(); //result = conflictResolver.ResolveConflicts(result); var itemMappingJson = JsonConvert.SerializeObject(result, Formatting.Indented); File.WriteAllText("spellConversionMapDraft.json", itemMappingJson); }
internal bool readInibin(string path, out Inibin iniFile) { if (Root == null) { iniFile = null; return(false); } var entries = Root.SearchFileEntries(path); if (entries.Count < 1) { iniFile = null; return(false); } if (entries.Count > 1) { Logger.LogCoreInfo("Found more than one inibin for query " + path); } var entry = entries.First(); iniFile = new Inibin(entry); return(true); }
public void FindValueType(int type, bool filter) { foreach (var entry in _files) { var file = _manager.ReadFile(entry.FullName).Uncompress(); var inibin = Inibin.DeserializeInibin(file, entry.FullName); foreach (var kvp in inibin.Content) { if (kvp.Value.Type != type) { continue; } var fileName = entry.FullName; var hash = kvp.Key.ToString(); var value = kvp.Value.Value.ToString(); if (_draft.Hashes.ContainsKey(kvp.Key)) { var section = _draft.Hashes[kvp.Key].First().Key.ToString(); var name = _draft.Hashes[kvp.Key].First().Value.First().ToString(); Console.WriteLine("{0} ({1}) \"{2}\": {3}*{4}", fileName, hash, value, section, name); } else if (!filter) { Console.WriteLine("{0} ({1}) \"{2}\"", fileName, hash, value); } } } }
public void LoadHashes(ArchiveFileManager manager) { UpdateStatus("Loading League hashes..."); var fileEntries = manager.GetAllFileEntries(); var hashList = new HashSet <uint>(); foreach (var entry in fileEntries) { if (!entry.FullName.Contains(".inibin")) { continue; } var file = manager.ReadFile(entry.FullName).Uncompress(); var inibin = Inibin.DeserializeInibin(file, entry.FullName); foreach (var kvp in inibin.Content) { if (hashList.Contains(kvp.Key)) { continue; } hashList.Add(kvp.Key); } } _hashes = hashList; }
public Dictionary <string, Dictionary <string, object> > Convert(Inibin inibin) { Clear(); foreach (var kvp in inibin.Content) { AddByHash(kvp.Key, kvp.Value); } return(Deserialize()); }
public static ContentFile FromInibin(Inibin source, ContentConfiguration configuration) { var result = new ContentFile(); result.Values = configuration.Converter.Convert(source); result.Id = configuration.FindId(source.FilePath); result.Name = configuration.FindName(result); result.ResourcePath = source.FilePath; result.ContentFormatVersion = 4; return(result); }
public Inibin ReadInibin(string filePath) { if (!filePath.EndsWith(".inibin")) { throw new Exception("Unsupported target file type"); } var file = ReadFile(filePath).Uncompress(); var inibin = Inibin.DeserializeInibin(file, filePath); return(inibin); }
public static ContentFile FromInibin(Inibin source, InibinConverter converter) { var result = new ContentFile(); result.Values = result.Values = converter.Convert(source); result.Id = 0; result.Name = ""; result.ResourcePath = source.FilePath; result.ContentFormatVersion = 4; return(result); }
public Character[] FindCharacters(string[] types, bool all = false) { var skins = new List <Character>(); var directories = _manifest.Root.GetChildDirectoryOrNull("DATA").GetChildDirectoryOrNull("Characters").Directories.ToArray(); for (int i = 0; i < directories.Length; i++) { var character = directories[i].GetChildFileOrNull(directories[i].Name + ".inibin"); if (character == null) { Console.WriteLine("Couldn't find file {0}.inibin from the releasemanifest", directories[i].FullName); continue; } var inibin = new Character(Inibin.DeserializeInibin(_manager.ReadFile(character.FullName).Uncompress(), character.FullName)); var flag = all; for (int j = 0; j < types.Length; j++) { if (inibin.Type.ToLower().Contains(types[j].ToLower())) { flag = true; break; } } if (flag) { skins.Add(inibin); var subdir = directories[i].GetChildDirectoryOrNull("Skins"); if (subdir != null) { var skindirs = subdir.Directories.ToArray(); for (int j = 0; j < skindirs.Length; j++) { var skin = skindirs[j].GetChildFileOrNull(skindirs[j].Name + ".inibin"); if (skin == null) { Console.WriteLine("Couldn't find file {0}.inibin from the releasemanifest", skindirs[j].FullName); continue; } skins.Add(new Character(Inibin.DeserializeInibin(_manager.ReadFile(skin.FullName).Uncompress(), skin.FullName))); } } } } return(skins.ToArray()); }
public void FindFiles(string section, string name) { uint hash = HashFunctions.GetInibinHash(section, name); foreach (var entry in _files) { var file = _manager.ReadFile(entry.FullName).Uncompress(); var inibin = Inibin.DeserializeInibin(file, entry.FullName); foreach (var kvp in inibin.Content) { if (kvp.Key == hash) { Console.WriteLine("{0}: {1}", entry.FullName, kvp.Value.Value.ToString()); } } } }
static void ExportData(ArchiveFileManager manager, InibinConverter converter) { var itemFiles = manager.GetFileEntriesFrom("DATA/Items", true); foreach (var entry in itemFiles) { var saveDirectory = Path.GetDirectoryName(string.Format("Content/{0}", entry.FullName)); if (!Directory.Exists(saveDirectory)) { Directory.CreateDirectory(saveDirectory); } var compressedFile = manager.ReadFile(entry.FullName, true); if (compressedFile == null) { continue; } var file = compressedFile.Uncompress(); if (entry.FullName.Contains(".inibin") || entry.FullName.Contains(".troybin")) { var inibin = Inibin.DeserializeInibin(file, entry.FullName); foreach (var kvp in inibin.Content) { converter.AddByHash(kvp.Key, kvp.Value); } var itemContent = converter.Deserialize(); var itemContentJson = JsonConvert.SerializeObject(itemContent, Formatting.Indented); var savePath = string.Format("Content/{0}", entry.FullName.Replace(".inibin", ".json")); if (entry.FullName.Contains(".troybin")) { savePath = string.Format("Content/{0}", entry.FullName.Replace(".troybin", ".troybin.json")); } File.WriteAllText(savePath, itemContentJson); converter.Clear(); } else { var savePath = string.Format("Content/{0}", entry.FullName); File.WriteAllBytes(savePath, file); } } }
public void BuildAzirTurret() { Inibin inibin; if (!_rafManager.readInibin("DATA/Characters/" + Model + "/" + Model + ".inibin", out inibin)) { _logger.LogCoreError("couldn't find turret stats for " + Model); return; } stats.HealthPoints.BaseValue = inibin.getFloatValue("Data", "BaseHP"); stats.CurrentHealth = stats.HealthPoints.Total; stats.ManaPoints.BaseValue = inibin.getFloatValue("Data", "BaseMP"); stats.CurrentMana = stats.ManaPoints.Total; stats.AttackDamage.BaseValue = inibin.getFloatValue("DATA", "BaseDamage"); stats.Range.BaseValue = TURRET_RANGE; stats.MoveSpeed.BaseValue = inibin.getFloatValue("DATA", "MoveSpeed"); stats.Armor.BaseValue = inibin.getFloatValue("DATA", "Armor"); stats.MagicResist.BaseValue = inibin.getFloatValue("DATA", "SpellBlock"); stats.HealthRegeneration.BaseValue = inibin.getFloatValue("DATA", "BaseStaticHPRegen"); stats.ManaRegeneration.BaseValue = inibin.getFloatValue("DATA", "BaseStaticMPRegen"); stats.AttackSpeedFlat = 0.625f / (1 + inibin.getFloatValue("DATA", "AttackDelayOffsetPercent")); stats.HealthPerLevel = inibin.getFloatValue("DATA", "HPPerLevel"); stats.ManaPerLevel = inibin.getFloatValue("DATA", "MPPerLevel"); stats.AdPerLevel = inibin.getFloatValue("DATA", "DamagePerLevel"); stats.ArmorPerLevel = inibin.getFloatValue("DATA", "ArmorPerLevel"); stats.MagicResistPerLevel = inibin.getFloatValue("DATA", "SpellBlockPerLevel"); stats.HealthRegenerationPerLevel = inibin.getFloatValue("DATA", "HPRegenPerLevel"); stats.ManaRegenerationPerLevel = inibin.getFloatValue("DATA", "MPRegenPerLevel"); stats.GrowthAttackSpeed = inibin.getFloatValue("DATA", "AttackSpeedPerLevel"); IsMelee = inibin.getBoolValue("DATA", "IsMelee"); CollisionRadius = inibin.getIntValue("DATA", "PathfindingCollisionRadius"); Inibin autoAttack = _rafManager.GetAutoAttackData(Model); if (autoAttack != null) { AutoAttackDelay = autoAttack.getFloatValue("SpellData", "castFrame") / 30.0f; AutoAttackProjectileSpeed = autoAttack.getFloatValue("SpellData", "MissileSpeed"); } }
public Inibin GetAutoAttackData(string model) { Inibin autoAttack = null; string[] autoAttackPaths = new string[] { string.Format("DATA/Characters/{0}/{0}BasicAttack.inibin", model), string.Format("DATA/Characters/{0}/Spells/{0}BasicAttack.inibin", model), string.Format("DATA/Spells/{0}BasicAttack.inibin", model) }; foreach (var path in autoAttackPaths) { if (readInibin(path, out autoAttack)) { break; } } if (autoAttack == null) { _logger.LogCoreError(string.Format("Couldn't find auto-attack data for {0}", model)); } return(autoAttack); }
public Character(Inibin inibin) { Inibin = inibin; }
public Character(byte[] data, string path) : this(Inibin.DeserializeInibin(data, path)) { }
public void init() { itemTemplates = new Dictionary <int, ItemTemplate>(); // TODO : this is highly inefficient var inibins = RAFManager.getInstance().SearchFileEntries("DATA/items/"); /* for (var i = 1000; i < 4000; ++i)*/ foreach (var ini in inibins) { //Inibin inibin; //if (!RAFManager.getInstance().readInibin("DATA/items/" + i + ".inibin", out inibin)) if (!System.Text.RegularExpressions.Regex.IsMatch(ini.FileName, "items/\\d.*.inibin", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { continue; } var id = int.Parse(ini.ShortFileName.Replace(".inibin", "")); if ((id <= 1000 && id >= 4000) || itemTemplates.ContainsKey(id)) { continue; } var inibin = new Inibin(ini); var maxStack = inibin.getIntValue("DATA", "MaxStack"); var price = inibin.GetValue <int>("DATA", "Price"); var type = inibin.GetValue <string>(3471506188); bool trinket = false; if (type != null && type.ToLower() == "RelicBase".ToLower()) { trinket = true; } float sellBack = 0.7f; if (inibin.KeyExists("DATA", "SellBackModifier")) { sellBack = inibin.getFloatValue("DATA", "SellBackModifier"); } var statMods = new List <StatMod>(); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Bonus_Ad_Flat, value = inibin.getFloatValue("DATA", "FlatPhysicalDamageMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Bonus_Ad_Pct, value = inibin.getFloatValue("DATA", "PercentPhysicalDamageMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Bonus_Ap_Flat, value = inibin.getFloatValue("DATA", "FlatMagicDamageMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Hp5, value = inibin.getFloatValue("DATA", "FlatHPRegenMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Crit_Chance, value = inibin.getFloatValue("DATA", "FlatCritChanceMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Armor, value = inibin.getFloatValue("DATA", "FlatArmorMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Magic_Armor, value = inibin.getFloatValue("DATA", "FlatSpellBlockMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Atks_multiplier, value = inibin.getFloatValue("DATA", "PercentAttackSpeedMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_LifeSteal, value = inibin.getFloatValue("DATA", "PercentLifeStealMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Four, mask = FieldMask.FM4_MaxHp, value = inibin.getFloatValue("DATA", "FlatHPPoolMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Four, mask = FieldMask.FM4_MaxMp, value = inibin.getFloatValue("DATA", "FlatMPPoolMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Four, mask = FieldMask.FM4_Speed, value = inibin.getFloatValue("DATA", "FlatMovementSpeedMod") }); var recipes = new List <int>(); var c = 1; while (inibin.KeyExists("DATA", "RecipeItem" + c)) { var componentId = inibin.getIntValue("DATA", "RecipeItem" + c); if (componentId > 0) { // sometimes there are "0" entries recipes.Add(componentId); } ++c; } itemTemplates.Add(id, new ItemTemplate(id, maxStack, price, sellBack, trinket, statMods, recipes)); } Logger.LogCoreInfo("Loaded " + itemTemplates.Count + " items"); }
public void init() { itemTemplates = new Dictionary<int, ItemTemplate>(); // TODO : this is highly inefficient var inibins = RAFManager.getInstance().SearchFileEntries("DATA/items/"); /* for (var i = 1000; i < 4000; ++i)*/ foreach (var ini in inibins) { //Inibin inibin; //if (!RAFManager.getInstance().readInibin("DATA/items/" + i + ".inibin", out inibin)) if (!System.Text.RegularExpressions.Regex.IsMatch(ini.FileName, "items/\\d.*.inibin", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) continue; var id = int.Parse(ini.ShortFileName.Replace(".inibin", "")); if ((id <= 1000 && id >= 4000) || itemTemplates.ContainsKey(id)) continue; var inibin = new Inibin(ini); var maxStack = inibin.getIntValue("DATA", "MaxStack"); var price = inibin.GetValue<int>("DATA", "Price"); var type = inibin.GetValue<string>(3471506188); bool trinket = false; if (type != null && type.ToLower() == "RelicBase".ToLower()) trinket = true; float sellBack = 0.7f; if (inibin.KeyExists("DATA", "SellBackModifier")) sellBack = inibin.getFloatValue("DATA", "SellBackModifier"); var statMods = new List<StatMod>(); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Bonus_Ad_Flat, value = inibin.getFloatValue("DATA", "FlatPhysicalDamageMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Bonus_Ad_Pct, value = inibin.getFloatValue("DATA", "PercentPhysicalDamageMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Bonus_Ap_Flat, value = inibin.getFloatValue("DATA", "FlatMagicDamageMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Hp5, value = inibin.getFloatValue("DATA", "FlatHPRegenMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Crit_Chance, value = inibin.getFloatValue("DATA", "FlatCritChanceMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Armor, value = inibin.getFloatValue("DATA", "FlatArmorMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Magic_Armor, value = inibin.getFloatValue("DATA", "FlatSpellBlockMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_Atks_multiplier, value = inibin.getFloatValue("DATA", "PercentAttackSpeedMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Two, mask = FieldMask.FM2_LifeSteal, value = inibin.getFloatValue("DATA", "PercentLifeStealMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Four, mask = FieldMask.FM4_MaxHp, value = inibin.getFloatValue("DATA", "FlatHPPoolMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Four, mask = FieldMask.FM4_MaxMp, value = inibin.getFloatValue("DATA", "FlatMPPoolMod") }); statMods.Add(new StatMod { blockId = MasterMask.MM_Four, mask = FieldMask.FM4_Speed, value = inibin.getFloatValue("DATA", "FlatMovementSpeedMod") }); var recipes = new List<int>(); var c = 1; while (inibin.KeyExists("DATA", "RecipeItem" + c)) { var componentId = inibin.getIntValue("DATA", "RecipeItem" + c); if (componentId > 0) { // sometimes there are "0" entries recipes.Add(componentId); } ++c; } itemTemplates.Add(id, new ItemTemplate(id, maxStack, price, sellBack, trinket, statMods, recipes)); } Logger.LogCoreInfo("Loaded " + itemTemplates.Count + " items"); }
internal bool readInibin(string path, out Inibin iniFile) { if (Root == null) { iniFile = null; return false; } var entries = Root.SearchFileEntries(path); if (entries.Count < 1) { iniFile = null; return false; } if (entries.Count > 1) Logger.LogCoreInfo("Found more than one inibin for query " + path); var entry = entries.First(); iniFile = new Inibin(entry); return true; }