HELP : Weapon sound

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Folker
Posts: 124
Joined: Fri, 31. Jul 20, 21:56
x4

HELP : Weapon sound

Post by Folker »

Hey, I have a problem, I want to replace sound of a weapon, and doesn't work. I dont know why. Let me explain :

I want to create the plasma canon of XR, and I want the same sound of the launch that XR. I use certain model of VRO like plasma ma bullet, I know that the sound don't come from bullet but from launch ref, is : plasmaemitter_muzzle_02. The effect was edited, and added to components.xml

Code: Select all

<diff>
  <replace sel="//macros">
  <macros>
  <macro name="bullet_gen_m_plasma_01_mk1_macro" class="bullet">
    <component ref="bullet_ma" />
    <properties>
      <bullet speed="4500" lifetime="2.4" amount="1" barrelamount="1" icon="weapon_plasma_mk1" angle="0.05" maxhits="1" ricochet="0" scale="0" attach="0" />
      <heat value="1592" />
      <reload rate="0.75" />
      <damage value="4000" shield="4400" repair="0" />
      <effects>
        <impact ref="plasmaemitter_player_impact" />
        <launch ref="plasmaemitter_muzzle_02" />
      </effects>
      <weapon system="weapon_standard" />
    </properties>
  </macro>
</macros>
  </replace>
  </diff>

So, I open the effect file :

Code: Select all

  
 <add sel="/effects">
  <effect name="plasmaemitter_muzzle_02" minscale="0.75" maxscale="1.25" alignment="object">
    <elements>
      <!-- MuzzleGeometry + Light -->
      <element id="1" ref="plasmaemitter_muzzle_02_macro" forkeffect="none" duration="0.1" forkmaterial="none" forklod="none"></element>
      <!-- Sound -->
      <element id="2" ref="effect_dummy_macro" forkeffect="none" duration="2.5" forkmaterial="none" forklod="none">
        <sound ref="wpn_plasma_am_muzzle"></sound>
      </element>
    </elements>
  </effect>
 </add>
I create wpn_plasma_am_muzzle. After, I go to the soundlibrary and I write that :

Code: Select all

 
  <add sel="//soundlibrary"> 
  <sound id="wpn_plasma_am_muzzle" description="AM_plasma sound" repeat="1" is3d="1" preload="1">
    <sample start="extensions\test\sfx\weapons\plasma_am_cannon_1"/>
    <volume start="1.25" distance="10"/>
  </sound>
  </add>
After I go to : sfx\weapons and I add a new sound named plasma_am_cannon_1 is a ogg sound file.

And at the end I will modify the M_plasma_01_mk1 weapon :

Code: Select all

<diff>
 <replace sel="/macros"> 
<macros>
  <macro name="weapon_gen_m_plasma_01_mk1_macro" class="weapon">
    <component ref="weapon_gen_m_plasma_01_mk1" />
    <properties>
      <identification name="{20105,2064}" basename="{20105,2061}" shortname="{20105,2065}" description="{20105,2062}" mk="1" />
      <bullet class="bullet_gen_m_plasma_01_mk1_macro" />
      <heat overheat="10000" cooldelay="1.13" coolrate="2000" reenable="2000" />
      <rotationspeed max="24.8" />
      <rotationacceleration max="49.6" />
      <hull max="1001" hittable="0" />
      <effects>
        <firing start="wpn_plasma_am_muzzle" />
      </effects>      
    </properties>
  </macro>
</macros>
</replace>
</diff>
As you see, I add :
<effects>
<firing start="wpn_plasma_am_muzzle" />
</effects>

The sound doesn't work, because when I shot with this weapon the same sound as vanilla is played. I don't know why, and where is my error.
I tested, if I replace the sound wpn_plasma_muzzle, the XR plasma sound work. Like that :

Code: Select all

  
  <replace sel="//soundlibrary/sound[@id='wpn_plasma_muzzle']">
    <sound id="wpn_plasma_muzzle" description="______" repeat="1" is3d="1" preload="1">
      <sample selection="random">
        <select start="extensions\rem\sfx\weapons\plasma_am_cannon_1 " />
      </sample>
      <volume start="0.8" distance="5" />
    </sound>
  </replace>
But I don't want to replace it, because every plasma sound will be the same. I just want to modify the sound of 1 weapon.
I hope you can help me
ChristianErding
Posts: 104
Joined: Tue, 10. May 05, 18:04
x4

Re: HELP : Weapon sound

Post by ChristianErding »

Sadly I am a newbie. But what did help me in finding errors:

Step 2: Replace the sound with a non plasma sound from the game, not custom.

If it works, the your code is correct.

Step 2: Rename a non plasma vanilla sound to the name of your effect.
If it works then your code is perfect and it can only be that your custom sound has the wrong format.
If your renamed vanilla sound does not play, then it means it is not correctly registered in the soundlibrary. If vro has custom sounds, look there how its done, or download a mod with custom sounds and look there.
Die Rente ist sicher, von der Höhe hat leider keiner was gesagt.
Folker
Posts: 124
Joined: Fri, 31. Jul 20, 21:56
x4

Re: HELP : Weapon sound

Post by Folker »

ChristianErding wrote: Mon, 19. May 25, 18:31 Sadly I am a newbie. But what did help me in finding errors:

