[Solved] XML: How to use a custom soundfile?

Started by Napoleonite, May 04, 2019, 11:58:11 AM

Previous topic - Next topic

Napoleonite

I placed the soundfile here:
D:\Steam\steamapps\common\RimWorld\Mods\MoreTurrets\Sounds\FireSniperMKII.wav

I then added a new SoundDef:
<?xml version="1.0" encoding="utf-8"?>

<Defs>

  <SoundDef>
    <defName>Shot_TurretSniperMKII</defName>
    <context>MapOnly</context>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Folder">
            <clipFolderPath>Sounds/FireSniperMKII</clipFolderPath> <!-- This also fails: <clipFolderPath>FireSniperMKII</clipFolderPath> -->
          </li>
        </grains>
        <volumeRange>
          <min>77</min>
          <max>77</max>
        </volumeRange>
        <pitchRange>
          <min>0.7</min>
          <max>0.8</max>
        </pitchRange>
        <sustainLoop>False</sustainLoop>
      </li>
    </subSounds>
  </SoundDef>
 
</Defs>


and used it here in my gun xml:
  <ThingDef ParentName="BaseHumanGun">
    <defName>Gun_TurretSniperMKII</defName>
    <label>hi-tech uranium slug cannon</label>
...
    <verbs>
      <li>
        <verbClass>Verb_Shoot</verbClass>
        <hasStandardCommand>true</hasStandardCommand>
        <defaultProjectile>Bullet_TurretSniperMKII</defaultProjectile>
        <warmupTime>0</warmupTime>
        <minRange>11.9</minRange>
        <range>49.9</range>
        <burstShotCount>1</burstShotCount>
        <!--<soundCast>Shot_TurretSniper</soundCast>-->
<soundCast>Shot_TurretSniperMKII</soundCast>
        <soundCastTail>GunTail_Heavy</soundCastTail>
        <muzzleFlashScale>18</muzzleFlashScale>
        <consumeFuelPerShot>1</consumeFuelPerShot>
      </li>
    </verbs>
  </ThingDef>


gives me this error:
QuoteCould not resolve cross-reference: No Verse.SoundDef named Shot_TurretSniperMKII found to give to Verse.VerbProperties VerbProperties(hi-tech uranium slug cannon) (using undefined sound instead)

What is the difference between clipPath and clipFolderPath btw?

Mehni

Quote from: Napoleonite on May 04, 2019, 11:58:11 AM
What is the difference between clipPath and clipFolderPath btw?

If you figure that out, you'll have figured out your problem.

AudioGrain_Folder implies you have multiple sounds in a folder. You're looking for AudioGrain_Clip and clipPath.

Napoleonite

#2
Thanks for the explanation now I know the difference :)

I already tried the 'clip-versions' before (I was yoloing/trial&error xml-nodes hoping for something that would work) but that didn't not work either. I looked at other mods and I use the same definition and still I fail. I did a text-compare to some and aside from the values it's the same as mine, but mine does not work. I made mine even shorter but it still fails with the same warning. Code:

<SoundDef>
<defName>Shot_TurretSniperMKII</defName>
<context>MapOnly</context>
<subSounds>
<li>
<grains>
<li Class="AudioGrain_Clip"> <!-- Clip now! -->
<clipPath>FireSniperMKII</clipPath>  <!-- Clip now! -->
</li>
</grains>
</li>
</subSounds>
</SoundDef>


I tried so many things and then I was like... Wait a minute... Could I've placed the XML file in the wrong folder? Yup I did... Moving the XML file fixed it... I can't believe I put the XML in the wrong folder  :o I feel rather stupid. Thanks for the answer though I still needed that as well!