void CWeaponGravityGun::WeaponIdle( void ) { if ( HasWeaponIdleTimeElapsed() ) { SendWeaponAnim( ACT_VM_IDLE ); if ( m_active ) { CBaseEntity *pObject = m_hObject; // pellet is touching object, so glue it if ( pObject && m_glueTouching ) { CGravityPellet *pPellet = m_activePellets[m_pelletAttract].pellet; if ( pPellet->MakeConstraint( pObject ) ) { WeaponSound( SPECIAL1 ); m_flNextPrimaryAttack = gpGlobals->curtime + 0.75; m_activePellets[m_pelletHeld].pellet->MakeInert(); } } EffectDestroy(); SoundDestroy(); } } }
void Drop(const Vector &vecVelocity) { EffectDestroy(); SoundDestroy(); #ifndef CLIENT_DLL UTIL_Remove( this ); #endif }
void CWeaponGravityGun::ItemPostFrame( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if (!pOwner) return; if ( pOwner->m_nButtons & IN_ATTACK ) { if ( pOwner->m_afButtonPressed & IN_ATTACK2 ) { SecondaryAttack(); } else if ( pOwner->m_nButtons & IN_ATTACK2 ) { if ( m_active ) { EffectDestroy(); SoundDestroy(); } WeaponIdle( ); return; } PrimaryAttack(); } else { if ( m_active ) { EffectDestroy(); SoundDestroy(); } WeaponIdle( ); return; } if ( pOwner->m_afButtonPressed & IN_RELOAD ) { Reload(); } }
virtual bool Holster( CBaseCombatWeapon *pSwitchingTo ) { EffectDestroy(); return BaseClass::Holster(); }
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 ); }
//----------------------------------------------------------------------------- // On Remove //----------------------------------------------------------------------------- void CWeaponGravityGun::UpdateOnRemove(void) { EffectDestroy(); SoundDestroy(); BaseClass::UpdateOnRemove(); }
void CWeaponGravityGun::ItemPostFrame( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if (!pOwner) return; #ifdef ARGG // adnan // this is where we check if we're orbiting the object // if we're holding something and pressing use, // then set us in the orbiting state // - this will indicate to OverrideMouseInput that we should zero the input and update our delta angles // UPDATE: not anymore. now this just sets our state variables. CBaseEntity *pObject = m_hObject; if( pObject ) { if((pOwner->m_nButtons & IN_ATTACK) && (pOwner->m_nButtons & IN_USE) ) { m_gravCallback.m_bHasRotatedCarryAngles = true; // did we JUST hit use? // if so, grab the current angles to begin with as the rotated angles if( !(pOwner->m_afButtonLast & IN_USE) ) { m_gravCallback.m_vecRotatedCarryAngles = pObject->GetAbsAngles(); } m_bIsCurrentlyRotating = true; } else { m_gravCallback.m_bHasRotatedCarryAngles = false; m_bIsCurrentlyRotating = false; } } else { m_bIsCurrentlyRotating = false; m_gravCallback.m_bHasRotatedCarryAngles = false; } // end adnan #endif if ( pOwner->m_nButtons & IN_ATTACK ) { #if defined( ARGG ) if( (pOwner->m_nButtons & IN_USE) ) { pOwner->m_vecUseAngles = pOwner->pl.v_angle; } #endif if ( pOwner->m_afButtonPressed & IN_ATTACK2 ) { SecondaryAttack(); } else if ( pOwner->m_nButtons & IN_ATTACK2 ) { if ( m_active ) { EffectDestroy(); SoundDestroy(); } WeaponIdle( ); return; } PrimaryAttack(); } else { if ( m_active ) { EffectDestroy(); SoundDestroy(); } WeaponIdle( ); return; } if ( pOwner->m_afButtonPressed & IN_RELOAD ) { Reload(); } }