void CNetworkPlayer::UpdateShot( bool bShooting ) { DEBUG_TRACE("CNetworkPlayer::UpdateShot"); // Is the playerped not valid? if( !m_pPlayerPed ) return; // Should we start shooting? if( bShooting && !IsShooting() ) { // Terminate the old shot object if it's valid if ( m_pShootObject ) m_pShootObject->Terminate (); // Delete the old shoot object SAFE_DELETE( m_pShootObject ); // Terminate the old aim object if it's valid if ( m_pAimObject ) m_pAimObject->Terminate (); // Delete the old aim object SAFE_DELETE( m_pAimObject ); // Create the initial shoot sync object if needed m_pShootObject = new CM2SyncObject( m_pPlayerPed->ShootAt( GetLookAt() ) ); // Mark as shooting SetShooting( true ); } // Should we stop shooting? else if( !bShooting && IsShooting() ) { // Terminate the old shot object if it's valid if ( m_pShootObject ) m_pShootObject->Terminate (); // Delete the old aim sync object SAFE_DELETE( m_pShootObject ); // Mark as not shooting SetShooting( false ); // Are we aiming? if( IsAiming() ) { // Mark as not aiming SetAiming( false ); // Update the aim now! UpdateAim( true ); } } // Should we update the aim position else if( bShooting && IsShooting() ) { // Is the aim sync object valid? if( m_pShootObject && !m_pShootObject->IsDone() ) { // Update the aim position m_pShootObject->SetTarget( GetLookAt(), eTargetType::E_TYPE_SHOOT ); } else if( m_pShootObject && m_pShootObject->IsDone() ) { // Mark as not shooting SetShooting( false ); } } }
bool Shooter::IsReady() { return (IsRunning() && !IsShooting() && (motor_timer.Get() > MOTOR_START) && pid_bottom.OnTarget() && pid_top.OnTarget()); }