/// <summary> /// Returns an enumerable containing all distinct FFX IDs referenced in the TAE. /// </summary> public static IEnumerable <int> GetAllFFXIDs(this TAE tae, int variation, GameParamHandler gParam) { List <int> FFX = new List <int>(); foreach (Animation anim in tae.Animations) { foreach (Event evt in anim.Events) { if (evt.Type >= 96 && evt.Type <= 121 && evt.Type != 116 && evt.Type != 120) { FFX.Add(Convert.ToInt32(evt.Parameters["FFXID"])); } else if (evt.Type == 2) { int subID = Convert.ToInt32(evt.Parameters["BehaviorSubID"]); int behID = 200000000 + (variation * 1000) + subID; if (!gParam.BehaviorsNPC.ContainsKey(behID)) { continue; } Behavior beh = gParam.BehaviorsNPC[behID]; if (beh.ReferenceType != 1) { continue; } if (!gParam.Bullets.ContainsKey(beh.RefID)) { continue; } Bullet bullet = gParam.Bullets[beh.RefID]; FFX.Add(bullet.FlickFX); FFX.Add(bullet.ImpactFX); FFX.Add(bullet.ProjectileFX); while (bullet.BulletOnHit != -1) { if (!gParam.Bullets.ContainsKey(bullet.BulletOnHit)) { break; // missing child bullet } bullet = gParam.Bullets[bullet.BulletOnHit]; FFX.Add(bullet.FlickFX); FFX.Add(bullet.ImpactFX); FFX.Add(bullet.ProjectileFX); } } } } return(FFX.Distinct().Where(i => i > -1)); }
public SoulsMod(string gameDir, string backupExt = ".smbak", byte[] paramBNDData = null, byte[] paramdefBNDData = null, byte[] itemMSGBNDData = null, byte[] menuMSGBNDData = null) { if (!gameDir.EndsWith(@"\")) { gameDir += @"\"; } GameDir = gameDir; BackupExt = backupExt; // RestoreBackups(); // No need to restore backups automatically, as all files are loaded directly FROM the backups anyway. // Text is loaded first so it can be passed to `GameParamHandler`. #if DEBUG Console.Write("Loading Text... "); #endif if (itemMSGBNDData == null) { itemMSGBNDData = File.ReadAllBytes(GameDir + @"msg/ENGLISH/item.msgbnd.dcx"); } if (menuMSGBNDData == null) { menuMSGBNDData = File.ReadAllBytes(GameDir + @"msg/ENGLISH/menu.msgbnd.dcx"); } Text = new TextHandler(itemMSGBNDData, menuMSGBNDData); #if DEBUG Console.Write("Done.\n"); Console.Write("Loading Text (vanilla copy)... "); #endif VanillaText = new TextHandler(itemMSGBNDData, menuMSGBNDData); #if DEBUG Console.Write("Done.\n"); Console.Write("Loading ParamDefs... "); #endif if (paramdefBNDData == null) { paramdefBNDData = File.ReadAllBytes(GameDir + @"paramdef\paramdef.paramdefbnd.dcx"); } BND3 paramdefBnd = BND3.Read(paramdefBNDData); foreach (BinderFile file in paramdefBnd.Files) { PARAMDEF paramdef = PARAMDEF.Read(file.Bytes); ParamDefs[paramdef.ParamType] = paramdef; } #if DEBUG Console.Write("Done.\n"); Console.Write("Loading GameParams... "); #endif if (paramBNDData == null) { paramBNDData = File.ReadAllBytes(GameDir + @"param\GameParam\GameParam.parambnd.dcx"); } GPARAM = new GameParamHandler(ParamDefs, Text, paramBNDData); #if DEBUG Console.Write("Done.\n"); Console.Write("Loading GameParams (vanilla copy)... "); #endif if (paramBNDData != null) { VanillaGPARAM = new GameParamHandler(ParamDefs, VanillaText, paramBNDData); } else { VanillaGPARAM = new GameParamHandler(ParamDefs, VanillaText, GameDir + @"param\GameParam\GameParam.parambnd.dcx"); } #if DEBUG Console.Write("Done.\n"); #endif }