You set pEntity equal to null, then two lines later try to access it. Thats your crash, a null pointer exception. Debugging this really would have pointed you to that! :)
Andrew > > Message: 6 > Date: Fri, 19 Dec 2008 20:28:29 +0100 > From: Yorg Kuijs <yorg.ku...@home.nl> > Subject: Re: [hlcoders] VelocityPunch and... what else? > To: Discussion of Half-Life Programming > <hlcoders@list.valvesoftware.com> > Message-ID: <494bf5dd.2060...@home.nl> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > A friend helped me out and pointed me too something usefull, namely a > entity for explosion that specifically has the code for pushing players, > but I haven't got it too work yet, I took the parts I needed but it > crashes on launch > > have been busy all day and need a fresh pair of eyes to look at it, > would ask the other guy but he's offline now > anyway here's the code: > > if( tr.fraction == 1.0 || !(tr.surface.flags & SURF_SKY) ) // this > makes grenade explode on contact > { > //WindDetonate1(); > SailboatEffects(); //smoke cloud on ground touch > CBaseEntity *pEntity = NULL; > Vector vecSpot, vecOrigin; > > if ( pEntity->GetMoveType() == MOVETYPE_VPHYSICS || > (pEntity->VPhysicsGetObject() /*&& !pEntity->IsPlayer()*/) ) // Only > push things if they're physics items > { > vecOrigin = GetAbsOrigin(); > > vecSpot = pEntity->BodyTarget( vecOrigin ); > // Squash this down to a circle > vecOrigin[2] = vecSpot[2]; > > if ( pEntity->IsPlayer() ) > { > Vector vecPushDir = ( pEntity->BodyTarget( > GetAbsOrigin(), false ) - GetAbsOrigin() ); > VectorNormalize( vecPushDir ); > > Vector vecPush = (vecPushDir * 100); > > if ( pEntity->GetFlags() & FL_BASEVELOCITY ) > { > vecPush = vecPush + pEntity->GetBaseVelocity(); > } > //if ( vecPush.z > 0 && (pEntity->GetFlags() & > FL_ONGROUND) ) > //{ > // pEntity->SetGroundEntity( NULL ); > // Vector origin = pEntity->GetAbsOrigin(); > // origin.z += 1.0f; > // pEntity->SetAbsOrigin( origin ); > //} > > pEntity->SetBaseVelocity( vecPush ); // is this the > actual push? > pEntity->AddFlag( FL_BASEVELOCITY ); > } > } > > //Explode( &tr, DMG_BLAST ); // old explosion > } > > > > ------------------------------ > > _______________________________________________ > To unsubscribe, edit your list preferences, or view the list archives, please > visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > > > End of hlcoders Digest, Vol 10, Issue 25 > **************************************** _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders