True Nukes


Adds realistic nuclear blasts, and more nuclear options, including various scales of atomic artillery shell, as well as atomic cannon shells. Also adds thermobaric weapons (these are like fuel air bombs), which act as early game nukes. Simulates the blast wave, thermal impact, crater and fireball of nuclear weapons.

Content
5 months ago
1.0 - 1.1
38.7K
Combat

g thermal blast UPS sink? :D

5 months ago

Hi my save seems to have a thermal blast stuck as far as i can see, its very modded (se+) but when I profile the save about 50% of the time is spent in atomic_thermal_blast_internal, which as far as i know can only be called when a thermal blast exists. However the last nuke i used was literally ages ago (i think 10+ real time hours, max i used atm is 1kt so it shouldn't give earth shattering blasts either way). Is it possible to add a command to clear all thermal blasts? or an interface? So i can see if it helps or persists? im sitting at ~50ups now in the mean time :/

5 months ago
(updated 5 months ago)

That's an interesting problem, I'd love to see if there's a cause for this type of thing.
Anyway, there is no simple way of running a command to clear the array, as mods are sandboxed, making the data difficult/impossible to access from outside.
I've added a bypass in the latest version (0.3.28), which should help.
Try the command:

/c remote.call("True-Nukes Scripts", "getGlobal").thermalBlasts = {}

5 months ago

Okay thanks, because you gave me full access to your global I was able to print all the blasts and boy there are MANY still active, most have a position in x minus thousands and y in positive thousands, i don't think they are supposed to travel that far? Btw its actually easy to add commands in your mod yourself to view/clear them, if you want i can send you the code?

5 months ago

I got 488 thermal blasts active atm :D
Are you on discord, maybe i can send you the data so you can check where it goes wrong? I would help but i don't know how your code works :)

5 months ago

Here is a few of them:
{
fireball_r = 80,
force = "neutral",
initialDamage = 5000,
position = {
x = -338.7890625,
y = 6718.33203125
},
surface_index = 7,
thermal_max_r = 1600,
x = -1938.7890625,
y = 8318.33203125
},
{
fireball_r = 80,
force = "neutral",
initialDamage = 5000,
position = {
x = -2004.09375,
y = 6812.765625
},
surface_index = 7,
thermal_max_r = 1600,
x = -3604.09375,
y = 8412.765625
},
{
fireball_r = 80,
force = "neutral",
initialDamage = 5000,
position = {
x = -732.2265625,
y = 6597.73828125
},
surface_index = 7,
thermal_max_r = 1600,
x = -2332.2265625,
y = 8197.73828125
}
they seem to be stuck and don't move, maybe the end detection has a slight mistake causing them to not actually get removed from the list? maybe a == instad of >= or smth ;)

5 months ago

Btw, the getglobal function only returns a read-only copy of your global. If you want to give people the ability to clean the blasts you also need to add a setglobal that overwrites your global with a given value (maybe after validation)
that said a fix would of course be greatly appreciated :D

5 months ago
(updated 5 months ago)

i just added:

local function setGlobal(newglobal)
global = newglobal;
end

and it seems to work fine ;) no more lag issues in my save
but also you can easily add these commands yourself, so for instance:

commands.add_command("truenukes_clear_thermalblasts", "clears true nuke blasts",
function(Data)
local printer = game
if (Data.player_index) then
printer = game.get_player(Data.player_index)
end
printer.print("Clearing all thermal blasts!")
global.thermalBlasts = {}
end)
commands.add_command("truenukes_print_thermalblasts", "prints true nuke blasts",
function(Data)
local printer = game
if (Data.player_index) then
printer = game.get_player(Data.player_index)
end
local thermalBlasts = global.thermalBlasts
printer.print("There are " .. #thermalBlasts .. " active, details in log")
log(serpent.block(thermalBlasts))
end)

5 months ago
(updated 5 months ago)

OK, I might have a fix, can you try (on the save with the lag issue):
Line 183 of scripts/thermal-system.lua, changed to:
if((math.abs(pos.x - (therm.position.x-therm.thermal_max_r))<1 and math.abs(pos.y - (therm.position.y+therm.thermal_max_r))<1) or (pos.x == -1 and pos.y == -1)) then

This should fix any floating point errors, and should fix an issue with variables ending on a different value...

5 months ago

Indeed that fixed it, i loaded the save with the 488 still active and immediately went to 0 :)
Thanks!

Btw let me know if you need help with those commands! ;)
if you want you could also add the crater thing as an actual command so people can run it without losing achievements

