本文整理汇总了C++中CBaseEntity::CollisionProp方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseEntity::CollisionProp方法的具体用法?C++ CBaseEntity::CollisionProp怎么用?C++ CBaseEntity::CollisionProp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseEntity
的用法示例。
在下文中一共展示了CBaseEntity::CollisionProp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEntInfoPtr
//-----------------------------------------------------------------------------
// Purpose: Used to iterate all the entities within a sphere.
// Input : pStartEntity -
// vecCenter -
// flRadius -
//-----------------------------------------------------------------------------
CBaseEntity *CGlobalEntityList::FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius )
{
const CEntInfo *pInfo = pStartEntity ? GetEntInfoPtr( pStartEntity->GetRefEHandle() )->m_pNext : FirstEntInfo();
for ( ;pInfo; pInfo = pInfo->m_pNext )
{
CBaseEntity *ent = (CBaseEntity *)pInfo->m_pEntity;
if ( !ent )
{
DevWarning( "NULL entity in global entity list!\n" );
continue;
}
if ( !ent->edict() )
continue;
Vector vecRelativeCenter;
ent->CollisionProp()->WorldToCollisionSpace( vecCenter, &vecRelativeCenter );
if ( !IsBoxIntersectingSphere( ent->CollisionProp()->OBBMins(), ent->CollisionProp()->OBBMaxs(), vecRelativeCenter, flRadius ) )
continue;
return ent;
}
// nothing found
return NULL;
}
示例2: FriendNumber
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CBaseEntity *CNPCSimpleTalker::EnumFriends( CBaseEntity *pPrevious, int listNumber, bool bTrace )
{
CBaseEntity *pFriend = pPrevious;
char *pszFriend;
trace_t tr;
Vector vecCheck;
pszFriend = m_szFriends[ FriendNumber(listNumber) ];
while ( pszFriend != NULL && ((pFriend = gEntList.FindEntityByClassname( pFriend, pszFriend )) != NULL) )
{
if (pFriend == this || !pFriend->IsAlive())
// don't talk to self or dead people
continue;
if ( bTrace )
{
Vector vecCheck;
pFriend->CollisionProp()->NormalizedToWorldSpace( Vector( 0.5f, 0.5f, 1.0f ), &vecCheck );
UTIL_TraceLine( GetAbsOrigin(), vecCheck, MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr);
}
else
{
tr.fraction = 1.0;
}
if (tr.fraction == 1.0)
{
return pFriend;
}
}
return NULL;
}
示例3: OnPreQuery
//-----------------------------------------------------------------------------
// Makes sure all entries in the KD tree are in the correct position
//-----------------------------------------------------------------------------
void CDirtySpatialPartitionEntityList::OnPreQuery( SpatialPartitionListMask_t listMask )
{
#ifdef CLIENT_DLL
if ( !( listMask & PARTITION_CLIENT_GAME_EDICTS ) )
return;
// FIXME: This should really be an assertion... feh!
if ( !C_BaseEntity::IsAbsRecomputationsEnabled() )
{
m_mutex.Lock();
return;
}
#else
if ( !( listMask & PARTITION_SERVER_GAME_EDICTS ) )
return;
#endif
m_mutex.Lock();
CUtlVector< CBaseHandle > vecStillDirty;
int nDirtyEntityCount = m_DirtyEntities.Count();
while ( nDirtyEntityCount > 0 )
{
CBaseHandle handle;
handle = m_DirtyEntities[nDirtyEntityCount-1];
#ifndef CLIENT_DLL
CBaseEntity *pEntity = gEntList.GetBaseEntity( handle );
#else
CBaseEntity *pEntity = cl_entitylist->GetBaseEntityFromHandle( handle );
#endif
m_DirtyEntities.FastRemove( nDirtyEntityCount-1 );
if ( pEntity )
{
// If an entity is in the middle of bone setup, don't call UpdatePartition
// which can cause it to redo bone setup on the same frame causing a recursive
// call to bone setup.
if ( !pEntity->IsEFlagSet( EFL_SETTING_UP_BONES ) )
{
pEntity->CollisionProp()->UpdatePartition();
}
else
{
vecStillDirty.AddToTail( handle );
}
}
nDirtyEntityCount = m_DirtyEntities.Count();
}
if ( vecStillDirty.Count() > 0 )
{
m_DirtyEntities = vecStillDirty;
}
}
示例4: MaintainTargetInSlot
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponMedigun::MaintainTargetInSlot()
{
CTFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );
if ( !pOwner )
return;
CBaseEntity *pTarget = m_hHealingTarget;
Assert( pTarget );
// Make sure the guy didn't go out of range.
bool bLostTarget = true;
Vector vecSrc = pOwner->Weapon_ShootPosition( );
Vector vecTargetPoint = pTarget->WorldSpaceCenter();
Vector vecPoint;
// If it's brush built, use absmins/absmaxs
pTarget->CollisionProp()->CalcNearestPoint( vecSrc, &vecPoint );
float flDistance = (vecPoint - vecSrc).Length();
if ( flDistance < GetStickRange() )
{
if ( m_flNextTargetCheckTime > gpGlobals->curtime )
return;
m_flNextTargetCheckTime = gpGlobals->curtime + 1.0f;
trace_t tr;
CMedigunFilter drainFilter( pOwner );
Vector vecAiming;
pOwner->EyeVectors( &vecAiming );
Vector vecEnd = vecSrc + vecAiming * GetTargetRange();
UTIL_TraceLine( vecSrc, vecEnd, (MASK_SHOT & ~CONTENTS_HITBOX), pOwner, DMG_GENERIC, &tr );
// Still visible?
if ( tr.m_pEnt == pTarget )
return;
UTIL_TraceLine( vecSrc, vecTargetPoint, MASK_SHOT, &drainFilter, &tr );
// Still visible?
if (( tr.fraction == 1.0f) || (tr.m_pEnt == pTarget))
return;
// If we failed, try the target's eye point as well
UTIL_TraceLine( vecSrc, pTarget->EyePosition(), MASK_SHOT, &drainFilter, &tr );
if (( tr.fraction == 1.0f) || (tr.m_pEnt == pTarget))
return;
}
// We've lost this guy
if ( bLostTarget )
{
RemoveHealingTarget();
}
}
示例5:
//-----------------------------------------------------------------------------
// Purpose: Finds the nearest entity by class name withing given search radius.
// Input : szName - Entity name to search for. Treated as a target name first,
// then as an entity class name, ie "info_target".
// vecSrc - Center of search radius.
// flRadius - Search radius for classname search, 0 to search everywhere.
// Output : Returns a pointer to the found entity, NULL if none.
//-----------------------------------------------------------------------------
CBaseEntity *CGlobalEntityList::FindEntityByClassnameNearest( const char *szName, const Vector &vecSrc, float flRadius, int brushPrecision )
{
CBaseEntity *pEntity = NULL;
//
// Check for matching class names within the search radius.
//
float flMaxDist2 = flRadius * flRadius;
if (flMaxDist2 == 0)
{
flMaxDist2 = MAX_TRACE_LENGTH * MAX_TRACE_LENGTH;
}
CBaseEntity *pSearch = NULL;
while ((pSearch = gEntList.FindEntityByClassname( pSearch, szName )) != NULL)
{
if ( !pSearch->edict() )
continue;
Vector origin;
if ( pSearch->IsBSPModel() && pSearch->CollisionProp())
{
if ( brushPrecision == BRUSHPRECISION_NEAREST )
pSearch->CollisionProp()->CalcNearestPoint(vecSrc,&origin);
else
origin = pSearch->CollisionProp()->GetCollisionOrigin();
}
else
origin = pSearch->GetAbsOrigin();
float flDist2 = (origin - vecSrc).LengthSqr();
if (flMaxDist2 > flDist2)
{
pEntity = pSearch;
flMaxDist2 = flDist2;
}
}
return pEntity;
}
示例6: GenerateObstacleNpcs
void CAI_PlaneSolver::GenerateObstacleNpcs( const AILocalMoveGoal_t &goal, float probeDist )
{
if ( !ProbeForNpcs() )
{
CAI_BaseNPC **ppAIs = g_AI_Manager.AccessAIs();
Vector minsSelf, maxsSelf;
m_pNpc->CollisionProp()->WorldSpaceSurroundingBounds( &minsSelf, &maxsSelf );
float radiusSelf = (minsSelf.AsVector2D() - maxsSelf.AsVector2D()).Length() * 0.5;
for ( int i = 0; i < g_AI_Manager.NumAIs(); i++ )
{
CAI_BaseNPC *pAI = ppAIs[i];
if ( pAI != m_pNpc && pAI->IsAlive() && ( !goal.pPath || pAI != goal.pPath->GetTarget() ) )
{
Vector mins, maxs;
pAI->CollisionProp()->WorldSpaceSurroundingBounds( &mins, &maxs );
if ( mins.z < maxsSelf.z + 12.0 && maxs.z > minsSelf.z - 12.0 )
{
float radius = (mins.AsVector2D() - maxs.AsVector2D()).Length() * 0.5;
float distance = ( pAI->GetAbsOrigin().AsVector2D() - m_pNpc->GetAbsOrigin().AsVector2D() ).Length();
if ( distance - radius < radiusSelf + probeDist )
{
AddObstacle( pAI->WorldSpaceCenter(), radius, pAI, AIMST_AVOID_NPC );
}
}
}
}
#ifdef SecobMod__Enable_Fixed_Multiplayer_AI
CBaseEntity *pPlayer = UTIL_GetNearestPlayer(m_pNpc->GetAbsOrigin());
#else
CBaseEntity *pPlayer = UTIL_PlayerByIndex( 1 );
#endif //SecobMod__Enable_Fixed_Multiplayer_AI
if ( pPlayer )
{
Vector mins, maxs;
pPlayer->CollisionProp()->WorldSpaceSurroundingBounds( &mins, &maxs );
if ( mins.z < maxsSelf.z + 12.0 && maxs.z > minsSelf.z - 12.0 )
{
float radius = (mins.AsVector2D() - maxs.AsVector2D()).Length();
float distance = ( pPlayer->GetAbsOrigin().AsVector2D() - m_pNpc->GetAbsOrigin().AsVector2D() ).Length();
if ( distance - radius < radiusSelf + probeDist )
{
AddObstacle( pPlayer->WorldSpaceCenter(), radius, pPlayer, AIMST_AVOID_NPC );
}
}
}
}
}
示例7:
const matrix3x4_t *CCollisionProperty::GetRootParentToWorldTransform() const
{
if ( IsSolidFlagSet( FSOLID_ROOT_PARENT_ALIGNED ) )
{
CBaseEntity *pEntity = m_pOuter->GetRootMoveParent();
Assert(pEntity);
if ( pEntity )
{
return &pEntity->CollisionProp()->CollisionToWorldTransform();
}
}
return NULL;
}
示例8: OnDensityConVarChanged
void OnDensityConVarChanged( IConVar *var, const char *pOldValue, float flOldValue )
{
CBaseEntity *pEnt = gEntList.FirstEnt();
while( pEnt )
{
const Vector& vMins = pEnt->CollisionProp()->OBBMins();
const Vector& vMaxs = pEnt->CollisionProp()->OBBMaxs();
pEnt->DensityMap()->RecalculateWeights(vMins, vMaxs);
//pEnt->DensityMap()->OnCollisionSizeChanged();
pEnt = gEntList.NextEnt( pEnt );
}
}
示例9: SpawnItemFromRatio
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CItem_DynamicResupply::SpawnItemFromRatio( int nCount, DynamicResupplyItems_t *pItems, int iDebug, SpawnInfo_t *pSpawnInfo, Vector *pVecSpawnOrigin )
{
// Now find the one we're farthest from
float flFarthest = 0;
int iSelectedIndex = -1;
for ( int i = 0; i < nCount; ++i )
{
if ( pSpawnInfo[i].m_flDelta > flFarthest )
{
flFarthest = pSpawnInfo[i].m_flDelta;
iSelectedIndex = i;
}
}
if ( iSelectedIndex < 0 )
return false;
if ( iDebug )
{
Msg("Chosen item: %s (had farthest delta, %.2f)\n", pItems[iSelectedIndex].sEntityName, pSpawnInfo[iSelectedIndex].m_flDelta );
}
CBaseEntity *pEnt = CBaseEntity::Create( pItems[iSelectedIndex].sEntityName, *pVecSpawnOrigin, GetAbsAngles(), this );
pEnt->SetAbsVelocity( GetAbsVelocity() );
pEnt->SetLocalAngularVelocity( GetLocalAngularVelocity() );
// Move the entity up so that it doesn't go below the spawn origin
Vector vecWorldMins, vecWorldMaxs;
pEnt->CollisionProp()->WorldSpaceAABB( &vecWorldMins, &vecWorldMaxs );
if ( vecWorldMins.z < pVecSpawnOrigin->z )
{
float dz = pVecSpawnOrigin->z - vecWorldMins.z;
pVecSpawnOrigin->z += dz;
vecWorldMaxs.z += dz;
pEnt->SetAbsOrigin( *pVecSpawnOrigin );
}
// Update the spawn position to spawn them on top of each other
pVecSpawnOrigin->z = vecWorldMaxs.z + 6.0f;
pVecSpawnOrigin->x += random->RandomFloat( -6, 6 );
pVecSpawnOrigin->y += random->RandomFloat( -6, 6 );
return true;
}
示例10: GetControllingObjectOBBox
void CParticleSystemQuery::GetControllingObjectOBBox(
CParticleCollection *pParticles,
int nControlPointNumber, Vector vecMin, Vector vecMax )
{
vecMin = vecMax = vec3_origin;
#ifndef GAME_DLL
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->ControlPoint( nControlPointNumber ).m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
vecMin = pMoveParent->CollisionProp()->OBBMins();
vecMax = pMoveParent->CollisionProp()->OBBMaxs();
}
#endif
}
示例11:
//-----------------------------------------------------------------------------
// Purpose: Finds the first entity within an extent by class name.
// Input : pStartEntity - The entity to start from when doing the search.
// szName - Entity class name, ie "info_target".
// vecMins - Search mins.
// vecMaxs - Search maxs.
// Output : Returns a pointer to the found entity, NULL if none.
//-----------------------------------------------------------------------------
CBaseEntity *CGlobalEntityList::FindEntityByClassnameWithin( CBaseEntity *pStartEntity, const char *szName, const Vector &vecMins, const Vector &vecMaxs )
{
//
// Check for matching class names within the search radius.
//
CBaseEntity *pEntity = pStartEntity;
while ((pEntity = gEntList.FindEntityByClassname( pEntity, szName )) != NULL)
{
if ( !pEntity->edict() && !pEntity->IsEFlagSet( EFL_SERVER_ONLY ) )
continue;
// check if the aabb intersects the search aabb.
Vector entMins, entMaxs;
pEntity->CollisionProp()->WorldSpaceAABB( &entMins, &entMaxs );
if ( IsBoxIntersectingBox( vecMins, vecMaxs, entMins, entMaxs ) )
{
return pEntity;
}
}
return NULL;
}
示例12: GenerateCircleObstacleSuggestions
//-----------------------------------------------------------------------------
bool CAI_PlaneSolver::GenerateCircleObstacleSuggestions( const AILocalMoveGoal_t &moveGoal, float probeDist )
{
bool result = false;
Vector npcLoc = m_pNpc->WorldSpaceCenter();
Vector mins, maxs;
m_pNpc->CollisionProp()->WorldSpaceSurroundingBounds( &mins, &maxs );
float radiusNpc = (mins.AsVector2D() - maxs.AsVector2D()).Length() * 0.5;
for ( int i = 0; i < m_Obstacles.Count(); i++ )
{
CBaseEntity *pObstacleEntity = NULL;
float zDistTooFar;
if ( m_Obstacles[i].hEntity && m_Obstacles[i].hEntity->CollisionProp() )
{
pObstacleEntity = m_Obstacles[i].hEntity.Get();
if( pObstacleEntity == moveGoal.pMoveTarget && (pObstacleEntity->IsNPC() || pObstacleEntity->IsPlayer()) )
{
// HEY! I'm trying to avoid the very thing I'm trying to get to. This will make we wobble like a drunk as I approach. Don't do it.
continue;
}
pObstacleEntity->CollisionProp()->WorldSpaceSurroundingBounds( &mins, &maxs );
zDistTooFar = ( maxs.z - mins.z ) * 0.5 + GetNpc()->GetHullHeight() * 0.5;
}
else
zDistTooFar = GetNpc()->GetHullHeight();
if ( fabs( m_Obstacles[i].center.z - npcLoc.z ) > zDistTooFar )
continue;
Vector vecToNpc = npcLoc - m_Obstacles[i].center;
vecToNpc.z = 0;
float distToObstacleSq = sq(vecToNpc.x) + sq(vecToNpc.y);
float radius = m_Obstacles[i].radius + radiusNpc;
if ( distToObstacleSq > 0.001 && distToObstacleSq < sq( radius + probeDist ) )
{
Vector vecToObstacle = vecToNpc * -1;
float distToObstacle = VectorNormalize( vecToObstacle );
float weight;
float arc;
float radiusSq = sq(radius);
float flDot = DotProduct( vecToObstacle, moveGoal.dir );
// Don't steer around to avoid obstacles we've already passed, unless we're right up against them.
// That is, do this computation without the probeDist added in.
if( flDot < 0.0f && distToObstacleSq > radiusSq )
{
continue;
}
if ( radiusSq < distToObstacleSq )
{
Vector vecTangent;
float distToTangent = FastSqrt( distToObstacleSq - radiusSq );
float oneOverDistToObstacleSq = 1 / distToObstacleSq;
vecTangent.x = ( -distToTangent * vecToNpc.x + radius * vecToNpc.y ) * oneOverDistToObstacleSq;
vecTangent.y = ( -distToTangent * vecToNpc.y - radius * vecToNpc.x ) * oneOverDistToObstacleSq;
vecTangent.z = 0;
float cosHalfArc = vecToObstacle.Dot( vecTangent );
arc = RAD2DEG(acosf( cosHalfArc )) * 2.0;
weight = 1.0 - (distToObstacle - radius) / probeDist;
if ( weight > 0.75 )
arc += (arc * 0.5) * (weight - 0.75) / 0.25;
Assert( weight >= 0.0 && weight <= 1.0 );
#if DEBUG_OBSTACLES
// -------------------------
Msg( "Adding arc %f, w %f\n", arc, weight );
Vector pointTangent = npcLoc + ( vecTangent * distToTangent );
NDebugOverlay::Line( npcLoc - Vector( 0, 0, 64 ), npcLoc + Vector(0,0,64), 0,255,0, false, 0.1 );
NDebugOverlay::Line( center - Vector( 0, 0, 64 ), center + Vector(0,0,64), 0,255,0, false, 0.1 );
NDebugOverlay::Line( pointTangent - Vector( 0, 0, 64 ), pointTangent + Vector(0,0,64), 0,255,0, false, 0.1 );
NDebugOverlay::Line( npcLoc + Vector(0,0,64), center + Vector(0,0,64), 0,0,255, false, 0.1 );
NDebugOverlay::Line( center + Vector(0,0,64), pointTangent + Vector(0,0,64), 0,0,255, false, 0.1 );
NDebugOverlay::Line( pointTangent + Vector(0,0,64), npcLoc + Vector(0,0,64), 0,0,255, false, 0.1 );
#endif
}
else
{
arc = 210;
weight = 1.0;
}
if ( m_Obstacles[i].hEntity != NULL )
{
weight = AdjustRegulationWeight( m_Obstacles[i].hEntity, weight );
}
//.........这里部分代码省略.........
示例13: OnPreQuery
//-----------------------------------------------------------------------------
// Makes sure all entries in the KD tree are in the correct position
//-----------------------------------------------------------------------------
void CDirtySpatialPartitionEntityList::OnPreQuery( SpatialPartitionListMask_t listMask )
{
#ifdef CLIENT_DLL
const int validMask = PARTITION_CLIENT_GAME_EDICTS;
#else
const int validMask = PARTITION_SERVER_GAME_EDICTS;
#endif
if ( !( listMask & validMask ) )
return;
if ( m_partitionWriteId != 0 && m_partitionWriteId == ThreadGetCurrentId() )
return;
#ifdef CLIENT_DLL
// FIXME: This should really be an assertion... feh!
if ( !C_BaseEntity::IsAbsRecomputationsEnabled() )
{
LockPartitionForRead();
return;
}
#endif
// if you're holding a read lock, then these are entities that were still dirty after your trace started
// or became dirty due to some other thread or callback. Updating them may cause corruption further up the
// stack (e.g. partition iterator). Ignoring the state change should be safe since it happened after the
// trace was requested or was unable to be resolved in a previous attempt (still dirty).
if ( m_DirtyEntities.Count() && !m_readLockCount )
{
CUtlVector< CBaseHandle > vecStillDirty;
m_partitionMutex.LockForWrite();
m_partitionWriteId = ThreadGetCurrentId();
CTSListWithFreeList<CBaseHandle>::Node_t *pCurrent, *pNext;
while ( ( pCurrent = m_DirtyEntities.Detach() ) != NULL )
{
while ( pCurrent )
{
CBaseHandle handle = pCurrent->elem;
pNext = (CTSListWithFreeList<CBaseHandle>::Node_t *)pCurrent->Next;
m_DirtyEntities.FreeNode( pCurrent );
pCurrent = pNext;
#ifndef CLIENT_DLL
CBaseEntity *pEntity = gEntList.GetBaseEntity( handle );
#else
CBaseEntity *pEntity = cl_entitylist->GetBaseEntityFromHandle( handle );
#endif
if ( pEntity )
{
// If an entity is in the middle of bone setup, don't call UpdatePartition
// which can cause it to redo bone setup on the same frame causing a recursive
// call to bone setup.
if ( !pEntity->IsEFlagSet( EFL_SETTING_UP_BONES ) )
{
pEntity->CollisionProp()->UpdatePartition();
}
else
{
vecStillDirty.AddToTail( handle );
}
}
}
}
if ( vecStillDirty.Count() > 0 )
{
for ( int i = 0; i < vecStillDirty.Count(); i++ )
{
m_DirtyEntities.PushItem( vecStillDirty[i] );
}
}
m_partitionWriteId = 0;
m_partitionMutex.UnlockWrite();
}
LockPartitionForRead();
}
示例14: if
//-----------------------------------------------------------------------------
// Purpose: Override to check throw
// Input :
// Output :
//-----------------------------------------------------------------------------
int CWeaponMolotov::WeaponRangeAttack1Condition( float flDot, float flDist )
{
// If things haven't changed too much since last time
// just return that previously calculated value
if (gpGlobals->curtime < m_fNextThrowCheck )
{
return m_iThrowBits;
}
if ( flDist < m_fMinRange1) {
m_iThrowBits = COND_TOO_CLOSE_TO_ATTACK;
}
else if (flDist > m_fMaxRange1) {
m_iThrowBits = COND_TOO_FAR_TO_ATTACK;
}
else if (flDot < 0.5) {
m_iThrowBits = COND_NOT_FACING_ATTACK;
}
// If moving, can't throw.
else if ( m_flGroundSpeed != 0 )
{
m_iThrowBits = COND_NONE;
}
else {
// Ok we should check again as some time has passed
// This function is only used by NPC's so we can cast to a Base Monster
CAI_BaseNPC *pNPC = GetOwner()->MyNPCPointer();
CBaseEntity *pEnemy = pNPC->GetEnemy();
if (!pEnemy)
{
m_iThrowBits = COND_NONE;
}
// Get Enemy Position
Vector vecTarget;
pEnemy->CollisionProp()->NormalizedToWorldSpace( Vector( 0.5f, 0.5f, 0.0f ), &vecTarget );
// Get Toss Vector
Vector throwStart = pNPC->Weapon_ShootPosition();
Vector vecToss;
CBaseEntity* pBlocker = NULL;
float throwDist = (throwStart - vecTarget).Length();
float fGravity = sv_gravity.GetFloat();
float throwLimit = pNPC->ThrowLimit(throwStart, vecTarget, fGravity, 35, WorldAlignMins(), WorldAlignMaxs(), pEnemy, &vecToss, &pBlocker);
// If I can make the throw (or most of the throw)
if (!throwLimit || (throwLimit != throwDist && throwLimit > 0.8*throwDist))
{
m_vecTossVelocity = vecToss;
m_iThrowBits = COND_CAN_RANGE_ATTACK1;
}
else
{
m_iThrowBits = COND_NONE;
}
}
// don't check again for a while.
m_fNextThrowCheck = gpGlobals->curtime + 0.33; // 1/3 second.
return m_iThrowBits;
}
示例15: UpdateCallout
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFFreezePanel::UpdateCallout( void )
{
CTFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pPlayer )
return;
// Abort early if we have no gibs or ragdoll
CUtlVector<EHANDLE> *pGibList = pPlayer->GetSpawnedGibs();
IRagdoll *pRagdoll = pPlayer->GetRepresentativeRagdoll();
if ( (!pGibList || pGibList->Count() == 0) && !pRagdoll )
return;
if ( m_pFreezePanelBG == NULL )
return;
// Precalc the vectors of the freezepanel & statpanel
int iX, iY;
m_pFreezePanelBG->GetPos( iX, iY );
Vector vecFreezeTL( iX, iY, 0 );
Vector vecFreezeBR( iX + m_pFreezePanelBG->GetWide(), iY + m_pFreezePanelBG->GetTall(), 1 );
CUtlVector<Vector> vecCalloutsTL;
CUtlVector<Vector> vecCalloutsBR;
Vector vecStatTL(0,0,0);
Vector vecStatBR(0,0,1);
CTFStatPanel *pStatPanel = GET_HUDELEMENT( CTFStatPanel );
if ( pStatPanel && pStatPanel->IsVisible() )
{
pStatPanel->GetPos( iX, iY );
vecStatTL.x = iX;
vecStatTL.y = iY;
vecStatBR.x = vecStatTL.x + pStatPanel->GetWide();
vecStatBR.y = vecStatTL.y + pStatPanel->GetTall();
}
Vector vMins, vMaxs;
// Check gibs
if ( pGibList && pGibList->Count() )
{
int iCount = 0;
for ( int i = 0; i < pGibList->Count(); i++ )
{
CBaseEntity *pGib = pGibList->Element(i);
if ( pGib )
{
Vector origin = pGib->GetRenderOrigin();
IPhysicsObject *pPhysicsObject = pGib->VPhysicsGetObject();
if( pPhysicsObject )
{
Vector vecMassCenter = pPhysicsObject->GetMassCenterLocalSpace();
pGib->CollisionProp()->CollisionToWorldSpace( vecMassCenter, &origin );
}
pGib->GetRenderBounds( vMins, vMaxs );
// Try and add the callout
CTFFreezePanelCallout *pCallout = TestAndAddCallout( origin, vMins, vMaxs, &vecCalloutsTL, &vecCalloutsBR,
vecFreezeTL, vecFreezeBR, vecStatTL, vecStatBR, &iX, &iY );
if ( pCallout )
{
pCallout->UpdateForGib( i, iCount );
iCount++;
}
}
}
}
else if ( pRagdoll )
{
Vector origin = pRagdoll->GetRagdollOrigin();
pRagdoll->GetRagdollBounds( vMins, vMaxs );
// Try and add the callout
CTFFreezePanelCallout *pCallout = TestAndAddCallout( origin, vMins, vMaxs, &vecCalloutsTL, &vecCalloutsBR,
vecFreezeTL, vecFreezeBR, vecStatTL, vecStatBR, &iX, &iY );
if ( pCallout )
{
pCallout->UpdateForRagdoll();
}
// even if the callout failed, check that our ragdoll is onscreen and our killer is taunting us (for an achievement)
if ( GetVectorInScreenSpace( origin, iX, iY ) )
{
C_TFPlayer *pKiller = ToTFPlayer( UTIL_PlayerByIndex( GetSpectatorTarget() ) );
if ( pKiller && pKiller->m_Shared.InCond( TF_COND_TAUNTING ) )
{
// tell the server our ragdoll just got taunted during our freezecam
char cmd[256];
int iPlayerID = pPlayer->GetUserID();
unsigned short mask = UTIL_GetAchievementEventMask();
Q_snprintf( cmd, sizeof( cmd ), "freezecam_taunt %d %d", GetSpectatorTarget() ^ mask, ( iPlayerID ^ GetSpectatorTarget() ) ^ mask );
engine->ClientCmd_Unrestricted( cmd );
}
}
}
}