[1.1.33] lua: unexpected projectile target miss at slow speeds

We are aware of them, but they have low priority. We have more important things to do. They go here in order not to take space in the main bug thread list.
Post Reply
KeepResearchinSpoons
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Tue Dec 01, 2020 6:57 pm
Contact:

[1.1.33] lua: unexpected projectile target miss at slow speeds

Post by KeepResearchinSpoons »

TL;DR: with surf.create_entity(projectile, target = playerpos.y +2, speed=0.1) cannon ball kills you instead :> (not exactly, just flies higher than the target).

expect: hit that pole
what you get: you get killed.
/c

Code: Select all

local ce = game.surfaces[1].create_entity; local ppos = game.player.position; local t = ce({name = "small-electric-pole", position = {x= ppos.x + 2, y = ppos.y + 2}});ce({name = "cannon-projectile", position = {x= ppos.x + 64, y = ppos.y}, target = t, speed = 0.12, max_range = 3200})
Can I even see it hit the pole? Set speed to 0.15 or higher, way waster than I want this one but should work for offset 2,2
Nota Bene: the offset it flies at behaves strangely to me so no luck with a *goalpost shift* function so far neither.

What works? The bullet. It's charming.
What does not? The targeting via set target at slow speeds.
May possibly be related to how spitters target the fast train in parallel, let's hope it is not...

Why do I want this? A bullet hell with a slow-mo mode awaits a new random encounter. The best idea rn is to set both game speed and player speed higher, looksbadman.

Best regards,
and good luck!

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5148
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [1.1.33] lua: unexpected projectile target miss at slow speeds

Post by Klonan »

This is some fixed point number rounding,
Basically the speed and angle is being rounded to the nearest map position (1/256 of a tile) every time it moves,
So at certain speeds and angles, it will not correctly follow the straight line to the target

KeepResearchinSpoons
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Tue Dec 01, 2020 6:57 pm
Contact:

Re: [1.1.33] lua: unexpected projectile target miss at slow speeds

Post by KeepResearchinSpoons »

I see...
If it were possible,
Would really like to see something like Bresenham's (wiki link) algorithm applied here for projectile position logic.

We set the source and the goal for the projectile (to even be able to spawn it) in the first place.
But then it reduces it to per-tick deltas...
And applies those deltas in pos recalc?
Would be great if the projectile stored the start/finish and applied the deduced (x,y) in recalc instead of (prev_x+delta_x, prev_y+delta_y)

As far as I can see though, even the bresenham's way introduces some additional complexity.
Even more, it is no longer `projectiles_array.add_deltas` but rather `projectiles_array.recalc_new_positions`
which should take more time fmpov. Not sure how many but a party pooper here is totally possible.
And it would certainly take at least _some_ time to ensure the change works as intended for all cases...
And even more it would take _some_ time to simply apply all the changes to the code in all places the simple logic may have been used for collisions checks and so on...

And all points together I can really see It may be not worth the bother.
No one uses slowish instakill balls - projectiles in mods, afaik.
And for the scenario issue It would probably be possible to just "emulate the slow speed bullet trajectory and re-spawn it on time" as well, since I don't need them too many.


IF it IS possible to augment projectiles with this logic,
bearing in mind that cars shoud not break and spitters would not target their spits in parallels to the moving trains they which they spit at :kappa: and all the other places around as well
then it would be great.

IF it is NOT,
then by best effort let's name this case as an out-of scope and drop it.
Not a pressing issue really anyways to dig into more troubles for it to work nicely in the corner case.

Post Reply

Return to “Minor issues”