]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_physics.qc
Merge remote-tracking branch 'origin/divVerent/new-laser-by-morphed'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
index b675c56e962ed9d94a5f8fddbdd01c3d619ff073..79087eb8a366e9a5ed91c67de9024d058ef3140f 100644 (file)
@@ -882,6 +882,10 @@ void SV_PlayerPhysics()
                swampspd_mod = self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
        }
 
+       // conveyors: first fix velocity
+       if(self.conveyor.state)
+               self.velocity -= self.conveyor.movedir;
+
        if(self.classname != "player")
        {
                maxspd_mod = autocvar_sv_spectator_speed_multiplier;
@@ -1211,6 +1215,28 @@ void SV_PlayerPhysics()
                                self.velocity = self.velocity * f;
                        else
                                self.velocity = '0 0 0';
+                       /*
+                          Mathematical analysis time!
+
+                          Our goal is to invert this mess.
+
+                          For the two cases we get:
+                               v = v0 * (1 - frametime * (autocvar_sv_stopspeed / v0) * autocvar_sv_friction)
+                                 = v0 - frametime * autocvar_sv_stopspeed * autocvar_sv_friction
+                               v0 = v + frametime * autocvar_sv_stopspeed * autocvar_sv_friction
+                          and
+                               v = v0 * (1 - frametime * autocvar_sv_friction)
+                               v0 = v / (1 - frametime * autocvar_sv_friction)
+
+                          These cases would be chosen ONLY if:
+                               v0 < autocvar_sv_stopspeed
+                               v + frametime * autocvar_sv_stopspeed * autocvar_sv_friction < autocvar_sv_stopspeed
+                               v < autocvar_sv_stopspeed * (1 - frametime * autocvar_sv_friction)
+                          and, respectively:
+                               v0 >= autocvar_sv_stopspeed
+                               v / (1 - frametime * autocvar_sv_friction) >= autocvar_sv_stopspeed
+                               v >= autocvar_sv_stopspeed * (1 - frametime * autocvar_sv_friction)
+                        */
                }
 
                // acceleration
@@ -1339,6 +1365,10 @@ void SV_PlayerPhysics()
        if(self.flags & FL_ONGROUND)
                self.lastground = time;
 
+       // conveyors: then break velocity again
+       if(self.conveyor.state)
+               self.velocity += self.conveyor.movedir;
+
        self.lastflags = self.flags;
        self.lastclassname = self.classname;
 }