Page MenuHomeWildfire Games

Stop dodging arrows by spamclicking or patrol: Acceleration
Needs ReviewPublic

Authored by bb on Sep 27 2020, 12:48 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Trac Tickets
#5106
Summary

As requested by wraitii, acceleration as an alternative to D2767 and D2837. Adding accelerations on every move. This fixes dancing much worse than D2837, the gameplay impact is much bigger by the looks of it, since one needs rather low accelerations even remotely stop dancing. Also chasing is beyond broken (can be fixed by a similar trick as D2767 and D2837, by not accelerating on all moves).

Note this can easily be combined with D2913, but not so easily with D2837 (see the code stopping the unit on big turns in this patch)

Test Plan

See the need for low accelerations for stopping dancing. Observer the gameplay impact.

Retest D2837 together with D2913.

Event Timeline

bb created this revision.Sep 27 2020, 12:48 AM

Build failure - The Moirai have given mortals hearts that can endure.

builderr-debug-gcc6.txt
<command-line>:0:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[1]: *** [obj/simulation2_Debug/CCmpFootprint.o] Error 1
make: *** [simulation2] Error 2

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/3251/display/redirect

bb added a subscriber: wraitii.Sep 27 2020, 12:50 AM
bb added inline comments.Sep 27 2020, 12:54 AM
source/simulation2/components/CCmpUnitMotion.cpp
1094–1098

These changes need to happen anyhow, the bug only gets showcased by this patch

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:155:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libnetwork.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libtinygettext.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libtinygettext.a(tinygettext.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblobby.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libglooxwrapper.a(precompiled.o) has no symbols
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:155:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libscriptinterface.a(precompiled.o) has no symbols
../../../source/third_party/fmt/format.cpp:145:7: warning: '_POSIX_C_SOURCE' is not defined, evaluates to 0 [-Wundef]
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || (defined(__ANDROID__) && __ANDROID__)
      ^
../../../source/third_party/fmt/format.cpp:145:37: warning: '_XOPEN_SOURCE' is not defined, evaluates to 0 [-Wundef]
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || (defined(__ANDROID__) && __ANDROID__)
                                    ^
2 warnings generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libengine.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgui.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblowlevel.a(dbghelp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblowlevel.a(file_stats.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblowlevel.a(vfs_path.o) has no symbols
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1599/display/redirect

bb requested review of this revision.Sep 27 2020, 12:58 AM
bb added inline comments.Sep 27 2020, 3:26 PM
source/simulation2/components/CCmpUnitMotion.cpp
355

nuke

415–424

unitMotionFlying needs same update

Also chasing is beyond broken

I actually find it a tad easier to hunt now, since the hunt does not speed away ^^

Even though the I very much like the concept, I don't know whether this works gameplay-wise indeed.

source/simulation2/components/CCmpUnitMotion.cpp
289

Is this (the duplication) on purpose?

bb added a comment.Sep 28 2020, 12:09 PM

Also chasing is beyond broken

I actually find it a tad easier to hunt now, since the hunt does not speed away ^^

Have you tried attacking an infantry unit which is walking away with melee cav?

source/simulation2/components/CCmpUnitMotion.cpp
289

Don't see the duplication m_CurSpeed and m_RealCurSpeed are different values and since the both change the simstate, they both need to be serialized.

bb updated this revision to Diff 13567.Sep 28 2020, 5:16 PM

Fix OOS noticed by Freagarach

Successful build - Chance fights ever on the side of the prudent.

builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1604/display/redirect

Stan added a subscriber: Stan.Sep 28 2020, 6:15 PM

Do we have deceleration as well?

Freagarach added inline comments.Sep 30 2020, 5:33 PM
source/simulation2/components/CCmpUnitMotion.cpp
195
1077
vladislavbelov added inline comments.
source/simulation2/components/CCmpUnitMotion.cpp
196

Having CurSpeed and RealCurSpeed seems misleading to me. Because they both are real speed, but maybe in different time points. I think they should have different names and a more detailed comment.

198

The acceleration breaks path finder more, since the acceleration isn't accounted.

1025

Dividing by 2 seems incorrect to me, since accelerations means how the speed is growing (m/s per second = m/s^2).

bb updated this revision to Diff 13616.Oct 10 2020, 4:52 PM

Comments

Successful build - Chance fights ever on the side of the prudent.

builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1637/display/redirect

bb added inline comments.Oct 10 2020, 5:12 PM
source/simulation2/components/CCmpUnitMotion.cpp
198

Only short range pathfinder collision tests will be less accurate. Else doesn't seem affected.

1025

Ahhaa, can explain some classical mechanics here: I hope you argree that a=d^2/dt^2x(t) (acceleration being the second derivative of the position of the unit). The general solution to this differential equation is x(t)=1/2at^2+v_0t+x_0 (where v_0 and x_0 are the initial position and velocity). Assuming x_0=0 (since we are interested in a difference between two points, not the global position), we see dist=1/2at^2+v_0t. Which is the formula used.
Intuitively it should also be clear: the final speed should be speed+m_Acceleration.Multiply(dt), but I start at with a speed of speed, so the covered distance must be in between speed *dt and (speed+m_Acceleration *dt)*dt since my average speed during the timestep is somewhere in between the initial and final speed.