Artillery sound enhancer

by yohannc

Add multiple sounds for artillery depending on distance (based on vanilla).

Content
2 years ago
1.1
4.41K
Combat

b Error together with True Nukes mod

1 year, 7 months ago

Hello, I got this error after updating to the latest true nukes mod

https://imgur.com/a/67QOFdy

1 year, 7 months ago
(updated 1 year, 7 months ago)

The issue is because I'm using final_action instead of action to put my effects into.
To fix this, I'd guess the replacement code for those lines would be:

    if(projectile_value.action ==nil) then
        projectile_value.action = {action_delivery = {target_effects = {}}}
        local target_effects = projectile_value.action.action_delivery.target_effects

        if projectile_index:find("atomic") then
            table.insert(target_effects, effect_trigger_nuke_mod)
        else
            table.insert(target_effects, effect_trigger_explosion_mod)
        end
    elseif projectile_value.action.action_delivery ~= nil then --if one delivery, add an effect

Although I haven't tested that.

1 year, 7 months ago

where exactly do I put that code?

the whole section looks like this

for projectile_index,projectile_value in pairs(data.raw["artillery-projectile"]) do
if projectile_index == "artillery-projectile" then
local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
table.insert(target_effects, effect_trigger_explosion)
else
if projectile_value.action.action_delivery ~= nil then --if one delivery, add an effect
local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
else --if multiple delivery, add an effect on the first one
local act;
_,act = next(projectile_value.action)
local target_effects = act.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
end
end
end

1 year, 7 months ago

for projectile_index,projectile_value in pairs(data.raw["artillery-projectile"]) do
if projectile_index == "artillery-projectile" then
local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
table.insert(target_effects, effect_trigger_explosion)
else
if(projectile_value.action ==nil) then
projectile_value.action = {action_delivery = {target_effects = {}}}
local target_effects = projectile_value.action.action_delivery.target_effects

    if projectile_index:find("atomic") then
        table.insert(target_effects, effect_trigger_nuke_mod)
    else
        table.insert(target_effects, effect_trigger_explosion_mod)
    end
elseif projectile_value.action.action_delivery ~= nil then --if one delivery, add an effect

local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
else --if multiple delivery, add an effect on the first one
local act;
_,act = next(projectile_value.action)
local target_effects = act.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
end
end
end

1 year, 7 months ago

Is my guess, although I can't say precisely

1 year, 7 months ago

thank you btw for helping out!

So I tried that and am getting this error now
https://imgur.com/NTdFXZO

1 year, 7 months ago

Yes, of course - I didn't actually check whether this was working. Try this:

1 year, 7 months ago

for projectile_index,projectile_value in pairs(data.raw["artillery-projectile"]) do
if projectile_index == "artillery-projectile" then
local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
table.insert(target_effects, effect_trigger_explosion)
else
if(projectile_value.action ==nil) then
projectile_value.action = {type = "direct", action_delivery = {type = "instant", target_effects = {}}}
local target_effects = projectile_value.action.action_delivery.target_effects

if projectile_index:find("atomic") then
    table.insert(target_effects, effect_trigger_nuke_mod)
else
    table.insert(target_effects, effect_trigger_explosion_mod)
end

elseif projectile_value.action.action_delivery ~= nil then --if one delivery, add an effect

local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
else --if multiple delivery, add an effect on the first one
local act;
_,act = next(projectile_value.action)
local target_effects = act.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
end
end
end

1 year, 7 months ago

The only difference being:
projectile_value.action = {type = "direct", action_delivery = {type = "instant", target_effects = {}}}

1 year, 7 months ago

That seems to be working now thank you a lot

1 year, 1 month ago

i dont get it

i did paste this: projectile_value.action = {type = "direct", action_delivery = {type = "instant", target_effects = {}}}

where this was: projectile_value.action.action_delivery ~= nil then
but then i get another error. i have no idea how to mod/code can you please help me or update your mod so it does not crash when using it with true nukes.

1 year, 1 month ago

Hi!
Unfortunately, I'm not the mod owner, and don't really want to clone the whole mod and such. The specific thing you want to do is replace the lines 52-78 with the comment I made before. That is replace:

for projectile_index,projectile_value in pairs(data.raw["artillery-projectile"]) do
if projectile_index == "artillery-projectile" then
local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
table.insert(target_effects, effect_trigger_explosion)
else
if projectile_value.action.action_delivery ~= nil then --if one delivery, add an effect
local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
else --if multiple delivery, add an effect on the first one
local act;
_,act = next(projectile_value.action)
local target_effects = act.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
end
end
end

1 year, 1 month ago

With:

1 year, 1 month ago

for projectile_index,projectile_value in pairs(data.raw["artillery-projectile"]) do
if projectile_index == "artillery-projectile" then
local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
table.insert(target_effects, effect_trigger_explosion)
else
if(projectile_value.action ==nil) then
projectile_value.action = {type = "direct", action_delivery = {type = "instant", target_effects = {}}}
local target_effects = projectile_value.action.action_delivery.target_effects

if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end

elseif projectile_value.action.action_delivery ~= nil then --if one delivery, add an effect

local target_effects = projectile_value.action.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
else --if multiple delivery, add an effect on the first one
local act;
_,act = next(projectile_value.action)
local target_effects = act.action_delivery.target_effects
ensure_table_is_list(target_effects)
if projectile_index:find("atomic") then
table.insert(target_effects, effect_trigger_nuke_mod)
else
table.insert(target_effects, effect_trigger_explosion_mod)
end
end
end
end

1 year, 1 month ago

To get to the file in question, unzip the mod and edit the file called "data-final-fixes.lua"

1 year, 1 month ago
(updated 1 year, 1 month ago)

it looks like this now https://imgur.com/a/DBnvCIF is it right like this?

1 year, 1 month ago

Yeah, should be. Try running it now.

1 year, 1 month ago

it works now thank you <3

1 year, 1 month ago

No problem!

2 months ago

Any chance to have this actually updated in the mod?

New response