This member has provided no bio about themself...

Image RSS Feed Latest Screens
s1a1 blkop_comanche intro
Blog RSS Feed Report abuse Latest Blog: ScrGold/Coding: water+trigger_push = impossible?

0 comments 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 ();
}

Media RSS Feed Latest Video
Post comment Comments
PanSartre
PanSartre Mar 21 2013, 10:55am says:

This code is more or less my code. The thing is, I never learned to program C++. I only tried to understand some parts in the goldscr-code and tried to use the existing functions to build this flamethrower. A good coder would see that this isn a smart methode to create a flamethrower in HL. It reach the engine limits very fast (too many entities error). At the moment its really more an experiment.

+2 votes     reply to comment
ADTeam™
ADTeam™ Mar 21 2013, 12:54pm replied:

Totally love it, anyways :D!

+1 vote     reply to comment
ADTeam™
ADTeam™ Mar 21 2013, 10:36am says:

You look like one of the last real HL modders out there. I totally agree with you, your comment in "EXTINCTION" can't be more accurate.

"Modders" these days are doing "mods" with others work, without giving any credit nor explaining where did they took the model/prop from. Such a shame.

Besides that, I love that flamethrower code, is that yours? Seems like an amazing job!

+1 vote     reply to comment
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
Avatar
Avatar
Offline Since
May 22, 2013
Country
Germany Germany
Gender
Male
Age
26
Member Watch
Track this member
Statistics
Activity Points
115
Rank
14,950 of 328,587
Watchers
1 member
Time Online
1 second
Comments
23
Site Visits
630
Profile Visitors
978 (1 today)
Contact
Private Message
Send Now
Email
Members Only
Trempler
Trempler friends since Mar 22, 2013
the-middleman
the-middleman friends since Mar 21, 2013
ADTeam™
ADTeam™ friends since Mar 21, 2013
ToTac
ToTac friends since Mar 22, 2013