diff options
-rw-r--r-- | src/constants.h | 6 | ||||
-rw-r--r-- | src/content_cao.h | 6 | ||||
-rw-r--r-- | src/content_sao.cpp | 3 | ||||
-rw-r--r-- | src/localplayer.cpp | 7 |
4 files changed, 19 insertions, 3 deletions
diff --git a/src/constants.h b/src/constants.h index fb9e97cb3..4079d0d8f 100644 --- a/src/constants.h +++ b/src/constants.h @@ -90,6 +90,12 @@ with this program; if not, write to the Free Software Foundation, Inc., // Maximum hit points of a player #define PLAYER_MAX_HP 20 +// Player weight +#define PLAYER_DEFAULT_WEIGHT 75 + +// Player step height +#define PLAYER_DEFAULT_STEPHEIGHT 0.6f + // Maximal breath of a player #define PLAYER_MAX_BREATH 11 diff --git a/src/content_cao.h b/src/content_cao.h index 3be753529..dde1dfe6f 100644 --- a/src/content_cao.h +++ b/src/content_cao.h @@ -154,6 +154,12 @@ public: scene::IBillboardSceneNode *getSpriteSceneNode(); + + inline f32 getStepheight() const + { + return m_prop.stepheight; + } + inline bool isPlayer() const { return m_is_player; diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 81c6902f5..d59f97276 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -797,7 +797,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id m_prop.hp_max = PLAYER_MAX_HP; m_prop.physical = false; - m_prop.weight = 75; + m_prop.weight = PLAYER_DEFAULT_WEIGHT; m_prop.collisionbox = aabb3f(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.); // start of default appearance, this should be overwritten by LUA m_prop.visual = "upright_sprite"; @@ -811,6 +811,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id // end of default appearance m_prop.is_visible = true; m_prop.makes_footstep_sound = true; + m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT; m_hp = PLAYER_MAX_HP; } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a909ff40f..37aef7afe 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "environment.h" #include "map.h" #include "client.h" +#include "content_cao.h" /* LocalPlayer @@ -343,8 +344,10 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, } } - // TODO: this shouldn't be hardcoded but transmitted from server - float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2); + float player_stepheight = (m_cao == 0) ? 0.0 : + (touching_ground ? + (m_cao->getStepheight() * BS) : + (m_cao->getStepheight() -0.4 * BS)); #ifdef __ANDROID__ player_stepheight += (0.6 * BS); |