Add disable_descend to disable active node sinking

This commit is contained in:
Wuzzy 2023-02-21 14:07:43 +01:00 committed by DS
parent a4e69d6843
commit 6b3deaa170
3 changed files with 11 additions and 4 deletions

@ -2069,6 +2069,9 @@ to games.
* `3`: the node always gets the digging time 0 seconds (torch)
* `disable_jump`: Player (and possibly other things) cannot jump from node
or if their feet are in the node. Note: not supported for `new_move = false`
* `disable_descend`: Player (and possibly other things) cannot *actively*
descend in node using Sneak or Aux1 key (for liquids and climbable nodes
only). Note: not supported for `new_move = false`
* `fall_damage_add_percent`: modifies the fall damage suffered when hitting
the top of this node. There's also an armor group with the same name.
The final player damage is determined by the following formula:

@ -463,6 +463,8 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
itemgroup_get(f1.groups, "disable_jump");
m_can_jump = ((touching_ground && !is_climbing) || sneak_can_jump || standing_node_bouncy != 0)
&& !m_disable_jump;
m_disable_descend = itemgroup_get(f.groups, "disable_descend") ||
itemgroup_get(f1.groups, "disable_descend");
// Jump/Sneak key pressed while bouncing from a bouncy block
float jumpspeed = movement_speed_jump * physics_override.jump;
@ -549,10 +551,10 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
speedV.Y = -movement_speed_fast;
else
speedV.Y = -movement_speed_walk;
} else if (in_liquid || in_liquid_stable) {
} else if ((in_liquid || in_liquid_stable) && !m_disable_descend) {
speedV.Y = -movement_speed_walk;
swimming_vertical = true;
} else if (is_climbing) {
} else if (is_climbing && !m_disable_descend) {
speedV.Y = -movement_speed_climb;
} else {
// If not free movement but fast is allowed, aux1 is
@ -581,13 +583,13 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
speedV.Y = -movement_speed_fast;
else
speedV.Y = -movement_speed_walk;
} else if (in_liquid || in_liquid_stable) {
} else if ((in_liquid || in_liquid_stable) && !m_disable_descend) {
if (fast_climb)
speedV.Y = -movement_speed_fast;
else
speedV.Y = -movement_speed_walk;
swimming_vertical = true;
} else if (is_climbing) {
} else if (is_climbing && !m_disable_descend) {
if (fast_climb)
speedV.Y = -movement_speed_fast;
else
@ -1088,6 +1090,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
// Determine if jumping is possible
m_disable_jump = itemgroup_get(f.groups, "disable_jump");
m_can_jump = (touching_ground || standing_node_bouncy != 0) && !m_disable_jump;
m_disable_descend = itemgroup_get(f.groups, "disable_descend");
// Jump/Sneak key pressed while bouncing from a bouncy block
float jumpspeed = movement_speed_jump * physics_override.jump;

@ -191,6 +191,7 @@ private:
bool m_can_jump = false;
bool m_disable_jump = false;
bool m_disable_descend = false;
u16 m_breath = PLAYER_MAX_BREATH_DEFAULT;
f32 m_yaw = 0.0f;
f32 m_pitch = 0.0f;