void CWeaponGravityGun::DeleteActivePellets() { CBaseEntity *pEnt = GetBeamEntity(); for ( int i = 0; i < m_pelletCount; i++ ) { CGravityPellet *pPellet = m_activePellets[i].pellet; if ( !pPellet ) continue; Vector forward; AngleVectors( pPellet->GetAbsAngles(), &forward ); g_pEffects->Dust( pPellet->GetAbsOrigin(), forward, 32, 30 ); // UNDONE: Probably should just do this client side CBeam *pBeam = CBeam::BeamCreate( PHYSGUN_BEAM_SPRITE, 1.5 ); pBeam->PointEntInit( pPellet->GetAbsOrigin(), pEnt ); pBeam->SetEndAttachment( 1 ); pBeam->SetBrightness( 255 ); pBeam->SetColor( 255, 0, 0 ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1 ); UTIL_Remove( pPellet ); } m_pelletCount = 0; }
void GetRenderBounds( Vector& mins, Vector& maxs ) { BaseClass::GetRenderBounds( mins, maxs ); // add to the bounds, don't clear them. // ClearBounds( mins, maxs ); AddPointToBounds( vec3_origin, mins, maxs ); AddPointToBounds( m_targetPosition, mins, maxs ); AddPointToBounds( m_worldPosition, mins, maxs ); CBaseEntity *pEntity = GetBeamEntity(); if ( pEntity ) { mins -= pEntity->GetRenderOrigin(); maxs -= pEntity->GetRenderOrigin(); } }
void CWeaponGravityGun::SecondaryAttack( void ) { m_flNextSecondaryAttack = gpGlobals->curtime + 0.1; if ( m_active ) { EffectDestroy(); SoundDestroy(); return; } CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); Assert( pOwner ); if ( pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0 ) return; m_viewModelIndex = pOwner->entindex(); // Make sure I've got a view model CBaseViewModel *vm = pOwner->GetViewModel(); if ( vm ) { m_viewModelIndex = vm->entindex(); } Vector forward; pOwner->EyeVectors( &forward ); Vector start = pOwner->Weapon_ShootPosition(); Vector end = start + forward * 4096; trace_t tr; UTIL_TraceLine( start, end, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction == 1.0 || (tr.surface.flags & SURF_SKY) ) return; CBaseEntity *pHit = tr.m_pEnt; if ( pHit->entindex() == 0 ) { pHit = NULL; } else { // if the object has no physics object, or isn't a physprop or brush entity, then don't glue if ( !pHit->VPhysicsGetObject() || pHit->GetMoveType() != MOVETYPE_VPHYSICS ) return; } QAngle angles; WeaponSound( SINGLE ); pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType ); VectorAngles( tr.plane.normal, angles ); Vector endPoint = tr.endpos + tr.plane.normal; CGravityPellet *pPellet = (CGravityPellet *)CBaseEntity::Create( "gravity_pellet", endPoint, angles, this ); if ( pHit ) { pPellet->SetParent( pHit ); } AddPellet( pPellet, pHit, tr.plane.normal ); // UNDONE: Probably should just do this client side CBaseEntity *pEnt = GetBeamEntity(); CBeam *pBeam = CBeam::BeamCreate( PHYSGUN_BEAM_SPRITE, 1.5 ); pBeam->PointEntInit( endPoint, pEnt ); pBeam->SetEndAttachment( 1 ); pBeam->SetBrightness( 255 ); pBeam->SetColor( 255, 0, 0 ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1 ); }