void CPropAPC2::AimSecondaryWeapon(Vector &vecWorldTarget )
{
	//m_hRocketTarget = vecWorldTarget;

	// Update the rocket target
	CreateAPCLaserDot();

	if ( m_hRocketTarget )
	{
		m_hLaserDot->SetAbsOrigin( m_hRocketTarget->BodyTarget( WorldSpaceCenter(), false ) );
	}
	SetLaserDotTarget( m_hLaserDot, m_hRocketTarget );
	EnableLaserDot( m_hLaserDot, m_hRocketTarget != NULL );
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Aims the secondary weapon at a target 
//-----------------------------------------------------------------------------
void CPropAPC::AimSecondaryWeaponAt( CBaseEntity *pTarget )
{
	m_hRocketTarget = pTarget;

	// Update the rocket target
	CreateAPCLaserDot();

	if ( m_hRocketTarget )
	{
		m_hLaserDot->SetAbsOrigin( m_hRocketTarget->BodyTarget( WorldSpaceCenter(), false ) );
	}
	SetLaserDotTarget( m_hLaserDot, m_hRocketTarget );
	EnableLaserDot( m_hLaserDot, m_hRocketTarget != NULL );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropAPC2::Think( void )
{
	if (!m_bSpawn) {
		if(m_fReloadTime<=gpGlobals->curtime && m_iAmmoCount<50) {
		m_iAmmoCount++;
		m_fReloadTime=gpGlobals->curtime+0.5f;
	}
	if(m_fCannonCharge<=gpGlobals->curtime && m_iCannonCount<100) {
		m_iCannonCount++;
		m_fCannonCharge=gpGlobals->curtime+0.03f;
	}
	BaseClass::Think();

	CBasePlayer	*pPlayer = UTIL_GetLocalPlayer();

	if ( m_bEngineLocked )
	{
		m_bUnableToFire = true;
		
		if ( pPlayer != NULL )
		{
			pPlayer->m_Local.m_iHideHUD |= HIDEHUD_VEHICLE_CROSSHAIR;
		}
	}
	else
	{
		// Start this as false and update it again each frame
		m_bUnableToFire = false;

		if ( pPlayer != NULL )
		{
			pPlayer->m_Local.m_iHideHUD &= ~HIDEHUD_VEHICLE_CROSSHAIR;
		}
	}

	SetNextThink( gpGlobals->curtime );

	if ( !m_bInitialHandbrake )	// after initial timer expires, set the handbrake
	{
		m_bInitialHandbrake = true;
		m_VehiclePhysics.SetHandbrake( true );
		m_VehiclePhysics.Think();
	}

	StudioFrameAdvance();

	if ( IsSequenceFinished() )
	{
		int iSequence = SelectWeightedSequence( ACT_IDLE );
		if ( iSequence > ACTIVITY_NOT_AVAILABLE )
		{
			SetCycle( 0 );
			m_flAnimTime = gpGlobals->curtime;
			ResetSequence( iSequence );
			ResetClientsideFrame();
		}
	}
	if ( m_hPlayer && !m_bExitAnimOn && !m_bEnterAnimOn )
	{
		Vector vecEyeDir, vecEyePos;
		m_hPlayer->EyePositionAndVectors( &vecEyePos, &vecEyeDir, NULL, NULL );

		// Trace out from the player's eye point.
		Vector	vecEndPos = vecEyePos + ( vecEyeDir * MAX_TRACE_LENGTH );
		trace_t	trace;
		UTIL_TraceLine( vecEyePos, vecEndPos, MASK_SHOT, this, COLLISION_GROUP_NONE, &trace );

		// See if we hit something, if so, adjust end position to hit location.
		if ( trace.fraction < 1.0 )
		{
   			vecEndPos = vecEyePos + ( vecEyeDir * MAX_TRACE_LENGTH * trace.fraction );
		}

		//m_vecLookCrosshair = vecEndPos;
		m_vecGunCrosshair=vecEndPos;
		AimPrimaryWeapon( vecEndPos );
		//GetRocketShootPosition( &vecEndPos );
		if ( m_hLaserDot != NULL )
		{
			Vector	laserPos = trace.endpos;
			m_hLaserDot->SetAbsOrigin(laserPos);
			
			if ( trace.DidHitNonWorldEntity() )
			{
				CBaseEntity *pHit = trace.m_pEnt;

				if ( ( pHit != NULL ) && ( pHit->m_takedamage ) )
				{
					SetLaserDotTarget( m_hLaserDot, pHit );
					EnableLaserDot( m_hLaserDot, pHit != NULL );
					
				}
				else
				{
					SetLaserDotTarget( m_hLaserDot, NULL );
					EnableLaserDot(m_hLaserDot,true);
					
				}
			}
			else
			{
				SetLaserDotTarget( m_hLaserDot, NULL );
				EnableLaserDot(m_hLaserDot,true);
			}
		}
		
	}
	}
}