From 3b43c69df4ce7d68aebb4bd02aaa4aca18b9afad Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 1 Sep 2012 12:58:37 +0300 Subject: Add bouncy node group --- src/environment.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/environment.cpp') diff --git a/src/environment.cpp b/src/environment.cpp index 292679542..24943ad5f 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -2033,25 +2033,26 @@ void ClientEnvironment::step(float dtime) i = player_collisions.begin(); i != player_collisions.end(); i++) { + 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.t == COLLISION_FALL) + if(info.type == COLLISION_NODE) { - //f32 tolerance = BS*10; // 2 without damage - //f32 tolerance = BS*12; // 3 without damage - f32 tolerance = BS*14; // 5 without damage - f32 factor = 1; const ContentFeatures &f = m_gamedef->ndef()-> - get(m_map->getNodeNoEx(lplayer->getStandingNodePos())); + get(m_map->getNodeNoEx(info.node_p)); // Determine fall damage multiplier int addp = itemgroup_get(f.groups, "fall_damage_add_percent"); - info.speed *= (1.0 + (float)addp/100.0); - if(info.speed > tolerance) - { - f32 damage_f = (info.speed - tolerance)/BS*factor; - u16 damage = (u16)(damage_f+0.5); - if(damage != 0) - damageLocalPlayer(damage, true); - } + pre_factor = 1.0 + (float)addp/100.0; + } + float speed = (info.new_speed - info.old_speed).getLength(); + speed *= pre_factor; + if(speed > tolerance) + { + f32 damage_f = (speed - tolerance)/BS * post_factor; + u16 damage = (u16)(damage_f+0.5); + if(damage != 0) + damageLocalPlayer(damage, true); } } -- cgit v1.2.3