diff options
author | ANAND <ClobberXD@gmail.com> | 2019-05-04 12:43:31 +0530 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2019-08-20 18:48:28 +0200 |
commit | 3c395d908f016158162f022f24d7ea48eeb7e8d5 (patch) | |
tree | 1fb25622374b7cf4cb0252cadf2dca08928cee42 | |
parent | ded5da780002c17f2079a1d8ea09eb923a3b5e8f (diff) | |
download | minetest-3c395d908f016158162f022f24d7ea48eeb7e8d5.tar.gz minetest-3c395d908f016158162f022f24d7ea48eeb7e8d5.tar.bz2 minetest-3c395d908f016158162f022f24d7ea48eeb7e8d5.zip |
Disable autoforward if player is dead
-rw-r--r-- | src/client/content_cao.cpp | 3 | ||||
-rw-r--r-- | src/client/game.cpp | 4 | ||||
-rw-r--r-- | src/client/localplayer.cpp | 8 | ||||
-rw-r--r-- | src/client/localplayer.h | 4 |
4 files changed, 12 insertions, 7 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index ce0e31839..e76cacdd4 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -1541,6 +1541,9 @@ void GenericCAO::processMessage(const std::string &data) m_hp = result_hp; + if (m_is_local_player) + m_env->getLocalPlayer()->hp = m_hp; + if (damage > 0) { if (m_hp <= 0) diff --git a/src/client/game.cpp b/src/client/game.cpp index 841357810..4d5fbfb97 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2466,7 +2466,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam) } // autoforward if set: simulate "up" key - if (player->getPlayerSettings().continuous_forward) { + if (player->getPlayerSettings().continuous_forward && !player->isDead()) { control.up = true; keypress_bits |= 1U << 0; } @@ -2483,7 +2483,7 @@ inline void Game::step(f32 *dtime) bool can_be_and_is_paused = (simple_singleplayer_mode && g_menumgr.pausesGame()); - if (can_be_and_is_paused) { // This is for a singleplayer server + if (can_be_and_is_paused) { // This is for a singleplayer server *dtime = 0; // No time passes } else { if (server) diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index 39e290c5b..1b0b667c8 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -259,7 +259,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, } /* - Check if player is climbing + Check if player is climbing */ @@ -489,7 +489,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env) PlayerSettings &player_settings = getPlayerSettings(); // All vectors are relative to the player's yaw, - // (and pitch if pitch fly mode enabled), + // (and pitch if pitch move mode enabled), // and will be rotated at the end v3f speedH = v3f(0,0,0); // Horizontal (X, Z) v3f speedV = v3f(0,0,0); // Vertical (Y) @@ -930,11 +930,11 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d, bool touching_ground_was = touching_ground; touching_ground = result.touching_ground; - //bool standing_on_unloaded = result.standing_on_unloaded; + //bool standing_on_unloaded = result.standing_on_unloaded; /* Check the nodes under the player to see from which node the - player is sneaking from, if any. If the node from under + player is sneaking from, if any. If the node from under the player has been removed, the player falls. */ f32 position_y_mod = 0.05 * BS; diff --git a/src/client/localplayer.h b/src/client/localplayer.h index 16e7996ae..252519aaa 100644 --- a/src/client/localplayer.h +++ b/src/client/localplayer.h @@ -100,7 +100,7 @@ public: bool makes_footstep_sound = true; int last_animation = NO_ANIM; - float last_animation_speed; + float last_animation_speed = 0.0f; std::string hotbar_image = ""; std::string hotbar_selected_image = ""; @@ -149,6 +149,8 @@ public: bool getAutojump() const { return m_autojump; } + bool isDead() const { return hp <= 0; } + inline void addVelocity(const v3f &vel) { added_velocity += vel; |