Is there a sort of dummy all purpose entity type available?

Place to get help with not working mods / modding interface.
rtssmkn
Inserter
Inserter
Posts: 20
Joined: Sun May 22, 2016 10:36 am
Contact:

Is there a sort of dummy all purpose entity type available?

Post by rtssmkn »

I am currently working on making the Helicopters mod more efficient. Is there a sort of dummy all purpose entity type available that I can use to simulate rotor and both body and rotor shadow movement without me having to make these additional entities also of type car? And I am quite reluctant to mis-re-use any other entity types for that purpose.

And, if there is no such general purpose entity type, would it be possible to introduce such an entity type? E.g. a custom-animated type that would support animations and smoke and so on.
321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Is there a sort of dummy all purpose entity type available?

Post by 321freddy »

It looks like you just need an anmated entity without any collision box so I can suggest you use "smoke".
It can have an animation, multiple sprite layers (for shadow), customizable render layer and is mostly for visuals only.
Although you would probably need to teleport the rotor to the helicopter base every tick which would impact performance.

But anyway here is an example:

Code: Select all

data:extend{
	{
		type = "smoke",
		name = "helicopter-rotor",
		flags = {"not-repairable", "not-blueprintable", "not-deconstructable", "placeable-off-grid", "not-on-map"},
		duration = 99999999,
		spread_duration = 1,
		start_scale = 1,
		end_scale = 1,
		color = { r = 1, g = 1, b = 1, a = 1 },
		cyclic = true,
		affected_by_wind = false,
		show_when_smoke_off = true,
		movement_slow_down_factor = 0,
		vertical_speed_slowdown = 0,
		render_layer = "air-object",
		animation = {
			layers = {
				{
					filename = "__my-mod__/graphics/rotor.png",
					width = 64,
					height = 64,
					scale = 0.5,
					frame_count = 1
				},
				{
					filename = "__my-mod__/graphics/rotor-shadow.png",
					width = 64,
					height = 64,
					draw_as_shadow = true,
					shift = {2,0.5},
					scale = 0.5,
					frame_count = 1
				}
			}
		}
	}
}
rtssmkn
Inserter
Inserter
Posts: 20
Joined: Sun May 22, 2016 10:36 am
Contact:

Re: Is there a sort of dummy all purpose entity type available?

Post by rtssmkn »

Thanks, I will try this. I have already reduced the number of entities to only 4 during the landing and starting phase.
During flight it will be reduced to only 3, but I reckon that I can reduce it to just two. Before that it was 7.
rtssmkn
Inserter
Inserter
Posts: 20
Joined: Sun May 22, 2016 10:36 am
Contact:

Re: Is there a sort of dummy all purpose entity type available?

Post by rtssmkn »

@321freddy Sadly, the smoke entity type has some issues that prevents me from reusing it. First, the smoke entity will be
destroyed after the specified duration. While these entities could be recreated, its animation cannot be controlled in the
way that the mod is implemented, so the rotors will not be moving at all.

Too bad, that there is no general purpose entity...
321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Is there a sort of dummy all purpose entity type available?

Post by 321freddy »

rtssmkn wrote:First, the smoke entity will be destroyed after the specified duration.
This is why I set the duration to be very large. 99999999 ticks is almost 20 days of pure game time, so the smoke will essentially last forever.
Set it higher if you want. I think the maxmimum is 2^31 (414 days).
rtssmkn wrote: its animation cannot be controlled in the way that the mod is implemented, so the rotors will not be moving at all.
How do you implement the animation? Smoke has a static animation which never ends (with cyclic = true).
So if you define a proper spritesheet for the animation it will work. The spritesheet contains every frame of the animation in order. You have to set the frame_count paramter to the correct value to ensure that the animation will play properly.
If you want to stop the animation replace the smoke entity with a second new smoke entity without any animation (use a seperate prototype definition).

If by animation you mean rotate the rotors direction every tick there is no other entitiy type than "car" that supports this behaviour. But I don't recommend doing this because the performance will be very bad, especially if you have multiple helicopters.
Once your helicopter is in the air you just need a static rotation animation for your rotor for which smoke would the perfect choice because you don't need to do all the rotation every tick and and it supports render layers so it can always be ontop of other entities.
Post Reply

Return to “Modding help”