コード例 #1
0
ファイル: vehicle_apc.cpp プロジェクト: paralin/hl2sdk
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropAPC::DriveVehicle( float flFrameTime, CUserCmd *ucmd, int iButtonsDown, int iButtonsReleased )
{
	switch( m_lifeState )
	{
	case LIFE_ALIVE:
		{
			int iButtons = ucmd->buttons;
			if ( iButtons & IN_ATTACK )
			{
				FireMachineGun();
			}
			else if ( iButtons & IN_ATTACK2 )
			{
				FireRocket();
			}
		}
		break;

	case LIFE_DYING:
		FireDying( );
		break;

	case LIFE_DEAD:
		return;
	}

	BaseClass::DriveVehicle( flFrameTime, ucmd, iButtonsDown, iButtonsReleased );
}
コード例 #2
0
void CWalkerMiniStrider::WalkerThink()
{
	float dt = GetTimeDelta();

	BaseClass::WalkerThink();

	// Shoot the machine gun?
	if ( !m_bFiringLargeGun )
	{
		if ( m_LastButtons & IN_ATTACK )
		{
			if ( !m_bFiringMachineGun )
				StartFiringMachineGun();
		}
		else if ( m_bFiringMachineGun )
		{
			StopFiringMachineGun();
		}
	}

	// Fire the large gun?
	if ( !m_bFiringMachineGun )
	{
		if ( m_LastButtons & IN_ATTACK2 )
		{
			if ( !m_bFiringLargeGun )
				StartFiringLargeGun();
		}
	}


	UpdateCrouch();

	// Make sure it's crouched when there is no driver.
	if ( GetPassenger( VEHICLE_DRIVER ) )
	{
		if ( m_LastButtons & IN_DUCK )
		{
			Crouch();
		}
		else
		{
			UnCrouch();
		}
	}
	else
	{
		Crouch();
	}

	if ( m_bFiringMachineGun )
	{
		while ( gpGlobals->curtime > m_flNextShootTime )
		{
			FireMachineGun();
		}
	}
	
	UpdateLargeGun();

	// Move our torso within range of our feet.
	if ( m_flOriginToLowestLegHeight != -1 )
	{
		Vector vCenter = WorldSpaceCenter();

		//NDebugOverlay::EntityBounds( this, 255, 100, 0, 0 ,0 );
		//NDebugOverlay::Line( vCenter, vCenter-Vector(0,0,2000), 255,0,0, true, 0 );
		
		trace_t trace;
		UTIL_TraceLine( 
			vCenter, 
			vCenter - Vector( 0, 0, 2000 ),
			MASK_SOLID_BRUSHONLY, 
			this, 
			COLLISION_GROUP_NONE, 
			&trace );

		if ( trace.fraction < 1 )
		{
			m_flWantedZ = trace.endpos.z + m_flOriginToLowestLegHeight;
		}
		
		// Move our Z towards the wanted Z.
		if ( m_flWantedZ != -1 )
		{
			Vector vCur = vCenter;
			vCur.z = Approach( m_flWantedZ, vCur.z, STRIDER_TORSO_VERTICAL_SLIDE_SPEED * dt );
			SetAbsOrigin( GetAbsOrigin() + Vector( 0, 0, vCur.z - vCenter.z ) );
		}		
	}
}