Need help with coding to replace game sound. I already know nameDef...

Started by viperwasp, October 19, 2018, 06:21:18 PM

Previous topic - Next topic

viperwasp

I'm trying to make my first mod. I have looked at similar mods but I don't know what changes to make.

I find the new Bill completed sound in 1.0 to be annoying. In particular

I found out the sound I want still exists within 1.0.
I opened both A17 and 1.0 and digged though the Dev tools. I found a way to preview all sounds.

This is what I found...

-----------------------------

A17

The sound for Bill Completed is...
DefName "MessageBenefit" (This is the sound I like!)

max voices 4
max simultanous 1
sustain fadeout time 0


1.0

The sound for Bill Completed is...
DefName "Message_TaskCompletion" (This is the sound I hate!)

max voices 4
max simultaneous 1
sustain fadeout time 0


Needs to be changed too this

DefName "Message_PositiveEvent"  (This is the sound I like.)

max voices 4
max simultaneous 1
sustain fadeout time 0



Note A17's "MessageBenefit" is the same sound as 1.0's "Message_PositiveEvent"

So the sound I want still exists within 1.0. I want to make a mod that basically tells Rimworld 1.0 to use "Message_PositiveEvent" instead of "Message_TaskCompletion"...

So I need to either record or find a copy of the sound "Message_PositiveEvent" from somewhere and make a mod to replace the new sound I don't like. Or I simply need to make a mod that tells the game to use "Message_PositiveEvent" instead of "Message_TaskCompletion" ..... both are probably possible. 

This is a code example from MarvinKosh's Less Annoying U.I Sounds. Is this similar to the code I need? This code replaces a nameDef with a source clip sound included in the mod. I want to replace mine with a sound that already exists? Can something be changed to make that possible. After all we already know the nameDef of the sound that I want instead. Thanks.
-
<Defs>


-<SoundDef>

<defName>ModdedMessageNegativeEvent</defName>

<eventNames/>

<maxSimultaneous>1</maxSimultaneous>


-<subSounds>


-<li>

<onCamera>True</onCamera>


-<grains>


-<li Class="AudioGrain_Clip">

<clipPath>UI/ModdedMessageAlertNegative</clipPath>

</li>

</grains>


-<volumeRange>

<min>32</min>

<max>32</max>

</volumeRange>

</li>

</subSounds>

</SoundDef>

</Defs>


The mod Less Annoying U.I Sounds. Also includes this code? I'm not sure if that is needed or not for what I am trying to do.

-<Patch>


-<Operation Class="PatchOperationReplace">

<xpath>*/SoundDef[defName = "TinyBell"]/subSounds/li[1]/grains/li[1]/clipPath</xpath>


-<value>

<clipPath>UI/ModdedTinyBell</clipPath>

</value>

</Operation>


-<Operation Class="PatchOperationReplace">

<xpath>*/SoundDef[defName = "TinyBell"]/subSounds/li[1]/volumeRange/min</xpath>


-<value>

<min>64</min>

</value>

</Operation>


-<Operation Class="PatchOperationReplace">

<xpath>*/SoundDef[defName = "TinyBell"]/subSounds/li[1]/volumeRange/max</xpath>


-<value>

<max>64</max>

</value>

</Operation>


-<Operation Class="PatchOperationReplace">

<xpath>*/MessageTypeDef[defName = "NegativeEvent"]/sound</xpath>


-<value>

<sound>ModdedMessageNegativeEvent</sound>

</value>

</Operation>

</Patch>


Can someone show me what changes need to be made. Or if it's not hard just post the code/def.
Thanks!!

•  Lian Li Lancool II MESH RGB
•  Intel Core i7-12700K Alder Lake 12-Core
•  64 GB Corsair Vengeance LPX 3600Mhz
•  WD Black SN850 2TB GEN4
•  2x WD Black 8TB
•  Windows 10 OS
•  RTX 4080 GIGABYTE Gaming OC 16GB
•  Dark Rock Pro 4 (CPU Cooler)
•  TUF Gaming Z690-Plus- WIFI D4

RemingtonRyder

Hey there!

If you want to simply change the sound played to Message_PositiveEvent, then you can do that with a simple patch operation like the second code block you posted.

<Patch>

<Operation Class="PatchOperationReplace">

<xpath>*/MessageTypeDef[defName = "Message_TaskCompletion"]/sound</xpath>


<value>

<sound>Message_PositiveEvent</sound>

</value>

</Operation>

</Patch>


Changing it to a custom sound that you made is not too complicated either.

<Patch>


<Operation Class="PatchOperationReplace">

<xpath>*/SoundDef[defName = "Message_TaskCompletion"]/subSounds/li[1]/grains/li[1]/clipPath</xpath>


<value>

<clipPath>NameOfYourSound</clipPath>

</value>

</Operation>

</Patch>


This does however require that you have a Sounds folder in your mod's folder (on the same level as Defs) and you then drop in a sound file with the desired name in OGG format.

I think sounds of this type are usually one channel (Mono, not Stereo) and 44100 Hz sample size.

Let me know if you need any more help with it. :)

viperwasp

I really appreciate it. Let me test it out. For now I don't really have a file to replace it with. I'm happy with just making it the other sound already in Rimworld 1.0. The old sound. So let me give it a try.
•  Lian Li Lancool II MESH RGB
•  Intel Core i7-12700K Alder Lake 12-Core
•  64 GB Corsair Vengeance LPX 3600Mhz
•  WD Black SN850 2TB GEN4
•  2x WD Black 8TB
•  Windows 10 OS
•  RTX 4080 GIGABYTE Gaming OC 16GB
•  Dark Rock Pro 4 (CPU Cooler)
•  TUF Gaming Z690-Plus- WIFI D4

viperwasp

Quote from: MarvinKosh on October 19, 2018, 07:30:35 PM
Hey there!

If you want to simply change the sound played to Message_PositiveEvent, then you can do that with a simple patch operation like the second code block you posted.

<Patch>

<Operation Class="PatchOperationReplace">

<xpath>*/MessageTypeDef[defName = "Message_TaskCompletion"]/sound</xpath>


<value>

<sound>Message_PositiveEvent</sound>

</value>

</Operation>

</Patch>



Is that all I need?

What I have now in my mod is the About folder with the about text. Which I feel I have correct.

Then I tried making a folder called "patches" made a text.doc and copied the exact code above in it.
I also tried it without a folder named patches and just put the code from above in a text document.

I imagine I am doing something wrong? Because in one case I got errors and it did not work. Other case I got no errors
but it still did not work. Plays old sound.

1. Besides the About Folder what should be the name of the other folders I need?
2. And do I really just need that one set of code?
3. Does it matter what I name the final text file with this code it it? I decided to call it "Message_PositiveEventPatches" for now and I don't know if that matters. Thanks.

Update:
Is it possible that there is a subsound involved? I notice the other coding has sub sound type stuff added. I don't know much about that but maybe I need that text too?


Update: Well thanks I was able to get this working by using Less Annoying U.I Sounds as a template and using a file to replace the sound. Now I simply need to record or find the correct sound I want. Which should be easy. Thanks.
•  Lian Li Lancool II MESH RGB
•  Intel Core i7-12700K Alder Lake 12-Core
•  64 GB Corsair Vengeance LPX 3600Mhz
•  WD Black SN850 2TB GEN4
•  2x WD Black 8TB
•  Windows 10 OS
•  RTX 4080 GIGABYTE Gaming OC 16GB
•  Dark Rock Pro 4 (CPU Cooler)
•  TUF Gaming Z690-Plus- WIFI D4

RemingtonRyder