Game sounds

Started by alchemyfool, October 15, 2017, 03:54:44 PM

Previous topic - Next topic

alchemyfool

Is it possible to replace game sounds either through Defs xml and   <clipPath>
or if i would like to add my own.

Im most interested in failed construction sound its way too loud. Im guessing its just an alert sounds. I had a quick look through defs and couldnt find anything for it

CannibarRechter

#1
Do you know the specific sound you're looking to replace? By filename?

Looking over the core: A) the modloader absolutely does support audio loads, and B) there don't appear to be readonly AudioClips in the core. That's a really preliminary answer, though...

Edit. I think you want to be looking in Core\Defs\SoundDefs\...
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

alchemyfool

Well this is the problem i went throguh sound defs pretty much one by one and couldnt find it.

I dont know its location. And because i cannot find the defs record for it i dont know how i would change that.

CannibarRechter

I looked through both the defs and the core, and couldn't find it. It's probably masquerading as something else. Has anyone ever extracted the sounds from the assets file like they have with the art? If they have, the solution might be to play them one by one until you hear the sound you are expecting.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

alchemyfool

I thought it was something like that because I couldnt find it anywhere either.

I dont know where to start to extract things like that.

alchemyfool

Help anyone?

I need an adult.

CannibarRechter

There is a thing called Unity Asset Explorer that will let you pull objects out of the resources file. Another option would be to incrementally mod objects, which play the likely named sounds, until you have found the one you want. Another option is dumping the game code with ILSpy, and finding out by enumerating the code what the failed construction sound is.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

DrMrEd

#7
I grepped through source and the only place I found anything to do with construction failure is in RimWorlds/Frame.cs, which has a FailConstruction method:


    public void FailConstruction(Pawn worker)
    {
      Map map = this.Map;
      this.Destroy(DestroyMode.FailConstruction);
      Blueprint_Build newBlueprint = (Blueprint_Build) null;
      if (this.def.entityDefToBuild.blueprintDef != null)
      {
        newBlueprint = (Blueprint_Build) ThingMaker.MakeThing(this.def.entityDefToBuild.blueprintDef, (ThingDef) null);
        newBlueprint.stuffToUse = this.Stuff;
        newBlueprint.SetFactionDirect(this.Faction);
        GenSpawn.Spawn((Thing) newBlueprint, this.Position, map, this.Rotation, false);
      }
      Lord lord = worker.GetLord();
      if (lord != null)
        lord.Notify_ConstructionFailed(worker, this, newBlueprint);
      MoteMaker.ThrowText(this.DrawPos, map, "TextMote_ConstructionFail".Translate(), 6f);
      if (this.Faction != Faction.OfPlayer || (double) this.WorkToMake <= 1400.0)
        return;
      Messages.Message("MessageConstructionFailed".Translate((object) this.Label, (object) worker.LabelShort), (GlobalTargetInfo) new TargetInfo(this.Position, map, false), MessageSound.Negative);
    }


The only explicit sound call here is the MessageSound.Negative one, but that's associated with the notification.

Next try was to grep through all the XML Defs, and again there are limited hits. The only thing that might be applicable is from Defs/SoundDefs/UI_Oneshots_Designation.xml:


  <SoundDef>
    <defName>DesignateFailed</defName> 
    <eventNames /> 
    <maxSimultaneous>1</maxSimultaneous> 
    <subSounds>
      <li>
        <onCamera>True</onCamera>     
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>UI/Designate/DesignateFailed</clipPath>
          </li>
        </grains>     
        <volumeRange>
          <min>19.11764</min>       
          <max>19.11764</max>
        </volumeRange>     
        <sustainLoop>False</sustainLoop>
      </li>
    </subSounds>
  </SoundDef>


Using the Unity Extractor, I can see there's a "resources/DesignateFailed.83" audio clip, and using something called "AssetsBundleExtractor" I was able to pull a .wav file out (along with all the other game sounds!!). DesignateFailed is a very, very short "splat" type sound. I didn't notice any volume oddities with it relative to the other extracted sounds. I tried to attach the .wav to this post (no idea if it'll work). 

I'm thinking at this point you could point that SoundDef to something else that's more pleasing to you via a patch.


[attachment deleted by admin: too old]

alchemyfool

Its deffinetly MessageSound.Negative
Its the same sound when you get negative message for sure. So i guess there is no way for me to change it because its hardcoded and i cant replace the sound because its in the assets.

CannibarRechter

QuoteSo i guess there is no way for me to change it because its hardcoded and i cant replace the sound because its in the assets.

I don't think this is correct. MessageSound.Negative is an enum. In the Messages.Message factory method, there is a snip that looks like this:


case MessageSound.Negative:
    soundDef = SoundDefOf.MessageAlertNegative;
    break;


If you search through the SoundDefs, you'll find MessageAlertNegative with a def in UI_Oneshots_Misc. Patch that, and you'll have a different sound for all alert negatives.

The game has very little in the way of hardcoded sound in the core, AFAICT. Almost everything is a def.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

alchemyfool

Thank you very much CannibarRechter and DrMrEd for your help.

I will start working on my first mod. Maybe one day i will be able to help you with something.