5 months ago

Hi, me again ;)

Another thing i have noticed now is that SE capsules can only fire compact 15kt+ nukes? does that have a reason? all the others use the normal variant?

5 months ago

Also 10Mt and up are not available :/ i would love to wipe planets with fusion nukes >:D

5 months ago

The non-compact 15kt nukes are intended to be really big, such that they can't be properly fitted into the capsules, forcing you to use the worse compact ones - similar to how the artillery shells can only fire the very-compact ones.
5Mt really should be enough, I would have thought...

5 months ago

The performance save should be in the new version.

5 months ago

Ah i see, thanks!
Well i bomb entire 8km radius planets before settling on them, so 10MT can do that in one go... and the less nukes i use to remove the nests the more efficient that goes since i have less "holes" in the map ;-)

5 months ago

Ah, that's fair. I'll consider it - tbh I hadn't considered the 10MT nukes worth it, but I guess SE changes that

5 months ago

I mean if its intended i have no issue with it, now i just go to the planet with a test site and do it like that ;)
Btw, do you think it might be possible to include the setglobal interface as well? Just in case i want to mess around a bit or do some testing to see if the issue really is gone now? ;) (since tbh i think it still has an issue with the big nukes, but i can't tell what) To be sure i want to reset the global to make sure i start from scratch so its not a lingering issue from before :)

5 months ago

Big nukes have eccentric performance impacts, notably including some (hopefully small) impact when a new chunk is loaded, so it's not unexpected that they're weird.
You're fine to add setGlobal yourself, but I don't want to make that an official route to fixing problems - I'd rather have bugs turn up here, so while I'm happy to add diagnostic tools, if I expose setGlobal, I can just see people using it to patch problems themselves, when I'd rather write a proper fix into the mod.

5 months ago

I see, totally understandable. I will have to see if i have time for testing it like this, because i can't test while playing in MP then. Since i can't send the modified control in MP. But it doesn't matter, the largest issue has been fixed now. I think the additional issue has something to do with global.optimisedNukes never being cleaned so every chunk generation will iterate all nukes? Is that possible?

Btw speaking of performance impacts, you could avoid a lot of lag if you would process the nuked chunks in succession rather than all at once. I noticed a lot of processing happens in the same tick as the nuke went off, you could spread it over multiple ticks without impacting fps or result. Its just a suggestion :)

5 months ago

So, unfortunately in most cases, I can't easily clear global.optimisedNukes, as I can only remove an element when every chunk affected by that nuke is loaded, which is hard to detect. I'll look into it, but in most cases I expect that very few very large nukes are detonated, so it shouldn't be too much of an issue - though SE makes it worse.

I already do a lot of processing on subsequent ticks (notably all the damage processing is spread out), but the crater generation is done in one tick, which I may improve in future - though this will result in more potential memory/performance leaks.

I'll look at doing those in future, but neither is a priority.

5 months ago

I see, yea SE really makes mod compatibility and priorities entirely different, might i still request an interface then to either set global or clear/reset global? So at least i can clear it every once in a while? Even if that means that some nukes will not have fully exploded. You don't need to put it in your mod description so most people will not find it and will still report bugs. But i am struggling to keep my multiplayer save going sadly with everyone clearing planets with nukes. And TN is still the top tick time user. :c
In the future you could maybe add a command like clearing craters for the optimized nukes that just request chunk generation in all the nuke affected chunks and then deletes them after x time? Or detect it by saving a list of chunks still needing generation and then when they are remove them, and when the list is empty remove the nuke?

5 months ago

OK, I'm adding setGlobal, but before you clear anything, would you mind giving me a summary of how big each global array is?
I'd love to try and fix these issues for good...

5 months ago

I'd be really interested if the optimized nukes were causing the lag, as they do absolutely minimal checks on chunk loads. I'd much more expect that it was the crater system, which really can use a lot of performance.
Before you do clear the optimized nukes, can you try running the "clearAllCraters", and see if that helps?

5 months ago

Yesterday, i did some more testing, i disabled the craters since those indeed cause lag, to see if anything else was as well. I threw 5 5Mt nukes on a planet and chunk loading tanked my fps/ups to 14 while staying at 60 normally. It was very odd... I'll try to profile some more or maybe dump the data when i have more time. :)

5 months ago

(Sorry for being slow - I didn't notice your response till just now).
Did chunk loading tank on other planets as well? Or just the one which was nuked?

New response