예제 #1
0
//=========================================================
// Spawn
//=========================================================
void CGenericActor::Spawn()
{
    Precache();

    SetModel( STRING( GetModelName() ) );

    /*
    	if ( FStrEq( STRING( GetModelName() ), "models/player.mdl" ) )
    		UTIL_SetSize(this, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);
    	else
    		UTIL_SetSize(this, VEC_HULL_MIN, VEC_HULL_MAX);
    */

    if ( FStrEq( STRING( GetModelName() ), "models/player.mdl" ) ||
            FStrEq( STRING( GetModelName() ), "models/holo.mdl" ) ||
            FStrEq( STRING( GetModelName() ), "models/blackout.mdl" ) )
    {
        UTIL_SetSize(this, VEC_HULL_MIN, VEC_HULL_MAX);
    }
    else
    {
        UTIL_SetSize(this, NAI_Hull::Mins(HULL_HUMAN), NAI_Hull::Maxs(HULL_HUMAN));
    }

    if ( !FStrEq( STRING( GetModelName() ), "models/blackout.mdl" ) )
    {
        SetSolid( SOLID_BBOX );
        AddSolidFlags( FSOLID_NOT_STANDABLE );
    }
    else
    {
        SetSolid( SOLID_NONE );
    }

    SetMoveType( MOVETYPE_STEP );
    SetBloodColor( BLOOD_COLOR_RED );
    m_iHealth			= 8;
    m_flFieldOfView		= 0.5;// indicates the width of this NPC's forward view cone ( as a dotproduct result )
    m_NPCState			= NPC_STATE_NONE;

    CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_OPEN_DOORS );

    // remove head turn if no eyes or forward attachment
    if (LookupAttachment( "eyes" ) > 0 && LookupAttachment( "forward" ) > 0)
    {
        CapabilitiesAdd(  bits_CAP_TURN_HEAD | bits_CAP_ANIMATEDFACE );
    }

    if (m_strHullName != NULL_STRING)
    {
        SetHullType( NAI_Hull::LookupId( STRING( m_strHullName ) ) );
    }
    else
    {
        SetHullType( HULL_HUMAN );
    }
    SetHullSizeNormal( );

    NPCInit();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CNPC_Portal_FloorTurret::Activate( void )
{
	BaseClass::Activate();

	// Find all nearby physics objects and add them to the list of objects we will sense
	CBaseEntity *pObject = gEntList.FindEntityByClassname( NULL, "prop_physics" );
	while ( pObject )
	{
		// Tell the AI sensing list that we want to consider this
		g_AI_SensedObjectsManager.AddEntity( pObject );

		pObject = gEntList.FindEntityByClassname( pObject, "prop_physics" );
	}

	pObject = gEntList.FindEntityByClassname( NULL, "func_physbox" );
	while ( pObject )
	{
		// Tell the AI sensing list that we want to consider this
		g_AI_SensedObjectsManager.AddEntity( pObject );

		pObject = gEntList.FindEntityByClassname( pObject, "func_physbox" );
	}

	m_iLastState = TURRET_AUTO_SEARCHING;

	m_iBarrelAttachments[ 0 ] = LookupAttachment( "LFT_Gun1_Muzzle" );
	m_iBarrelAttachments[ 1 ] = LookupAttachment( "RT_Gun1_Muzzle" );
	m_iBarrelAttachments[ 2 ] = LookupAttachment( "LFT_Gun2_Muzzle" );
	m_iBarrelAttachments[ 3 ] = LookupAttachment( "RT_Gun2_Muzzle" );
}
예제 #3
0
void CASW_Zombie::CreateEyeGlows( void )
{
	//Create our Eye sprites
	if ( m_pEyeGlow[0] == NULL )
	{
		m_pEyeGlow[0] = CSprite::SpriteCreate( ZOMBIE_GLOW_SPRITE, GetLocalOrigin(), false );
		m_pEyeGlow[0]->SetAttachment( this, LookupAttachment( "LeftEye" ) );
	
		m_pEyeGlow[0]->SetTransparency( kRenderTransAdd, 128, 0, 0, 128, kRenderFxNoDissipation );
		m_pEyeGlow[0]->SetBrightness( 164, 0.1f );
		m_pEyeGlow[0]->SetScale( 0.1f, 0.1f );
		m_pEyeGlow[0]->SetColor( 128, 0, 0 );
		m_pEyeGlow[0]->SetAsTemporary();
	}
	if ( m_pEyeGlow[1] == NULL )
	{
		m_pEyeGlow[1] = CSprite::SpriteCreate( ZOMBIE_GLOW_SPRITE, GetLocalOrigin(), false );
		m_pEyeGlow[1]->SetAttachment( this, LookupAttachment( "RightEye" ) );
		
		m_pEyeGlow[1]->SetTransparency( kRenderTransAdd, 128, 0, 0, 128, kRenderFxNoDissipation );
		m_pEyeGlow[1]->SetBrightness( 164, 0.1f );
		m_pEyeGlow[1]->SetScale( 0.1f, 0.1f );
		m_pEyeGlow[1]->SetColor( 128, 0, 0 );
		m_pEyeGlow[1]->SetAsTemporary();
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CObjectBuffStation::InitAttachmentData( void )
{
	// Initialize the attachment data.
	char szAttachName[13];

	m_nPlayerCount = 0;
	Q_strncpy( szAttachName, "playercable1", 13 );
	for ( int iPlayer = 0; iPlayer < BUFF_STATION_MAX_PLAYERS; ++iPlayer )
	{
		m_hPlayers.Set( iPlayer, NULL );

		szAttachName[11] = '1' + iPlayer;
		m_aPlayerAttachInfo[iPlayer].m_iAttachPoint = LookupAttachment( szAttachName );
	}

	m_nObjectCount = 0;
	Q_strncpy( szAttachName, "objectcable1", 13 );	
	for ( int iObject = 0; iObject < BUFF_STATION_MAX_OBJECTS; ++iObject )
	{
		m_hObjects.Set( iObject, NULL );

		szAttachName[11] = '1' + iObject;
		m_aObjectAttachInfo[iObject].m_iAttachPoint = LookupAttachment( szAttachName );
	}
}
예제 #5
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &startPos - 
//			&endPos - 
//			width - 
//			useMuzzle - 
//-----------------------------------------------------------------------------
void CASW_PropJeep::DrawBeam( const Vector &startPos, const Vector &endPos, float width )
{
	//Tracer down the middle
	UTIL_Tracer( startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer" );

	//Draw the main beam shaft
	CBeam *pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, 0.5 );
	
	pBeam->SetStartPos( startPos );
	pBeam->PointEntInit( endPos, this );
	pBeam->SetEndAttachment( LookupAttachment("Muzzle") );
	pBeam->SetWidth( width );
	pBeam->SetEndWidth( 0.05f );
	pBeam->SetBrightness( 255 );
	pBeam->SetColor( 255, 185+random->RandomInt( -16, 16 ), 40 );
	pBeam->RelinkBeam();
	pBeam->LiveForTime( 0.1f );

	//Draw electric bolts along shaft
	pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, 3.0f );
	
	pBeam->SetStartPos( startPos );
	pBeam->PointEntInit( endPos, this );
	pBeam->SetEndAttachment( LookupAttachment("Muzzle") );

	pBeam->SetBrightness( random->RandomInt( 64, 255 ) );
	pBeam->SetColor( 255, 255, 150+random->RandomInt( 0, 64 ) );
	pBeam->RelinkBeam();
	pBeam->LiveForTime( 0.1f );
	pBeam->SetNoise( 1.6f );
	pBeam->SetEndWidth( 0.1f );
}
예제 #6
0
void CObjectSentrygun::FinishUpgrading( void )
{
	m_iState.Set( SENTRY_STATE_SEARCHING );
	m_hEnemy = NULL;

	switch( m_iUpgradeLevel )
	{
	case 1:
		SetModel( SENTRY_MODEL_LEVEL_1 );
		break;
	case 2:
		SetModel( SENTRY_MODEL_LEVEL_2 );
		break;
	case 3:
		SetModel( SENTRY_MODEL_LEVEL_3 );
		break;
	default:
		Assert(0);
		break;
	}

	// Look up the new attachments
	m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE] = LookupAttachment( "muzzle_l" );
	m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE_ALT] = LookupAttachment( "muzzle_r" );
	m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_L] = LookupAttachment( "rocket_l" );
	m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_R] = LookupAttachment( "rocket_r" );

	BaseClass::FinishUpgrading();
}
예제 #7
0
//-----------------------------------------------------------------------------
// Purpose: Sets up the attachment point lookup for the model
//-----------------------------------------------------------------------------
void C_WeaponStunStick::SetupAttachmentPoints( void )
{
	// Setup points for both types of views
	if ( ShouldDrawUsingViewModel() )
	{
		const char *szBeamAttachNamesTop[NUM_BEAM_ATTACHMENTS] =
		{
			"spark1a","spark2a","spark3a","spark4a",
			"spark5a","spark6a","spark7a","spark8a",
			"spark9a",
		};

		const char *szBeamAttachNamesBottom[NUM_BEAM_ATTACHMENTS] =
		{
			"spark1b","spark2b","spark3b","spark4b",
			"spark5b","spark6b","spark7b","spark8b",
			"spark9b",
		};
		
		// Lookup and store all connections
		for ( int i = 0; i < NUM_BEAM_ATTACHMENTS; i++ )
		{
			m_BeamAttachments[i].IDs[0] = LookupAttachment( szBeamAttachNamesTop[i] );
			m_BeamAttachments[i].IDs[1] = LookupAttachment( szBeamAttachNamesBottom[i] );
		}

		// Setup the center beam point
		m_BeamCenterAttachment = LookupAttachment( BEAM_ATTACH_CORE_NAME );
	}
	else
	{
		// Setup the center beam point
		m_BeamCenterAttachment = 1;
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponGauss::DrawBeam( const Vector &startPos, const Vector &endPos, float width, bool useMuzzle )
{

#ifndef CLIENT_DLL

	//Draw the main beam shaft
	CBeam *m_pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, width );

	if ( useMuzzle )
	{
		m_pBeam->PointEntInit( endPos, this );
		m_pBeam->SetEndAttachment( LookupAttachment("Muzzle") );
		m_pBeam->SetWidth( width / 4.0f );
		m_pBeam->SetEndWidth( width );
		m_pBeam->RelinkBeam();
	}

	else
	{
		m_pBeam->SetStartPos( startPos );
		m_pBeam->SetEndPos( endPos );
		m_pBeam->SetWidth( width );
		m_pBeam->SetEndWidth( width / 4.0f );
		m_pBeam->RelinkBeam();
	}
	m_pBeam->SetBrightness( 255 );
	m_pBeam->SetColor( 255, 145+random->RandomInt( -16, 16 ), 0 );
	m_pBeam->LiveForTime( 0.1f );
	m_pBeam->RelinkBeam();
	//Draw electric bolts along shaft
	for ( int i = 0; i < 3; i++ )
	{
		m_pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, (width/2.0f) + i );
		
		if ( useMuzzle )
		{
			m_pBeam->PointEntInit( endPos, this );
			m_pBeam->SetEndAttachment( LookupAttachment("Muzzle") );
			m_pBeam->RelinkBeam();
		}
		else
		{
			m_pBeam->SetStartPos( startPos );
			m_pBeam->SetEndPos( endPos );
			m_pBeam->RelinkBeam();
		}
		m_pBeam->SetBrightness( random->RandomInt( 64, 255 ) );
	    m_pBeam->SetColor( 255, 255, 150+random->RandomInt( 0, 64 ) );
		m_pBeam->LiveForTime( 0.1f );
		m_pBeam->SetNoise( 1.6f * i );
		m_pBeam->SetEndWidth( 0.1f );
		m_pBeam->RelinkBeam();
	}
#endif
return;
}
예제 #9
0
	int CWeaponElite::GetMuzzleAttachment( void )
	{
		if ( m_bFireRight )  //even number
		{
			return LookupAttachment( "muzzle_flash_r" );
		}
		else
		{
			return LookupAttachment( "muzzle_flash_l" );	
		}
	}
