]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/localplayer.cpp
Add dtime_s to entity activation
[dragonfireclient.git] / src / localplayer.cpp
index 16111629e60662a36178046e72f713174eb8944c..4b5e53fea294734e765ea262ab0eb070f69ea697 100644 (file)
@@ -150,13 +150,16 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
                position.X = rangelim(position.X, lwn_f.X-maxd, lwn_f.X+maxd);
                position.Z = rangelim(position.Z, lwn_f.Z-maxd, lwn_f.Z+maxd);
                
-               f32 min_y = lwn_f.Y + 0.5*BS;
-               if(position.Y < min_y)
+               if(!is_climbing)
                {
-                       position.Y = min_y;
+                       f32 min_y = lwn_f.Y + 0.5*BS;
+                       if(position.Y < min_y)
+                       {
+                               position.Y = min_y;
 
-                       if(m_speed.Y < 0)
-                               m_speed.Y = 0;
+                               if(m_speed.Y < 0)
+                                       m_speed.Y = 0;
+                       }
                }
        }
 
@@ -189,7 +192,7 @@ void LocalPlayer::move(f32 dtime, Map &map, 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
@@ -282,18 +285,25 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
        /*
                Report collisions
        */
+       bool bouncy_jump = false;
        if(collision_info)
        {
-               // Report fall collision
-               if(old_speed.Y < m_speed.Y - 0.1 && !standing_on_unloaded)
-               {
-                       CollisionInfo info;
-                       info.t = COLLISION_FALL;
-                       info.speed = m_speed.Y - old_speed.Y;
+               for(size_t i=0; i<result.collisions.size(); i++){
+                       const CollisionInfo &info = result.collisions[i];
                        collision_info->push_back(info);
+                       if(info.new_speed.Y - info.old_speed.Y > 0.1*BS &&
+                                       info.bouncy)
+                               bouncy_jump = true;
                }
        }
 
+       if(bouncy_jump && control.jump){
+               m_speed.Y += 6.5*BS;
+               touching_ground = false;
+               MtEvent *e = new SimpleTriggerEvent("PlayerJump");
+               m_gamedef->event()->put(e);
+       }
+
        if(!touching_ground_was && touching_ground){
                MtEvent *e = new SimpleTriggerEvent("PlayerRegainGround");
                m_gamedef->event()->put(e);