Page 1 of 1

can I make a technology for the AOE of Shell?

Posted: Fri Nov 06, 2020 6:27 pm
by seolisky
I try to make a Mod for Artillery shell, And i did it for damage, thanks to ammo-damage modifier. but I couldn't find Area of effect modifier or even solution of increasing things... can't I get solution for it?

now I can modify the A.O.E. for startup option, but I still don't know how to increase it by technology.. please help me :)

Re: can I make a technology for the AOE of Shell?

Posted: Fri Nov 06, 2020 11:56 pm
by NotRexButCaesar
you could spawn multiple small shells and move them outward/add more for a larger radius.

Re: can I make a technology for the AOE of Shell?

Posted: Sat Nov 07, 2020 12:23 am
by Deadlock989
seolisky wrote: Fri Nov 06, 2020 6:27 pm I try to make a Mod for Artillery shell, And i did it for damage, thanks to ammo-damage modifier. but I couldn't find Area of effect modifier or even solution of increasing things... can't I get solution for it?

now I can modify the A.O.E. for startup option, but I still don't know how to increase it by technology.. please help me :)
If you are asking if there is a technology effect that increases the size of projectile AOE effects, the answer is no, there isn't. The full list of built-in effects is here. Projectile parameters aren't accessible at runtime so there is no way to change them in the control stage.

The only thing I can think of is giving the projectile a large AOE and then process the things struck by it in a scripted ScriptTriggerEffectItem and handling it in on_script_trigger_effect - e.g. ignoring things that are too far away from the source_position. You could then have techs which, if researched, effectively increase the radius in which something actually happens to the targets. But that might get expensive and to be honest I wouldn't touch it with a bargepole.

Re: can I make a technology for the AOE of Shell?

Posted: Sat Nov 07, 2020 12:45 am
by seolisky
Deadlock989 wrote: Sat Nov 07, 2020 12:23 am
If you are asking if there is a technology effect that increases the size of projectile AOE effects, the answer is no, there isn't. The full list of built-in effects is here. Projectile parameters aren't accessible at runtime so there is no way to change them in the control stage.

The only thing I can think of is giving the projectile a large AOE and then process the things struck by it in a scripted ScriptTriggerEffectItem and handling it in on_script_trigger_effect - e.g. ignoring things that are too far away from the source_position. You could then have techs which, if researched, effectively increase the radius in which something actually happens to the targets. But that might get expensive and to be honest I wouldn't touch it with a bargepole.
Thanks to your reply, and It sounds very sad...

Re: can I make a technology for the AOE of Shell?

Posted: Sat Nov 07, 2020 2:25 am
by Deadlock989
Actually I just ran a couple of tests and it's not too painful.

scriptedeffect.jpg
scriptedeffect.jpg (748.28 KiB) Viewed 1119 times

This replaces the entire artillery shell effect with this action:

Code: Select all

data.raw["artillery-projectile"]["artillery-projectile"].action= {
	action_delivery = {
		target_effects = {
			{
				type = "script",
				effect_id = "artillery-test",
			},
		},
		type = "instant"
	},
	type = "direct",
}
And then for your event:

Code: Select all

script.on_event(defines.events.on_script_trigger_effect, function(event)
	if event.effect_id == "artillery-test" then
		local surface = game.surfaces[event.surface_index]
		for _,entity in pairs(surface.find_entities_filtered{force="enemy", radius = 10, position = event.target_position}) do
                        -- whatever
		end
	end
end)
So it's not an AOE effect at all but just strikes a location. This shows up in the on_script_trigger_effect as a target position. (If instead you ran the script on every entity in an area effect, you don't necessarily know where the shell landed.) Searching an area radius 10 (you would modify this depending on the technology level esearched) around where the shell lands and filtering only for enemy force, with shells being fired about once every 2 seconds, I was seeing something like an additional 0.003s load on UPS. You could maybe reduce that with better filtering and of course it depends on what you're doing with all the entities, I had a nasty full distance function with math.sqrt which you could easily avoid (just compare squared distances).

I don't know how this would all stack up in a big endgame base with multiple artilleries firing constantly.

Re: can I make a technology for the AOE of Shell?

Posted: Sat Nov 07, 2020 3:07 am
by seolisky
Deadlock989 wrote: Sat Nov 07, 2020 2:25 am
So it's not an AOE effect at all but just strikes a location ...
...
I don't know how this would all stack up in a big endgame base with multiple artilleries firing constantly.
Oh! I'm soooooooooo thanks for your code! I'll try it base on your code, and if i find something great to apply then I'll feed back that code! thank you bery much!