Helicopters

by kumpu

Adds a fully animated attack helicopter to the game. Ideal for getting from A to B quickly, exploring the map, building islands and nuking biters from the sky. Now 84% less buggier!

Content
4 years ago
0.15 - 0.17
292
Transportation

g UPS impact

5 years ago
(updated 5 years ago)

Hello,
First of all, thanks for this mod! It really makes the (mid) end game with biters + expansion enjoyable!

When doing a quick check of my UPS(detailed usage), I have noticed this mod is taking around 120ms update time.
It is indeed not much, by why is not zero(or almost zero)?

PS: that was with the heli landed somewhere on the map; I do have a remote control on me all the time: is it pathfinding/checking some stuff even when landed?
PS2: for reference: Bottleneck is around 400ms, and LTN 30ms. Aircraft is installed but not shown in stats.

5 years ago
(updated 5 years ago)

Does that mean 120ms per update/frame? If so that would be huuge and something is wrong.
Anyway, the reason it's not taking zero time is because... this mod is one giant workaround. The modding api is very very limiting so what you're seeing is several car entities glued together with scripts. I need a main entity that you can steer, a collision entity (I need to disable collision when youre flying but there is no way to do that except to remove the entity), one for the rotor because it's the only way to animate it, two shadow entities, and many more.
The result of this workaround is that now I have to fake vanilla behaviour. For example you could drive a tank into a landed heli, but only the collision entity is taking damage. So I have to check for damage on that every tick and transfer it to the main entity.
Or when you press enter to go into the heli, there is no way to predict in which of the several car entities you're ending up in so I have to check all entities and move players.

All that being said there is certainly potential for optimization. For example I teleport every entity to their correct position on every tick, even when landed. iirc I did that because you could land on the edge of a belt and it would tear the heli appart, the rotor would get dragged away or something. But in a factorio update some while ago they added a feature to make cars immune to belts so it's not really needed anymore.
But yeah no one complained about performance so far so I didn't bother.

5 years ago

Thanks for the explanations.

My bad about the timings: I meant : 0.120ms for this mod, 0.400 for Bottleneck etc
All things considered, it is definitely "not much". I was just curious.

If I may ask: how is this mod different(coding + API requirements) from Aircraft? or any other vehicle mod?
Or more precisely: why can't it be just an "helicopter texture" + animations for main rotor + tail rotor?

5 years ago

Ah 0.120ms sounds a lot better :)
Last time I checked aircraft was literally just a reskinned car with no collision. Easy to do but for me, the resulting lack of immersion is unacceptable. You can walk through it when it's landed, there is no "height", no takeoff, no crashing, etc.
The reason why these things are so hard to do is because there is no api for them, you have to "emulate" them with scripts. When Wube created the api all they gave us modders was an interface for vanilla features.
For example there are two car entities in vanilla, the car and the tank. They only need to have different textures, fuel consumptions, acceleration, collider boxes, etc, and hence these are the only things you can change as a modder. Adding things like (mod controlled) animation capability just wasn't needed for them so it's not possible. The workaround is to have a second car entity, script glue it to the first, and change the car orientation with scripts to specify the frame being displayed. So the rotor is actually a car. But that's not all, if you do just that the animation won't be smooth at all, because the orientation angle-frame relationship is not linear. It looks more like sin(x)+x, not sure why but you have to compensate for that. So all that just for a spinning rotor and that's just one of the tricks you need to find out. All in all making this mod was a very frustrating experience, but it's satisfying to see things working well at the end. I hope wube will add some flexibility when they reach 1.0 and they have more time for this sort of thing. From time to time, if you're lucky, they will even implement modding feature requests (like the belt immunity I mentioned).

5 years ago

All right then. Thanks for taking the time to explain.
You are right about Aircraft: it does feel "fake".
[I still use them use to clear new lands because with the grids they are so massively overpowered]

New response