void QUA_helicopter::Activate() {
	BaseClass::Activate();
	m_nGunBaseAttachment = LookupAttachment("gun");
	m_nMachineGunMuzzleAttachment = LookupAttachment( "muzzle" );
	m_nBombAttachment=LookupAttachment("Bomb");
	Vector vecWorldBarrelPos;
	QAngle worldBarrelAngle;
	matrix3x4_t matRefToWorld;
	GetAttachment( m_nMachineGunMuzzleAttachment, vecWorldBarrelPos, worldBarrelAngle );
	GetAttachment(m_nGunBaseAttachment, matRefToWorld );
	VectorITransform( vecWorldBarrelPos, matRefToWorld, m_vecBarrelPos );
}
//-----------------------------------------------------------------------------
// Sets up various attachment points once the model is selected 
//-----------------------------------------------------------------------------
void CObjectBaseMannedGun::OnModelSelected()
{
	m_nBarrelAttachment = LookupAttachment( "barrel" );
	m_nBarrelPivotAttachment = LookupAttachment( "barrelpivot" );
	m_nStandAttachment = LookupAttachment( "vehicle_feet_passenger0" );
	m_nEyesAttachment = LookupAttachment( "vehicle_eyes_passenger0" );

	// Find the barrel height in its quiescent state...
	Vector vBarrel;
	QAngle vBarrelAngles;
	GetAttachmentLocal( m_nBarrelAttachment, vBarrel, vBarrelAngles );
	m_flBarrelHeight = vBarrel.z;
}
//-----------------------------------------------------------------------------
// Purpose: the entity
//-----------------------------------------------------------------------------
void CNPC_RocketTurret::Spawn( void )
{ 
	Precache();

	BaseClass::Spawn();

	SetViewOffset( vec3_origin );

	AddEFlags( EFL_NO_DISSOLVE );

	SetModel( ROCKET_TURRET_MODEL_NAME );
	SetSolid( SOLID_VPHYSICS );

	m_iMuzzleAttachment = LookupAttachment ( "barrel" );
	m_iLightAttachment = LookupAttachment ( "eye" );

	m_iPosePitch = LookupPoseParameter( "aim_pitch" );
	m_iPoseYaw   = LookupPoseParameter( "aim_yaw" );

	m_vecCurrentAngles = m_vecGoalAngles = GetAbsAngles();

	CreateVPhysics();

	//Set our autostart state
	m_bEnabled	 = ( ( m_spawnflags & SF_ROCKET_TURRET_START_INACTIVE ) == false );

	// Set Locked sprite
	if ( m_bEnabled )
	{
		m_iLaserState = 1;
		SetSequence(LookupSequence("idle"));
	}
	else
	{
		m_iLaserState = 0;
		SetSequence(LookupSequence("inactive"));
	}
	SetCycle(1.0f);
	UpdateSkin( ROCKET_SKIN_IDLE );

	SetPoseParameter( "aim_pitch", 0 );
	SetPoseParameter( "aim_yaw", -180 );

	if ( m_bEnabled )
	{
		SetThink( &CNPC_RocketTurret::FollowThink );
	}
	
	SetNextThink( gpGlobals->curtime + ROCKET_TURRET_THINK_RATE );
}
예제 #13
0
//-----------------------------------------------------------------------------
// Purpose: Spawn the entity
//-----------------------------------------------------------------------------
void CNPC_Portal_FloorTurret::Spawn( void )
{ 
	BaseClass::Spawn();

	m_iBarrelAttachments[ 0 ] = LookupAttachment( "LFT_Gun1_Muzzle" );
	m_iBarrelAttachments[ 1 ] = LookupAttachment( "RT_Gun1_Muzzle" );
	m_iBarrelAttachments[ 2 ] = LookupAttachment( "LFT_Gun2_Muzzle" );
	m_iBarrelAttachments[ 3 ] = LookupAttachment( "RT_Gun2_Muzzle" );

	m_fSearchSpeed = RandomFloat( 1.0f, 1.4f );
	m_fMovingTargetThreashold = 20.0f;

	m_bNoAlarmSounds = true;
	m_bOutOfAmmo = ( m_spawnflags & SF_FLOOR_TURRET_OUT_OF_AMMO ) != 0;
}
예제 #14
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CASW_PropJeep::CheckWaterLevel( void )
{
	CBaseEntity *pEntity = GetDriver();
	if ( pEntity && pEntity->IsPlayer() )
	{
		CBasePlayer *pPlayer = static_cast<CBasePlayer*>( pEntity );
		
		Vector vecAttachPoint;
		QAngle vecAttachAngles;
		
		// Check eyes. (vehicle_driver_eyes point)
		int iAttachment = LookupAttachment( "vehicle_driver_eyes" );
		GetAttachment( iAttachment, vecAttachPoint, vecAttachAngles );

		// Add the jeep's Z view offset
		Vector vecUp;
		AngleVectors( vecAttachAngles, NULL, NULL, &vecUp );
		vecUp.z = clamp( vecUp.z, 0.0f, vecUp.z );
		vecAttachPoint.z += r_JeepViewZHeight.GetFloat() * vecUp.z;

		bool bEyes = ( UTIL_PointContents( vecAttachPoint, MASK_WATER ) & MASK_WATER ) ? true : false;
		if ( bEyes )
		{
			pPlayer->SetWaterLevel( WL_Eyes );
			return;
		}

		// Check waist.  (vehicle_engine point -- see parent function).
		if ( m_WaterData.m_bBodyInWater )
		{
			pPlayer->SetWaterLevel( WL_Waist );
			return;
		}

		// Check feet. (vehicle_feet_passenger0 point)
		iAttachment = LookupAttachment( "vehicle_feet_passenger0" );
		GetAttachment( iAttachment, vecAttachPoint, vecAttachAngles );
		bool bFeet = ( UTIL_PointContents( vecAttachPoint, MASK_WATER ) & MASK_WATER ) ? true : false;
		if ( bFeet )
		{
			pPlayer->SetWaterLevel( WL_Feet );
			return;
		}

		// Not in water.
		pPlayer->SetWaterLevel( WL_NotInWater );
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_PropVehicleDriveable::RestrictView( float *pYawBounds, float *pPitchBounds,
										   float *pRollBounds, QAngle &vecViewAngles )
{
	int eyeAttachmentIndex = LookupAttachment( "vehicle_driver_eyes" );
	Vector vehicleEyeOrigin;
	QAngle vehicleEyeAngles;
	GetAttachmentLocal( eyeAttachmentIndex, vehicleEyeOrigin, vehicleEyeAngles );

	// Limit the yaw.
	if ( pYawBounds )
	{
		float flAngleDiff = AngleDiff( vecViewAngles.y, vehicleEyeAngles.y );
		flAngleDiff = clamp( flAngleDiff, pYawBounds[0], pYawBounds[1] );
		vecViewAngles.y = vehicleEyeAngles.y + flAngleDiff;
	}

	// Limit the pitch.
	if ( pPitchBounds )
	{
		float flAngleDiff = AngleDiff( vecViewAngles.x, vehicleEyeAngles.x );
		flAngleDiff = clamp( flAngleDiff, pPitchBounds[0], pPitchBounds[1] );
		vecViewAngles.x = vehicleEyeAngles.x + flAngleDiff;
	}

	// Limit the roll.
	if ( pRollBounds )
	{
		float flAngleDiff = AngleDiff( vecViewAngles.z, vehicleEyeAngles.z );
		flAngleDiff = clamp( flAngleDiff, pRollBounds[0], pRollBounds[1] );
		vecViewAngles.z = vehicleEyeAngles.z + flAngleDiff;
	}
}
예제 #16
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pOperator - 
//-----------------------------------------------------------------------------
void CWeaponAR2::FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, bool bUseWeaponAngles )
{
	Vector vecShootOrigin, vecShootDir;

	CAI_BaseNPC *npc = pOperator->MyNPCPointer();
	ASSERT( npc != NULL );

	if ( bUseWeaponAngles )
	{
		QAngle	angShootDir;
		GetAttachment( LookupAttachment( "muzzle" ), vecShootOrigin, angShootDir );
		AngleVectors( angShootDir, &vecShootDir );
	}
	else 
	{
		vecShootOrigin = pOperator->Weapon_ShootPosition();
		vecShootDir = npc->GetActualShootTrajectory( vecShootOrigin );
	}

	WeaponSoundRealtime( SINGLE_NPC );

	CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_MACHINEGUN, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() );

	pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2 );

	// NOTENOTE: This is overriden on the client-side
	// pOperator->DoMuzzleFlash();

	m_iClip1 = m_iClip1 - 1;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPropAirboat::FireGun( void )
{
	// Trace from eyes and see what we hit.
	Vector vecEyeDirection;
	m_hPlayer->EyeVectors( &vecEyeDirection, NULL, NULL );
	Vector vecEndPos = m_hPlayer->EyePosition() + ( vecEyeDirection * MAX_TRACE_LENGTH );
	trace_t	trace;
	UTIL_TraceLine( m_hPlayer->EyePosition(), vecEndPos, MASK_SHOT, this, COLLISION_GROUP_NONE, &trace );

	if ( trace.m_pEnt )
	{
		// Get the gun position.
		Vector	vecGunPosition;
		QAngle	vecGunAngles;
		GetAttachment( LookupAttachment( "gun_barrel" ), vecGunPosition, vecGunAngles );
		
		// Get a ray from the gun to the target.
		Vector vecRay = trace.endpos - vecGunPosition;
		VectorNormalize( vecRay );
		
		CAmmoDef *pAmmoDef = GetAmmoDef();
		int ammoType = pAmmoDef->Index( "MediumRound" );
		FireBullets( 1, vecGunPosition, vecRay, vec3_origin, 4096, ammoType );
	}
}
예제 #18
0
void CNPC_Dog::CreateBeams( void )
{
	if ( m_bBeamEffects == false )
	{
		ClearBeams();
		return;
	}

	CreateSprites();

	for ( int i = 0; i < EFFECT_COUNT; i++ )
	{
		if ( m_hBeams[i] )
			continue;

		const char *attachNames[] = 
		{
			"physgun",
			"thumb",
			"pinky",
			"index",
		};

		m_hBeams[i] = CBeam::BeamCreate( "sprites/physcannon_bluelight2.vmt", 5.0 );

		m_hBeams[i]->EntsInit( m_hPhysicsEnt, this );
		m_hBeams[i]->SetEndAttachment( LookupAttachment( attachNames[i] ) );
		m_hBeams[i]->SetBrightness( 255 );
		m_hBeams[i]->SetColor( 255, 255, 255 );
		m_hBeams[i]->SetNoise( 5.5 );
		m_hBeams[i]->SetRenderMode( kRenderTransAdd );
	}

}
예제 #19
0
//-----------------------------------------------------------------------------
// Get a position in *world space* inside the vehicle for the player to start at
//-----------------------------------------------------------------------------
void CBaseTFVehicle::GetPassengerStartPoint( int nRole, Vector *pAbsPoint, QAngle *pAbsAngles )
{
	char pAttachmentName[32];
	Q_snprintf( pAttachmentName, sizeof( pAttachmentName ), "vehicle_feet_passenger%d", nRole );
	int nFeetAttachmentIndex = LookupAttachment(pAttachmentName);
	GetAttachment( nFeetAttachmentIndex, *pAbsPoint, *pAbsAngles );
}
예제 #20
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CAntlionGrub::CreateNugget( void )
{
	CGrubNugget *pNugget = (CGrubNugget *) CreateEntityByName( "item_grubnugget" );
	if ( pNugget == NULL )
		return;

	Vector vecOrigin;
	Vector vecForward;
	GetAttachment( LookupAttachment( "glow" ), vecOrigin, &vecForward );

	// Find out what size to make this nugget!
	int nDenomination = GetNuggetDenomination();
	pNugget->SetDenomination( nDenomination );
	
	pNugget->SetAbsOrigin( vecOrigin );
	pNugget->SetAbsAngles( RandomAngle( 0, 360 ) );
	DispatchSpawn( pNugget );

	IPhysicsObject *pPhys = pNugget->VPhysicsGetObject();
	if ( pPhys )
	{
		Vector vecForward;
		GetVectors( &vecForward, NULL, NULL );
		
		Vector vecVelocity = RandomVector( -35.0f, 35.0f ) + ( vecForward * -RandomFloat( 50.0f, 75.0f ) );
		AngularImpulse vecAngImpulse = RandomAngularImpulse( -100.0f, 100.0f );

		pPhys->AddVelocity( &vecVelocity, &vecAngImpulse );
	}
}
void CEnvEffectsScript::TrailEffectEvent( CEffectScriptElement *pEffect )
{
	if ( pEffect->IsActive() == false )
	{
		//Only one type of this effect active at a time.
		if ( pEffect->m_pTrail == NULL )
		{
			pEffect->m_pTrail = CSpriteTrail::SpriteTrailCreate( pEffect->m_szMaterial, GetAbsOrigin(), true );
			pEffect->m_pTrail->FollowEntity( this );
			pEffect->m_pTrail->SetTransparency( pEffect->m_iRenderType, pEffect->m_iR, pEffect->m_iG, pEffect->m_iB, pEffect->m_iA, kRenderFxNone );
			pEffect->m_pTrail->SetStartWidth( pEffect->m_flScale );
			if ( pEffect->m_flTextureRes < 0.0f )
			{
				pEffect->m_pTrail->SetTextureResolution( 1.0f / ( 16.0f * pEffect->m_flScale ) );
			}
			else
			{
				pEffect->m_pTrail->SetTextureResolution( pEffect->m_flTextureRes );
			}
			pEffect->m_pTrail->SetLifeTime( pEffect->m_flFadeTime );
			pEffect->m_pTrail->TurnOn();
			pEffect->m_pTrail->SetAttachment( this, LookupAttachment( pEffect->m_szAttachment ) );

			pEffect->Activate();
		}
	}
}
예제 #22
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CGrenadeFrag::CreateEffects( void )
{
	// Start up the eye glow
	m_pMainGlow = CSprite::SpriteCreate( "sprites/redglow1.vmt", GetLocalOrigin(), false );

	int	nAttachment = LookupAttachment( "fuse" );

	if ( m_pMainGlow != NULL )
	{
		m_pMainGlow->FollowEntity( this );
		m_pMainGlow->SetAttachment( this, nAttachment );
		m_pMainGlow->SetTransparency( kRenderGlow, 255, 255, 255, 200, kRenderFxNoDissipation );
		m_pMainGlow->SetScale( 0.2f );
		m_pMainGlow->SetGlowProxySize( 4.0f );
	}

	// Start up the eye trail
	m_pGlowTrail	= CSpriteTrail::SpriteTrailCreate( "sprites/bluelaser1.vmt", GetLocalOrigin(), false );

	if ( m_pGlowTrail != NULL )
	{
		m_pGlowTrail->FollowEntity( this );
		m_pGlowTrail->SetAttachment( this, nAttachment );
		m_pGlowTrail->SetTransparency( kRenderTransAdd, 255, 0, 0, 255, kRenderFxNone );
		m_pGlowTrail->SetStartWidth( 8.0f );
		m_pGlowTrail->SetEndWidth( 1.0f );
		m_pGlowTrail->SetLifeTime( 0.5f );
	}
}
예제 #23
0
void CWeaponMomentumGun::DrawBeam(const Vector &startPos, const Vector &endPos, float width)
{
	//Tracer down the middle
	UTIL_Tracer(startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer");

	//Draw the main beam shaft
	CBeam *pBeam = CBeam::BeamCreate("sprites/orangelight1.vmt", 15.5);

	// It starts at startPos
	pBeam->SetStartPos(startPos);

	// This sets up some things that the beam uses to figure out where
	// it should start and end
	pBeam->PointEntInit(endPos, this);

	// This makes it so that the laser appears to come from the muzzle of the pistol
	pBeam->SetEndAttachment(LookupAttachment("Muzzle"));
	pBeam->SetWidth(width);
	//	pBeam->SetEndWidth( 0.05f );

	// Higher brightness means less transparent
	pBeam->SetBrightness(255);
	pBeam->SetColor(255, 185 + random->RandomInt(-16, 16), 40);
	pBeam->RelinkBeam();

	// The beam should only exist for a very short time
	pBeam->LiveForTime(0.1f);
}
예제 #24
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool C_WeaponPhysCannon::SetupEmitter( void )
{
	if ( !m_pLocalEmitter.IsValid() )
	{
		m_pLocalEmitter = CLocalSpaceEmitter::Create( "physpowerup", GetRefEHandle(), LookupAttachment( "core" ) );

		if ( m_pLocalEmitter.IsValid() == false )
			return false;
	}

	if ( !m_pAttractor.IsValid() )
	{
		m_pAttractor = CParticleAttractor::Create( vec3_origin, "physpowerup_att" );

		if ( m_pAttractor.IsValid() == false )
			return false;
	}

	if ( !m_pEmitter.IsValid() )
	{
		m_pEmitter = CSimpleEmitter::Create( "physpowerup_glow" );

		if ( m_pEmitter.IsValid() == false )
			return false;
	}

	return true;
}
//-----------------------------------------------------------------------------
// Purpose: Blend view angles.
//-----------------------------------------------------------------------------
void C_PropJeep::UpdateViewAngles( C_BasePlayer *pLocalPlayer, CUserCmd *pCmd )
{
	if ( r_JeepViewBlendTo.GetInt() )
	{
		// Check to see if the mouse has been touched in a bit or that we are not throttling.
		if ( ( pCmd->mousedx != 0 || pCmd->mousedy != 0 ) || ( fabsf( m_flThrottle ) < 0.01f ) )
		{
			m_flViewAngleDeltaTime = 0.0f;
		}
		else
		{
			m_flViewAngleDeltaTime += gpGlobals->frametime;
		}

		if ( m_flViewAngleDeltaTime > r_JeepViewBlendToTime.GetFloat() )
		{
			// Blend the view angles.
			int eyeAttachmentIndex = LookupAttachment( "vehicle_driver_eyes" );
			Vector vehicleEyeOrigin;
			QAngle vehicleEyeAngles;
			GetAttachmentLocal( eyeAttachmentIndex, vehicleEyeOrigin, vehicleEyeAngles );
			
			QAngle outAngles;
			InterpolateAngles( pCmd->viewangles, vehicleEyeAngles, outAngles, r_JeepViewBlendToScale.GetFloat() );
			pCmd->viewangles = outAngles;
		}
	}

	BaseClass::UpdateViewAngles( pLocalPlayer, pCmd );
}
//=========================================================
// Disparo primario desde un NPC.
//=========================================================
void CWeaponAlyxGun::FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, bool bUseWeaponAngles )
{
  		Vector vecShootOrigin, vecShootDir;
		CAI_BaseNPC *pNPC = pOperator->MyNPCPointer();

		ASSERT( pNPC != NULL );

		if ( bUseWeaponAngles )
		{
			QAngle	angShootDir;
			GetAttachment(LookupAttachment("muzzle"), vecShootOrigin, angShootDir);
			AngleVectors(angShootDir, &vecShootDir);
		}
		else 
		{
			vecShootOrigin	= pOperator->Weapon_ShootPosition();
 			vecShootDir		= pNPC->GetActualShootTrajectory(vecShootOrigin);
		}

		WeaponSound(SINGLE_NPC);

		if ( hl2_episodic.GetBool() )
			pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 1 );
		else
			pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2 );

		pOperator->DoMuzzleFlash();

		// Never fire Alyx's last bullet just in case there's an emergency
		// and she needs to be able to shoot without reloading.
		if( m_iClip1 > 1 )
			m_iClip1 = m_iClip1 - 1;
}
예제 #27
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CPropJeep::CheckWater( void )
{
	bool bInWater = false;

	// Check all four wheels.
	for ( int iWheel = 0; iWheel < JEEP_WHEEL_COUNT; ++iWheel )
	{
		// Get the current wheel and get its contact point.
		IPhysicsObject *pWheel = m_VehiclePhysics.GetWheel( iWheel );
		if ( !pWheel )
			continue;

		// Check to see if we hit water.
		if ( pWheel->GetContactPoint( &m_WaterData.m_vecWheelContactPoints[iWheel], NULL ) )
		{
			m_WaterData.m_bWheelInWater[iWheel] = ( UTIL_PointContents( m_WaterData.m_vecWheelContactPoints[iWheel] ) & MASK_WATER ) ? true : false;
			if ( m_WaterData.m_bWheelInWater[iWheel] )
			{
				bInWater = true;
			}
		}
	}

	// Check the body and the BONNET.
	int iEngine = LookupAttachment( "vehicle_engine" );
	Vector vecEnginePoint;
	QAngle vecEngineAngles;
	GetAttachment( iEngine, vecEnginePoint, vecEngineAngles );

	m_WaterData.m_bBodyInWater = ( UTIL_PointContents( vecEnginePoint ) & MASK_WATER ) ? true : false;
	if ( m_WaterData.m_bBodyInWater )
	{
		if ( m_bHasPoop )
		{
			RemoveAllDecals();
			m_bHasPoop = false;
		}

		if ( !m_VehiclePhysics.IsEngineDisabled() )
		{
			m_VehiclePhysics.SetDisableEngine( true );
		}
	}
	else
	{
		if ( m_VehiclePhysics.IsEngineDisabled() )
		{
			m_VehiclePhysics.SetDisableEngine( false );
		}
	}

	if ( bInWater )
	{
		// Check the player's water level.
		CheckWaterLevel();
	}

	return bInWater;
}
void CNPC_Cremator::Spawn()
{	
	Precache();
	SetModel( "models/cremator_test2.mdl" ); // a model with a bit of a tesselation (tesselated head and collar)
	
	SetHullType(HULL_HUMAN); // отключено, т.к. это новый введенный тип хулла, и вряд ли есть смысл возиться с его введением. 

	//SetHullType( HULL_MEDIUM_TALL ); // данный стандартный тип подходит для большинства ситуаций, однако крематор не сможет проходить в двери, если они ненамного выше его
	
	/*that hull type is made special for a cremator since HULL_MEDIUM is not high enough but HULL_LARGE is too big
	and a cremator cannot fit in Borealis maps with it. The hull type is enumarated in ai_hull.h under the HULL_MEDIUM_TALL
	and then MUST be enumeraten in Hull_Bits_t, again, UNDER HULL_MEDIUM_TALL with the adress of 0x00000400,
	so that the definitions in ai_hull.cpp will then find the corresponding hull type.*/
	SetHullSizeNormal();
	
	SetBodygroup( 1, 0 ); // the gun
	SetBodygroup( 2, 0 ); // the head

	SetSolid( SOLID_BBOX );
	AddSolidFlags( FSOLID_NOT_STANDABLE );
	SetMoveType( MOVETYPE_STEP );

	m_bloodColor		= DONT_BLEED;//BLOOD_COLOR_YELLOW;
	m_iHealth			= sk_cremator_health.GetFloat();
	m_flFieldOfView		= VIEW_FIELD_WIDE;// indicates the width of this NPC's forward view cone ( as a dotproduct result )
	m_NPCState			= NPC_STATE_NONE;
	m_nSkin				= CREMATOR_SKIN_ALERT; // original yellow-eyes skin // Если надо спаунить крематора с иным цветом глаз, подставь значение из npc_cremator_h. 
	m_iAmmo				= m_iMaxAmmo = 54;

	NPCInit();

	m_flDistTooFar		= 6000.0;
	GetSenses()->SetDistLook( 6000.0 -1 );
	
	m_flNextIdleSoundTime	= gpGlobals->curtime; // + random->RandomFloat( 14.0f, 28.0f );
	m_flNextRangeAttack2Time = gpGlobals->curtime; // + random->RandomFloat( 10.0f, 20.0f );

	m_MuzzleAttachment	= LookupAttachment( "muzzle" );
	m_HeadAttachment	= LookupAttachment( "headattachment" );
		
	CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_TURN_HEAD );
	CapabilitiesAdd( bits_CAP_INNATE_RANGE_ATTACK1 ); // flamethrower
	CapabilitiesAdd( bits_CAP_INNATE_RANGE_ATTACK2 );

	CapabilitiesAdd( bits_CAP_MOVE_SHOOT ); // TODO: Melee?
}
예제 #29
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropAPC::Activate()
{
	BaseClass::Activate();

	m_nRocketAttachment = LookupAttachment( "cannon_muzzle" );
	m_nMachineGunMuzzleAttachment = LookupAttachment( "muzzle" );
	m_nMachineGunBaseAttachment = LookupAttachment( "gun_base" );

	// NOTE: gun_ref must have the same position as gun_base, but rotates with the gun
	int nMachineGunRefAttachment = LookupAttachment( "gun_def" );

	Vector vecWorldBarrelPos;
	matrix3x4_t matRefToWorld;
	GetAttachment( m_nMachineGunMuzzleAttachment, vecWorldBarrelPos );
	GetAttachment( nMachineGunRefAttachment, matRefToWorld );
	VectorITransform( vecWorldBarrelPos, matRefToWorld, m_vecBarrelPos );
}
예제 #30
0
//-----------------------------------------------------------------------------
// Purpose: Finds the true aiming position of the gun (looks at what player 
//			is looking at and adjusts)
// Input  : &resultDir - direction to be calculated
//-----------------------------------------------------------------------------
void CASW_PropJeep::GetCannonAim( Vector *resultDir )
{
	Vector	muzzleOrigin;
	QAngle	muzzleAngles;

	GetAttachment( LookupAttachment("gun_ref"), muzzleOrigin, muzzleAngles );

	AngleVectors( muzzleAngles, resultDir );
}