Also cut the veolcity of predators, the closer they are to swallowing. Do it more...
[voretournament/voretournament.git] / data / qcsrc / server / cl_physics.qc
index 81c2afc..b0b0425 100644 (file)
@@ -29,6 +29,11 @@ float sv_warsowbunny_backtosideratio;
 .float wasFlying;\r
 .float spectatorspeed;\r
 \r
+.float multijump_count;\r
+.float multijump_ready;\r
+.float prevjumpbutton;\r
+.float prevlastteleporttime;\r
+\r
 /*\r
 =============\r
 PlayerJump\r
@@ -39,8 +44,24 @@ When you press the jump key
 void PlayerJump (void)\r
 {\r
        float mjumpheight;\r
+       float doublejump;\r
+\r
+       doublejump = FALSE;\r
+       if (cvar("sv_doublejump"))\r
+       {\r
+               tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);\r
+               if (trace_fraction < 1 && trace_plane_normal_z > 0.7)\r
+                       doublejump = TRUE;\r
+       }\r
 \r
        mjumpheight = cvar("sv_jumpvelocity");\r
+       if(self.scale) // we are smaller or larger, so we jump lower or higher\r
+               mjumpheight *= (1 - cvar("g_healthsize_movementfactor")) + cvar("g_healthsize_movementfactor") * self.scale;\r
+       if(self.swallow_progress_prey) // cut jumping based on swallow progress for prey\r
+               mjumpheight *= 1 - (self.swallow_progress_prey * cvar("g_balance_vore_swallow_speed_cutspd_prey"));\r
+       if(self.swallow_progress_pred) // cut jumping based on swallow progress for preds\r
+               mjumpheight *= 1 - (self.swallow_progress_pred * cvar("g_balance_vore_swallow_speed_cutspd_pred"));\r
+\r
        if (self.waterlevel >= WATERLEVEL_SWIMMING)\r
        {\r
                if (self.watertype == CONTENT_WATER)\r
@@ -53,8 +74,66 @@ void PlayerJump (void)
                return;\r
        }\r
 \r
-       if (!(self.flags & FL_ONGROUND))\r
-               return;\r
+       if (cvar("g_multijump"))\r
+       {\r
+               if(self.prevlastteleporttime != self.lastteleporttime)\r
+               {\r
+                       // if we teleported above the ground, require touching the ground again to multi-jump\r
+                       self.multijump_ready = FALSE;\r
+                       if(self.flags & FL_ONGROUND)\r
+                               self.prevlastteleporttime = self.lastteleporttime;\r
+               }\r
+               else if (self.prevjumpbutton == FALSE && !(self.flags & FL_ONGROUND)) // jump button pressed this frame and we are in midair\r
+                       self.multijump_ready = TRUE;  // this is necessary to check that we released the jump button and pressed it again\r
+               else\r
+                       self.multijump_ready = FALSE;\r
+       }\r
+\r
+       if(!doublejump && self.multijump_ready && self.multijump_count < cvar("g_multijump") && self.velocity_z > cvar("g_multijump_speed"))\r
+       {\r
+               // doublejump = FALSE; // checked above in the if\r
+               if (cvar("g_multijump"))\r
+               {\r
+                       if (cvar("g_multijump_add") == 0) // in this case we make the z velocity == jumpvelocity\r
+                       {\r
+                               if (self.velocity_z < mjumpheight)\r
+                               {\r
+                                       doublejump = TRUE;\r
+                                       self.velocity_z = 0;\r
+                               }\r
+                       }\r
+                       else\r
+                               doublejump = TRUE;\r
+\r
+                       if(doublejump)\r
+                       {\r
+                               if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys\r
+                               {\r
+                                       float curspeed;\r
+                                       vector wishvel, wishdir;\r
+\r
+                                       curspeed = max(\r
+                                               vlen(vec2(self.velocity)), // current xy speed\r
+                                               vlen(vec2(antilag_takebackavgvelocity(self, max(self.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs\r
+                                       );\r
+                                       makevectors(self.v_angle_y * '0 1 0');\r
+                                       wishvel = v_forward * self.movement_x + v_right * self.movement_y;\r
+                                       wishdir = normalize(wishvel);\r
+\r
+                                       self.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump\r
+                                       self.velocity_y = wishdir_y * curspeed;\r
+                                       // keep velocity_z unchanged!\r
+                               }\r
+                               if (cvar("g_multijump") > 0)\r
+                                       self.multijump_count += 1;\r
+                       }\r
+               }\r
+               self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump\r
+       }\r
+\r
+       if (!doublejump)\r
+               if (!(self.flags & FL_ONGROUND))\r
+                       return;\r
 \r
        if(!sv_pogostick)\r
                if (!(self.flags & FL_JUMPRELEASED))\r
@@ -428,6 +507,15 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce
        if(speedclamp)\r
                accelqw = -accelqw;\r
 \r
+       if(cvar("g_balance_vore_weight_gravity") > 0) // apply stomach weight\r
+               wishspeed *= 1 - bound(0, self.stomach_load * cvar("g_balance_vore_weight_speed"), 1);\r
+       if(self.scale) // we are smaller or larger, so we run slower or faster\r
+               wishspeed *= (1 - cvar("g_healthsize_movementfactor")) + cvar("g_healthsize_movementfactor") * self.scale; \r
+       if(self.swallow_progress_prey) // cut speed based on swallow progress for prey\r
+               wishspeed *= 1 - (self.swallow_progress_prey * cvar("g_balance_vore_swallow_speed_cutspd_prey"));\r
+       if(self.swallow_progress_pred) // cut speed based on swallow progress for preds\r
+               wishspeed *= 1 - (self.swallow_progress_pred * cvar("g_balance_vore_swallow_speed_cutspd_pred"));\r
+\r
        if(cvar("sv_gameplayfix_q2airaccelerate"))\r
                wishspeed0 = wishspeed;\r
 \r
@@ -645,7 +733,7 @@ void SV_PlayerPhysics()
 \r
        if (self.punchangle != '0 0 0')\r
        {\r
-               f = vlen(self.punchangle) - 10 * frametime;\r
+               f = vlen(self.punchangle) - 15 * frametime;\r
                if (f > 0)\r
                        self.punchangle = normalize(self.punchangle) * f;\r
                else\r
@@ -697,7 +785,7 @@ void SV_PlayerPhysics()
                }\r
        }\r
 \r
-       if(self.predator.classname == "player")\r
+       if(self.stat_eaten)\r
                return;\r
 \r
        if (self.movetype == MOVETYPE_NONE)\r
@@ -745,8 +833,6 @@ void SV_PlayerPhysics()
        }\r
 \r
        maxspd_mod *= swampspd_mod; // only one common speed modder please!\r
-       if(cvar("g_balance_vore_weight_gravity") > 0)\r
-               maxspd_mod *= 1 - bound(0, self.stomach_load * cvar("g_balance_vore_weight_speed"), 1); // apply stomach weight\r
        swampspd_mod = 1;\r
 \r
        // if dead, behave differently\r
@@ -787,12 +873,12 @@ void SV_PlayerPhysics()
 \r
        if(self.classname == "player")\r
        {\r
-               if(sv_doublejump && time - self.jumppadusetime > 2 * sys_frametime)\r
+               if(self.flags & FL_ONGROUND)\r
                {\r
-                       tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);\r
-                       self.flags &~= FL_ONGROUND;\r
-                       if(trace_fraction < 1 && trace_plane_normal_z > 0.7)\r
-                               self.flags |= FL_ONGROUND;\r
+                       if (cvar("g_multijump") > 0)\r
+                               self.multijump_count = 0;\r
+                       else\r
+                               self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller\r
                }\r
 \r
                if (self.BUTTON_JUMP)\r
@@ -802,6 +888,7 @@ void SV_PlayerPhysics()
 \r
                if (self.waterlevel == WATERLEVEL_SWIMMING)\r
                        CheckWaterJump ();\r
+               self.prevjumpbutton = self.BUTTON_JUMP;\r
        }\r
 \r
        if (self.flags & FL_WATERJUMP )\r
@@ -902,7 +989,7 @@ void SV_PlayerPhysics()
                        PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);\r
                }\r
        }\r
-       else if ((self.items & IT_JETPACK) && self.BUTTON_JETPACK && (!cvar("g_jetpack_fuel") || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO) && self.predator.classname != "player")\r
+       else if ((self.items & IT_JETPACK) && self.BUTTON_JETPACK && (!cvar("g_jetpack_fuel") || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO) && !self.stat_eaten)\r
        {\r
                //makevectors(self.v_angle_y * '0 1 0');\r
                makevectors(self.v_angle);\r
@@ -998,13 +1085,13 @@ void SV_PlayerPhysics()
                        self.items |= IT_USING_JETPACK;\r
 \r
                        // jetpack also inhibits health regeneration, but only for 1 second\r
-                       self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen"));\r
+                       self.pauseregenhealth_finished = max(self.pauseregenhealth_finished, time + cvar("g_balance_pause_fuel_regen"));\r
                }\r
        }\r
        else if (self.flags & FL_ONGROUND)\r
        {\r
                // we get here if we ran out of ammo\r
-               if((self.items & IT_JETPACK) && self.BUTTON_JETPACK && !(buttons_prev & 32) && self.predator.classname != "player")\r
+               if((self.items & IT_JETPACK) && self.BUTTON_JETPACK && !(buttons_prev & 32) && !self.stat_eaten)\r
                        sprint(self, "You don't have any fuel for the ^2Jetpack\n");\r
 \r
                // walking\r
@@ -1065,7 +1152,7 @@ void SV_PlayerPhysics()
        {\r
                float wishspeed0;\r
                // we get here if we ran out of ammo\r
-               if((self.items & IT_JETPACK) && self.BUTTON_JETPACK && !(buttons_prev & 32) && self.predator.classname != "player")\r
+               if((self.items & IT_JETPACK) && self.BUTTON_JETPACK && !(buttons_prev & 32) && !self.stat_eaten)\r
                        sprint(self, "You don't have any fuel for the ^2Jetpack\n");\r
 \r
                if(maxspd_mod < 1)\r
@@ -1157,6 +1244,10 @@ void SV_PlayerPhysics()
                        }\r
                }\r
        }\r
+\r
+       if(vlen(self.velocity) > cvar("g_deathspeed"))\r
+               Damage(self, world, world, 100000, DEATH_KILL, self.origin, '0 0 0');\r
+\r
 :end\r
        if(self.flags & FL_ONGROUND)\r
                self.lastground = time;\r