aa6 / minetest_wadsprint

Minetest mod for sprinting with W, A and D buttons.
GNU Affero General Public License v3.0
5 stars 1 forks source link

Random physic issue #3

Closed rusty-snake closed 4 years ago

rusty-snake commented 4 years ago

There is a physic issue where the player gravity is to high to jump 1 block high after sprinting. This happens never(??[1]) if wadsprint is the only mod in a world. I can say which mod is causing this. It happens, then it is gone and then happens it again.

[1]: Maybe just never in my test.

rusty-snake commented 4 years ago

With a chance of about 5% it happens using these mods.

https://content.minetest.net/packages/TBSHEB/balloonblocks/ https://content.minetest.net/packages/rnd/basic_machines/ https://content.minetest.net/packages/SpaghettiToastBook/beacons/ https://content.minetest.net/packages/VanessaE/basic_materials/

aa6 commented 4 years ago

Do enabling bad physics override mode in the wadsprint mod settings helps to solve the problem?

There's still plenty of mods who didn't care about another mods and their physics issues at all. player_monoids mod is used as intermediate mod to help this but other mods must support it too in order to work properly.

rusty-snake commented 4 years ago

Bad news: "bad physics override mode" does not help

Good news: It is basic_machines and I found a workaround. Comment dofile(minetest.get_modpath("basic_machines").."/enviro.lua" in basic_machines/init.lua.

rusty-snake commented 4 years ago

If I use minetest_wadsprint with player_monoids (no other mods) the speed is never reset. This means you can reach "infinity" speed.

rusty-snake commented 4 years ago

Do you know why these physics issues don't happen with hbsprint (tested w/o player_monoids)?

aa6 commented 4 years ago

If I use minetest_wadsprint with player_monoids (no other mods) the speed is never reset. This means you can reach "infinity" speed.

That's because https://content.minetest.net/packages/Byakuren/player_monoids/ provides older version of monoids than https://github.com/minetest-mods/player_monoids has. Fixed that by switching to an old monoids API.

aa6 commented 4 years ago

Do you know why these physics issues don't happen with hbsprint (tested w/o player_monoids)?

Probably because wadsprint tries to add and subtract percentages from current physics value instead of setting it directly to a certain value. Looks like that approach doesn't work as intended and need to be fixed too.

rusty-snake commented 4 years ago

minetest_wadsprint 0.10.13 + hudbars:

ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'minetest_wadsprint' in callback on_joinplayer(): /home/user/.minetest/mods/hudbars/init.lua:299: attempt to index a nil value
ERROR[Main]: stack traceback:
ERROR[Main]:    /home/user/.minetest/mods/hudbars/init.lua:299: in function 'init_hudbar'
ERROR[Main]:    ...user/.minetest/mods/minetest_wadsprint/init.hudbars.lua:32: in function 'initialize_hudbar'
ERROR[Main]:    /home/user/.minetest/mods/minetest_wadsprint/init.core.lua:149: in function </home/user/.minetest/mods/minetest_wadsprint/init.core.lua:133>
ERROR[Main]:    /app/share/minetest/builtin/game/register.lua:429: in function </app/share/minetest/builtin/game/register.lua:413>

I found a fix:

             if is_on_val == true then
                 player.obj:set_physics_override(
                 {
-                    jump = (round(physics.jump,0.01) - 1 + minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT),
-                    speed = (round(physics.speed,0.01) - 1 + minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT),
+                    jump = (physics.jump - 1 + minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT),
+                    speed = (physics.speed - 1 + minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT),
                 })
             elseif player.is_sprinting_physics_on ~= nil then
                 player.obj:set_physics_override(
                 {
-                    jump = (round(physics.jump,0.01) + 1 - minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT),
-                    speed = (round(physics.speed,0.01) + 1 - minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT),
+                    jump = (physics.jump + 1 - minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT),
+                    speed = (physics.speed + 1 - minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT),
                 })
             end
             player.is_sprinting_physics_on = is_on_val
aa6 commented 4 years ago

minetest_wadsprint 0.10.13 + hudbars:

ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'minetest_wadsprint' in callback on_joinplayer(): /home/user/.minetest/mods/hudbars/init.lua:299: attempt to index a nil value
ERROR[Main]: stack traceback:
ERROR[Main]:    /home/user/.minetest/mods/hudbars/init.lua:299: in function 'init_hudbar'
ERROR[Main]:    ...user/.minetest/mods/minetest_wadsprint/init.hudbars.lua:32: in function 'initialize_hudbar'
ERROR[Main]:    /home/user/.minetest/mods/minetest_wadsprint/init.core.lua:149: in function </home/user/.minetest/mods/minetest_wadsprint/init.core.lua:133>
ERROR[Main]:    /app/share/minetest/builtin/game/register.lua:429: in function </app/share/minetest/builtin/game/register.lua:413>

How to reproduce this bug? I tried with hudbars 2.2.2 but everything seems to be ok.

aa6 commented 4 years ago

Now I see.

aa6 commented 4 years ago

Updated https://content.minetest.net/packages/drkwv/minetest_wadsprint/ to 0.10.16 That happened because minetest_wadsprint.register_hudbar() was not called in 0.10.13

rusty-snake commented 4 years ago

Works. The stamina degenerates very slow or better: degenerates never while sprinting. Removing round(…,0.01) fixes the jump/gravity issue.

aa6 commented 4 years ago

Works. The stamina degenerates very slow or better: degenerates never while sprinting.

Increased default change rates to be noticeable.

Removing round(…,0.01) fixes the jump/gravity issue.

Rounding was introduced because Lua can't properly add/subtract floats slowly shifting the value from it's initial state. Probably the whole code block should be rewritten.

aa6 commented 4 years ago

I've removed BAD_PHYSICS_OVERRIDE_MODE and set it by default with some changes. So now it's either player_monoids or bad physics. Please test if that helps to solve the problem. Please also note that basic_machines sometimes alters gravity under some circumstances. Tthis could also be the cause for inability to jump higher than 1 block.

rusty-snake commented 4 years ago

Please test if that helps to solve the problem.

No, issue still present.

Please also note that basic_machines sometimes alters gravity under some circumstances. Tthis could also be the cause for inability to jump higher than 1 block.

Before sprinting: Speed: 1; Jump: 1; Gravity: 1; After sprinting: Speed: 1.1089488…; Jump: 0.777237236…; Gravity: 1;

minetest.register_chatcommand("physics_debug", {
        func = function(name, param)
                local physics = minetest.get_player_by_name("singleplayer"):get_physics_override()
                return true, "Speed: "..physics.speed.."; Jump: "..physics.jump.."; Gravity: "..physics.gravity..";"
        end
})

Increased default change rates to be noticeable.

I can sprint around 9 hours in minetest. IDK what your intention is, but this isn't realistic (and the rest of the game too).

aa6 commented 4 years ago

Before sprinting: Speed: 1; Jump: 1; Gravity: 1; After sprinting: Speed: 1.1089488…; Jump: 0.777237236…; Gravity: 1;

As of 0.10.19 it should be 1;1;1 before sprinting and 1;1;1 after sprinting too. Did you use the github-master wadsprint version?

I can sprint around 9 hours in minetest.

Do you mean 9 in-game hours?

IDK what your intention is

I just don't like when stamina ends. There was no intention to add a hardcore mechanics when you need to struggle to survive/sprint. But I probably should increase it one more time since it's too much confusing.

rusty-snake commented 4 years ago

Do you mean 9 in-game hours?

yes

aa6 commented 4 years ago

yes

Well the part of a plan (that didn't work) was that every player will set his own preferrable values in the mod settings or config/world config.

rusty-snake commented 4 years ago

I just don't like when stamina ends. There was no intention to add a hardcore mechanics when you need to struggle to survive/sprint. But I probably should increase it one more time since it's too much confusing.

Looks good.

As of 0.10.19 it should be 1;1;1 before sprinting and 1;1;1 after sprinting too. Did you use the github-master wadsprint version?

:+1: minetest_wadsprint works now with other mods.

aa6 commented 4 years ago

Ok. I'm closing this issue then.