public static void AddMapTextures(int area, List <string> textureNames) { if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1) { foreach (var t in textureNames) { if (fetches.ContainsKey(t)) { continue; } string tpfPath = GameDataManager.GetInterrootPath($@"map\tx\{t}.tpf"); if (File.Exists(tpfPath)) { AddTpfFromPath(tpfPath); } } } else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1R) { var bxfs = Directory.GetFiles(GameDataManager.GetInterrootPath($@"map\m{area:D2}", isDirectory: true), "*.tpfbhd"); foreach (var b in bxfs) { AddSpecificTexturesFromBXF3(b, textureNames); } } else { throw new NotImplementedException("ONLY FOR DS1(R)"); } }
//public static bool PlayEventInFEV(string fevFilePath, string eventName) //{ // //if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 || // // GameDataManager.GameType == GameDataManager.GameTypes.DS1R || // // GameDataManager.GameType == GameDataManager.GameTypes.DS3 || // // GameDataManager.GameType == GameDataManager.GameTypes.SDT)) // //{ // // return false; // //} // var foundFev = LoadFEV(fevFilePath); // if (!foundFev) // return false; // else // return PlayEvent(eventName, null, null); //} /// <summary> /// Example "main" will return the full path ending like "Game/sound/fdp_main.fev" in DS3. /// </summary> /// <param name="fevNameAfterPrefix"></param> /// <returns></returns> private static string GetFevPathFromInterroot(string name, bool isDs1Dlc = false) { if (GameDataManager.GameType == GameDataManager.GameTypes.DS1 || GameDataManager.GameType == GameDataManager.GameTypes.DS1R) { return(GameDataManager.GetInterrootPath($@"sound\{(isDs1Dlc ? "fdlc" : "frpg")}_{name}.fev")); } else if (GameDataManager.GameType == GameDataManager.GameTypes.DS3) { return(GameDataManager.GetInterrootPath($@"sound\fdp_{name}.fev")); } else if (GameDataManager.GameType == GameDataManager.GameTypes.BB) { return(GameDataManager.GetInterrootPath($@"sound_win\sprj_{name}.fev")); } else if (GameDataManager.GameType == GameDataManager.GameTypes.SDT) { return(GameDataManager.GetInterrootPath($@"sound\{name}.fev")); } else { return(null); } }
private static void LoadRemoHKX(byte[] hkxBytes, string animName) { Scene.DisableModelDrawing(); Scene.DisableModelDrawing2(); HKX.HKAAnimationBinding hk_binding = null; HKX.HKASplineCompressedAnimation hk_anim = null; HKX.HKASkeleton hk_skeleton = null; if (remoCutsLoaded.ContainsKey(animName)) { hk_binding = remoCutsLoaded[animName].hk_binding; hk_anim = remoCutsLoaded[animName].hk_anim; hk_skeleton = remoCutsLoaded[animName].hk_skeleton; } else { var hkx = HKX.Read(hkxBytes, HKX.HKXVariation.HKXDS1, false); foreach (var o in hkx.DataSection.Objects) { if (o is HKX.HKASkeleton asSkeleton) { hk_skeleton = asSkeleton; } else if (o is HKX.HKAAnimationBinding asBinding) { hk_binding = asBinding; } else if (o is HKX.HKASplineCompressedAnimation asAnim) { hk_anim = asAnim; } } remoCutsLoaded.Add(animName, new RemoCutCache() { hk_binding = hk_binding, hk_anim = hk_anim, hk_skeleton = hk_skeleton, }); } var animContainer = new NewAnimationContainer(); AnimContainer = animContainer; animContainer.ClearAnimations(); animContainer.Skeleton.LoadHKXSkeleton(hk_skeleton); var testIdleAnimThing = new NewHavokAnimation_SplineCompressed(animName, animContainer.Skeleton, null, hk_binding, hk_anim, animContainer); animContainer.AddNewAnimation(animName, testIdleAnimThing); animContainer.CurrentAnimationName = animName; var modelNames = animContainer.Skeleton.TopLevelHkxBoneIndices.Select(b => animContainer.Skeleton.HkxSkeleton[b].Name).ToList(); CurrentCutHits.Clear(); CurrentCutOtherBlocks.Clear(); lock (Scene._lock_ModelLoad_Draw) { Scene.Models.Clear(); } foreach (var name in modelNames) { Model mdl = null; if (!remoModelDict.ContainsKey(name)) { PauseStreamBGM(); if (name.StartsWith("c")) { string shortName = name.Substring(0, 5); mdl = GameDataManager.LoadCharacter(shortName); FmodManager.LoadInterrootFEV(shortName); if (mdl.IS_PLAYER) { ViewportInteractor.InitializeCharacterModel(mdl, isRemo: true); } } else if (name.StartsWith("o")) { string shortName = name.Substring(0, 5); mdl = GameDataManager.LoadObject(shortName); FmodManager.LoadInterrootFEV(shortName); } else if (name.StartsWith("m")) { mdl = GameDataManager.LoadMapPiece(AreaInt, BlockInt, 0, 0, int.Parse(name.Substring(1, 4))); } else if (name.StartsWith("A")) { int a = int.Parse(name.Substring(1, 2)); int b = int.Parse(name.Substring(4, 2)); if (b != BlockInt && !CurrentCutOtherBlocks.Contains(b)) { CurrentCutOtherBlocks.Add(b); } mdl = GameDataManager.LoadMapPiece(a, b, 0, 0, int.Parse(name.Substring(8, 4))); } else if (name.StartsWith("d")) { // TODO // Dummy entity e.g. 'd0000_0000'. Apparently just acts as a single DummyPoly? mdl = GameDataManager.LoadCharacter("c1000"); mdl.RemoDummyTransformPrim = new DebugPrimitives.DbgPrimWireArrow(name, new Transform(Microsoft.Xna.Framework.Matrix.CreateScale(0.25f) * mdl.CurrentTransform.WorldMatrix), Microsoft.Xna.Framework.Color.Lime) { Category = DebugPrimitives.DbgPrimCategory.AlwaysDraw }; mdl.RemoDummyTransformTextPrint = new StatusPrinter(null, Microsoft.Xna.Framework.Color.Lime); mdl.RemoDummyTransformTextPrint.AppendLine(name); mdl.IS_REMO_DUMMY = true; } else if (name.StartsWith("h")) { // Collision. CurrentCutHits.Add(name); } else { throw new NotImplementedException($"Cannot tell what object type '{name}' is in remo HKX"); } if (mdl != null) { mdl.Name = name; remoModelDict.Add(name, mdl); } } else { mdl = remoModelDict[name]; } if (mdl != null) { mdl.AnimContainer = animContainer; mdl.IsRemoModel = true; mdl.Name = name; mdl.SkeletonFlver.RevertToReferencePose(); mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true); mdl.UpdateSkeleton(); lock (Scene._lock_ModelLoad_Draw) { Scene.Models.Add(mdl); } } } var msbName = GameDataManager.GetInterrootPath($@"map\MapStudio\m{AreaInt:D2}_{BlockInt:D2}_00_00.msb"); var msb = MSB1.Read(msbName); Vector3 mapOffset = msb.Events.MapOffsets.FirstOrDefault()?.Position.ToXna() ?? Vector3.Zero; uint dg1 = 0, dg2 = 0, dg3 = 0, dg4 = 0; foreach (var hitName in CurrentCutHits) { var hit = msb.Parts.Collisions.FirstOrDefault(h => h.Name == hitName); dg1 |= hit.DrawGroups[0]; dg2 |= hit.DrawGroups[1]; dg3 |= hit.DrawGroups[2]; dg4 |= hit.DrawGroups[3]; } bool IsThingVisible(uint[] drawGroups) { return(((drawGroups[0] & dg1) == dg1) && ((drawGroups[1] & dg2) == dg2) && ((drawGroups[2] & dg3) == dg3) && ((drawGroups[3] & dg4) == dg4)); } foreach (var mapPiece in msb.Parts.MapPieces) { var thisEntityName = CurrentCutOtherBlocks.Count > 0 ? $"A{AreaInt:D2}B{BlockInt:D2}_{mapPiece.Name}" : mapPiece.Name; if (IsThingVisible(mapPiece.DrawGroups)) { Model mdl = null; if (remoModelDict.ContainsKey(thisEntityName)) { mdl = remoModelDict[thisEntityName]; mdl.AnimContainer = animContainer; mdl.IsRemoModel = true; mdl.SkeletonFlver.RevertToReferencePose(); mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true); mdl.UpdateSkeleton(); lock (Scene._lock_ModelLoad_Draw) { Scene.Models.Add(mdl); } continue; } mdl = GameDataManager.LoadMapPiece(AreaInt, BlockInt, 0, 0, int.Parse(mapPiece.ModelName.Substring(1, 4))); mdl.AnimContainer = animContainer; mdl.IsRemoModel = true; mdl.Name = thisEntityName; mdl.SkeletonFlver.RevertToReferencePose(); mdl.StartTransform.Position = mapPiece.Position.ToXna() - mapOffset; mdl.StartTransform.Rotation = Utils.EulerToQuaternion((mapPiece.Rotation * (SapMath.Pi / 180f)).ToXna()); mdl.StartTransform.Scale = mapPiece.Scale.ToXna(); mdl.CurrentTransform = mdl.StartTransform; mdl.IS_REMO_NOTSKINNED = true; mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true); mdl.UpdateSkeleton(); lock (Scene._lock_ModelLoad_Draw) { Scene.Models.Add(mdl); } remoModelDict.Add(thisEntityName, mdl); } } foreach (var mapPiece in msb.Parts.Objects) { var thisEntityName = CurrentCutOtherBlocks.Count > 0 ? $"A{AreaInt:D2}B{BlockInt:D2}_{mapPiece.Name}" : mapPiece.Name; if (IsThingVisible(mapPiece.DrawGroups)) { Model mdl = null; if (remoModelDict.ContainsKey(thisEntityName)) { mdl = remoModelDict[thisEntityName]; mdl.AnimContainer = animContainer; mdl.IsRemoModel = true; mdl.SkeletonFlver.RevertToReferencePose(); mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true); mdl.UpdateSkeleton(); lock (Scene._lock_ModelLoad_Draw) { Scene.Models.Add(mdl); } continue; } mdl = GameDataManager.LoadObject(mapPiece.ModelName); mdl.AnimContainer = animContainer; mdl.IsRemoModel = true; mdl.Name = thisEntityName; mdl.StartTransform.Position = mapPiece.Position.ToXna() - mapOffset; mdl.StartTransform.Rotation = Utils.EulerToQuaternion((mapPiece.Rotation * (SapMath.Pi / 180f)).ToXna()); mdl.StartTransform.Scale = mapPiece.Scale.ToXna(); mdl.CurrentTransform = mdl.StartTransform; mdl.IS_REMO_NOTSKINNED = true; mdl.SkeletonFlver.RevertToReferencePose(); mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true); mdl.UpdateSkeleton(); lock (Scene._lock_ModelLoad_Draw) { Scene.Models.Add(mdl); } remoModelDict.Add(thisEntityName, mdl); } } lock (Scene._lock_ModelLoad_Draw) { Scene.Models = Scene.Models.OrderBy(m => m.IS_PLAYER ? 0 : 1).ToList(); } CurrentCut = animName; animContainer.ScrubRelative(0); List <Model> mdls = null; lock (Scene._lock_ModelLoad_Draw) { mdls = Scene.Models.ToList(); } foreach (var m in mdls) { m.UpdateSkeleton(); } GFX.World.Update(0); Scene.EnableModelDrawing(); Scene.EnableModelDrawing2(); ResumeStreamedBGM(); ViewportInteractor.Graph.MainScreen.REMO_HOTFIX_REQUEST_PLAY_RESUME_NEXT_FRAME = true; ViewportInteractor.Graph.MainScreen.HardReset(); }
public static void LoadAllFMG(bool forceReload) { if (!forceReload && GameTypeCurrentFmgsAreLoadedFrom == GameDataManager.GameType) { return; } List <FMG> weaponNameFMGs = new List <FMG>(); List <FMG> armorNameFMGs = new List <FMG>(); /* * [ptde] * weapon 1 * armor 2 * * [ds1r] * weapon 1, 30 * armor 2, 32 * * [ds3] * weapon 1 * armor 2 * weapon_dlc1 18 * armor_dlc1 19 * weapon_dlc2 33 * armor_dlc2 34 * * [bb] * weapon 1 * armor 2 * * [sdt] * weapon 1 * armor 2 */ void TryToLoadFromMSGBND(string language, string msgbndName, int weaponNamesIdx, int armorNamesIdx) { var msgbndRelativePath = $@"msg\{language}\{msgbndName}"; var fullMsgbndPath = GameDataManager.GetInterrootPath(msgbndRelativePath); IBinder msgbnd = null; if (File.Exists(fullMsgbndPath)) { if (BND3.Is(fullMsgbndPath)) { msgbnd = BND3.Read(fullMsgbndPath); } else if (BND4.Is(fullMsgbndPath)) { msgbnd = BND4.Read(fullMsgbndPath); } weaponNameFMGs.Add(FMG.Read(msgbnd.Files.First(x => x.ID == weaponNamesIdx).Bytes)); armorNameFMGs.Add(FMG.Read(msgbnd.Files.First(x => x.ID == armorNamesIdx).Bytes)); } if (msgbnd == null) { System.Windows.Forms.MessageBox.Show( $"Unable to find text file '{msgbndRelativePath}'. Some player equipment may not show names.", "Unable to find asset", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); return; } } if (GameDataManager.GameType == GameDataManager.GameTypes.DS1) { TryToLoadFromMSGBND("ENGLISH", "item.msgbnd", 11, 12); TryToLoadFromMSGBND("ENGLISH", "menu.msgbnd", 115, 117); //Patch } else if (GameDataManager.GameType == GameDataManager.GameTypes.DS1R) { TryToLoadFromMSGBND("ENGLISH", "item.msgbnd.dcx", 11, 12); TryToLoadFromMSGBND("ENGLISH", "item.msgbnd.dcx", 115, 117); //Patch } else if (GameDataManager.GameType == GameDataManager.GameTypes.DS3) { TryToLoadFromMSGBND("engus", "item_dlc1.msgbnd.dcx", 11, 12); TryToLoadFromMSGBND("engus", "item_dlc1.msgbnd.dcx", 211, 212); //DLC1 TryToLoadFromMSGBND("engus", "item_dlc2.msgbnd.dcx", 11, 12); TryToLoadFromMSGBND("engus", "item_dlc2.msgbnd.dcx", 211, 212); //DLC1 TryToLoadFromMSGBND("engus", "item_dlc2.msgbnd.dcx", 251, 252); //DLC2 } else if (GameDataManager.GameType == GameDataManager.GameTypes.SDT) { TryToLoadFromMSGBND("engus", "item.msgbnd.dcx", 11, 12); } else if (GameDataManager.GameType == GameDataManager.GameTypes.BB) { TryToLoadFromMSGBND("engus", "item.msgbnd.dcx", 11, 12); } WeaponNames.Clear(); void DoWeaponEntry(FMG.Entry entry) { if (string.IsNullOrWhiteSpace(entry.Text) || !ParamManager.EquipParamWeapon.ContainsKey(entry.ID)) { return; } //if (GameDataManager.GameType == GameDataManager.GameTypes.DS3 && (entry.ID % 10000) != 0) // return; //else if ((entry.ID % 1000) != 0) // return; string val = entry.Text + $" <{entry.ID}>"; if (WeaponNames.ContainsKey(entry.ID)) { WeaponNames[entry.ID] = val; } else { WeaponNames.Add(entry.ID, val); } } foreach (var wpnNameFmg in weaponNameFMGs) { foreach (var entry in wpnNameFmg.Entries) { DoWeaponEntry(entry); } } ProtectorNames_HD.Clear(); ProtectorNames_BD.Clear(); ProtectorNames_AM.Clear(); ProtectorNames_LG.Clear(); void DoProtectorParamEntry(FMG.Entry entry) { if (string.IsNullOrWhiteSpace(entry.Text)) { return; } //if (entry.ID < 1000000 && GameDataManager.GameType == GameDataManager.GameTypes.DS3) // return; if (ParamManager.EquipParamProtector.ContainsKey(entry.ID)) { string val = entry.Text + $" <{entry.ID}>"; var protectorParam = ParamManager.EquipParamProtector[entry.ID]; if (protectorParam.HeadEquip) { if (ProtectorNames_HD.ContainsKey(entry.ID)) { ProtectorNames_HD[entry.ID] = val; } else { ProtectorNames_HD.Add(entry.ID, val); } } else if (protectorParam.BodyEquip) { if (ProtectorNames_BD.ContainsKey(entry.ID)) { ProtectorNames_BD[entry.ID] = val; } else { ProtectorNames_BD.Add(entry.ID, entry.Text + $" <{entry.ID}>"); } } else if (protectorParam.ArmEquip) { if (ProtectorNames_AM.ContainsKey(entry.ID)) { ProtectorNames_AM[entry.ID] = val; } else { ProtectorNames_AM.Add(entry.ID, entry.Text + $" <{entry.ID}>"); } } else if (protectorParam.LegEquip) { if (ProtectorNames_LG.ContainsKey(entry.ID)) { ProtectorNames_LG[entry.ID] = val; } else { ProtectorNames_LG.Add(entry.ID, entry.Text + $" <{entry.ID}>"); } } } } foreach (var armorNameFmg in armorNameFMGs) { foreach (var entry in armorNameFmg.Entries) { DoProtectorParamEntry(entry); } } WeaponNames = WeaponNames.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); ProtectorNames_HD = ProtectorNames_HD.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); ProtectorNames_BD = ProtectorNames_BD.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); ProtectorNames_AM = ProtectorNames_AM.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); ProtectorNames_LG = ProtectorNames_LG.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); foreach (var protector in ParamManager.EquipParamProtector) { if (protector.Value.HeadEquip && !ProtectorNames_HD.ContainsKey((int)protector.Key)) { ProtectorNames_HD.Add((int)protector.Key, $"<{protector.Key}>"); } else if (protector.Value.BodyEquip && !ProtectorNames_BD.ContainsKey((int)protector.Key)) { ProtectorNames_BD.Add((int)protector.Key, $"<{protector.Key}>"); } else if (protector.Value.ArmEquip && !ProtectorNames_AM.ContainsKey((int)protector.Key)) { ProtectorNames_AM.Add((int)protector.Key, $"<{protector.Key}>"); } else if (protector.Value.LegEquip && !ProtectorNames_LG.ContainsKey((int)protector.Key)) { ProtectorNames_LG.Add((int)protector.Key, $"<{protector.Key}>"); } } foreach (var weapon in ParamManager.EquipParamWeapon) { if (!WeaponNames.ContainsKey((int)weapon.Key)) { WeaponNames.Add((int)weapon.Key, $"<{weapon.Key}>"); } } ProtectorNames_HD = ProtectorNames_HD.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); ProtectorNames_BD = ProtectorNames_BD.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); ProtectorNames_AM = ProtectorNames_AM.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); ProtectorNames_LG = ProtectorNames_LG.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); WeaponNames = WeaponNames.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); GameTypeCurrentFmgsAreLoadedFrom = GameDataManager.GameType; }