This member has provided no bio about themself...

Image RSS Feed Latest Screens
OpOrders dm_ship handgrenades
Blog RSS Feed Report abuse Latest Blog: ScrGold/Coding: func_pushable speeds up player

0 comments by PanSartre on Jun 9th, 2013

Here is the Problem: If the player "uses" ( push USE-Key) on a func_pushable, he can speed up himself by strafing or he can push it very fast away ignoring friction of the entity. Here is my fix. New/changed entries are pink.

Open func_break.cpp and go to CPushable::Move:

void CPushable :: Move( CBaseEntity *pOther, int push )
{
    entvars_t*    pevToucher = pOther->pev;
    int playerTouch = 0;

    // Is entity standing on this pushable ?
    if ( FBitSet(pevToucher->flags,FL_ONGROUND) && pevToucher->groundentity && VARS(pevToucher->groundentity) == pev )
    {
        // Only push if floating
        if ( pev->waterlevel > 0 )
            pev->velocity.z += pevToucher->velocity.z * 0.1;

        return;
    }

    if ( pOther->IsPlayer() )
    {
        if ( push && !(pevToucher->button & (IN_FORWARD|IN_USE)) )    // Don't push unless the player is pushing forward and NOT use (pull)
            return;
        playerTouch = 1;
    }

    float factor;

    if ( playerTouch )
    {
        if ( !(pevToucher->flags & FL_ONGROUND) )    // Don't push away from jumping/falling players unless in water
        {
            if ( pev->waterlevel < 1 )
                return;
            else
                factor = 0.1;
        }
        else
            factor = 1;
    }
    else
        factor = 0.25;

    pev->velocity.x += pevToucher->velocity.x * factor;
    pev->velocity.y += pevToucher->velocity.y * factor;

    float length = sqrt( pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y );

    if ( length > MaxSpeed()  ) //if ( push && (length > MaxSpeed()) ) <- this is the old entry. why no fricition (maxspeed) if player uses ( means "push = 0" ) the func_pushable? delete this!
    {
        pev->velocity.x = (pev->velocity.x * MaxSpeed() / length );
        pev->velocity.y = (pev->velocity.y * MaxSpeed() / length );
    }

    if ( playerTouch )
    {
        if ( pevToucher->button & IN_FORWARD ) //we need this! without the entity doesnt stop when player halts. no player movement = no entity movement.
        {
            pevToucher->velocity.x = pev->velocity.x;
            pevToucher->velocity.y = pev->velocity.y;
        }

        if ( (gpGlobals->time - m_soundTime) > 0.7 )
        {
            m_soundTime = gpGlobals->time;
            if ( length > 0 && FBitSet(pev->flags,FL_ONGROUND) )
            {
                m_lastSound = RANDOM_LONG(0,2);
                EMIT_SOUND(ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound], 0.5, ATTN_NORM);
    //            SetThink( StopSound );
    //            pev->nextthink = pev->ltime + 0.1;
            }
            else
                STOP_SOUND( ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound] );
        }
    }
}

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
93%
Gamer
7
Avatar
Avatar
Offline Since
Aug 15, 2014
Country
Germany Germany
Gender
Male
Member Watch
Track this member
Statistics
Activity Points
194
Rank
12,213 of 474,930
Watchers
2 members
Time Online
1 second
Comments
34
Site Visits
1,139
Profile Visitors
2,746 (6 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
kefch0
kefch0 friends since May 17, 2014