//------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ bool CAI_ASW_RangedAttackBehavior::ValidateMissileLocation( ) { // Don't bother checking the for a radial attack. if ( !m_bRadiusAttack ) { trace_t tr; Vector vStart = GetAbsOrigin() + Vector( 0.0f, 0.0f, 15.0f ); Vector vFinal = m_vMissileLocation + Vector( 0.0f, 0.0f, 15.0f ); #ifdef DRAW_DEBUG UTIL_AddDebugLine( vStart, vFinal, true, true ); #endif // #ifdef DRAW_DEBUG UTIL_TraceHull( vStart, vFinal, -Vector(2,2,2), Vector(2,2,2), MASK_SOLID, GetOuter(), ASW_COLLISION_GROUP_IGNORE_NPCS, &tr ); if ( tr.fraction != 1.0f ) { return false; } } s_flGlobalShotDeferUntil = gpGlobals->curtime + m_flGlobalShotDelay; return true; }
TFlickInfo *CAI_ASW_FlickBehavior::GetFlickActivity( ) { Vector vRightNPC, vForwardNPC, vForwardEnemy; int nCount = 0; int nFlickTotal[ MAX_FLICKS ]; for( int i = 0; i < MAX_FLICKS; i++ ) { nFlickTotal[ i ] = 0; } AngleVectors( GetAbsAngles(), &vForwardNPC, &vRightNPC, NULL ); #ifdef DRAW_DEBUG UTIL_AddDebugLine( GetAbsOrigin(), GetAbsOrigin() + vForwardNPC * 300.0f, true, false ); #endif // #ifdef DRAW_DEBUG AIEnemiesIter_t iter; for( AI_EnemyInfo_t *pEMemory = GetEnemies()->GetFirst( &iter ); pEMemory != NULL; pEMemory = GetEnemies()->GetNext( &iter ) ) { CBaseEntity *pEntity = pEMemory->hEnemy; Vector vDelta = GetAbsOrigin() - pEntity->GetAbsOrigin(); float flLenSq = vDelta.LengthSqr(); if ( flLenSq > m_flDistanceSq ) { continue; } #ifdef DRAW_DEBUG UTIL_AddDebugLine( GetAbsOrigin(), pEntity->GetAbsOrigin(), true, false ); #endif // #ifdef DRAW_DEBUG vForwardEnemy = vDelta; vForwardEnemy.NormalizeInPlace(); float flResult = vForwardNPC.Dot( vForwardEnemy ); if ( flResult > 0.0f ) { // we are behind continue; } flResult = vRightNPC.Dot( vForwardEnemy ); for( int j = 0; j < MAX_FLICKS; j++ ) { if ( flResult >= FlickInfo[ j ].m_flMinDot && flResult <= FlickInfo[ j ].m_flMaxDot ) { // we are within the flick angle of this arm nFlickTotal[ j ]++; nCount++; break; } } } if ( nCount > 0 ) { int nTotal = 0; nCount = RandomInt( 0, nCount - 1 ); for( int j = 0; j < MAX_FLICKS; j++ ) { nTotal += nFlickTotal[ j ]; if ( nCount < nTotal ) { return &FlickInfo[ j ]; } } } return NULL; }