diff options
Diffstat (limited to 'src/client/localplayer.cpp')
-rw-r--r-- | src/client/localplayer.cpp | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index f3eb1a2dd..7d532c602 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -27,6 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "map.h" #include "client.h" #include "content_cao.h" +#include "util/pointedthing.h" +#include "client/game.h" /* LocalPlayer @@ -87,7 +89,7 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, new_sneak_node_exists = false; } else { node = map->getNode(current_node, &is_valid_position); - if (!is_valid_position || !nodemgr->get(node).walkable) + if (!is_valid_position || nodemgr->get(node).walkable) new_sneak_node_exists = false; } @@ -113,7 +115,7 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, // The node to be sneaked on has to be walkable node = map->getNode(p, &is_valid_position); - if (!is_valid_position || !nodemgr->get(node).walkable) + if (!is_valid_position || ! nodemgr->get(node).walkable) continue; // And the node(s) above have to be nonwalkable bool ok = true; @@ -130,7 +132,7 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, } else { // legacy behaviour: check just one node node = map->getNode(p + v3s16(0, 1, 0), &is_valid_position); - ok = is_valid_position && !nodemgr->get(node).walkable; + ok = is_valid_position && ! nodemgr->get(node).walkable; } if (!ok) continue; @@ -159,7 +161,7 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, node = map->getNode(m_sneak_node + v3s16(0, 3, 0), &is_valid_position); m_sneak_ladder_detected = is_valid_position && - !nodemgr->get(node).walkable; + ! nodemgr->get(node).walkable; } } return true; @@ -168,6 +170,9 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, std::vector<CollisionInfo> *collision_info) { + if (m_cao && m_cao->m_waiting_for_reattach > 0) + m_cao->m_waiting_for_reattach -= dtime; + // Node at feet position, update each ClientEnvironment::step() if (!collision_info || collision_info->empty()) m_standing_node = floatToInt(m_position, BS); @@ -296,7 +301,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, collisionMoveResult result = collisionMoveSimple(env, m_client, pos_max_d, m_collisionbox, player_stepheight, dtime, - &position, &m_speed, accel_f); + &position, &m_speed, accel_f, NULL, true, true); bool could_sneak = control.sneak && !free_move && !in_liquid && !is_climbing && physics_override_sneak; @@ -456,6 +461,8 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, m_speed.Y += jumpspeed; } setSpeed(m_speed); + if (! m_freecam) + m_legit_speed = m_speed; m_can_jump = false; } @@ -604,14 +611,14 @@ void LocalPlayer::applyControl(float dtime, Environment *env) else speedV.Y = movement_speed_walk; } - } else if (m_can_jump) { + } else if (m_can_jump || g_settings->getBool("jetpack")) { /* NOTE: The d value in move() affects jump height by raising the height at which the jump speed is kept at its starting value */ v3f speedJ = getSpeed(); - if (speedJ.Y >= -0.5f * BS) { + if (speedJ.Y >= -0.5f * BS || g_settings->getBool("jetpack")) { speedJ.Y = movement_speed_jump * physics_override_jump; setSpeed(speedJ); m_client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::PLAYER_JUMP)); @@ -634,7 +641,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env) if (superspeed || (is_climbing && fast_climb) || ((in_liquid || in_liquid_stable) && fast_climb)) speedH = speedH.normalize() * movement_speed_fast; - else if (control.sneak && !free_move && !in_liquid && !in_liquid_stable) + else if (control.sneak && !free_move && !in_liquid && !in_liquid_stable && !g_settings->getBool("no_slow")) speedH = speedH.normalize() * movement_speed_crouch; else speedH = speedH.normalize() * movement_speed_walk; @@ -712,7 +719,7 @@ v3f LocalPlayer::getEyeOffset() const ClientActiveObject *LocalPlayer::getParent() const { - return m_cao ? m_cao->getParent() : nullptr; + return (m_cao && ! g_settings->getBool("entity_speed")) ? m_cao->getParent() : nullptr; } bool LocalPlayer::isDead() const @@ -721,6 +728,18 @@ bool LocalPlayer::isDead() const return !getCAO()->isImmortal() && hp == 0; } +void LocalPlayer::tryReattach(int id) +{ + PointedThing pointed(id, v3f(0, 0, 0), v3s16(0, 0, 0), 0); + m_client->interact(INTERACT_PLACE, pointed); + m_cao->m_waiting_for_reattach = 10; +} + +bool LocalPlayer::isWaitingForReattach() const +{ + return g_settings->getBool("entity_speed") && m_cao && ! m_cao->getParent() && m_cao->m_waiting_for_reattach > 0; +} + // 3D acceleration void LocalPlayer::accelerate(const v3f &target_speed, const f32 max_increase_H, const f32 max_increase_V, const bool use_pitch) @@ -904,7 +923,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d, collisionMoveResult result = collisionMoveSimple(env, m_client, pos_max_d, m_collisionbox, player_stepheight, dtime, - &position, &m_speed, accel_f); + &position, &m_speed, accel_f, NULL, true, true); // Positition was slightly changed; update standing node pos if (touching_ground) @@ -1083,7 +1102,7 @@ float LocalPlayer::getSlipFactor(Environment *env, const v3f &speedH) Map *map = &env->getMap(); const ContentFeatures &f = nodemgr->get(map->getNode(getStandingNodePos())); int slippery = 0; - if (f.walkable) + if (f.walkable && ! g_settings->getBool("antislip")) slippery = itemgroup_get(f.groups, "slippery"); if (slippery >= 1) { @@ -1156,7 +1175,7 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env, // try at peak of jump, zero step height collisionMoveResult jump_result = collisionMoveSimple(env, m_client, pos_max_d, - m_collisionbox, 0.0f, dtime, &jump_pos, &jump_speed, v3f(0.0f)); + m_collisionbox, 0.0f, dtime, &jump_pos, &jump_speed, v3f(0.0f), NULL, true, true); // see if we can get a little bit farther horizontally if we had // jumped @@ -1169,3 +1188,4 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env, m_autojump_time = 0.1f; } } + |