aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-09-01 13:21:52 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-09-01 13:21:52 +0300
commitc129b3852b97b7bd7ea7fe904af68243ad44a333 (patch)
treed7bd69172762f730d3c8d320355e7a8380e04db7 /src
parent3b43c69df4ce7d68aebb4bd02aaa4aca18b9afad (diff)
downloadminetest-c129b3852b97b7bd7ea7fe904af68243ad44a333.tar.gz
minetest-c129b3852b97b7bd7ea7fe904af68243ad44a333.tar.bz2
minetest-c129b3852b97b7bd7ea7fe904af68243ad44a333.zip
Fix the bouncy node related stuff a bit
Diffstat (limited to 'src')
-rw-r--r--src/environment.cpp13
-rw-r--r--src/localplayer.cpp3
2 files changed, 11 insertions, 5 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 24943ad5f..a49a5e384 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -2033,10 +2033,18 @@ void ClientEnvironment::step(float dtime)
i = player_collisions.begin();
i != player_collisions.end(); i++)
{
+ CollisionInfo &info = *i;
+ v3f speed_diff = info.new_speed - info.old_speed;;
+ // Handle only fall damage
+ // (because otherwise walking against something in fast_move kills you)
+ if(speed_diff.Y < 0 || info.old_speed.Y >= 0)
+ continue;
+ // Get rid of other components
+ speed_diff.X = 0;
+ speed_diff.Z = 0;
f32 pre_factor = 1; // 1 hp per node/s
f32 tolerance = BS*14; // 5 without damage
f32 post_factor = 1; // 1 hp per node/s
- CollisionInfo &info = *i;
if(info.type == COLLISION_NODE)
{
const ContentFeatures &f = m_gamedef->ndef()->
@@ -2045,8 +2053,7 @@ void ClientEnvironment::step(float dtime)
int addp = itemgroup_get(f.groups, "fall_damage_add_percent");
pre_factor = 1.0 + (float)addp/100.0;
}
- float speed = (info.new_speed - info.old_speed).getLength();
- speed *= pre_factor;
+ float speed = pre_factor * speed_diff.getLength();
if(speed > tolerance)
{
f32 damage_f = (speed - tolerance)/BS * post_factor;
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 15b6fd15d..46a10c90b 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -486,9 +486,8 @@ void LocalPlayer::applyControl(float dtime)
v3f speed = getSpeed();
if(speed.Y >= -0.5*BS)
{
- speed.Y += 6.5*BS;
+ speed.Y = 6.5*BS;
setSpeed(speed);
- m_can_jump = false;
MtEvent *e = new SimpleTriggerEvent("PlayerJump");
m_gamedef->event()->put(e);