X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fcl_physics.qc;h=40ab462f17746b4b433ec98aeb58739b38f1f1cd;hb=b2df32d96df3e954d54f6e4b9bbb6c98d77ef507;hp=102680c9f4c427ed0cac601221e0fdc1fc3577aa;hpb=68345fee2d8e799989dfa1fa07c63d902f9dbbdc;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/cl_physics.qc b/data/qcsrc/server/cl_physics.qc index 102680c9..40ab462f 100644 --- a/data/qcsrc/server/cl_physics.qc +++ b/data/qcsrc/server/cl_physics.qc @@ -55,10 +55,12 @@ void PlayerJump (void) } mjumpheight = cvar("sv_jumpvelocity"); - if(self.scale) // we are smaller or larger, so we jump lower or higher + if(cvar("g_healthsize")) // if we are smaller or larger, we jump lower or higher mjumpheight *= (1 - cvar("g_healthsize_movementfactor")) + cvar("g_healthsize_movementfactor") * self.scale; - if(self.swallow_progress_prey) // cut jumping based on swallow progress - mjumpheight *= 1 - (self.swallow_progress_prey * cvar("g_balance_vore_swallow_speed_cutspd")); + if(self.swallow_progress_prey) // cut jumping based on swallow progress for prey + mjumpheight *= 1 - (self.swallow_progress_prey * cvar("g_balance_vore_swallow_speed_cutspd_prey")); + if(self.swallow_progress_pred) // cut jumping based on swallow progress for preds + mjumpheight *= 1 - (self.swallow_progress_pred * cvar("g_balance_vore_swallow_speed_cutspd_pred")); if (self.waterlevel >= WATERLEVEL_SWIMMING) { @@ -183,6 +185,82 @@ void PlayerJump (void) // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping) } +/* +============= +PlayerDodge + +When you double-press a movement key rapidly to leap in that direction +============= +*/ +void PlayerDodge() +{ + float common_factor; + float new_velocity_gain; + float velocity_difference; + + // make sure v_up, v_right and v_forward are sane + makevectors(self.angles); + + // if we have e.g. 0.5 sec ramptime and a frametime of 0.25, then the ramp code + // will be called ramp_time/frametime times = 2 times. so, we need to + // add 0.5 * the total speed each frame until the dodge action is done.. + common_factor = sys_frametime / cvar("sv_dodging_ramp_time"); + + // if ramp time is smaller than frametime we get problems ;D + if (common_factor > 1) + common_factor = 1; + + new_velocity_gain = self.dodging_velocity_gain - (common_factor * cvar("sv_dodging_horiz_speed")); + if (new_velocity_gain < 0) + new_velocity_gain = 0; + + velocity_difference = self.dodging_velocity_gain - new_velocity_gain; + if(cvar("g_healthsize")) // if we are smaller or larger, we jump lower or higher + velocity_difference *= (1 - cvar("g_healthsize_movementfactor")) + cvar("g_healthsize_movementfactor") * self.scale; + if(self.swallow_progress_prey) // cut jumping based on swallow progress for prey + velocity_difference *= 1 - (self.swallow_progress_prey * cvar("g_balance_vore_swallow_speed_cutspd_prey")); + if(self.swallow_progress_pred) // cut jumping based on swallow progress for preds + velocity_difference *= 1 - (self.swallow_progress_pred * cvar("g_balance_vore_swallow_speed_cutspd_pred")); + + // ramp up dodging speed by adding some velocity each frame.. TODO: do it! :D + if (self.dodging_action == 1) { + //disable jump key during dodge accel phase + if (self.movement_z > 0) self.movement_z = 0; + + self.velocity = + self.velocity + + ((self.dodging_direction_y * velocity_difference) * v_right) + + ((self.dodging_direction_x * velocity_difference) * v_forward); + + self.dodging_velocity_gain = self.dodging_velocity_gain - velocity_difference; + } + + // the up part of the dodge is a single shot action + if (self.dodging_single_action == 1) { + self.flags &~= FL_ONGROUND; + + self.velocity = + self.velocity + + (cvar("sv_dodging_up_speed") * v_up); + + if (cvar("sv_dodging_sound")) + PlayerSound(self, playersound_jump, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); + + setanim(self, self.anim_jump, TRUE, FALSE, TRUE); + + self.dodging_single_action = 0; + } + + // are we done with the dodging ramp yet? + if((self.dodging_action == 1) && ((time - self.last_dodging_time) > cvar("sv_dodging_ramp_time"))) + { + // reset state so next dodge can be done correctly + self.dodging_action = 0; + self.dodging_direction_x = 0; + self.dodging_direction_y = 0; + } +} + void CheckWaterJump() { local vector start, end; @@ -261,10 +339,9 @@ void RaceCarPhysics() self.angles_z = 0; makevectors(self.angles); // new forward direction! + float myspeed, upspeed, steerfactor, accelfactor; if(self.flags & FL_ONGROUND || g_bugrigs_air_steering) { - float myspeed, upspeed, steerfactor, accelfactor; - myspeed = self.velocity * v_forward; upspeed = self.velocity * v_up; @@ -505,12 +582,19 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce if(speedclamp) accelqw = -accelqw; - if(cvar("g_balance_vore_weight_gravity") > 0) // apply stomach weight - wishspeed *= 1 - bound(0, self.stomach_load * cvar("g_balance_vore_weight_speed"), 1); - if(self.scale) // we are smaller or larger, so we run slower or faster - wishspeed *= (1 - cvar("g_healthsize_movementfactor")) + cvar("g_healthsize_movementfactor") * self.scale; - if(self.swallow_progress_prey) // cut speed based on swallow progress - wishspeed *= 1 - (self.swallow_progress_prey * cvar("g_balance_vore_swallow_speed_cutspd")); + if(self.classname == "player") + { + if(cvar("g_balance_vore_load_pred_weight") > 0) // apply stomach weight + wishspeed /= 1 + (self.stomach_load / self.stomach_maxload) * cvar("g_balance_vore_load_pred_speed"); + if(cvar("g_healthsize")) // if we are smaller or larger, we run slower or faster + wishspeed *= (1 - cvar("g_healthsize_movementfactor")) + cvar("g_healthsize_movementfactor") * self.scale; + if(self.swallow_progress_prey) // cut speed based on swallow progress for prey + wishspeed *= 1 - (self.swallow_progress_prey * cvar("g_balance_vore_swallow_speed_cutspd_prey")); + if(self.swallow_progress_pred) // cut speed based on swallow progress for preds + wishspeed *= 1 - (self.swallow_progress_pred * cvar("g_balance_vore_swallow_speed_cutspd_pred")); + if(self.grabber_stunned > time && random() <= cvar("g_balance_grabber_secondary_stun_rate")) // randomly cut speed while the player is stunned + return; + } if(cvar("sv_gameplayfix_q2airaccelerate")) wishspeed0 = wishspeed; @@ -729,7 +813,7 @@ void SV_PlayerPhysics() if (self.punchangle != '0 0 0') { - f = vlen(self.punchangle) - 15 * frametime; + f = vlen(self.punchangle) - cvar("sv_punchangle_speed") * frametime; if (f > 0) self.punchangle = normalize(self.punchangle) * f; else @@ -738,7 +822,7 @@ void SV_PlayerPhysics() if (self.punchvector != '0 0 0') { - f = vlen(self.punchvector) - 30 * frametime; + f = vlen(self.punchvector) - cvar("sv_punchvector_speed") * frametime; if (f > 0) self.punchvector = normalize(self.punchvector) * f; else @@ -847,6 +931,7 @@ void SV_PlayerPhysics() { self.wasFlying = 0; + if(self.classname == "player") if(self.waterlevel < WATERLEVEL_SWIMMING) if(time >= self.ladder_time) if not(self.grabber) @@ -856,10 +941,60 @@ void SV_PlayerPhysics() tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self); if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS) { - if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) - GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); + if(cvar("g_healthsize")) + { + if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) + { + GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, bound(0, VOL_BASE * (1 - playersize_micro(self)), 1)); + pointparticles(particleeffectnum("ground_metal"), self.origin, '0 0 0', floor(self.scale * PARTICLE_MULTIPLIER)); + } + else + { + GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, bound(0, VOL_BASE * (1 - playersize_micro(self)), 1)); + pointparticles(particleeffectnum("ground_dirt"), self.origin, '0 0 0', floor(self.scale * PARTICLE_MULTIPLIER)); + } + sound(self, CHAN_AUTO, "misc/macro_hitground.wav", bound(0, VOL_BASE * playersize_macro(self), 1), ATTN_NORM); + + // earthquake effect for nearby players when a macro falls + if(cvar("g_healthsize_quake_fall")) + { + entity head; + for(head = findradius(self.origin, cvar("g_healthsize_quake_fall_radius")); head; head = head.chain) + { + if not(head.classname == "player" || head.classname == "spectator") + continue; + if(head == self || head.spectatee_status == num_for_edict(self)) + continue; // not for self + if not(head.flags & FL_ONGROUND) + continue; // we only feel the ground shaking if we are sitting on it + if(head.stat_eaten) + continue; // not for prey + + float shake; + shake = vlen(head.origin - self.origin); + if(shake) + shake = 1 - bound(0, shake / cvar("g_healthsize_quake_fall_radius"), 1); + shake *= playersize_macro(self) * cvar("g_healthsize_quake_fall"); + + head.punchvector_x += crandom() * shake; + head.punchvector_y += crandom() * shake; + head.punchvector_z += crandom() * shake; + } + } + } else - GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); + { + if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) + { + GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, VOL_BASE); + pointparticles(particleeffectnum("ground_metal"), self.origin, '0 0 0', PARTICLE_MULTIPLIER); + } + else + { + GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, VOL_BASE); + pointparticles(particleeffectnum("ground_dirt"), self.origin, '0 0 0', PARTICLE_MULTIPLIER); + } + } } } } @@ -901,7 +1036,7 @@ void SV_PlayerPhysics() { RaceCarPhysics(); } - else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY) + else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY) { // noclipping or flying self.flags &~= FL_ONGROUND; @@ -1140,7 +1275,7 @@ void SV_PlayerPhysics() if (wishspeed > sv_maxspeed*maxspd_mod) wishspeed = sv_maxspeed*maxspd_mod; if (self.crouch) - wishspeed = wishspeed * 0.5; + wishspeed = wishspeed * cvar("sv_crouchvelocity"); if (time >= self.teleport_time) PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0); } @@ -1172,7 +1307,7 @@ void SV_PlayerPhysics() if (wishspeed > maxairspd) wishspeed = maxairspd; if (self.crouch) - wishspeed = wishspeed * 0.5; + wishspeed = wishspeed * cvar("sv_crouchvelocity"); if (time >= self.teleport_time) { float accelerating; @@ -1217,6 +1352,16 @@ void SV_PlayerPhysics() } } + // dodging code + if (cvar("g_dodging") == 0 || self.waterlevel >= WATERLEVEL_SWIMMING) // when swimming, no dodging allowed.. + { + self.dodging_action = 0; + self.dodging_direction_x = 0; + self.dodging_direction_y = 0; + } + else + PlayerDodge(); + if((g_cts || g_race) && self.classname != "observer") { if(vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) { speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');