]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/cl_physics.qc
Include gmqcc binaries for Windows and Linux
[voretournament/voretournament.git] / data / qcsrc / server / cl_physics.qc
index 492dc2a4fb828db0cbdca36c6ed5a954fe71fc1a..8fdd51a6d8fe018437bd9cc8c283ca5be4a4e4b7 100644 (file)
@@ -185,6 +185,82 @@ void PlayerJump (void)
        // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping)\r
 }\r
 \r
+/*\r
+=============\r
+PlayerDodge\r
+\r
+When you double-press a movement key rapidly to leap in that direction\r
+=============\r
+*/\r
+void PlayerDodge()\r
+{\r
+       float common_factor;\r
+       float new_velocity_gain;\r
+       float velocity_difference;\r
+\r
+       // make sure v_up, v_right and v_forward are sane\r
+       makevectors(self.angles);\r
+\r
+       // if we have e.g. 0.5 sec ramptime and a frametime of 0.25, then the ramp code \r
+       // will be called ramp_time/frametime times = 2 times. so, we need to \r
+       // add 0.5 * the total speed each frame until the dodge action is done..\r
+       common_factor = sys_frametime / cvar("sv_dodging_ramp_time");\r
+\r
+       // if ramp time is smaller than frametime we get problems ;D\r
+       if (common_factor > 1) \r
+               common_factor = 1;\r
+\r
+       new_velocity_gain = self.dodging_velocity_gain - (common_factor * cvar("sv_dodging_horiz_speed"));\r
+       if (new_velocity_gain < 0)\r
+               new_velocity_gain = 0;\r
+\r
+       velocity_difference = self.dodging_velocity_gain - new_velocity_gain;\r
+       if(cvar("g_healthsize")) // if we are smaller or larger, we jump lower or higher\r
+               velocity_difference *= (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
+               velocity_difference *= 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
+               velocity_difference *= 1 - (self.swallow_progress_pred * cvar("g_balance_vore_swallow_speed_cutspd_pred"));\r
+\r
+       // ramp up dodging speed by adding some velocity each frame.. TODO: do it! :D\r
+       if (self.dodging_action == 1) {\r
+               //disable jump key during dodge accel phase\r
+               if (self.movement_z > 0) self.movement_z = 0;\r
+\r
+               self.velocity = \r
+                         self.velocity \r
+                       + ((self.dodging_direction_y * velocity_difference) * v_right)\r
+                       + ((self.dodging_direction_x * velocity_difference) * v_forward);\r
+\r
+               self.dodging_velocity_gain = self.dodging_velocity_gain - velocity_difference;\r
+       }\r
+\r
+       // the up part of the dodge is a single shot action\r
+       if (self.dodging_single_action == 1) {\r
+               self.flags &~= FL_ONGROUND;\r
+\r
+               self.velocity = \r
+                         self.velocity \r
+                       + (cvar("sv_dodging_up_speed") * v_up);\r
+\r
+               if (cvar("sv_dodging_sound"))\r
+                       PlayerSound(self, playersound_jump, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);\r
+\r
+               setanim(self, self.anim_jump, TRUE, FALSE, TRUE);\r
+\r
+               self.dodging_single_action = 0;\r
+       }\r
+\r
+       // are we done with the dodging ramp yet?\r
+       if((self.dodging_action == 1) && ((time - self.last_dodging_time) > cvar("sv_dodging_ramp_time")))\r
+       {\r
+               // reset state so next dodge can be done correctly\r
+               self.dodging_action = 0;\r
+               self.dodging_direction_x = 0;\r
+               self.dodging_direction_y = 0;\r
+       }\r
+}\r
+\r
 void CheckWaterJump()\r
 {\r
        local vector start, end;\r
@@ -263,10 +339,9 @@ void RaceCarPhysics()
        self.angles_z = 0;\r
        makevectors(self.angles); // new forward direction!\r
 \r
+       float myspeed, upspeed, steerfactor, accelfactor;\r
        if(self.flags & FL_ONGROUND || g_bugrigs_air_steering)\r
        {\r
-               float myspeed, upspeed, steerfactor, accelfactor;\r
-\r
                myspeed = self.velocity * v_forward;\r
                upspeed = self.velocity * v_up;\r
 \r
@@ -738,21 +813,33 @@ void SV_PlayerPhysics()
 \r
        if (self.punchangle != '0 0 0')\r
        {\r
-               f = vlen(self.punchangle) - 15 * frametime;\r
+               float speed = cvar("sv_punchangle_speed");\r
+               if (self.punchangle_speed)\r
+                       speed *= self.punchangle_speed + 1;\r
+\r
+               f = vlen(self.punchangle) - speed * frametime;\r
                if (f > 0)\r
                        self.punchangle = normalize(self.punchangle) * f;\r
                else\r
                        self.punchangle = '0 0 0';\r
        }\r
+       else\r
+               self.punchangle_speed = 0;\r
 \r
        if (self.punchvector != '0 0 0')\r
        {\r
-               f = vlen(self.punchvector) - 30 * frametime;\r
+               float speed = cvar("sv_punchvector_speed");\r
+               if (self.punchvector_speed)\r
+                       speed *= self.punchvector_speed + 1;\r
+\r
+               f = vlen(self.punchvector) - speed * frametime;\r
                if (f > 0)\r
                        self.punchvector = normalize(self.punchvector) * f;\r
                else\r
                        self.punchvector = '0 0 0';\r
        }\r
+       else\r
+               self.punchvector_speed = 0;\r
 \r
        if (clienttype(self) == CLIENTTYPE_BOT)\r
        {\r
@@ -856,6 +943,7 @@ void SV_PlayerPhysics()
        {\r
                self.wasFlying = 0;\r
 \r
+               if(self.classname == "player")\r
                if(self.waterlevel < WATERLEVEL_SWIMMING)\r
                if(time >= self.ladder_time)\r
                if not(self.grabber)\r
@@ -865,15 +953,59 @@ void SV_PlayerPhysics()
                        tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);\r
                        if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)\r
                        {\r
-                               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)\r
+                               if(cvar("g_healthsize"))\r
                                {\r
-                                       GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);\r
-                                       pointparticles(particleeffectnum("ground_metal"), self.origin, '0 0 0', 1);\r
+                                       if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)\r
+                                       {\r
+                                               GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, bound(0, VOL_BASE * (1 - playersize_micro(self)), 1));\r
+                                               pointparticles(particleeffectnum("ground_metal"), self.origin, '0 0 0', floor(self.scale * PARTICLE_MULTIPLIER));\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, bound(0, VOL_BASE * (1 - playersize_micro(self)), 1));\r
+                                               pointparticles(particleeffectnum("ground_dirt"), self.origin, '0 0 0', floor(self.scale * PARTICLE_MULTIPLIER));\r
+                                       }\r
+                                       sound(self, CHAN_AUTO, "misc/macro_hitground.wav", bound(0, VOL_BASE * playersize_macro(self), 1), ATTN_NORM);\r
+\r
+                                       // earthquake effect for nearby players when a macro falls\r
+                                       if(cvar("g_healthsize_quake_fall"))\r
+                                       {\r
+                                               entity head;\r
+                                               for(head = findradius(self.origin, cvar("g_healthsize_quake_fall_radius")); head; head = head.chain)\r
+                                               {\r
+                                                       if not(head.classname == "player" || head.classname == "spectator")\r
+                                                               continue;\r
+                                                       if(head == self || head.spectatee_status == num_for_edict(self))\r
+                                                               continue; // not for self\r
+                                                       if not(head.flags & FL_ONGROUND)\r
+                                                               continue; // we only feel the ground shaking if we are sitting on it\r
+                                                       if(head.stat_eaten)\r
+                                                               continue; // not for prey\r
+\r
+                                                       float shake;\r
+                                                       shake = vlen(head.origin - self.origin);\r
+                                                       if(shake)\r
+                                                               shake = 1 - bound(0, shake / cvar("g_healthsize_quake_fall_radius"), 1);\r
+                                                       shake *= playersize_macro(self) * cvar("g_healthsize_quake_fall");\r
+\r
+                                                       head.punchvector_x += crandom() * shake;\r
+                                                       head.punchvector_y += crandom() * shake;\r
+                                                       head.punchvector_z += crandom() * shake;\r
+                                               }\r
+                                       }\r
                                }\r
                                else\r
                                {\r
-                                       GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);\r
-                                       pointparticles(particleeffectnum("ground_dirt"), self.origin, '0 0 0', 1);\r
+                                       if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)\r
+                                       {\r
+                                               GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, VOL_BASE);\r
+                                               pointparticles(particleeffectnum("ground_metal"), self.origin, '0 0 0', PARTICLE_MULTIPLIER);\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, VOL_BASE);\r
+                                               pointparticles(particleeffectnum("ground_dirt"), self.origin, '0 0 0', PARTICLE_MULTIPLIER);\r
+                                       }\r
                                }\r
                        }\r
                }\r