Step 2: Replace the sound with a non plasma sound from the game, not custom.

If it works, the your code is correct.

Step 2: Rename a non plasma vanilla sound to the name of your effect.
If it works then your code is perfect and it can only be that your custom sound has the wrong format.
If your renamed vanilla sound does not play, then it means it is not correctly registered in the soundlibrary. If vro has custom sounds, look there how its done, or download a mod with custom sounds and look there.
Ok, thanks for the tips, I will try it this weekend
ChristianErding
Posts: 104
Joined: Tue, 10. May 05, 18:04
x4

Re: HELP : Weapon sound

Post by ChristianErding »

<replace sel="//macros">
<macros>
<macro name="bullet_gen_m_plasma_01_mk1_macro" class="bullet">

I think the "macros" in line 2 is wrong. I have general doubts that the syntax is correct.
Thats what I use:

Code: Select all

<diff>
 	<replace sel="//macros/macro/properties/physics">
              <physics mass="28.75">
                  <inertia pitch="5.723" yaw="5.723" roll="4.578" />
                  <drag forward="5.1" reverse="21.773" horizontal="13.85" vertical="13.85" pitch="9.897" yaw="9.897" roll="9.897" />
                  <accfactors forward="1.2" />
              </physics>	  
	</replace>	
</diff>
Die Rente ist sicher, von der Höhe hat leider keiner was gesagt.
Folker
Posts: 124
Joined: Fri, 31. Jul 20, 21:56
x4

Re: HELP : Weapon sound

Post by Folker »

ChristianErding wrote: Fri, 23. May 25, 12:04 <replace sel="//macros">
<macros>
<macro name="bullet_gen_m_plasma_01_mk1_macro" class="bullet">

I think the "macros" in line 2 is wrong. I have general doubts that the syntax is correct.
Thats what I use:

Code: Select all

<diff>
 	<replace sel="//macros/macro/properties/physics">
              <physics mass="28.75">
                  <inertia pitch="5.723" yaw="5.723" roll="4.578" />
                  <drag forward="5.1" reverse="21.773" horizontal="13.85" vertical="13.85" pitch="9.897" yaw="9.897" roll="9.897" />
                  <accfactors forward="1.2" />
              </physics>	  
	</replace>	
</diff>

Ok, I tested what you told me before, I think the problem comes from the effect, but I don't know how to edit it. I'm going to take a break from modding, maybe then I'll have a new thought, different from now.

As for your problem, I don't know. I haven't seen this line code on a bullet, but I have seen it in a ship macro. In any case, if you're in any doubt about how to write a sentence to edit things on a macro, you need to write a replacement macro, after you've copied and pasted the set of things and edited it. I'll explain with the help of this example:

This works for many things. Here's an example of an M shotgun:

Egosoft write that :

Code: Select all

<macros>
  <macro name="bullet_gen_m_shotgun_01_mk2_macro" class="bullet">
    <component ref="bullet_gen_m_shotgun_01_mk2" />
    <properties>
      <bullet speed="4838" lifetime="0.762" amount="5" barrelamount="1" icon="weapon_shotgun_mk2" timediff="0.004" angle="1" maxhits="3" ricochet="0.5" restitution="1" scale="0" attach="0" />
      <heat value="234" />
      <reload rate="1" />
      <damage value="146" repair="0" />
      <effects>
        <impact ref="impact_gen_m_shotgun_01_mk1" inside="impact_gen_m_shotgun_01_mk1_inside" />
        <bigobjectimpact ref="impact_gen_m_shotgun_01_mk1_bigobject" inside="impact_gen_m_shotgun_01_mk1_bigobject_inside" />
        <launch ref="muzzle_gen_m_shotgun_01_mk1" />
      </effects>
      <weapon system="weapon_standard" />
    </properties>
  </macro>
</macros>
And you should to edit, copy paste this between there lines

Code: Select all

<diff>
  <replace sel="//macros">

Code: Select all

</replace>
</diff>
The final result is :

Code: Select all

<diff>
  <replace sel="//macros">
<macros>
  <macro name="bullet_gen_m_shotgun_01_mk2_macro" class="bullet">
    <component ref="bullet_gen_m_shotgun_01_mk2" />
    <properties>
      <bullet speed="4838" lifetime="0.762" amount="5" barrelamount="1" icon="weapon_shotgun_mk2" timediff="0.004" angle="1" maxhits="3" ricochet="0.5" restitution="1" scale="0" attach="0" />
      <heat value="234" />
      <reload rate="1" />
      <damage value="146" repair="0" />
      <effects>
        <impact ref="impact_gen_m_shotgun_01_mk1" inside="impact_gen_m_shotgun_01_mk1_inside" />
        <bigobjectimpact ref="impact_gen_m_shotgun_01_mk1_bigobject" inside="impact_gen_m_shotgun_01_mk1_bigobject_inside" />
        <launch ref="muzzle_gen_m_shotgun_01_mk1" />
      </effects>
      <weapon system="weapon_standard" />
    </properties>
  </macro>
</macros>
  </replace>
</diff>
The disadvantage of this method is that the folder/your mod will be larger, and less optimized. The advantage is ergonomics and editing.
Personally, I frequently edit more than 75% of all parameters, so I use this method. And my advice is to use it, if you want to be sure that the second line is right.

Return to “X4: Foundations - Scripts and Modding”