本文整理汇总了C++中C_TFPlayer::IsLocalPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ C_TFPlayer::IsLocalPlayer方法的具体用法?C++ C_TFPlayer::IsLocalPlayer怎么用?C++ C_TFPlayer::IsLocalPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_TFPlayer
的用法示例。
在下文中一共展示了C_TFPlayer::IsLocalPlayer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateMuzzleFlashEffects
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFRocketLauncher::CreateMuzzleFlashEffects( C_BaseEntity *pAttachEnt, int nIndex )
{
BaseClass::CreateMuzzleFlashEffects( pAttachEnt, nIndex );
// Don't do backblast effects in first person
C_TFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );
if ( pOwner->IsLocalPlayer() )
return;
ParticleProp()->Create( "rocketbackblast", PATTACH_POINT_FOLLOW, "backblast" );
}
示例2: FX_FireBullets
//-----------------------------------------------------------------------------
// Purpose: This runs on both the client and the server. On the server, it
// only does the damage calculations. On the client, it does all the effects.
//-----------------------------------------------------------------------------
void FX_FireBullets( int iPlayer, const Vector &vecOrigin, const QAngle &vecAngles,
int iWeapon, int iMode, int iSeed, float flSpread, float flDamage /* = -1.0f */, bool bCritical /* = false*/ )
{
// Get the weapon information.
const char *pszWeaponAlias = WeaponIdToAlias( iWeapon );
if ( !pszWeaponAlias )
{
DevMsg( 1, "FX_FireBullets: weapon alias for ID %i not found\n", iWeapon );
return;
}
WEAPON_FILE_INFO_HANDLE hWpnInfo = LookupWeaponInfoSlot( pszWeaponAlias );
if ( hWpnInfo == GetInvalidWeaponInfoHandle() )
{
DevMsg( 1, "FX_FireBullets: LookupWeaponInfoSlot failed for weapon %s\n", pszWeaponAlias );
return;
}
CTFWeaponInfo *pWeaponInfo = static_cast<CTFWeaponInfo*>( GetFileWeaponInfoFromHandle( hWpnInfo ) );
if( !pWeaponInfo )
return;
bool bDoEffects = false;
#ifdef CLIENT_DLL
C_TFPlayer *pPlayer = ToTFPlayer( ClientEntityList().GetBaseEntity( iPlayer ) );
#else
CTFPlayer *pPlayer = ToTFPlayer( UTIL_PlayerByIndex( iPlayer ) );
#endif
if ( !pPlayer )
return;
// Client specific.
#ifdef CLIENT_DLL
bDoEffects = true;
// The minigun has custom sound & animation code to deal with its windup/down.
if ( !pPlayer->IsLocalPlayer()
&& iWeapon != TF_WEAPON_MINIGUN )
{
// Fire the animation event.
if ( pPlayer && !pPlayer->IsDormant() )
{
if ( iMode == TF_WEAPON_PRIMARY_MODE )
{
pPlayer->m_PlayerAnimState->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
}
else
{
pPlayer->m_PlayerAnimState->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_SECONDARY );
}
}
//FX_WeaponSound( pPlayer->entindex(), SINGLE, vecOrigin, pWeaponInfo );
}
// Server specific.
#else
// If this is server code, send the effect over to client as temp entity and
// dispatch one message for all the bullet impacts and sounds.
TE_FireBullets( pPlayer->entindex(), vecOrigin, vecAngles, iWeapon, iMode, iSeed, flSpread, bCritical );
// Let the player remember the usercmd he fired a weapon on. Assists in making decisions about lag compensation.
pPlayer->NoteWeaponFired();
#endif
// Fire bullets, calculate impacts & effects.
StartGroupingSounds();
#if !defined (CLIENT_DLL)
// Move other players back to history positions based on local player's lag
lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
// Get the shooting angles.
Vector vecShootForward, vecShootRight, vecShootUp;
AngleVectors( vecAngles, &vecShootForward, &vecShootRight, &vecShootUp );
// Initialize the static firing information.
FireBulletsInfo_t fireInfo;
fireInfo.m_vecSrc = vecOrigin;
if ( flDamage < 0.0f )
{
fireInfo.m_flDamage = pWeaponInfo->GetWeaponData( iMode ).m_nDamage;
}
else
{
fireInfo.m_flDamage = static_cast<int>(flDamage);
}
fireInfo.m_flDistance = pWeaponInfo->GetWeaponData( iMode ).m_flRange;
fireInfo.m_iShots = 1;
fireInfo.m_vecSpread.Init( flSpread, flSpread, 0.0f );
fireInfo.m_iAmmoType = pWeaponInfo->iAmmoType;
// Setup the bullet damage type & roll for crit.
//.........这里部分代码省略.........
示例3: DrawModel
//-----------------------------------------------------------------------------
// Purpose:
// TFTODO: Make the sniper dot get brighter the more damage it will do.
//-----------------------------------------------------------------------------
int CSniperDot::DrawModel( int flags )
{
// Get the owning player.
C_TFPlayer *pPlayer = ToTFPlayer( GetOwnerEntity() );
if ( !pPlayer )
return -1;
// Get the sprite rendering position.
Vector vecEndPos;
float flSize = 6.0;
if ( !pPlayer->IsDormant() )
{
Vector vecAttachment, vecDir;
QAngle angles;
float flDist = MAX_TRACE_LENGTH;
// Always draw the dot in front of our faces when in first-person.
if ( pPlayer->IsLocalPlayer() )
{
// Take our view position and orientation
vecAttachment = CurrentViewOrigin();
vecDir = CurrentViewForward();
// Clamp the forward distance for the sniper's firstperson
flDist = 384;
flSize = 2.0;
}
else
{
// Take the owning player eye position and direction.
vecAttachment = pPlayer->EyePosition();
QAngle angles = pPlayer->EyeAngles();
AngleVectors( angles, &vecDir );
}
trace_t tr;
UTIL_TraceLine( vecAttachment, vecAttachment + ( vecDir * flDist ), MASK_SHOT, pPlayer, COLLISION_GROUP_NONE, &tr );
// Backup off the hit plane, towards the source
vecEndPos = tr.endpos + vecDir * -4;
}
else
{
// Just use our position if we can't predict it otherwise.
vecEndPos = GetAbsOrigin();
}
// Draw our laser dot in space.
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->Bind( m_hSpriteMaterial, this );
float flLifeTime = gpGlobals->curtime - m_flChargeStartTime;
float flStrength = RemapValClamped( flLifeTime, 0.0, TF_WEAPON_SNIPERRIFLE_DAMAGE_MAX / TF_WEAPON_SNIPERRIFLE_CHARGE_PER_SEC, 0.1, 1.0 );
color32 innercolor = { 255, 255, 255, 255 };
color32 outercolor = { 255, 255, 255, 128 };
DrawSprite( vecEndPos, flSize, flSize, outercolor );
DrawSprite( vecEndPos, flSize * flStrength, flSize * flStrength, innercolor );
// Successful.
return 1;
}
示例4: DrawModel
//-----------------------------------------------------------------------------
// Purpose:
// TFTODO: Make the sniper dot get brighter the more damage it will do.
//-----------------------------------------------------------------------------
int CSniperDot::DrawModel( int flags )
{
// Get the owning player.
C_TFPlayer *pPlayer = ToTFPlayer( GetOwnerEntity() );
if ( !pPlayer )
return -1;
// Get the sprite rendering position.
Vector vecEndPos;
float flSize = 6.0;
if ( !pPlayer->IsDormant() )
{
Vector vecAttachment, vecDir;
QAngle angles;
float flDist = MAX_TRACE_LENGTH;
// Always draw the dot in front of our faces when in first-person.
if ( pPlayer->IsLocalPlayer() )
{
// Take our view position and orientation
vecAttachment = CurrentViewOrigin();
vecDir = CurrentViewForward();
// Clamp the forward distance for the sniper's firstperson
flDist = 384;
flSize = 2.0;
}
else
{
// Take the owning player eye position and direction.
vecAttachment = pPlayer->EyePosition();
QAngle angles = pPlayer->EyeAngles();
AngleVectors( angles, &vecDir );
}
trace_t tr;
UTIL_TraceLine( vecAttachment, vecAttachment + ( vecDir * flDist ), MASK_SHOT, pPlayer, COLLISION_GROUP_NONE, &tr );
// Backup off the hit plane, towards the source
vecEndPos = tr.endpos + vecDir * -4;
}
else
{
// Just use our position if we can't predict it otherwise.
vecEndPos = GetAbsOrigin();
}
// Draw our laser dot in space.
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->Bind( m_hSpriteMaterial, this );
float flLifeTime = gpGlobals->curtime - m_flChargeStartTime;
float flStrength = RemapValClamped( flLifeTime, 0.0, TF_WEAPON_SNIPERRIFLE_DAMAGE_MAX / TF_WEAPON_SNIPERRIFLE_CHARGE_PER_SEC, 0.1, 1.0 );
color32 innercolor = { 255, 255, 255, 255 };
color32 outercolor = { 255, 255, 255, 128 };
// PistonMiner: DM sniper point coloring
if (TFGameRules()->IsDeathmatch())
{
// Get the color of the mercenary we are drawing the dot of.
C_TF_PlayerResource *tf_PR = dynamic_cast<C_TF_PlayerResource *>(g_PR);
Color ownercolor = tf_PR->GetPlayerColor(pPlayer->index);
// Convert to HSV so we can edit the color better.
Vector hsv, rgb;
RGBtoHSV(Vector(ownercolor.r() / 255.f, ownercolor.g() / 255.f, ownercolor.b() / 255.f), hsv);
// Set the Value to max for constant brightness.
hsv.z = 1.0;
// Convert back to RGB
HSVtoRGB(hsv, rgb);
// Apply the color to our sprite.
m_hSpriteMaterial->ColorModulate( rgb.x, rgb.y, rgb.z );
}
DrawSprite( vecEndPos, flSize, flSize, outercolor );
DrawSprite( vecEndPos, flSize * flStrength, flSize * flStrength, innercolor );
// Successful.
return 1;
}