private void AddHB(object sender, RoutedEventArgs e) { //debug stuff Console.WriteLine(@"HitBox Count : " + App.OpenedFiles.BACFile.HitboxTable.Count); App.OpenedFiles.BACFile.HitboxTable.Add(new HitBoxDataset(BACFile.LoadedHitBoxCount+1)); Console.WriteLine(@"HitBox Count : " + App.OpenedFiles.BACFile.HitboxTable.Count); BACFile.LoadedHitBoxCount++; var dataset = App.OpenedFiles.BACFile.HitboxTable[App.OpenedFiles.BACFile.HitboxTable.Count-1]; for (var j = 0; j < 12; j++) { var data = new HitBoxData(j); dataset.Data.Add(data); data.Damage = 0; data.Stun = 0; data.Effect = HitBoxData.HitBoxEffect.HIT; data.OnHit = new Script(0); data.SelfHitstop = 0; data.SelfShaking = 0; data.TgtHitstop = 0; data.TgtShaking = 0; data.HitGFX = -1; data.Unknown1 = 0; data.Unused = 0; data.HitGFX2 = -1; data.Unused2 = 0; data.Unused3 = 0; data.HitSFX = -1; data.HitSFX2 = -1; data.TgtSFX = -1; data.ArcadeScore = 0; data.SelfMeter = 0; data.TgtMeter = 0; data.JuggleStart = 1; data.TgtAnimTime = 10; data.MiscFlag = HitBoxData.MiscFlags.NONE; data.VelX = 0.05f; data.VelY = 0.05f; data.VelZ = 0; data.PushbackDist = 0.5f; data.AccX = 0; data.AccY = -0.005f; data.AccZ = 0; } }
public static BACFile FromFilename(string name, BCMFile bcm) { using (var fs = File.OpenRead(name)) using (var tracker = new TrackingStream(fs)) using (var inFile = new BinaryReader(tracker)) { AELogger.Log(AELogger.O_SEPARATOR, false); tracker.SetLabel("Header"); if (new String(inFile.ReadChars(4)) != "#BAC") throw new IOException("Not a valid BAC file"); tracker.IgnoreBytes(8); inFile.BaseStream.Seek(12); ushort ScriptCount = inFile.ReadUInt16(); ushort VFXScriptCount = inFile.ReadUInt16(); uint HitboxTableSize = inFile.ReadUInt32(); int ScriptOffset = inFile.ReadInt32(); int VFXScriptOffset = inFile.ReadInt32(); int ScriptNameOffset = inFile.ReadInt32(); int VFXScriptNameOffset = inFile.ReadInt32(); int HitboxTableOffset = inFile.ReadInt32(); AELogger.Log("Header done, reading floats"); var bac = new BACFile(); for (int i = 0; i < 0x1c; i++) { var list = new ObservableCollection<float>(); for (int j = 0; j < 6; j++) { list.Add(inFile.ReadSingle()); } bac.UnknownFloatData.Add(list); } AELogger.Log("floats done, reading scripts"); for (int i = 0; i < ScriptCount; i++) bac.Scripts.Add(new Script(i)); for (int i = 0; i < VFXScriptCount; i++) bac.VFXScripts.Add(new Script(i)); for (int i = 0; i < HitboxTableSize; i++) bac.HitboxTable.Add(new HitBoxDataset(i)); //Link BCM if (bcm != null) { foreach (BCM.Move move in bcm.Moves) if (move.ScriptIndex != -1) move.Script = bac.Scripts[move.ScriptIndex]; } //Read Scripts readScripts(inFile, bac.Scripts, bcm, ScriptCount, ScriptOffset, ScriptNameOffset, bac); readScripts(inFile, bac.VFXScripts, bcm, VFXScriptCount, VFXScriptOffset, VFXScriptNameOffset, bac); AELogger.Log("scripts done, reading hitboxtable"); //Read Hitbox Table for (int i = 0; i < HitboxTableSize; i++) { tracker.SetLabel("HitboxTable#" + i.ToString()); inFile.BaseStream.Seek(HitboxTableOffset + i*4); inFile.BaseStream.Seek(inFile.ReadUInt32()); if (inFile.BaseStream.Position == 0) { continue; } var dataset = bac.HitboxTable[i]; LoadedHitBoxCount = i; for (int j = 0; j < 12; j++) { HitBoxData data = new HitBoxData(j); dataset.Data.Add(data); data.Damage = inFile.ReadInt16(); data.Stun = inFile.ReadInt16(); data.Effect = (HitBoxData.HitBoxEffect)inFile.ReadUInt16(); Util.LogUnkEnum(data.Effect, "Hitbox #" + dataset.Index, "hitboxdataset", j); var index = inFile.ReadInt16() + HitBoxData.getIndexOffset(data.Effect); if (index > -1) data.OnHit = bac.Scripts.Where(x => x.Index == index).First(); else { data.OnHit = new Script(index); if (index <= -1) { AELogger.Log("negative index " + index + " in hitboxdata #" + i); } } data.SelfHitstop = inFile.ReadUInt16(); data.SelfShaking = inFile.ReadUInt16(); data.TgtHitstop = inFile.ReadUInt16(); data.TgtShaking = inFile.ReadUInt16(); data.HitGFX = inFile.ReadInt16(); data.Unknown1 = inFile.ReadInt32(); data.Unused = (Unused16)inFile.ReadInt16(); data.HitGFX2 = inFile.ReadInt16(); data.Unused2 = (Unused32)inFile.ReadInt32(); data.Unused3 = (Unused16)inFile.ReadInt16(); data.HitSFX = inFile.ReadInt16(); data.HitSFX2 = inFile.ReadInt16(); data.TgtSFX = inFile.ReadInt16(); data.ArcadeScore = inFile.ReadUInt16(); data.SelfMeter = inFile.ReadInt16(); data.TgtMeter = inFile.ReadInt16(); data.JuggleStart = inFile.ReadInt16(); data.TgtAnimTime = inFile.ReadInt16(); data.MiscFlag = (HitBoxData.MiscFlags)inFile.ReadInt32(); data.VelX = inFile.ReadSingle(); data.VelY = inFile.ReadSingle(); data.VelZ = inFile.ReadSingle(); data.PushbackDist = inFile.ReadSingle(); data.AccX = inFile.ReadSingle(); data.AccY = inFile.ReadSingle(); data.AccZ = inFile.ReadSingle(); } } AELogger.Log("hitbox done"); List<HitBoxDataset> nullHitboxData = bac.HitboxTable.Where(x => x.Data.Count() == 0).ToList(); foreach (HitBoxDataset tmp in nullHitboxData) bac.HitboxTable.Remove(tmp); FilterScripts(bac.Scripts); FilterScripts(bac.VFXScripts); AELogger.Log(AELogger.O_SEPARATOR, false); return bac; } }