This member has provided no bio about themself...

Report article RSS Feed ScrGold/Coding: water+trigger_push = impossible?

Posted by PanSartre on Apr 20th, 2013

Do you know this problem? Since a previous HL update (1.1.1.0 ? in times of WON) it isn't possible to push the player underwater. The combination of func_water and trigger_push didn't work anymore. Consequently original maps like c2a4b or c2a5 are missing the nice streaming effect of the old shipped version from 1998. Interestingly it still works in Opposing Force, Blue Shift and Uplink.
At the moment I am working on this problem and I already have a solution which isn't perfect. New/changed entries are pink.

Open pm_shared.c and go to PM_WaterMove:

void PM_WaterMove (void)
{
int i;
vec3_t wishvel;
float wishspeed;
vec3_t wishdir;
vec3_t start, dest;
vec3_t temp;
pmtrace_t trace;

float speed, newspeed, addspeed, accelspeed;

vec3_t basevec;
float basevel;

//
// user intentions
//

VectorCopy (pmove->basevelocity, basevec);
basevel = VectorNormalize(basevec);

for (i=0 ; i<3 ; i++)
{
wishvel[i]= pmove->forward[i]*pmove->cmd.forwardmove + pmove->right[i]*pmove->cmd.sidemove;
}

// Sinking after no other movement occurs
if (!pmove->cmd.forwardmove && !pmove->cmd.sidemove && !pmove->cmd.upmove && !basevel) //no sinking if there is basevelocity (e.g. trigger_push)
wishvel[2] -= 60; // drift towards bottom
else // Go straight up by upmove amount.
wishvel[2] += pmove->cmd.upmove;

// Copy it over and determine speed
VectorCopy (wishvel, wishdir);
wishspeed = VectorNormalize(wishdir);

// Cap speed.
if (wishspeed > pmove->maxspeed)
{
VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel);
wishspeed = pmove->maxspeed;
}
// Slow us down a bit.
wishspeed *= 0.8;

//VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); //entry moved. you can even delete it
//Water friction
VectorCopy(pmove->velocity, temp);
speed = VectorNormalize(temp);
if (speed)
{
newspeed = speed - pmove->frametime * speed * pmove->movevars->friction * pmove->friction;

if (newspeed < 0.1f)
newspeed = 0;
VectorScale (pmove->velocity, newspeed/speed, pmove->velocity);
}
else
newspeed = 0;

//
// water acceleration
//
if (wishspeed >= 0.1f)
{
addspeed = wishspeed - newspeed;
if (addspeed > 0)
{

VectorNormalize(wishvel);
accelspeed = pmove->movevars->accelerate * wishspeed * pmove->frametime * pmove->friction;
if (accelspeed > addspeed)
accelspeed = addspeed;

for (i = 0; i < 3; i++)
{
pmove->velocity[i]+= accelspeed * wishvel[i];
//float deltaSpeed = accelspeed * wishvel[i];
//pmove->velocity[i]+= deltaSpeed;
//wishvel[i]+= deltaSpeed;
}

}
}
// HACKHACK: to reduce water pushspeed and imitate original waterfriction scale basevelocity; this solve the water + trigger_push bug
VectorScale (pmove->basevelocity, 0.30, pmove->basevelocity);
VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity);

// Now move
// assume it is a stair or a slope, so press down from stepheight above
VectorMA (pmove->origin, pmove->frametime, pmove->velocity, dest);
VectorCopy (dest, start);
start[2] += pmove->movevars->stepsize + 1;
trace = pmove->PM_PlayerTrace (start, dest, PM_NORMAL, -1 );
if (!trace.startsolid && !trace.allsolid) // FIXME: check steep slope?
{ // walked up the step, so just keep result and exit
VectorCopy (trace.endpos, pmove->origin);
return;
}

// Try moving straight along out normal path.
PM_FlyMove ();
}

Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Level
93%
Gamer
7
Avatar
Avatar
Offline Since
Aug 15, 2014
Country
Germany Germany
Gender
Male
Member Watch
Track this member
Blog
Browse
Blogs
Views
37 (1 today)
Report Abuse
Report article