本文整理汇总了C++中ConVar::GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ ConVar::GetFloat方法的具体用法?C++ ConVar::GetFloat怎么用?C++ ConVar::GetFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConVar
的用法示例。
在下文中一共展示了ConVar::GetFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clientView
//-----------------------------------------------------------------------------
// Draws all the debugging info
//-----------------------------------------------------------------------------
void CDebugViewRender::Draw2DDebuggingInfo( const CViewSetup &view )
{
if ( IsX360() && IsRetail() )
return;
// HDRFIXME: Assert NULL rendertarget
if ( mat_yuv.GetInt() && (engine->GetDXSupportLevel() >= 80) )
{
IMaterial *pMaterial;
pMaterial = materials->FindMaterial( "debug/yuv", TEXTURE_GROUP_OTHER, true );
if( !IsErrorMaterial( pMaterial ) )
{
DrawScreenEffectMaterial( pMaterial, view.x, view.y, view.width, view.height );
}
}
if ( mat_hsv.GetInt() && (engine->GetDXSupportLevel() >= 90) )
{
IMaterial *pMaterial;
pMaterial = materials->FindMaterial( "debug/hsv", TEXTURE_GROUP_OTHER, true );
if( !IsErrorMaterial( pMaterial ) )
{
DrawScreenEffectMaterial( pMaterial, view.x, view.y, view.width, view.height );
}
}
// Draw debugging lightmaps
if ( mat_showlightmappage.GetInt() != -1 )
{
CLightmapDebugView clientView( assert_cast<CViewRender *>( ::view ) );
clientView.Setup( view );
clientView.Draw();
}
if ( cl_drawshadowtexture.GetInt() )
{
int nSize = cl_shadowtextureoverlaysize.GetInt();
g_pClientShadowMgr->RenderShadowTexture( nSize, nSize );
}
const char *pDrawMaterial = cl_drawmaterial.GetString();
if ( pDrawMaterial && pDrawMaterial[0] )
{
RenderMaterial( pDrawMaterial );
}
if ( mat_showwatertextures.GetBool() )
{
OverlayWaterTextures();
}
if ( mat_showcamerarendertarget.GetBool() )
{
float w = mat_wateroverlaysize.GetFloat();
float h = mat_wateroverlaysize.GetFloat();
#ifdef PORTAL
g_pPortalRender->OverlayPortalRenderTargets( w, h );
#else
OverlayCameraRenderTarget( "debug/debugcamerarendertarget", 0, 0, w, h );
#endif
}
if ( mat_showframebuffertexture.GetBool() )
{
// HDRFIXME: Get rid of these rendertarget sets assuming that the assert at the top of this function is true.
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->PushRenderTargetAndViewport( NULL );
OverlayFrameBufferTexture( 0 );
OverlayFrameBufferTexture( 1 );
pRenderContext->PopRenderTargetAndViewport( );
}
const char *pDrawTexture = mat_drawTexture.GetString();
if ( pDrawTexture && pDrawTexture[0] )
{
OverlayShowTexture( pDrawTexture, mat_drawTextureScale.GetFloat() );
}
#ifdef _X360
if ( mat_drawColorRamp.GetBool() )
{
OverlayColorRamp( mat_drawColorRamp.GetInt() == 2 );
}
#endif
if ( r_flashlightdrawdepth.GetBool() )
{
shadowmgr->DrawFlashlightDepthTexture( );
}
if ( mat_drawTitleSafe.GetBool() )
{
OverlayTitleSafe();
}
}
示例2: BusterFlyThink
//-----------------------------------------------------------------------------
// Purpose: Give the buster a slight attraction to striders.
// Ported back from the magnade.
//-----------------------------------------------------------------------------
void CWeaponStriderBuster::BusterFlyThink()
{
if (IsAttachedToStrider())
return; // early out. Think no more.
// If we're nosediving, forget about magnetism.
if ( m_bNoseDiving )
{
if ( VPhysicsGetObject() )
VPhysicsGetObject()->ApplyForceCenter( Vector( 0, 0, striderbuster_dive_force.GetFloat() ) );
SetNextThink(gpGlobals->curtime + 0.01f);
return;
}
// seek?
const float magradius = 38.0 * sk_striderbuster_magnet_multiplier.GetFloat(); // radius of strider hull times multiplier
if (magradius > 0 &&
GetMoveType() == MOVETYPE_VPHYSICS &&
VPhysicsGetObject()
)
{
// find the nearest enemy.
CBaseEntity *pList[16];
Vector origin = GetAbsOrigin();
// do a find in box ( a little faster than sphere )
int count;
{
Vector mins,maxs;
mins = origin;
mins -= magradius;
maxs = origin;
maxs += magradius;
count = UTIL_EntitiesInBox(pList, 16, mins, maxs, FL_NPC);
}
float magradiusSq = Square( magradius );
float nearestDistSq = magradiusSq + 1;
int bestFit = -1;
Vector toTarget; // will be garbage unless something good is found
CNPC_Strider *pBestStrider = NULL;
for ( int ii = 0 ; ii < count ; ++ii )
{
CNPC_Strider *pStrider = dynamic_cast<CNPC_Strider *>(pList[ii]);
if ( pStrider && !pStrider->CarriedByDropship() ) // ShouldStickToEntity() doesn't work because the strider NPC isn't what we glue to
{
// get distance squared
VectorSubtract( pStrider->GetAdjustedOrigin(), GetAbsOrigin(), toTarget );
//NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + toTarget, 128, 0, 128, false, 0.1 );
float dSq = toTarget.LengthSqr();
if (dSq < nearestDistSq)
{
bestFit = ii; nearestDistSq = dSq;
pBestStrider = pStrider;
}
}
}
if (bestFit >= 0) // we found something and should attract towards it. (hysterisis later?)
{
if ( striderbuster_debugseek.GetBool() )
{
NDebugOverlay::Circle( GetAbsOrigin() + toTarget, magradius, 255, 255, 255, 255, true, .1 );
NDebugOverlay::Cross3D( GetAbsOrigin() + toTarget, magradius, 255, 255, 255, true, .1 );
}
// force magnitude.
float magnitude = GetMass() * striderbuster_magnetic_force_strider.GetFloat();
int falloff = striderbuster_falloff_power.GetInt();
switch (falloff)
{
case 1:
VPhysicsGetObject()->ApplyForceCenter( toTarget * (magnitude / nearestDistSq) ); // dividing through by distance squared normalizes toTarget and gives a linear falloff
break;
case 2:
VPhysicsGetObject()->ApplyForceCenter( toTarget * (magnitude / (nearestDistSq * sqrtf(nearestDistSq))) ); // dividing through by distance cubed normalizes toTarget and gives a quadratic falloff
break;
case 3:
VPhysicsGetObject()->ApplyForceCenter( toTarget * (magnitude / (nearestDistSq * nearestDistSq)) ); // dividing through by distance fourth normalizes toTarget and gives a cubic falloff
break;
case 4:
{
Vector toTarget;
pBestStrider->GetAttachment( "buster_target", toTarget );
if ( striderbuster_debugseek.GetBool() )
{
NDebugOverlay::Cross3D( toTarget, magradius, 255, 0, 255, true, .1 );
NDebugOverlay::Cross3D( toTarget, magradius, 255, 0, 255, true, .1 );
}
//.........这里部分代码省略.........
示例3:
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_ASW_Prop_Physics::C_ASW_Prop_Physics( void ) :
m_MotionBlurObject( this, asw_phys_prop_motion_blur_scale.GetFloat() )
{
m_bClientOnFire = false;
}
示例4: Smack
// -----------------------------------------------------------------------------
// Purpose:
// Note: Think function to delay the impact decal until the animation is finished
// playing.
// -----------------------------------------------------------------------------
void CTFWeaponBaseMelee::Smack( void )
{
trace_t trace;
CBasePlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return;
#if !defined (CLIENT_DLL)
// Move other players back to history positions based on local player's lag
lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
// We hit, setup the smack.
if ( DoSwingTrace( trace ) )
{
// Hit sound - immediate.
if( trace.m_pEnt->IsPlayer() )
{
WeaponSound( MELEE_HIT );
}
else
{
WeaponSound( MELEE_HIT_WORLD );
}
// Get the current player.
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( !pPlayer )
return;
Vector vecForward;
AngleVectors( pPlayer->EyeAngles(), &vecForward );
Vector vecSwingStart = pPlayer->Weapon_ShootPosition();
Vector vecSwingEnd = vecSwingStart + vecForward * 48;
#ifndef CLIENT_DLL
// Do Damage.
int iCustomDamage = TF_DMG_CUSTOM_NONE;
float flDamage = GetMeleeDamage( trace.m_pEnt, iCustomDamage );
int iDmgType = DMG_BULLET | DMG_NEVERGIB | DMG_CLUB;
if ( IsCurrentAttackACrit() )
{
// TODO: Not removing the old critical path yet, but the new custom damage is marking criticals as well for melee now.
iDmgType |= DMG_CRITICAL;
}
CTakeDamageInfo info( pPlayer, pPlayer, flDamage, iDmgType, iCustomDamage );
CalculateMeleeDamageForce( &info, vecForward, vecSwingEnd, 1.0f / flDamage * tf_meleeattackforcescale.GetFloat() );
trace.m_pEnt->DispatchTraceAttack( info, vecForward, &trace );
ApplyMultiDamage();
OnEntityHit( trace.m_pEnt );
#endif
// Don't impact trace friendly players or objects
if ( trace.m_pEnt && trace.m_pEnt->GetTeamNumber() != pPlayer->GetTeamNumber() )
{
#ifdef CLIENT_DLL
UTIL_ImpactTrace( &trace, DMG_CLUB );
#endif
m_bConnected = true;
}
}
#if !defined (CLIENT_DLL)
lagcompensation->FinishLagCompensation( pPlayer );
#endif
}
示例5: PhysGunLaunchVelocity
//-----------------------------------------------------------------------------
// Purpose:
// Input : &forward -
// flMass -
// Output : Vector
//-----------------------------------------------------------------------------
Vector CWeaponStriderBuster::PhysGunLaunchVelocity( const Vector &forward, float flMass )
{
return ( striderbuster_shot_velocity.GetFloat() * forward );
}
示例6: ItemPostFrame
void CWeaponIFMSteadyCam::ItemPostFrame()
{
CBasePlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return;
float flSensitivity = ifm_steadycam_sensitivity.GetFloat();
Vector2D vecOldActualViewOffset = m_vecActualViewOffset.AsVector2D();
if ( pPlayer->m_nButtons & IN_ATTACK )
{
const CUserCmd *pUserCmd = pPlayer->GetCurrentUserCommand();
m_vecActualViewOffset.x += pUserCmd->mousedx * flSensitivity;
m_vecActualViewOffset.y += pUserCmd->mousedy * flSensitivity;
}
else
{
if ( !m_bIsLocked && !m_bInDirectMode )
{
float flDamp = ifm_steadycam_rotatedamp.GetFloat();
m_vecActualViewOffset.x *= flDamp;
m_vecActualViewOffset.y *= flDamp;
}
}
// Add noise
if ( !m_bIsLocked )
{
float flNoise = ifm_steadycam_noise.GetFloat();
if ( flNoise > 0.0f )
{
CUniformRandomStream stream;
stream.SetSeed( (int)(gpGlobals->curtime * 100) );
CGaussianRandomStream gauss( &stream );
float dx = gauss.RandomFloat( 0.0f, flNoise );
float dy = gauss.RandomFloat( 0.0f, flNoise );
m_vecActualViewOffset.x += dx;
m_vecActualViewOffset.y += dy;
}
}
ComputeViewOffset();
if ( pPlayer->m_nButtons & IN_ZOOM )
{
const CUserCmd *pUserCmd = pPlayer->GetCurrentUserCommand();
m_flFOVOffsetY += pUserCmd->mousedy * flSensitivity;
}
else
{
float flDamp = ifm_steadycam_zoomdamp.GetFloat();
m_flFOVOffsetY *= flDamp;
}
m_flFOV += m_flFOVOffsetY * ifm_steadycam_zoomspeed.GetFloat() / 1000.0f;
m_flFOV = clamp( m_flFOV, 0.5f, 160.0f );
if ( pPlayer->m_nButtons & IN_WALK )
{
const CUserCmd *pUserCmd = pPlayer->GetCurrentUserCommand();
m_flArmLength -= ifm_steadycam_armspeed.GetFloat() * pUserCmd->mousedy;
}
if ( pPlayer->GetImpulse() == 87 )
{
ToggleDirectMode();
}
if ( pPlayer->GetImpulse() == 89 )
{
m_bInSpringMode = !m_bInSpringMode;
}
if ( pPlayer->m_afButtonPressed & IN_USE )
{
LockCamera();
}
if ( pPlayer->m_afButtonPressed & IN_ATTACK2 )
{
m_bFullScreen = !m_bFullScreen;
}
if ( pPlayer->GetImpulse() == 88 )
{
// Make the view angles exactly match the player
m_vecViewOffset.Init();
m_vecActualViewOffset.Init();
m_vecOffset.Init();
m_vec2DVelocity.Init();
m_hLockTarget.Set( NULL );
m_flArmLength = 0.0f;
if ( m_bIsLocked )
{
LockCamera();
}
m_angRelativeAngles = pPlayer->EyeAngles();
m_flFOV = pPlayer->GetFOV();
}
//.........这里部分代码省略.........
示例7: Use
void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
// if it's not a player, ignore
if ( !pActivator->IsPlayer() )
return;
// if there is no juice left, turn it off
if (m_iJuice <= 0)
{
SetTextureFrameIndex( 1 );
Off();
}
// if the player doesn't have the suit, or there is no juice left, make the deny noise
if ( m_iJuice <= 0 )
{
if (m_flSoundTime <= gpGlobals->curtime)
{
m_flSoundTime = gpGlobals->curtime + 0.62;
EmitSound( "SuitRecharge.Deny" );
}
return;
}
SetNextThink( gpGlobals->curtime + 0.25 );
SetThink(Off);
// Time to recharge yet?
if (m_flNextCharge >= gpGlobals->curtime)
return;
// Make sure that we have a caller
if (!pActivator)
return;
m_hActivator = pActivator;
//only recharge the player
if (!m_hActivator->IsPlayer() )
return;
// Play the on sound or the looping charging sound
if (!m_iOn)
{
m_iOn++;
EmitSound( "SuitRecharge.Start" );
m_flSoundTime = 0.56 + gpGlobals->curtime;
}
if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->curtime))
{
m_iOn++;
CPASAttenuationFilter filter( this, "SuitRecharge.ChargingLoop" );
filter.MakeReliable();
EmitSound( filter, entindex(), "SuitRecharge.ChargingLoop" );
}
CBasePlayer *pl = (CBasePlayer *) m_hActivator.Get();
// charge the player
if (pl->ArmorValue() < 100)
{
m_iJuice--;
pl->IncrementArmorValue( 1, 100 );
}
// Send the output.
float flRemaining = m_iJuice / sk_suitcharger.GetFloat();
m_OutRemainingCharge.Set(flRemaining, pActivator, this);
// govern the rate of charge
m_flNextCharge = gpGlobals->curtime + 0.1;
}
示例8: Initialize
bool C_PhysPropClientside::Initialize()
{
if ( InitializeAsClientEntity( STRING(GetModelName()), RENDER_GROUP_OPAQUE_ENTITY ) == false )
{
return false;
}
const model_t *mod = GetModel();
if ( mod )
{
Vector mins, maxs;
modelinfo->GetModelBounds( mod, mins, maxs );
SetCollisionBounds( mins, maxs );
}
solid_t tmpSolid;
// Create the object in the physics system
if ( !PhysModelParseSolid( tmpSolid, this, GetModelIndex() ) )
{
DevMsg("C_PhysPropClientside::Initialize: PhysModelParseSolid failed for entity %i.\n", GetModelIndex() );
return false;
}
else
{
m_pPhysicsObject = VPhysicsInitNormal( SOLID_VPHYSICS, 0, m_spawnflags & SF_PHYSPROP_START_ASLEEP, &tmpSolid );
if ( !m_pPhysicsObject )
{
// failed to create a physics object
DevMsg(" C_PhysPropClientside::Initialize: VPhysicsInitNormal() failed for %s.\n", STRING(GetModelName()) );
return false;
}
}
// We want touch calls when we hit the world
unsigned int flags = VPhysicsGetObject()->GetCallbackFlags();
VPhysicsGetObject()->SetCallbackFlags( flags | CALLBACK_GLOBAL_TOUCH_STATIC );
if ( m_spawnflags & SF_PHYSPROP_MOTIONDISABLED )
{
m_pPhysicsObject->EnableMotion( false );
}
Spawn(); // loads breakable & prop data
if ( m_iPhysicsMode == PHYSICS_MULTIPLAYER_AUTODETECT )
{
m_iPhysicsMode = GetAutoMultiplayerPhysicsMode(
CollisionProp()->OBBSize(), m_pPhysicsObject->GetMass() );
}
if ( m_spawnflags & SF_PHYSPROP_FORCE_SERVER_SIDE )
{
// forced to be server-side by map maker
return false;
}
if ( m_iPhysicsMode != PHYSICS_MULTIPLAYER_CLIENTSIDE )
{
// spawn only clientside entities
return false;
}
else
{
if ( engine->IsInEditMode() )
{
// don't spawn in map edit mode
return false;
}
}
if ( m_fadeMinDist < 0 )
{
// start fading out at 75% of r_propsmaxdist
m_fadeMaxDist = r_propsmaxdist.GetFloat();
m_fadeMinDist = r_propsmaxdist.GetFloat() * 0.75f;
}
// player can push it away
SetCollisionGroup( COLLISION_GROUP_PUSHAWAY );
UpdatePartitionListEntry();
CollisionProp()->UpdatePartition();
SetBlocksLOS( false ); // this should be a small object
// Set up shadows; do it here so that objects can change shadowcasting state
CreateShadow();
UpdateVisibility();
SetNextClientThink( CLIENT_THINK_NEVER );
return true;
}
示例9: CreateRagdoll
void C_SDKRagdoll::CreateRagdoll()
{
// First, initialize all our data. If we have the player's entity on our client,
// then we can make ourselves start out exactly where the player is.
C_SDKPlayer *pPlayer = dynamic_cast< C_SDKPlayer* >( m_hPlayer.Get() );
if ( pPlayer && !pPlayer->IsDormant() )
{
// move my current model instance to the ragdoll's so decals are preserved.
pPlayer->SnatchModelInstance( this );
VarMapping_t *varMap = GetVarMapping();
// Copy all the interpolated vars from the player entity.
// The entity uses the interpolated history to get bone velocity.
if ( !pPlayer->IsLocalPlayer() && pPlayer->IsInterpolationEnabled() )
{
Interp_Copy( pPlayer );
SetAbsAngles( pPlayer->GetRenderAngles() );
GetRotationInterpolator().Reset(0.0f);
m_flAnimTime = pPlayer->m_flAnimTime;
SetSequence( pPlayer->GetSequence() );
m_flPlaybackRate = pPlayer->GetPlaybackRate();
}
else
{
// This is the local player, so set them in a default
// pose and slam their velocity, angles and origin
SetAbsOrigin( m_vecRagdollOrigin );
SetAbsAngles( pPlayer->GetRenderAngles() );
SetAbsVelocity( m_vecRagdollVelocity );
int iSeq = LookupSequence( "RagdollSpawn" ); // hax, find a neutral standing pose
if ( iSeq == -1 )
{
Assert( false ); // missing look_idle?
iSeq = 0;
}
SetSequence( iSeq ); // look_idle, basic pose
SetCycle( 0.0 );
Interp_Reset( varMap );
}
m_nBody = pPlayer->GetBody();
}
else
{
// overwrite network origin so later interpolation will
// use this position
SetNetworkOrigin( m_vecRagdollOrigin );
SetAbsOrigin( m_vecRagdollOrigin );
SetAbsVelocity( m_vecRagdollVelocity );
Interp_Reset( GetVarMapping() );
}
SetModelIndex( m_nModelIndex );
// Turn it into a ragdoll.
if ( cl_ragdoll_physics_enable.GetInt() )
{
// Make us a ragdoll..
//m_nRenderFX = kRenderFxRagdoll;
//SetRenderMode(kRenderFxRagdoll);
matrix3x4a_t boneDelta0[MAXSTUDIOBONES];
matrix3x4a_t boneDelta1[MAXSTUDIOBONES];
matrix3x4a_t currentBones[MAXSTUDIOBONES];
const float boneDt = 0.05f;
if ( pPlayer && pPlayer == C_BasePlayer::GetLocalPlayer() )
{
pPlayer->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt );
}
else
{
GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt );
}
InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt );
}
else
{
//ClientLeafSystem()->SetRenderGroup( GetRenderHandle(), RENDER_GROUP_TRANSLUCENT_ENTITY );
}
// Fade out the ragdoll in a while
StartFadeOut( cl_ragdoll_fade_time.GetFloat() );
SetNextClientThink( gpGlobals->curtime + 5.0f );
}
示例10: RenderDeathFrame
void C_SDKRootPanel::RenderDeathFrame( void )
{
int iWidth = ScreenWidth();
int iHeight = ScreenHeight();
int iTopBarHeight = 150;
int iBottomBarHeight = 75;
surface()->DrawSetColor(Color(0, 0, 0, 255));
surface()->DrawFilledRect( 0, 0, iWidth, iTopBarHeight );
surface()->DrawFilledRect( 0, iHeight-iBottomBarHeight, iWidth, iHeight );
if (m_hDeathFrameLarge == vgui::INVALID_FONT)
{
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
vgui::IScheme *pScheme = vgui::scheme()->GetIScheme( scheme );
m_hDeathFrameLarge = pScheme->GetFont("DeathFrameLarge", false);
m_hDeathFrameMedium = pScheme->GetFont("DeathFrameMedium", false);
m_hDeathFrameSmall = pScheme->GetFont("DeathFrameSmall", false);
}
std::wstring sKilledBy;
C_SDKPlayer* pPlayer = C_SDKPlayer::GetLocalOrSpectatedPlayer();
C_SDKPlayer* pKiller = pPlayer->GetKiller();
if (!m_flKilledByStartTime)
m_flKilledByStartTime = gpGlobals->curtime;
float flLerpTime = da_deathframe_lerp_time.GetFloat();
wchar_t* pszScreenshot = g_pVGuiLocalize->Find("#DA_DeathFrame_Screenshot");
if (pszScreenshot)
{
wchar_t szScreenshot[512];
UTIL_ReplaceKeyBindings( pszScreenshot, wcslen(pszScreenshot)*sizeof(wchar_t), szScreenshot, sizeof( szScreenshot ) );
float flXOffset = RemapValClamped(Bias(RemapValClamped(gpGlobals->curtime, m_flKilledByStartTime + 0.5f, m_flKilledByStartTime + 0.5f + flLerpTime, 0, 1), 0.8f), 0, 1, -iWidth*2/3, 0);
int iWide, iTall;
surface()->GetTextSize(m_hDeathFrameSmall, pszScreenshot, iWide, iTall);
surface()->DrawSetTextFont(m_hDeathFrameSmall);
surface()->DrawSetTextPos(10 + flXOffset, 10);
surface()->DrawSetTextColor(Color(255, 255, 255, 255));
surface()->DrawPrintText(szScreenshot, wcslen(szScreenshot));
}
if (pKiller != pPlayer)
{
wchar_t* pszKilledBy = g_pVGuiLocalize->Find("#DA_DeathFrame_KilledBy");
float flKilledByXOffset = RemapValClamped(Bias(RemapValClamped(gpGlobals->curtime, m_flKilledByStartTime, m_flKilledByStartTime + flLerpTime, 0, 1), 0.8f), 0, 1, -iWidth*2/3, 0);
if (pszKilledBy)
{
int iWide, iTall;
surface()->GetTextSize(m_hDeathFrameLarge, pszKilledBy, iWide, iTall);
surface()->DrawSetTextFont(m_hDeathFrameLarge);
surface()->DrawSetTextPos(flKilledByXOffset + iWidth/2 - iWide/2, 10);
surface()->DrawSetTextColor(Color(255, 255, 255, 255));
surface()->DrawPrintText(pszKilledBy, wcslen(pszKilledBy));
}
wchar_t wszPlayerName[MAX_PLAYER_NAME_LENGTH];
if (pKiller)
g_pVGuiLocalize->ConvertANSIToUnicode( pKiller->GetPlayerName(), wszPlayerName, sizeof(wszPlayerName) );
else
{
wchar_t* pszTheGround;
switch (((int)m_flKilledByStartTime)%3) // Effectively a random number.
{
case 0:
default:
pszTheGround = g_pVGuiLocalize->Find("#DA_DeathFrame_TheGround");
break;
case 1:
pszTheGround = g_pVGuiLocalize->Find("#DA_DeathFrame_SuddenStop");
break;
case 2:
pszTheGround = g_pVGuiLocalize->Find("#DA_DeathFrame_Gravity");
break;
}
if (pszTheGround)
wcscpy(wszPlayerName, pszTheGround);
else
wcscpy(wszPlayerName, L"The Ground");
}
int iWide, iTall;
surface()->GetTextSize(m_hDeathFrameLarge, wszPlayerName, iWide, iTall);
surface()->DrawSetTextFont(m_hDeathFrameLarge);
surface()->DrawSetTextPos(flKilledByXOffset + iWidth/2 - iWide/2, 20 + surface()->GetFontTall(m_hDeathFrameLarge));
surface()->DrawSetTextColor(Color(255, 255, 255, 255));
surface()->DrawPrintText(wszPlayerName, wcslen(wszPlayerName));
}
//.........这里部分代码省略.........
示例11: ClientThink
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_FuncPhysicsRespawnZone::ClientThink( void )
{
RespawnProps();
SetNextClientThink( gpGlobals->curtime + (cl_phys_props_respawnrate.GetFloat() * RandomFloat(1.0,1.1)) );
}
示例12: Die
//.........这里部分代码省略.........
ep.m_SoundLevel = params.soundlevel;
ep.m_nPitch = pitch;
EmitSound( filter, entindex(), ep );
}
}
switch( m_Explosion )
{
case expDirected:
vecVelocity = g_vecAttackDir * -200;
break;
case expUsePrecise:
{
AngleVectors( m_GibDir, &vecVelocity, NULL, NULL );
vecVelocity *= 200;
}
break;
case expRandom:
vecVelocity.x = 0;
vecVelocity.y = 0;
vecVelocity.z = 0;
break;
default:
DevMsg("**ERROR - Unspecified gib dir method in func_breakable!\n");
break;
}
Vector vecSpot = WorldSpaceCenter();
CPVSFilter filter2( vecSpot );
int iModelIndex = 0;
CCollisionProperty *pCollisionProp = CollisionProp();
Vector vSize = pCollisionProp->OBBSize();
int iCount = ( vSize[0] * vSize[1] + vSize[1] * vSize[2] + vSize[2] * vSize[0] ) / ( 3 * 12 * 12 );
if ( iCount > func_break_max_pieces.GetInt() )
{
iCount = func_break_max_pieces.GetInt();
}
if ( !breakable_disable_gib_limit.GetBool() && iCount )
{
if ( m_PerformanceMode == PM_NO_GIBS )
{
iCount = 0;
}
else if ( m_PerformanceMode == PM_REDUCED_GIBS )
{
int iNewCount = iCount * func_break_reduction_factor.GetFloat();
iCount = MAX( iNewCount, 1 );
}
}
if ( m_iszModelName != NULL_STRING )
{
for ( int i = 0; i < iCount; i++ )
{
iModelIndex = modelinfo->GetModelIndex( g_PropDataSystem.GetRandomChunkModel( STRING( m_iszModelName ) ) );
// All objects except the first one in this run are marked as slaves...
int slaveFlag = 0;
if ( i != 0 )
{
slaveFlag = BREAK_SLAVE;
}
te->BreakModel( filter2, 0.0,
vecSpot, pCollisionProp->GetCollisionAngles(), vSize,
vecVelocity, iModelIndex, 100, 1, 2.5, cFlag | slaveFlag );
}
}
ResetOnGroundFlags();
// Don't fire something that could fire myself
SetName( NULL_STRING );
AddSolidFlags( FSOLID_NOT_SOLID );
// Fire targets on break
m_OnBreak.FireOutput( m_hBreaker, this );
VPhysicsDestroyObject();
SetThink( &CBreakable::SUB_Remove );
SetNextThink( gpGlobals->curtime + 0.1f );
if ( m_iszSpawnObject != NULL_STRING )
{
CBaseEntity::Create( STRING(m_iszSpawnObject), vecSpot, pCollisionProp->GetCollisionAngles(), this );
}
if ( Explodable() )
{
ExplosionCreate( vecSpot, pCollisionProp->GetCollisionAngles(), this, GetExplosiveDamage(), GetExplosiveRadius(), true );
}
}
示例13: Think
void CASW_Health_Regen::Think()
{
BaseClass::Think();
CBaseEntity* pEntity = NULL;
while ((pEntity = gEntList.FindEntityByClassname( pEntity, "asw_marine" )) != NULL)
{
CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>(pEntity);
if (pMarine)
{
int cur_health = pMarine->GetHealth();
int max_health = pMarine->GetMaxHealth();
int regen_ammount = rm_health_regen_amount.GetInt();
if (cur_health < max_health)
{
//Check if this marine is dead.
if (cur_health < 1)
continue;
int result_health = cur_health + regen_ammount;
if (result_health > max_health)
result_health = max_health;
// if (pMarine->m_bKnockedOut)
// {
// result_health = cur_health - 3;
// if (result_health <= 0)
// {
// CTakeDamageInfo info(
// pMarine,
// pMarine,
// Vector(0,0,0),
// GetAbsOrigin(),
// 100,
// DMG_NEVERGIB);
// pMarine->TakeDamage(info);
// }
// else
// {
// pMarine->SetHealth(result_health);
// }
// }
// else
// {
if (!pMarine->m_bKnockedOut && ASWGameRules()->m_iHpRegen)
pMarine->SetHealth(result_health);
// riflemod: incapacitated marines have decreasing hp
if (pMarine->m_bKnockedOut)
{
int decreased_hp = pMarine->GetHealth() - rm_health_decrease_amount.GetInt();
if (decreased_hp <= 0)
{
pMarine->SetKnockedOut(false);
pMarine->SetHealth(1);
// HACK
int allow_revive = ASWGameRules()->m_iAllowRevive;
ASWGameRules()->m_iAllowRevive = 0;
CTakeDamageInfo info(this, this, Vector(0, 0, 0), GetAbsOrigin(), 100,
DMG_NEVERGIB);
pMarine->TakeDamage(info);
ASWGameRules()->m_iAllowRevive = allow_revive;
}
else
pMarine->SetHealth(decreased_hp);
}
// }
}
}
}
SetNextThink( gpGlobals->curtime + rm_health_regen_interval.GetFloat());
}
示例14: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponLaserRifle::PrimaryAttack( void )
{
CBaseTFPlayer *pPlayer = ToBaseTFPlayer( m_hOwner );
if ( !pPlayer )
return;
if ( !ComputeEMPFireState() )
return;
WeaponSound(SINGLE);
PlayAttackAnimation( GetPrimaryAttackActivity() );
pPlayer->m_fEffects |= EF_MUZZLEFLASH;
// Fire the beam: BLOW OFF AUTOAIM
Vector vecSrc = pPlayer->Weapon_ShootPosition( pPlayer->GetOrigin() );
Vector vecAiming, right, up;
pPlayer->EyeVectors( &vecAiming, &right, &up);
Vector vecSpread = VECTOR_CONE_4DEGREES;
// Get endpoint
float x, y, z;
do {
x = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5);
y = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5);
z = x*x+y*y;
} while (z > 1);
Vector vecDir = vecAiming + x * vecSpread.x * right + y * vecSpread.y * up;
Vector vecEnd = vecSrc + vecDir * weapon_laserrifle_range.GetFloat();
trace_t tr;
float damagefactor = TFGameRules()->WeaponTraceLine(vecSrc, vecEnd, MASK_SHOT, pPlayer, DMG_ENERGYBEAM, &tr);
// Hit target?
if (tr.fraction != 1.0)
{
CBaseEntity *pEntity = CBaseEntity::Instance(tr.u.ent);
if ( pEntity )
{
ClearMultiDamage();
float flDamage = GetDamage( (tr.endpos - vecSrc).Length(), tr.hitgroup );
flDamage *= damagefactor;
pEntity->TraceAttack( CTakeDamageInfo( pPlayer, pPlayer, flDamage, DMG_ENERGYBEAM ), vecDir, &tr );
ApplyMultiDamage( pPlayer, pPlayer );
}
g_pEffects->EnergySplash( tr.endpos, tr.plane.normal );
}
// Get hacked gun position
AngleVectors( pPlayer->EyeAngles() + pPlayer->m_Local.m_vecPunchAngle, NULL, &right, NULL );
Vector vecTracerSrc = vecSrc + Vector (0,0,-8) + right * 12 + vecDir * 16;
// Laser beam
CBroadcastRecipientFilter filter;
te->BeamPoints( filter, 0.0,
&vecTracerSrc,
&tr.endpos,
m_iSpriteTexture,
0, // Halo index
0, // Start frame
0, // Frame rate
0.2, // Life
15, // Width
15, // EndWidth
0, // FadeLength
0, // Amplitude
200, // r
200, // g
255, // b
255, // a
255 ); // speed
pPlayer->m_iAmmo[m_iPrimaryAmmoType]--;
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
CheckRemoveDisguise();
}
示例15: PerformClientSideNPCSpeedModifiers
void C_BaseHLPlayer::PerformClientSideNPCSpeedModifiers( float flFrameTime, CUserCmd *pCmd )
{
if ( m_hClosestNPC == NULL )
{
if ( m_flSpeedMod != cl_forwardspeed.GetFloat() )
{
float flDeltaTime = (m_flSpeedModTime - gpGlobals->curtime);
m_flSpeedMod = RemapValClamped( flDeltaTime, cl_npc_speedmod_outtime.GetFloat(), 0, m_flExitSpeedMod, cl_forwardspeed.GetFloat() );
}
}
else
{
C_AI_BaseNPC *pNPC = dynamic_cast< C_AI_BaseNPC *>( m_hClosestNPC.Get() );
if ( pNPC )
{
float flDist = (GetAbsOrigin() - pNPC->GetAbsOrigin()).LengthSqr();
bool bShouldModSpeed = false;
// Within range?
if ( flDist < pNPC->GetSpeedModifyRadius() )
{
// Now, only slowdown if we're facing & running parallel to the target's movement
// Facing check first (in 2D)
Vector vecTargetOrigin = pNPC->GetAbsOrigin();
Vector los = ( vecTargetOrigin - EyePosition() );
los.z = 0;
VectorNormalize( los );
Vector facingDir;
AngleVectors( GetAbsAngles(), &facingDir );
float flDot = DotProduct( los, facingDir );
if ( flDot > 0.8 )
{
/*
// Velocity check (abort if the target isn't moving)
Vector vecTargetVelocity;
pNPC->EstimateAbsVelocity( vecTargetVelocity );
float flSpeed = VectorNormalize(vecTargetVelocity);
Vector vecMyVelocity = GetAbsVelocity();
VectorNormalize(vecMyVelocity);
if ( flSpeed > 1.0 )
{
// Velocity roughly parallel?
if ( DotProduct(vecTargetVelocity,vecMyVelocity) > 0.4 )
{
bShouldModSpeed = true;
}
}
else
{
// NPC's not moving, slow down if we're moving at him
//Msg("Dot: %.2f\n", DotProduct( los, vecMyVelocity ) );
if ( DotProduct( los, vecMyVelocity ) > 0.8 )
{
bShouldModSpeed = true;
}
}
*/
bShouldModSpeed = true;
}
}
if ( !bShouldModSpeed )
{
m_hClosestNPC = NULL;
m_flSpeedModTime = gpGlobals->curtime + cl_npc_speedmod_outtime.GetFloat();
m_flExitSpeedMod = m_flSpeedMod;
return;
}
else
{
if ( m_flSpeedMod != pNPC->GetSpeedModifySpeed() )
{
float flDeltaTime = (m_flSpeedModTime - gpGlobals->curtime);
m_flSpeedMod = RemapValClamped( flDeltaTime, cl_npc_speedmod_intime.GetFloat(), 0, cl_forwardspeed.GetFloat(), pNPC->GetSpeedModifySpeed() );
}
}
}
}
if ( pCmd->forwardmove > 0.0f )
{
pCmd->forwardmove = clamp( pCmd->forwardmove, -m_flSpeedMod, m_flSpeedMod );
}
else
{
pCmd->forwardmove = clamp( pCmd->forwardmove, -m_flSpeedMod, m_flSpeedMod );
}
pCmd->sidemove = clamp( pCmd->sidemove, -m_flSpeedMod, m_flSpeedMod );
//Msg( "fwd %f right %f\n", pCmd->forwardmove, pCmd->sidemove );
}