This member has provided no bio about themself...

Report content RSS feed ScrGold/Coding: water+trigger_push = impossible?

Posted by on

Do you know this problem? Since a previous HL update ( ? 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);
newspeed = 0;

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

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);

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

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Last Online
Germany Germany
Become friends
Member watch
Start tracking
61 (1 today)