@@ -916,7 +1048,7 @@ void SV_PlayerPhysics()
        {\r
                RaceCarPhysics();\r
        }\r
-       else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY)\r
+       else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY)\r
        {\r
                // noclipping or flying\r
                self.flags &~= FL_ONGROUND;\r
@@ -1155,7 +1287,7 @@ void SV_PlayerPhysics()
                if (wishspeed > sv_maxspeed*maxspd_mod)\r
                        wishspeed = sv_maxspeed*maxspd_mod;\r
                if (self.crouch)\r
-                       wishspeed = wishspeed * 0.5;\r
+                       wishspeed = wishspeed * cvar("sv_crouchvelocity");\r
                if (time >= self.teleport_time)\r
                        PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);\r
        }\r
@@ -1187,7 +1319,7 @@ void SV_PlayerPhysics()
                if (wishspeed > maxairspd)\r
                        wishspeed = maxairspd;\r
                if (self.crouch)\r
-                       wishspeed = wishspeed * 0.5;\r
+                       wishspeed = wishspeed * cvar("sv_crouchvelocity");\r
                if (time >= self.teleport_time)\r
                {\r
                        float accelerating;\r
@@ -1232,6 +1364,16 @@ void SV_PlayerPhysics()
                }\r
        }\r
 \r
+       // dodging code\r
+       if (cvar("g_dodging") == 0 || self.waterlevel >= WATERLEVEL_SWIMMING) // when swimming, no dodging allowed..\r
+       {\r
+               self.dodging_action = 0;\r
+               self.dodging_direction_x = 0;\r
+               self.dodging_direction_y = 0;\r
+       }\r
+       else\r
+               PlayerDodge();\r
+\r
        if((g_cts || g_race) && self.classname != "observer") {\r
                if(vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) {\r
                        speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');\r