stellarorion / gc_sprint

A simple sprinting utility for Minetest Game without the need for food consumption :^)
MIT License
0 stars 1 forks source link

set_physics_override #1

Open Atlante1952 opened 5 months ago

Atlante1952 commented 5 months ago

Your code is clean and well structured, but it has one major problem. When you use set_physics_override, you specify fixed values. This can cause problems if a player already benefits from a speed effect, for example via a potion or thanks to the 3d_armor mod.

Let me explain: if a player under the effect of a speed bonus uses this sprint mod, at the end of their race, their speed will be reset to 1.0, thus canceling the initial speed effect. To fix this, you need to get the player's current speed from before the sprint and add the sprint value to that speed on top, and replace the 1.0 with the player's initial speed found before the sprint

stellarorion commented 5 months ago

Hi,

Thank you for your feedback. I'm well aware of this issue and intend to fix it soon! This mod was made as a quick fix for the lack of faster movement in the Minetest Game. Originally, it was made for my current project I'm working on, and I thought other people either playing or modding MTG would find it useful.

stellarorion commented 5 months ago

Okay, I took a look into this issue, and I'm afraid I won't be able to solve this (at least for now). From what I've seen in other mods such as Stamina, Magic Potions and Player Effect Potions they all rely on set_physics_override. This means that they are not only incompatible with my mod because it resets the speed value upon releasing the aux1 button, but they are also incompatible with each other. A speed potion from PEP won't stack with other speed effects from Magic Potions because they will override each other.

I also took a look at the source code of Voxelibre (Mineclone 2) and from what I understood is that they don't have this problem since the potions are made in mind with the default speed variable. Meaning they have a variable representing the original speed and upon consuming speed potion it won't override until the potions counter will expire.

I'm still fairly a begginer programmer and don't have the full grasp of the Minetest API. If you find a solution to this issue, feel free to create a pull request.