本文整理汇总了C++中ConVar::GetBool方法的典型用法代码示例。如果您正苦于以下问题:C++ ConVar::GetBool方法的具体用法?C++ ConVar::GetBool怎么用?C++ ConVar::GetBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConVar
的用法示例。
在下文中一共展示了ConVar::GetBool方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
bool CDeferredManagerClient::Init()
{
AssertMsg( g_pCurrentViewRender == NULL, "viewrender already allocated?!" );
// Make sure deferred lighting setting is read out at this point
ReadVideoCfgExt();
const bool bLowPerfSystem = GetGPULevel() <= GPU_LEVEL_LOW || GetGPUMemLevel() <= GPU_MEM_LEVEL_LOW || GetCPULevel() <= CPU_LEVEL_LOW;
const int iDeferredLevel = CommandLine() ? CommandLine()->ParmValue("-deferred", 1) : 1;
const bool bAllowDeferred = deferred_lighting_enabled.GetBool() && !bLowPerfSystem && (!CommandLine() || CommandLine()->FindParm("-disabledeferred") == 0);
const bool bForceDeferred = CommandLine() && CommandLine()->FindParm("-forcedeferred") != 0;
bool bSM30 = g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 95;
if ( !bSM30 )
{
Warning( "The engine doesn't recognize your GPU to support SM3.0, running deferred anyway...\n" );
bSM30 = true;
}
if ( bAllowDeferred && (bSM30 || bForceDeferred) )
{
bool bGotDefShaderDll = ConnectDeferredExt();
if ( bGotDefShaderDll )
{
m_bDefRenderingEnabled = true;
GetDeferredExt()->EnableDeferredLighting();
if( iDeferredLevel > 1 )
g_pCurrentViewRender = new CDeferredViewRender();
else
g_pCurrentViewRender = new CViewRender();
ConVarRef r_shadows( "r_shadows" );
r_shadows.SetValue( "0" );
InitDeferredRTs( true );
materials->AddModeChangeCallBack( &DefRTsOnModeChanged );
InitializeDeferredMaterials();
}
}
if ( !m_bDefRenderingEnabled )
{
Assert( g_pCurrentViewRender == NULL );
if( bAllowDeferred )
Warning( "Your hardware does not seem to support shader model 3.0. If you think that this is an error (hybrid GPUs), add -forcedeferred as start parameter.\n" );
g_pCurrentViewRender = new CViewRender();
}
else
{
#define VENDOR_NVIDIA 0x10DE
#define VENDOR_INTEL 0x8086
#define VENDOR_ATI 0x1002
#define VENDOR_AMD 0x1022
#ifndef SHADOWMAPPING_USE_COLOR
MaterialAdapterInfo_t info;
materials->GetDisplayAdapterInfo( materials->GetCurrentAdapter(), info );
if ( info.m_VendorID == VENDOR_ATI ||
info.m_VendorID == VENDOR_AMD )
{
vgui::MessageBox *pATIWarning = new vgui::MessageBox("UNSUPPORTED HARDWARE", VarArgs( "AMD/ATI IS NOT YET SUPPORTED IN HARDWARE FILTERING MODE\n"
"(cdeferred_manager_client.cpp #%i).", __LINE__ ) );
pATIWarning->InvalidateLayout();
pATIWarning->DoModal();
}
#endif
}
return true;
}
示例2: sizeof
bool CP3DRenderer::InitRenderer(HWND hWnd)
{
I_RegisterModule("rendererDX9");
// memory leaks detection
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
//_CrtSetBreakAlloc(152);
g_pConsole = (IP3DConsole*)I_GetClass(IP3DENGINE_CONSOLE);
g_pConsole->RegisterLastConVar(g_pLastConVar); // zaregistrovat ConVary tohoto dll projektu - NUTNÉ!
g_pFS = (IP3DFileSystem*)I_GetClass(IP3DENGINE_FILESYSTEM); //get filesystem
g_pEngine = (IP3DEngine*)I_GetClass(IP3DENGINE_ENGINE);
g_pTimer = (IP3DTimer*)I_GetClass(IP3DENGINE_TIMER);
// profiler
Prof_stackPTR = g_pEngine->GetProf_stack();
Prof_dummyPTR = g_pEngine->GetProf_dummy();
Prof_StackAppendPTR = g_pEngine->GetProf_StackAppendFn();
g_pEngSet.Width = CVr_width.GetInt();
g_pEngSet.Height = CVr_height.GetInt();
g_pEngSet.Windowed = CVr_windowed.GetBool();
g_pEngSet.hWnd = hWnd;
// zkontroluj, zda se shoduji verze .h a DLL
if (!D3DXCheckVersion(D3D_SDK_VERSION, D3DX_SDK_VERSION))
CON(MSG_CON_ERR, "Warning: Wrong DirectX DLL versions, please install latest DirectX!");
// Vytvoø D3D objekt
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
CON(MSG_ERR_FATAL, "Can't create Direct3D object! Please install DirectX 9...");
// test for depth buffer support - zatial sa nepouziva stencil
// D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D16
D3DFORMAT DepthBufFormat = D3DFMT_D16;
if (SUCCEEDED (g_pD3D->GetDeviceCaps (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_caps)))
if (SUCCEEDED (g_pD3D->CheckDeviceFormat(m_caps.AdapterOrdinal, D3DDEVTYPE_HAL, \
D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8)))
DepthBufFormat = D3DFMT_D24X8;
// test na vs a ps 2.0
if(m_caps.VertexShaderVersion<D3DVS_VERSION(1,1) || m_caps.PixelShaderVersion<D3DPS_VERSION(2,0))
{
CON(MSG_ERR_FATAL, "Pixel shaders 2.0 not supported!");
}
// test na format backbufferu
if(FAILED(g_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, CVr_ref.GetBool() ? D3DDEVTYPE_REF : D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8, g_pEngSet.Windowed)))
{
CON(MSG_ERR_FATAL, "Backbuffer format A8R8G8B8 not supported!");
}
// ziskej caps do member promennych
m_caps_max_anisotr = (int)m_caps.MaxAnisotropy;
// Set up the structure used to create the D3DDevice
ZeroMemory( &m_pparams, sizeof(m_pparams) );
m_pparams.Windowed = g_pEngSet.Windowed;
m_pparams.hDeviceWindow = hWnd;
m_pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_pparams.BackBufferCount = 1;
m_pparams.BackBufferFormat = D3DFMT_A8R8G8B8;
m_pparams.EnableAutoDepthStencil = TRUE;
m_pparams.AutoDepthStencilFormat = DepthBufFormat;
m_pparams.BackBufferWidth = g_pEngSet.Width;
m_pparams.BackBufferHeight = g_pEngSet.Height;
m_pparams.MultiSampleType = CVr_multisample.GetInt() ? D3DMULTISAMPLE_NONMASKABLE : D3DMULTISAMPLE_NONE;
m_pparams.MultiSampleQuality = CVr_multisample.GetInt();
m_pparams.PresentationInterval = CVr_vsync.GetBool() ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
m_pparams.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER | D3DPRESENT_LINEAR_CONTENT;
m_nWidth = g_pEngSet.Width;
m_nHeight = g_pEngSet.Height;
#ifdef _DEBUG
CON(MSG_CON_INFO, "= DirectX 9 (D3D%d, D3DX%d) Renderer (%s, %s, DEBUG) initialization =", D3D_SDK_VERSION, D3DX_SDK_VERSION,__DATE__, __TIME__);
#else
CON(MSG_CON_INFO, "= DirectX 9 (D3D%d, D3DX%d) Renderer (%s, %s) initialization =", D3D_SDK_VERSION, D3DX_SDK_VERSION, __DATE__, __TIME__);
#endif
// vypis nazev a info o grafarne do konzole
D3DADAPTER_IDENTIFIER9 ai;
if(SUCCEEDED(g_pD3D->GetAdapterIdentifier(CVr_adapter.GetInt(), 0, &ai)))
{
CON(MSG_CON_INFO, "Renderer: %s", ai.Description);
}
// vytvoreni zarizeni
#ifdef USE_PERFHUD
// debug pre NVPerfHUD
if (FAILED (g_pD3D->CreateDevice (g_pD3D->GetAdapterCount()-1, D3DDEVTYPE_REF, hWnd, \
D3DCREATE_HARDWARE_VERTEXPROCESSING, &m_pparams, &g_pD3DDevice)))
#else
if (FAILED (g_pD3D->CreateDevice( CVr_adapter.GetInt(), CVr_ref.GetBool() ? D3DDEVTYPE_REF : D3DDEVTYPE_HAL, hWnd, \
D3DCREATE_HARDWARE_VERTEXPROCESSING, &m_pparams, &g_pD3DDevice)))
#endif
{
CON(MSG_ERR_FATAL, "Renderer: Can't create rendering device!\n\rTry restart or reinstall game...\n\rTry reinstall DirectX and graphic drivers...");
//.........这里部分代码省略.........
示例3: InfestMarine
void CASW_Parasite::InfestMarine(CASW_Marine* pMarine)
{
if ( !pMarine )
return;
pMarine->BecomeInfested(this);
// attach
int attachment = pMarine->LookupAttachment( "chest" );
if ( attachment )
{
SetSolid( SOLID_NONE );
SetMoveType( MOVETYPE_NONE );
QAngle current(0,0,0);
Vector diff = pMarine->GetAbsOrigin() - GetAbsOrigin();
float angle = UTIL_VecToYaw(diff);
angle -= pMarine->GetAbsAngles()[YAW]; // get the diff between our angle from the marine and the marine's facing;
current = GetAbsAngles();
Vector vAttachmentPos;
pMarine->GetAttachment( attachment, vAttachmentPos );
// Make sure it's near the chest attachement before parenting
Teleport( &vAttachmentPos, &vec3_angle, &vec3_origin );
SetParent( pMarine, attachment );
float flRaise = RandomFloat( 15.0f, 18.0f );
float flForward = RandomFloat( -3.0f, 0.0f );
float flSide = RandomFloat( 1.75f, 3.0f ) * ( RandomInt( 0, 1 ) == 0 ? 1.0f : -1.0f );
if ( asw_debug_alien_damage.GetBool() )
{
Msg( "INFEST: flRaise = %f flForward = %f flSide = %f yaw = %f\n", flRaise, flForward, flSide, angle + asw_infest_angle.GetFloat() );
}
SetLocalOrigin( Vector( flForward, flSide, flRaise ) );
SetLocalAngles( QAngle( asw_infest_pitch.GetFloat(), angle + asw_infest_angle.GetFloat(), 0 ) );
// play our infesting anim
if ( asw_parasite_inside.GetBool() )
{
SetActivity(ACT_RANGE_ATTACK2);
}
else
{
int iInfestAttack = LookupSequence("Infest_attack");
if (GetSequence() != iInfestAttack)
{
ResetSequence(iInfestAttack);
}
}
AddFlag( FL_NOTARGET );
SetThink( &CASW_Parasite::InfestThink );
SetTouch( NULL );
m_bInfesting = true;
}
else
{
FinishedInfesting();
}
}
示例4: FX_DebrisFlecks
//-----------------------------------------------------------------------------
// Purpose: Debris flecks caused by impacts
// Input : origin - start
// *trace - trace information
// *materialName - material hit
// materialType - type of material hit
//-----------------------------------------------------------------------------
void FX_DebrisFlecks( const Vector& origin, trace_t *tr, char materialType, int iScale, bool bNoFlecks )
{
VPROF_BUDGET( "FX_DebrisFlecks", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
if ( !fx_drawimpactdebris.GetBool() )
return;
#ifdef _XBOX
//
// XBox version
//
Vector offset;
float spread = 0.2f;
CSmartPtr<CDustParticle> pSimple = CDustParticle::Create( "dust" );
pSimple->SetSortOrigin( origin );
// Lock the bbox
pSimple->GetBinding().SetBBox( origin - ( Vector( 16, 16, 16 ) * iScale ), origin + ( Vector( 16, 16, 16 ) * iScale ) );
// Get the color of the surface we've impacted
Vector color;
float colorRamp;
GetColorForSurface( tr, &color );
int i;
SimpleParticle *pParticle;
for ( i = 0; i < 4; i++ )
{
if ( i == 3 )
{
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), g_Mat_BloodPuff[0], origin );
}
else
{
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), g_Mat_DustPuff[0], origin );
}
if ( pParticle != NULL )
{
pParticle->m_flLifetime = 0.0f;
pParticle->m_flDieTime = random->RandomFloat( 0.5f, 1.0f );
pParticle->m_vecVelocity.Random( -spread, spread );
pParticle->m_vecVelocity += ( tr->plane.normal * random->RandomFloat( 1.0f, 6.0f ) );
VectorNormalize( pParticle->m_vecVelocity );
float fForce = random->RandomFloat( 250, 500 ) * i * 0.5f;
// scaled
pParticle->m_vecVelocity *= fForce * iScale;
// Ramp the color
colorRamp = random->RandomFloat( 0.5f, 1.25f );
pParticle->m_uchColor[0] = MIN( 1.0f, color[0] * colorRamp ) * 255.0f;
pParticle->m_uchColor[1] = MIN( 1.0f, color[1] * colorRamp ) * 255.0f;
pParticle->m_uchColor[2] = MIN( 1.0f, color[2] * colorRamp ) * 255.0f;
// scaled
pParticle->m_uchStartSize = (iScale*0.5f) * random->RandomInt( 3, 4 ) * (i+1);
// scaled
pParticle->m_uchEndSize = (iScale*0.5f) * pParticle->m_uchStartSize * 4;
pParticle->m_uchStartAlpha = random->RandomInt( 200, 255 );
pParticle->m_uchEndAlpha = 0;
pParticle->m_flRoll = random->RandomInt( 0, 360 );
pParticle->m_flRollDelta = random->RandomFloat( -1.0f, 1.0f );
}
}
// Covers the impact spot with flecks
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), g_DustPuff2, origin );
if ( pParticle != NULL )
{
offset = origin;
offset[0] += random->RandomFloat( -8.0f, 8.0f );
offset[1] += random->RandomFloat( -8.0f, 8.0f );
pParticle->m_flLifetime = 0.0f;
pParticle->m_flDieTime = random->RandomFloat( 0.5f, 1.0f );
spread = 1.0f;
pParticle->m_vecVelocity.Init();
colorRamp = random->RandomFloat( 0.5f, 1.25f );
//.........这里部分代码省略.........
示例5: Explode
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFWeaponBaseGrenadeProj::Explode( trace_t *pTrace, int bitsDamageType )
{
SetModelName( NULL_STRING );//invisible
AddSolidFlags( FSOLID_NOT_SOLID );
m_takedamage = DAMAGE_NO;
// Pull out of the wall a bit
if ( pTrace->fraction != 1.0 )
{
SetAbsOrigin( pTrace->endpos + ( pTrace->plane.normal * 1.0f ) );
}
CSoundEnt::InsertSound ( SOUND_COMBAT, GetAbsOrigin(), BASEGRENADE_EXPLOSION_VOLUME, 3.0 );
// Explosion effect on client
Vector vecOrigin = GetAbsOrigin();
CPVSFilter filter( vecOrigin );
if ( UseImpactNormal() )
{
if ( pTrace->m_pEnt && pTrace->m_pEnt->IsPlayer() )
{
TE_TFExplosion( filter, 0.0f, vecOrigin, GetImpactNormal(), GetWeaponID(), pTrace->m_pEnt->entindex() );
}
else
{
TE_TFExplosion( filter, 0.0f, vecOrigin, GetImpactNormal(), GetWeaponID(), -1 );
}
}
else
{
if ( pTrace->m_pEnt && pTrace->m_pEnt->IsPlayer() )
{
TE_TFExplosion( filter, 0.0f, vecOrigin, pTrace->plane.normal, GetWeaponID(), pTrace->m_pEnt->entindex() );
}
else
{
TE_TFExplosion( filter, 0.0f, vecOrigin, pTrace->plane.normal, GetWeaponID(), -1 );
}
}
// Use the thrower's position as the reported position
Vector vecReported = GetThrower() ? GetThrower()->GetAbsOrigin() : vec3_origin;
CTakeDamageInfo info( this, GetThrower(), GetBlastForce(), GetAbsOrigin(), m_flDamage, bitsDamageType, 0, &vecReported );
float flRadius = GetDamageRadius();
if ( tf_grenade_show_radius.GetBool() )
{
DrawRadius( flRadius );
}
RadiusDamage( info, vecOrigin, flRadius, CLASS_NONE, NULL );
// Don't decal players with scorch.
if ( pTrace->m_pEnt && !pTrace->m_pEnt->IsPlayer() )
{
UTIL_DecalTrace( pTrace, "Scorch" );
}
SetThink( &CBaseGrenade::SUB_Remove );
SetTouch( NULL );
AddEffects( EF_NODRAW );
SetAbsVelocity( vec3_origin );
SetNextThink( gpGlobals->curtime );
}
示例6: Draw
//--------------------------------------------------------------------------------------------------------------
void CNavNode::Draw( void )
{
#if DEBUG_NAV_NODES
if ( !nav_show_nodes.GetBool() )
return;
int r = 0, g = 0, b = 0;
if ( m_isCovered )
{
if ( GetAttributes() & NAV_MESH_CROUCH )
{
b = 255;
}
else
{
r = 255;
}
}
else
{
if ( GetAttributes() & NAV_MESH_CROUCH )
{
b = 255;
}
g = 255;
}
NDebugOverlay::Cross3D( m_pos, 2, r, g, b, true, 0.1f );
if ( (!m_isCovered && nav_show_node_id.GetBool()) || (m_isCovered && nav_show_node_id.GetInt() < 0) )
{
char text[16];
Q_snprintf( text, sizeof( text ), "%d", m_id );
NDebugOverlay::Text( m_pos, text, true, 0.1f );
}
if ( (unsigned int)(nav_test_node.GetInt()) == m_id )
{
TheNavMesh->TestArea( this, 1, 1 );
nav_test_node.SetValue( 0 );
}
if ( (unsigned int)(nav_test_node_crouch.GetInt()) == m_id )
{
CheckCrouch();
nav_test_node_crouch.SetValue( 0 );
}
if ( GetAttributes() & NAV_MESH_CROUCH )
{
int i;
for( i=0; i<NUM_CORNERS; i++ )
{
if ( m_crouch[i] )
{
Vector2D dir;
CornerToVector2D( (NavCornerType)i, &dir );
const float scale = 3.0f;
Vector scaled( dir.x * scale, dir.y * scale, 0 );
NDebugOverlay::HorzArrow( m_pos, m_pos + scaled, 0.5, 0, 0, 255, 255, true, 0.1f );
}
}
}
#endif // DEBUG_NAV_NODES
}
示例7: ClientThink
void C_GlobalLight::ClientThink()
{
VPROF("C_GlobalLight::ClientThink");
bool bSupressWorldLights = false;
if ( cl_globallight_freeze.GetBool() == true )
{
return;
}
if ( m_bEnabled )
{
Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b );
float flLinearFloatLightAlpha = m_LightColor.a;
if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha )
{
float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f;
m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed );
m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed );
m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed );
m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed );
}
FlashlightState_t state;
Vector vDirection = m_shadowDirection;
VectorNormalize( vDirection );
//Vector vViewUp = Vector( 0.0f, 1.0f, 0.0f );
Vector vSunDirection2D = vDirection;
vSunDirection2D.z = 0.0f;
HACK_GETLOCALPLAYER_GUARD( "C_GlobalLight::ClientThink" );
if ( !C_BasePlayer::GetLocalPlayer() )
return;
Vector vPos;
QAngle EyeAngles;
float flZNear, flZFar, flFov;
C_BasePlayer::GetLocalPlayer()->CalcView( vPos, EyeAngles, flZNear, flZFar, flFov );
// Vector vPos = C_BasePlayer::GetLocalPlayer()->GetAbsOrigin();
// vPos = Vector( 0.0f, 0.0f, 500.0f );
vPos = ( vPos + vSunDirection2D * m_flNorthOffset ) - vDirection * m_flSunDistance;
vPos += Vector( cl_globallight_xoffset.GetFloat(), cl_globallight_yoffset.GetFloat(), 0.0f );
QAngle angAngles;
VectorAngles( vDirection, angAngles );
Vector vForward, vRight, vUp;
AngleVectors( angAngles, &vForward, &vRight, &vUp );
state.m_fHorizontalFOVDegrees = m_flFOV;
state.m_fVerticalFOVDegrees = m_flFOV;
state.m_vecLightOrigin = vPos;
BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation );
state.m_fQuadraticAtten = 0.0f;
state.m_fLinearAtten = m_flSunDistance * 2.0f;
state.m_fConstantAtten = 0.0f;
state.m_FarZAtten = m_flSunDistance * 2.0f;
state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient;
state.m_NearZ = 4.0f;
state.m_FarZ = m_flSunDistance * 2.0f;
state.m_fBrightnessScale = 2.0f;
state.m_bGlobalLight = true;
float flOrthoSize = 1000.0f;
if ( flOrthoSize > 0 )
{
state.m_bOrtho = true;
state.m_fOrthoLeft = -flOrthoSize;
state.m_fOrthoTop = -flOrthoSize;
state.m_fOrthoRight = flOrthoSize;
state.m_fOrthoBottom = flOrthoSize;
}
else
{
state.m_bOrtho = false;
}
state.m_bDrawShadowFrustum = true;
state.m_flShadowSlopeScaleDepthBias = g_pMaterialSystemHardwareConfig->GetShadowSlopeScaleDepthBias();;
state.m_flShadowDepthBias = g_pMaterialSystemHardwareConfig->GetShadowDepthBias();
state.m_bEnableShadows = m_bEnableShadows;
state.m_pSpotlightTexture = m_SpotlightTexture;
state.m_pProjectedMaterial = NULL; // don't complain cause we aren't using simple projection in this class
state.m_nSpotlightTextureFrame = 0;
state.m_nShadowQuality = 1; // Allow entity to affect shadow quality
//.........这里部分代码省略.........
示例8: Paint
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNetGraphPanel::Paint()
{
VPROF( "CNetGraphPanel::Paint" );
// Don't display net_graph if taking freezecam screenshot and hud_freezecamhide is enabled
extern ConVar hud_freezecamhide;
if ( hud_freezecamhide.GetBool() && IsTakingAFreezecamScreenshot() )
return;
int graphtype;
int x, y;
int w;
vrect_t vrect;
int maxmsgbytes = 0;
float avg_message = 0.0f;
float warning_threshold = 0.0f;
if ( ( graphtype = GraphValue() ) == 0 )
return;
// Since we divide by scale, make sure it's sensible
if ( net_scale.GetFloat() <= 0 )
{
net_scale.SetValue( 0.1f );
}
int sw, sh;
surface()->GetScreenSize( sw, sh );
// Get screen rectangle
vrect.x = 0;
vrect.y = 0;
vrect.width = sw;
vrect.height = sh;
w = MIN( (int)TIMINGS, m_EstimatedWidth );
if ( vrect.width < w + 10 )
{
w = vrect.width - 10;
}
// get current client netchannel INetChannelInfo interface
INetChannelInfo *nci = engine->GetNetChannelInfo();
if ( nci )
{
// update incoming data
GetFrameData( nci, &maxmsgbytes, &avg_message, &warning_threshold );
// update outgoing data
GetCommandInfo( nci, m_Cmdinfo );
UpdateEstimatedServerFramerate( nci );
}
GraphGetXY( &vrect, w, &x, &y );
if ( graphtype > 1 )
{
PaintLineArt( x, y, w, graphtype, maxmsgbytes );
DrawLargePacketSizes( x, w, graphtype, warning_threshold );
}
// Draw client frame timing info
DrawTimes( vrect, m_Cmdinfo, x, w, graphtype );
DrawTextFields( graphtype, x, y, w, m_Graph, m_Cmdinfo );
}
示例9: PaintLineArt
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNetGraphPanel::PaintLineArt( int x, int y, int w, int graphtype, int maxmsgbytes )
{
VPROF( "CNetGraphPanel::PaintLineArt" );
ResetLineSegments();
int lastvalidh = 0;
byte color[3];
int ping;
byte alpha;
vrect_t rcFill = {0,0,0,0};
int pingheight = m_nNetGraphHeight - LERP_HEIGHT - 2;
if (net_graphmsecs.GetInt() < 50 )
{
net_graphmsecs.SetValue( 50 );
}
bool bShowLatency = net_graphshowlatency.GetBool() && graphtype >= 2;
for (int a=0 ; a<w ; a++)
{
int i = (m_IncomingSequence-a) & ( TIMINGS - 1 );
int h = bShowLatency ? m_PacketLatency[i].latency : 0;
packet_latency_t *pl = &m_PacketLatency[ i ];
ColorForHeight( pl, color, &ping, &alpha );
// Skipped
if ( !ping )
{
// Re-use the last latency
h = lastvalidh;
}
else
{
h = pingheight * (float)h/net_graphmsecs.GetFloat();
lastvalidh = h;
}
if ( h > pingheight )
{
h = pingheight;
}
rcFill.x = x + w -a -1;
rcFill.y = y - h;
rcFill.width = 1;
rcFill.height = h;
if ( ping )
{
rcFill.height = pl->choked ? 2 : 1;
}
if ( !ping )
{
DrawLine2(&rcFill, color, color, alpha, 31 );
}
else
{
DrawLine(&rcFill, color, alpha );
}
rcFill.y = y;
rcFill.height = 1;
color[0] = 0;
color[1] = 255;
color[2] = 0;
DrawLine( &rcFill, color, 160 );
if ( graphtype < 2 )
continue;
// Draw a separator.
rcFill.y = y - m_nNetGraphHeight - 1;
rcFill.height = 1;
color[0] = 255;
color[1] = 255;
color[2] = 255;
DrawLine(&rcFill, color, 255 );
// Move up for begining of data
rcFill.y -= 1;
// Packet didn't have any real data...
if ( m_PacketLatency[i].latency > 9995 )
continue;
if ( !DrawDataSegment( &rcFill, m_Graph[ i ].msgbytes[INetChannelInfo::LOCALPLAYER], 0, 0, 255 ) )
continue;
//.........这里部分代码省略.........
示例10: FindLateralCover
bool CAI_TacticalServices::FindLateralCover( const Vector &vNearPos, const Vector &vecThreat, float flMinDist, float distToCheck, int numChecksPerDir, Vector *pResult )
{
AI_PROFILE_SCOPE( CAI_TacticalServices_FindLateralCover );
MARK_TASK_EXPENSIVE();
Vector vecLeftTest;
Vector vecRightTest;
Vector vecStepRight;
Vector vecCheckStart;
int i;
if ( TestLateralCover( vecThreat, vNearPos, flMinDist ) )
{
*pResult = GetLocalOrigin();
return true;
}
if( !ai_find_lateral_cover.GetBool() )
{
// Force the NPC to use the nodegraph to find cover. NOTE: We let the above code run
// to detect the case where the NPC may already be standing in cover, but we don't
// make any additional lateral checks.
return false;
}
Vector right = vecThreat - vNearPos;
float temp;
right.z = 0;
VectorNormalize( right );
temp = right.x;
right.x = -right.y;
right.y = temp;
vecStepRight = right * (distToCheck / (float)numChecksPerDir);
vecStepRight.z = 0;
vecLeftTest = vecRightTest = vNearPos;
vecCheckStart = vecThreat;
for ( i = 0 ; i < numChecksPerDir ; i++ )
{
vecLeftTest = vecLeftTest - vecStepRight;
vecRightTest = vecRightTest + vecStepRight;
if (TestLateralCover( vecCheckStart, vecLeftTest, flMinDist ))
{
*pResult = vecLeftTest;
return true;
}
if (TestLateralCover( vecCheckStart, vecRightTest, flMinDist ))
{
*pResult = vecRightTest;
return true;
}
}
return false;
}
示例11: FindLateralLos
bool CAI_TacticalServices::FindLateralLos( const Vector &vecThreat, Vector *pResult )
{
AI_PROFILE_SCOPE( CAI_TacticalServices_FindLateralLos );
if( !m_bAllowFindLateralLos )
{
return false;
}
MARK_TASK_EXPENSIVE();
Vector vecLeftTest;
Vector vecRightTest;
Vector vecStepRight;
Vector vecCheckStart;
bool bLookingForEnemy = GetEnemy() && VectorsAreEqual(vecThreat, GetEnemy()->EyePosition(), 0.1f);
int i;
if( !bLookingForEnemy || GetOuter()->HasCondition(COND_SEE_ENEMY) || GetOuter()->HasCondition(COND_HAVE_ENEMY_LOS) ||
GetOuter()->GetTimeScheduleStarted() == gpGlobals->curtime ) // Conditions get nuked before tasks run, assume should try
{
// My current position might already be valid.
if ( TestLateralLos(vecThreat, GetLocalOrigin()) )
{
*pResult = GetLocalOrigin();
return true;
}
}
if( !ai_find_lateral_los.GetBool() )
{
// Allows us to turn off lateral LOS at the console. Allow the above code to run
// just in case the NPC has line of sight to begin with.
return false;
}
int iChecks = COVER_CHECKS;
int iDelta = COVER_DELTA;
// If we're limited in how far we're allowed to move laterally, don't bother checking past it
int iMaxLateralDelta = GetOuter()->GetMaxTacticalLateralMovement();
if ( iMaxLateralDelta != MAXTACLAT_IGNORE && iMaxLateralDelta < iDelta )
{
iChecks = 1;
iDelta = iMaxLateralDelta;
}
Vector right;
AngleVectors( GetLocalAngles(), NULL, &right, NULL );
vecStepRight = right * iDelta;
vecStepRight.z = 0;
vecLeftTest = vecRightTest = GetLocalOrigin();
vecCheckStart = vecThreat;
for ( i = 0 ; i < iChecks; i++ )
{
vecLeftTest = vecLeftTest - vecStepRight;
vecRightTest = vecRightTest + vecStepRight;
if (TestLateralLos( vecCheckStart, vecLeftTest ))
{
*pResult = vecLeftTest;
return true;
}
if (TestLateralLos( vecCheckStart, vecRightTest ))
{
*pResult = vecRightTest;
return true;
}
}
return false;
}
示例12: SetPlayerAvoidState
void CNPC_Dog::SetPlayerAvoidState( void )
{
bool bIntersectingBoneFollowers = false;
bool bIntersectingNPCBox = false;
Vector vNothing;
GetSequenceLinearMotion( GetSequence(), &vNothing );
bool bIsMoving = ( IsMoving() || ( vNothing != vec3_origin ) );
//If we are coming out of a script, check if we are stuck inside the player.
if ( m_bPerformAvoidance || ( ShouldPlayerAvoid() && bIsMoving ) )
{
trace_t trace;
Vector vMins, vMaxs;
Vector vWorldMins, vWorldMaxs;
Vector vPlayerMins, vPlayerMaxs;
physfollower_t *pBone;
int i;
#ifdef SecobMod__Enable_Fixed_Multiplayer_AI
CBasePlayer *pLocalPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
#else
CBasePlayer *pLocalPlayer = AI_GetSinglePlayer();
#endif //SecobMod__Enable_Fixed_Multiplayer_AI
if ( pLocalPlayer )
{
vWorldMins = WorldAlignMins();
vWorldMaxs = WorldAlignMaxs();
vPlayerMins = pLocalPlayer->GetAbsOrigin() + pLocalPlayer->WorldAlignMins();
vPlayerMaxs = pLocalPlayer->GetAbsOrigin() + pLocalPlayer->WorldAlignMaxs();
// check if the player intersects the bounds of any of the bone followers
for ( i = 0; i < m_BoneFollowerManager.GetNumBoneFollowers(); i++ )
{
pBone = m_BoneFollowerManager.GetBoneFollower( i );
if ( pBone && pBone->hFollower )
{
pBone->hFollower->CollisionProp()->WorldSpaceSurroundingBounds( &vMins, &vMaxs );
if ( IsBoxIntersectingBox( vMins, vMaxs, vPlayerMins, vPlayerMaxs ) )
{
bIntersectingBoneFollowers = true;
break;
}
}
}
bIntersectingNPCBox = IsBoxIntersectingBox( GetAbsOrigin() + vWorldMins, GetAbsOrigin() + vWorldMaxs, vPlayerMins, vPlayerMaxs );
if ( ai_debug_avoidancebounds.GetBool() )
{
int iRed = ( bIntersectingNPCBox == true ) ? 255 : 0;
NDebugOverlay::Box( GetAbsOrigin(), vWorldMins, vWorldMaxs, iRed, 0, 255, 64, 0.1 );
// draw the bounds of the bone followers
for ( i = 0; i < m_BoneFollowerManager.GetNumBoneFollowers(); i++ )
{
pBone = m_BoneFollowerManager.GetBoneFollower( i );
if ( pBone && pBone->hFollower )
{
pBone->hFollower->CollisionProp()->WorldSpaceSurroundingBounds( &vMins, &vMaxs );
iRed = ( IsBoxIntersectingBox( vMins, vMaxs, vPlayerMins, vPlayerMaxs ) ) ? 255 : 0;
NDebugOverlay::Box( vec3_origin, vMins, vMaxs, iRed, 0, 255, 64, 0.1 );
}
}
}
}
}
m_bPlayerAvoidState = ShouldPlayerAvoid();
m_bPerformAvoidance = bIntersectingNPCBox || bIntersectingBoneFollowers;
if ( GetCollisionGroup() == COLLISION_GROUP_NPC || GetCollisionGroup() == COLLISION_GROUP_NPC_ACTOR )
{
if ( bIntersectingNPCBox == true )
{
SetCollisionGroup( COLLISION_GROUP_NPC_ACTOR );
}
else
{
SetCollisionGroup( COLLISION_GROUP_NPC );
}
if ( bIntersectingBoneFollowers == true )
{
MantainBoneFollowerCollisionGroups( COLLISION_GROUP_NPC_ACTOR );
}
else
{
MantainBoneFollowerCollisionGroups( COLLISION_GROUP_NPC );
}
}
}
示例13: FindPhysicsObject
bool CNPC_Dog::FindPhysicsObject( const char *pPickupName, CBaseEntity *pIgnore )
{
CBaseEntity *pEnt = NULL;
CBaseEntity *pNearest = NULL;
float flDist;
IPhysicsObject *pPhysObj = NULL;
float flNearestDist = 99999;
if ( pPickupName != NULL && strlen( pPickupName ) > 0 )
{
pEnt = gEntList.FindEntityByName( NULL, pPickupName );
if ( m_hUnreachableObjects.Find( pEnt ) == -1 )
{
m_bHasObject = false;
m_hPhysicsEnt = pEnt;
return true;
}
}
while ( ( pEnt = gEntList.FindEntityByClassname( pEnt, "prop_physics" ) ) != NULL )
{
//We don't want this one.
if ( pEnt == pIgnore )
continue;
if ( m_hUnreachableObjects.Find( pEnt ) != -1 )
continue;
pPhysObj = pEnt->VPhysicsGetObject();
if( pPhysObj == NULL )
continue;
if ( pPhysObj->GetMass() > DOG_MAX_THROW_MASS )
continue;
Vector center = pEnt->WorldSpaceCenter();
flDist = UTIL_DistApprox2D( GetAbsOrigin(), center );
vcollide_t *pCollide = modelinfo->GetVCollide( pEnt->GetModelIndex() );
if ( pCollide == NULL )
continue;
if ( pPhysObj->GetGameFlags() & FVPHYSICS_PLAYER_HELD )
continue;
if ( pPhysObj->IsMoveable() == false )
continue;
if ( pEnt->GetCollisionGroup() == COLLISION_GROUP_DEBRIS ||
pEnt->GetCollisionGroup() == COLLISION_GROUP_INTERACTIVE_DEBRIS )
continue;
if ( center.z > EyePosition().z )
continue;
if ( flDist >= flNearestDist )
continue;
if ( FVisible( pEnt ) == false )
continue;
pNearest = pEnt;
flNearestDist = flDist;
}
m_bHasObject = false;
m_hPhysicsEnt = pNearest;
if ( dog_debug.GetBool() == true )
{
if ( pNearest )
NDebugOverlay::Box( pNearest->WorldSpaceCenter(), pNearest->CollisionProp()->OBBMins(), pNearest->CollisionProp()->OBBMaxs(), 255, 0, 255, true, 3 );
}
if( m_hPhysicsEnt == NULL )
{
return false;
}
else
{
return true;
}
}
示例14: FireBullet
void CBliinkPlayer::FireBullet(
Vector vecSrc, // shooting postion
const QAngle &shootAngles, //shooting angle
float vecSpread, // spread vector
int iDamage, // base damage
int iBulletType, // ammo type
CBaseEntity *pevAttacker, // shooter
bool bDoEffects, // create impact effect ?
float x, // spread x factor
float y // spread y factor
)
{
float fCurrentDamage = iDamage; // damage of the bullet at it's current trajectory
float flCurrentDistance = 0.0; //distance that the bullet has traveled so far
// Increasing damage based on the player's stats.
fCurrentDamage *= GetBliinkPlayerStats().GetDamagePercent();
Vector vecDirShooting, vecRight, vecUp;
AngleVectors( shootAngles, &vecDirShooting, &vecRight, &vecUp );
if ( !pevAttacker )
pevAttacker = this; // the default attacker is ourselves
// add the spray
Vector vecDir = vecDirShooting +
x * vecSpread * vecRight +
y * vecSpread * vecUp;
VectorNormalize( vecDir );
float flMaxRange = 8000;
Vector vecEnd = vecSrc + vecDir * flMaxRange; // max bullet range is 10000 units
trace_t tr; // main enter bullet trace
UTIL_TraceLine( vecSrc, vecEnd, MASK_SOLID|CONTENTS_DEBRIS|CONTENTS_HITBOX, this, COLLISION_GROUP_NONE, &tr );
if ( tr.fraction == 1.0f )
return; // we didn't hit anything, stop tracing shoot
if ( sv_showimpacts.GetBool() )
{
#ifdef CLIENT_DLL
// draw red client impact markers
debugoverlay->AddBoxOverlay( tr.endpos, Vector(-2,-2,-2), Vector(2,2,2), QAngle( 0, 0, 0), 255,0,0,127, 4 );
if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )
{
C_BasePlayer *player = ToBasePlayer( tr.m_pEnt );
player->DrawClientHitboxes( 4, true );
}
#else
// draw blue server impact markers
NDebugOverlay::Box( tr.endpos, Vector(-2,-2,-2), Vector(2,2,2), 0,0,255,127, 4 );
if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )
{
CBasePlayer *player = ToBasePlayer( tr.m_pEnt );
player->DrawServerHitboxes( 4, true );
}
#endif
}
//calculate the damage based on the distance the bullet travelled.
flCurrentDistance += tr.fraction * flMaxRange;
// damage get weaker of distance
fCurrentDamage *= pow ( 0.85f, (flCurrentDistance / 500));
int iDamageType = DMG_BULLET | DMG_NEVERGIB;
#ifndef CLIENT_DLL
CBliinkPlayer* pAttacker = static_cast<CBliinkPlayer*> ( pevAttacker );
int iActiveAmmo = GetAmmoDef()->Index( pAttacker->GetActiveWeapon()->GetWpnData().szAmmo1 );
int iAmmoSubtype = pAttacker->GetBliinkInventory().GetAmmoSubtype( iActiveAmmo );
switch( iAmmoSubtype )
{
case ITEM_STYPE_AMMO_NORMAL:
break;
case ITEM_STYPE_AMMO_POISON:
iDamageType &= DMG_POISON; break;
case ITEM_STYPE_AMMO_FOGGED:
iDamageType &= DMG_NERVEGAS; break;
case ITEM_STYPE_AMMO_FIRE:
iDamageType &= DMG_BURN; break;
case ITEM_STYPE_AMMO_SLOW:
iDamageType &= DMG_PARALYZE; break;
}
#endif
if( bDoEffects )
{
// See if the bullet ended up underwater + started out of the water
if ( enginetrace->GetPointContents( tr.endpos ) & (CONTENTS_WATER|CONTENTS_SLIME) )
{
trace_t waterTrace;
UTIL_TraceLine( vecSrc, tr.endpos, (MASK_SHOT|CONTENTS_WATER|CONTENTS_SLIME), this, COLLISION_GROUP_NONE, &waterTrace );
//.........这里部分代码省略.........
示例15: ItemBusyFrame
void CASW_Weapon::ItemBusyFrame( void )
{
CASW_Marine* pMarine = GetMarine();
if ( !pMarine )
return;
bool bAttack1, bAttack2, bReload, bOldReload, bOldAttack1;
GetButtons(bAttack1, bAttack2, bReload, bOldReload, bOldAttack1 );
// check for clearing our weapon switching bool
if (m_bSwitchingWeapons && gpGlobals->curtime > m_flNextPrimaryAttack)
{
m_bSwitchingWeapons = false;
}
// check for clearing our firing bool from reloading
if (m_bInReload && gpGlobals->curtime > m_fReloadClearFiringTime)
{
ClearIsFiring();
}
if ( (bReload && !bOldReload) && UsesClipsForAmmo1() && asw_fast_reload_enabled.GetBool() )
{
if ( m_bInReload )
{
// check for a fast reload
//Msg("%f Check for fast reload while busy\n", gpGlobals->curtime);
if (gpGlobals->curtime >= m_fFastReloadStart && gpGlobals->curtime <= m_fFastReloadEnd)
{
// todo: reduce next attack time
m_fFastReloadEnd = 0;
m_fFastReloadStart = 0;
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner )
{
float flSucceedDelay = gpGlobals->curtime + 0.5f;
pOwner->SetNextAttack( flSucceedDelay );
m_flNextPrimaryAttack = m_flNextSecondaryAttack = flSucceedDelay;
}
// TODO: hook up anim
//pMarine->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_SUCCEED );
DispatchParticleEffect( "fast_reload", PATTACH_POINT_FOLLOW, this, "muzzle" );
pMarine->m_flPreventLaserSightTime = gpGlobals->curtime + 2.5f;
#ifdef GAME_DLL
pMarine->m_nFastReloadsInARow++;
IGameEvent * event = gameeventmanager->CreateEvent( "fast_reload" );
if ( event )
{
event->SetInt( "marine", pMarine->entindex() );
event->SetInt( "reloads", pMarine->m_nFastReloadsInARow );
gameeventmanager->FireEvent( event );
}
if ( pMarine->m_nFastReloadsInARow >= 4 && pMarine->IsInhabited() )
{
if ( pMarine->GetMarineResource() )
{
pMarine->GetMarineResource()->m_bDidFastReloadsInARow = true;
}
if ( pMarine->GetCommander() )
{
pMarine->GetCommander()->AwardAchievement( ACHIEVEMENT_ASW_FAST_RELOADS_IN_A_ROW );
}
}
#endif
CSoundParameters params;
if ( !GetParametersForSound( "FastReload.Success", params, NULL ) )
return;
EmitSound_t playparams(params);
playparams.m_nPitch = params.pitch;
CASW_Player *pPlayer = GetCommander();
if ( pPlayer )
{
CSingleUserRecipientFilter filter( pMarine->GetCommander() );
if ( IsPredicted() && CBaseEntity::GetPredictionPlayer() )
{
filter.UsePredictionRules();
}
EmitSound(filter, entindex(), playparams);
}
//Msg("%f RELOAD SUCCESS! - bAttack1 = %d, bOldAttack1 = %d\n", gpGlobals->curtime, bAttack1, bOldAttack1 );
//Msg( "S: %f - %f - %f RELOAD SUCCESS! -- Progress = %f\n", gpGlobals->curtime, fFastStart, fFastEnd, flProgress );
#ifdef GAME_DLL
pMarine->GetMarineSpeech()->PersonalChatter(CHATTER_SELECTION);
#endif
m_bFastReloadSuccess = true;
m_bFastReloadFailure = false;
}
else if (m_fFastReloadStart != 0)
{
CSoundParameters params;
//.........这里部分代码省略.........