Physics: Fix grenade bouncing down slopes
Posted: Tue Jun 07, 2011 4:33 pm
Grenades in Quake don't bounce down slopes and in multiplayer often they get stuck and vibrate annoyingly in places. DarkPlaces has sv_gameplayfix_grenadebouncedownslopes which repairs this and R00k implemented this in Qrack and a custom ProQuake server long ago. This is adapted from Qrack's implementation.
Implementing
1. Create a cvar called sv_gameplayfix_grenadebouncedownslopes and register it. A value of 0 is original Quake behavior obviously.
2. Open sv_physics.c and find this:
And replace with:
Disclaimer: I'm not Mr. Physics but have interest in this feature mostly because I find grenades getting stuck in multiplayer annoying and like R00k's fix.
Implementing
1. Create a cvar called sv_gameplayfix_grenadebouncedownslopes and register it. A value of 0 is original Quake behavior obviously.
2. Open sv_physics.c and find this:
Code: Select all
// stop if on ground
if (trace.plane.normal[2] > 0.7)
{
if (ent->v.velocity[2] < 60 || ent->v.movetype != MOVETYPE_BOUNCE)
{
ent->v.flags = (int)ent->v.flags | FL_ONGROUND;
ent->v.groundentity = EDICT_TO_PROG(trace.ent);
VectorCopy (vec3_origin, ent->v.velocity);
VectorCopy (vec3_origin, ent->v.avelocity);
}
}Code: Select all
// stop if on ground
if (trace.plane.normal[2] > 0.7)
{
int stop_moving = false;
if (sv_gameplayfix_grenadebouncedownslopes.value)
{
if (DotProduct(trace.plane.normal, ent->v.velocity) < 60)
stop_moving = true;
}
else
{
if (ent->v.velocity[2] < 60 || ent->v.movetype != MOVETYPE_BOUNCE)
stop_moving = true;
}
if (stop_moving)
{
ent->v.flags = (int)ent->v.flags | FL_ONGROUND;
ent->v.groundentity = EDICT_TO_PROG(trace.ent);
VectorCopy (vec3_origin, ent->v.velocity);
VectorCopy (vec3_origin, ent->v.avelocity);
}
}