Make Artillery Great Again


Fire power, more more Fire Power ! Add some options for Artillery Shell

Content
a month ago
1.1 - 2.0
5.59K
Combat

i Add area of effect as a technology

4 years ago

Artillery do enough damage for me. The problem is the AOE is too small. However just setting that to a higher number feels too much like cheating. How about a tech for this? Could be an infinity tech (although that could get ridiculous) or even just 5-6 levels like the bounded techs.

4 years ago

That's exactly what I want to do, but officially Mod wiki or even googling, I couldn't find how to increase the AOE, so I'm finding how can do, I'll do my best for find it, Thanks for your comment! and I'll finally add it some day!

And I'm sorry to late for reply :)

4 years ago
(updated 4 years ago)

I have had similar issues, and this kind of thing in Factorio is truly impossible to do well, however it can be done if you are prepared to use more scripting, the basic systems built off of the impact of a projectile are really not that great, however the lua scripting can be very flexible.
I would guess the best way of doing this would be to set the upgrade to change something with no in-game effect, (just make something up I guess), and then read that using a script triggered by the impact of the projectile.
To get this to work, you need to add (I'm using "Artillery-Impact" for the identifier, but any string will do)
{
type = "script",
effect_id = "Artillery-Impact"
},
to the target effects, and then in the control.lua file add a function (e.g. called artillery_impact) and attach it to the trigger:

local function artillery_impact(event)
--add code to do all the things you need...
end

script.on_event(defines.events.on_script_trigger_effect, function(event)
if(event.effect_id=="Artillery-Impact") then
artillery_impact(event);
end
end)

You can then read the level of upgrade in the script, and do the appropriate action.
If you have a limited number of upgrades (which I would advise, as otherwise the game will not get kind of weird with 1km radius blasts, or similar), then simply use the script to spawn a new shell, targeted at the location where the old shell hit, with the new shell set up to have the blast range you desire (e.g. if you had only 4 levels of upgrade, you could just use an if statement on the research), and spawn the shell you need:

game.surfaces[event.surface_index].create_entity{name="artillery-blast-projectile-4",force = event.source_entity.force,position = event.target_position,target=event.target_position, source=event.source_entity, speed=100,max_range=100}

or something like that (with artillery-blast-projectile-4 replaced with the new entity name).
This would be pretty quick, as it would just create a new projectile, which would immediately hit the ground, and then explode. The explosion would be handled by the game's internal logic, which is good as the lua is much slower. You could also change the type of explosion spawned, so an upgraded shell gives a bigger boom.

If you wanted a really flexible damage handling system, you could hand code it in lua, but that is really hard to do (trust me, I've done this before, you don't want to if you can avoid it), and is much lower performance, and is harder to balance, and can cause all sorts of unexpected crashed (killing a spidertron kills it's legs, which are separate entities, so trying to kill them as well causes a crash, etc.

If you want a compromise, then you could use the script to launch several projectiles at different ranges, all quite close, and launch more, further, with more upgrades.

Beware, all of these result in the in game description of the ammunition not matching the actual effects, so it might say it does no damage, as there is no direct damage action being taken in the target-effects. You can't fix this, it just happens.

The code I have given you is not solid, it probably won't work, but it is where I would start, if you want more guidance on these things then the Factorio lua docs:
https://lua-api.factorio.com/latest/
Particularly the page on surfaces (needed to spawn entities):
https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.create_entity
And the page on events:
https://lua-api.factorio.com/latest/events.html#on_script_trigger_effect

And the Factorio wiki Prototypes page:
https://wiki.factorio.com/Prototype_definitions
and the page on TriggerEffects:
https://wiki.factorio.com/Types/TriggerEffect

4 years ago

Another thought is that you might (I sort of doubt it, but still) be able to make the shell fire a scatter effect, then change the number of scattered shells, using the upgrade, with an area trigger item
https://wiki.factorio.com/Types/AreaTriggerItem
and then upgrade the repeat_count, but I still kind of doubt that that would work, and it would have the problem of causing a scattered explosion, more like a cluster grenade than an artillery shell.

The only other thing I can think of is an area mode set of things like cannon shells, which hit anything in their path, and the more of them you spawn, the further the effective range is, due to the shells destroying their obstacles, but that isn't very explosion-like either.

3 years ago

I was wondering that exact thing !
So that's why when mods add ammunition research, there are power upgrades, range upgrades and speed upgrades and whatelse, but never an area of effect upgrade... When that seems to be the more obvious one to make ! ^^ Well I Hope it will be possible one day, because that's kindof missing for now indeed.