How to add charging sound to Laser Turrets

Place to get help with not working mods / modding interface.
kaldskryke
Inserter
Inserter
Posts: 27
Joined: Mon Nov 17, 2014 3:49 am
Contact:

How to add charging sound to Laser Turrets

Post by kaldskryke »

I managed to find some sound files from the original Command & Conquer, from way back in my childhood. One of the iconic buildings in that game was the Obelisk of Light, a giant laser turret with a very memorable sound. I thought it would be fun to change Factorio's laser turrets to sound the same.

It was pretty easy to change the sound element of the laser turret's attack_parameters, and it works well. I've also changed the attack cooldown to be much slower, which better reflects how the Obelisk behaved. So far so good.

The Obelisk also had a distinct sound while it recharged, and I'd also like to implement that in Factorio. I remembered that the Basic Accumulator has a charging sound and looked in the base prototype to see how it was defined. It looks like this:

Code: Select all

working_sound =
    {
      sound =
      {
        filename = "__base__/sound/accumulator-working.ogg",
        volume = 1
      },
      idle_sound = {
        filename = "__base__/sound/accumulator-idle.ogg",
        volume = 0.4
      },
      max_sounds_per_type = 5
    }
I had hoped that if I simply added a working_sound element to the laser turret, then I could add the Obelisk Charging file either as the main sound or the idle_sound. Sadly this does not appear to do anything.

Is it possible to do this?

EDIT: I decided to add a launch sound to the rocket launcher, but it isn't working either. Can anyone see what I'm doing wrong?

Code: Select all

table.insert(data.raw["gun"]["rocket-launcher"].attack_parameters, {sound = 
{
   filename = "__rocketsounds__/sound/rocket 1.wav",
   volume = 0.8
}
})
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: How to add charging sound to Laser Turrets

Post by Choumiko »

kaldskryke wrote:EDIT: I decided to add a launch sound to the rocket launcher, but it isn't working either. Can anyone see what I'm doing wrong?
An untested guess:
You need to create a entity like explosion-gunshot or huge-explosion (see prototypes/entity/demo-entities.lua) with your sound. Then change data.raw[""ammo"]["rocket"].ammo_type.action.action_delivery.source_effects.entity_name to whatever your entity is (prototypes/items/ammo.lua)
Here's how i guess a weapon is fired: press attackbutton -> reduce ammo -> do what the ammo says in action_delivery.

Not sure if that will work, but i'm fairly certain that changing the rocket-launcher itself will get you nowhere

As for the Obelisk: Absolutely no idea, sorry
Post Reply

Return to “Modding help”