game/server/hl2/weapon_immolator.cpp
bool CWeaponImmolator::WeaponLOSCondition( const Vector &ownerPos, const Vector &targetPos, bool bSetConditions )
{
	CAI_BaseNPC* npcOwner = GetOwner()->MyNPCPointer();

	if( !npcOwner )
	{
		return false;
	}

	if( IsImmolating() )
	{
		// Don't update while Immolating. This is a committed attack.
		return false;
	}

	// Assume we won't find a target.
//	m_vecImmolatorTarget = IMMOLATOR_TARGET_INVALID;
	m_vecImmolatorTarget = targetPos;

	if( npcOwner->FInViewCone( targetPos ) && npcOwner->FVisible( targetPos ) )
	{
		// We can see the target (usually the enemy). Don't fire the immolator directly at them.
		return false;
	}

	// Find a nearby immolator target that CAN see targetPOS
	float flNearest = FLT_MAX;
	CBaseEntity *pNearest = NULL;

	CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, "info_target_immolator" );

	while( pEnt )
	{
		float flDist = ( pEnt->GetAbsOrigin() - targetPos ).Length();

		if( flDist < flNearest )
		{
			trace_t tr;

			UTIL_TraceLine( targetPos, pEnt->GetAbsOrigin(), MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &tr );

			if( tr.fraction == 1.0 )
			{
				pNearest = pEnt;
				flNearest = flDist;
			}
		}

		pEnt = gEntList.FindEntityByClassname( pEnt, "info_target_immolator" );
	}

	if( pNearest )
	{
		m_vecImmolatorTarget = pNearest->GetAbsOrigin();
		return true;
	}

	return false;
}
//-----------------------------------------------------------------------------
// This weapon is said to have Line of Sight when it CAN'T see the target, but
// can see a place near the target than can.
//-----------------------------------------------------------------------------
This weapon is said to have Line of Sight when it CAN'T see the target, but
can see a place near the target than can.
This weapon is said to have Line of Sight when it CAN ' T see the target but can see a place near the target than can .
bool CWeaponImmolator::WeaponLOSCondition( const Vector &ownerPos, const Vector &targetPos, bool bSetConditions )
{
	CAI_BaseNPC* npcOwner = GetOwner()->MyNPCPointer();
	if( !npcOwner )
	{
		return false;
	}
	if( IsImmolating() )
	{
		return false;
	}
	m_vecImmolatorTarget = targetPos;
	if( npcOwner->FInViewCone( targetPos ) && npcOwner->FVisible( targetPos ) )
	{
		return false;
	}
	float flNearest = FLT_MAX;
	CBaseEntity *pNearest = NULL;
	CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, "info_target_immolator" );
	while( pEnt )
	{
		float flDist = ( pEnt->GetAbsOrigin() - targetPos ).Length();
		if( flDist < flNearest )
		{
			trace_t tr;
			UTIL_TraceLine( targetPos, pEnt->GetAbsOrigin(), MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &tr );
			if( tr.fraction == 1.0 )
			{
				pNearest = pEnt;
				flNearest = flDist;
			}
		}
		pEnt = gEntList.FindEntityByClassname( pEnt, "info_target_immolator" );
	}
	if( pNearest )
	{
		m_vecImmolatorTarget = pNearest->GetAbsOrigin();
		return true;
	}
	return false;
}
bool CWeaponImmolator :: WeaponLOSCondition ( const Vector & ownerPos , const Vector & targetPos , bool bSetConditions ) { CAI_BaseNPC * npcOwner = GetOwner ( ) -> MyNPCPointer ( ) ; if ( ! npcOwner ) { return false ; } if ( IsImmolating ( ) ) { return false ; } m_vecImmolatorTarget = targetPos ; if ( npcOwner -> FInViewCone ( targetPos ) && npcOwner -> FVisible ( targetPos ) ) { return false ; } float flNearest = FLT_MAX ; CBaseEntity * pNearest = NULL ; CBaseEntity * pEnt = gEntList . FindEntityByClassname ( NULL , " " ) ; while ( pEnt ) { float flDist = ( pEnt -> GetAbsOrigin ( ) - targetPos ) . Length ( ) ; if ( flDist < flNearest ) { trace_t tr ; UTIL_TraceLine ( targetPos , pEnt -> GetAbsOrigin ( ) , MASK_SOLID_BRUSHONLY , NULL , COLLISION_GROUP_NONE , & tr ) ; if ( tr . fraction == 1.0 ) { pNearest = pEnt ; flNearest = flDist ; } } pEnt = gEntList . FindEntityByClassname ( pEnt , " " ) ; } if ( pNearest ) { m_vecImmolatorTarget = pNearest -> GetAbsOrigin ( ) ; return true ; } return false ; }
This weapon is said to have Line of Sight when it CAN'T see the target, but
can see a place near the target than can.
This weapon is said to have Line of Sight when it CAN ' T see the target but can see a place near the target than can .
// Don't update while Immolating. This is a committed attack. // Assume we won't find a target. //	m_vecImmolatorTarget = IMMOLATOR_TARGET_INVALID; // We can see the target (usually the enemy). Don't fire the immolator directly at them. // Find a nearby immolator target that CAN see targetPOS