本文整理汇总了C++中C_TFPlayer::GetWaterLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ C_TFPlayer::GetWaterLevel方法的具体用法?C++ C_TFPlayer::GetWaterLevel怎么用?C++ C_TFPlayer::GetWaterLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_TFPlayer
的用法示例。
在下文中一共展示了C_TFPlayer::GetWaterLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TFBloodSprayCallback
//-----------------------------------------------------------------------------
// Purpose: Intercepts the blood spray message.
//-----------------------------------------------------------------------------
void TFBloodSprayCallback( Vector vecOrigin, Vector vecNormal, ClientEntityHandle_t hEntity )
{
QAngle vecAngles;
VectorAngles( -vecNormal, vecAngles );
// determine if the bleeding player is underwater
bool bUnderwater = false;
C_TFPlayer *pPlayer = dynamic_cast<C_TFPlayer*>( ClientEntityList().GetBaseEntityFromHandle( hEntity ) );
if ( pPlayer && ( WL_Eyes == pPlayer->GetWaterLevel() ) )
{
bUnderwater = true;
}
if ( !bUnderwater && TFGameRules() && TFGameRules()->IsBirthday() && RandomFloat(0,1) < 0.2 )
{
DispatchParticleEffect( "bday_blood", vecOrigin, vecAngles, pPlayer );
}
else
{
DispatchParticleEffect( bUnderwater ? "water_blood_impact_red_01" : "blood_impact_red_01", vecOrigin, vecAngles, pPlayer );
}
// if underwater, don't add additional spray
if ( bUnderwater )
return;
// Now throw out a spray away from the view
// Get the distance to the view
float flDistance = (vecOrigin - MainViewOrigin()).Length();
float flLODDistance = 0.25 * (flDistance / 512);
Vector right, up;
if (vecNormal != Vector(0, 0, 1) )
{
right = vecNormal.Cross( Vector(0, 0, 1) );
up = right.Cross( vecNormal );
}
else
{
right = Vector(0, 0, 1);
up = right.Cross( vecNormal );
}
// If the normal's too close to being along the view, push it out
Vector vecForward, vecRight;
AngleVectors( MainViewAngles(), &vecForward, &vecRight, NULL );
float flDot = DotProduct( vecNormal, vecForward );
if ( fabs(flDot) > 0.5 )
{
float flPush = random->RandomFloat(0.5, 1.5) + flLODDistance;
float flRightDot = DotProduct( vecNormal, vecRight );
// If we're up close, randomly move it around. If we're at a distance, always push it to the side
// Up close, this can move it back towards the view, but the random chance still looks better
if ( ( flDistance >= 512 && flRightDot > 0 ) || ( flDistance < 512 && RandomFloat(0,1) > 0.5 ) )
{
// Turn it to the right
vecNormal += (vecRight * flPush);
}
else
{
// Turn it to the left
vecNormal -= (vecRight * flPush);
}
}
VectorAngles( vecNormal, vecAngles );
if ( flDistance < 400 )
{
DispatchParticleEffect( "blood_spray_red_01", vecOrigin, vecAngles, pPlayer );
}
else
{
DispatchParticleEffect( "blood_spray_red_01_far", vecOrigin, vecAngles, pPlayer );
}
}