Gotcha. I was successful in creating/duplicating an animation and make it play custom sounds via xml editing.Ah, I read your comment, I think you were only trying to replace native sound? That's not what I'm doing. I'm trying to add a new sound and play it from the code side. It's not playing or finding the sound even though XML is correct - according to documentation.
In other words, you still need that bulky Modding Tools even for such a simple operation?edit project.mbproj
Yes, I mentioned this in my previous post but the problem was that the game didn't seem to use the XMLs. Debugging showed that it was detecting the documents, yet changes didn't actually show in-game. skins.xml is loaded the same way, and someone whom had successfully loaded a custom skins.xml before suddenly couldn't get it to work anymore, so we figured something was broken. Let me know if you are successfully able to add and play custom sounds like that right now. I just double-checked my files and it's not working for me.It is possible to play sound in game. It was hard to find how to do that though. People need to edit project.mbproj file according to the way native project.mbproj file did.
to set up a module, yes you need.In other words, you still need that bulky Modding Tools even for such a simple operation?
Firstly i added this to the module_sounds.xmlYes, I mentioned this in my previous post but the problem was that the game didn't seem to use the XMLs. Debugging showed that it was detecting the documents, yet changes didn't actually show in-game. skins.xml is loaded the same way, and someone whom had successfully loaded a custom skins.xml before suddenly couldn't get it to work anymore, so we figured something was broken. Let me know if you are successfully able to add and play custom sounds like that right now. I just double-checked my files and it's not working for me.
I'll add a section on loading the files through project.mbproj when I do get it working though.
<module_sound name="sam_musket_firing_01" sound_category="mission_foley" path="musket_firing_01.wav"/>
Well, that's bad and sad. Because there is no packaging happening anyway for audios and they are all read from disk/folder directly - and for module_strings.xml for example, you don't require to have modding tools.to set up a module, yes you need.
I guess something is not right with sound modding at the moment as Reus and you already mentioned and struggled with. Let's see if they can fix this soon. Playing a sound shouldn't be rocket science and shouldn't require hella different weird changes.- Sounds that dont have valid categories wont be played!
example:
int soundIndex = SoundEvent.GetEventIdFromString("example/voice/charge");//to avoid string operations in runtime soundIndex can be cached.
if (playOneshot)
{
MakeSound(soundIndex, MainAgent.Position, false, true, -1, -1);//plays oneshot sound at position with given parameters.
}
else
{
SoundEvent eventRef = SoundEvent.CreateEvent(soundIndex, Scene);//get a reference to sound and update parameters later.
eventRef.SetPosition(MainAgent.Position);
eventRef.Play();
}
Well, that's bad and sad
100% Agreed! This overly convoluted method should be fixed.I guess something is not right with sound modding at the moment as Reus and you already mentioned and struggled with. Let's see if they can fix this soon. Playing a sound shouldn't be rocket science and shouldn't require hella different weird changes.
namespace Shokuho
{
// Music Patching
[HarmonyPatch(typeof(MBMusicManager), MethodType.Constructor)]
public class MBMusicManagerPatch
{
private static void Postfix(MBMusicManager __instance)
{
if (!NativeConfig.DisableSound)
{
int num = (int)PsaiCore.Instance.LoadSoundtrackFromProjectFile(BasePath.Name + "Modules/Shokuho/ModuleSounds/Music/soundtrack.xml");
}
System.Diagnostics.Debug.WriteLine("Postfix loaded! (Music)");
}
}
}
I'm not sure but based on that code piece, it appears that this Instance can be called from anywhere - hence you don't need Harmony for that - you can simply call it in your OnSubmoduleLoad or somewhere else, right?Speaking of rocket science, we figured out how to use harmony to force load custom soundtrack.xml (so you can play music from your own mod folder without the need to overwrite any vanilla files.
It can be done by postfixing the path to the xml like this:
It's related to https://assetstore.unity.com/packages/tools/audio/psai-music-engine-pro-24788(Note: Not sure if related but https://csharp.hotexamples.com/examples/psai.Editor/Segment/-/php-segment-class-examples.html)
Technically yes, however, it needs to write to "_battleMode" and "_campaignMode", both of which are readonly (and then probably call Initialize), in order for it to take effect.I'm not sure but based on that code piece, it appears that this Instance can be called from anywhere - hence you don't need Harmony for that - you can simply call it in your OnSubmoduleLoad or somewhere else, right?
private readonly MBMusicManager.BattleMusicMode _battleMode;
private readonly MBMusicManager.CampaignMusicMode _campaignMode;
private MBMusicManager()
{
if (!NativeConfig.DisableSound)
{
int num = (int) PsaiCore.Instance.LoadSoundtrackFromProjectFile(BasePath.Name + "music/soundtrack.xml");
}
this._battleMode = new MBMusicManager.BattleMusicMode();
this._campaignMode = new MBMusicManager.CampaignMusicMode();
}
Yes but it's not related to that line anyway. Because return value isn't used.Technically yes, however, it needs to write to "_battleMode" and "_campaignMode", both of which are readonly (and then probably call Initialize), in order for it to take effect.
int num = (int) PsaiCore.Instance.LoadSoundtrackFromProjectFile(BasePath.Name + "music/soundtrack.xml");
this._battleMode = new MBMusicManager.BattleMusicMode(num);
this._campaignMode = new MBMusicManager.CampaignMusicMode(num);