Пример #1
0
int CNPC_APCDriver::RangeAttack2Conditions( float flDot, float flDist )
{
	if ( HasSpawnFlags(SF_APCDRIVER_NO_ROCKET_ATTACK) )
		return COND_NONE;

	if ( m_hAPC->m_lifeState != LIFE_ALIVE )
		return COND_NONE;

	if ( IsBeingCarried() || m_bFiringDisabled )
		return COND_NONE;

	if ( !HasCondition( COND_SEE_ENEMY ) )
		return COND_NONE;

	// Vehicle not ready to fire again yet?
	if ( m_pVehicleInterface->Weapon_SecondaryCanFireAt() > gpGlobals->curtime + 0.1f )
		return COND_NONE;

	float flMinDist, flMaxDist;
	m_pVehicleInterface->Weapon_SecondaryRanges( &flMinDist, &flMaxDist );

	if (flDist < flMinDist)
		return COND_NONE;

	if (flDist > flMaxDist)
		return COND_NONE;

	return COND_CAN_RANGE_ATTACK2;
}
Пример #2
0
//-----------------------------------------------------------------------------
// Is the enemy visible?
//-----------------------------------------------------------------------------
bool CNPC_APCDriver::FVisible( CBaseEntity *pTarget, int traceMask, CBaseEntity **ppBlocker )
{
	if ( m_hAPC->m_lifeState != LIFE_ALIVE )
		return false;

	if ( IsBeingCarried() || m_bFiringDisabled )
		return false;

	float flTargetDist = GetAbsOrigin().DistTo( pTarget->GetAbsOrigin() );
	if (flTargetDist > m_hAPC->MaxAttackRange())
		return false;

	bool bVisible = m_hAPC->FVisible( pTarget, traceMask, ppBlocker );
	if ( bVisible && (pTarget == GetEnemy()) )
	{
		m_flTimeLastSeenEnemy = gpGlobals->curtime;
	}

	if ( pTarget->IsPlayer() || pTarget->Classify() == CLASS_BULLSEYE )
	{
		if (!bVisible)
		{
			if ( ( gpGlobals->curtime - m_flTimeLastSeenEnemy ) <= NPC_APCDRIVER_REMEMBER_TIME )
				return true;
		}
	}

	return bVisible;
}
//-----------------------------------------------------------------------------
// Should this object cast shadows?
//-----------------------------------------------------------------------------
ShadowType_t C_BaseCombatWeapon::ShadowCastType()
{
	if (!IsBeingCarried())
		return SHADOWS_RENDER_TO_TEXTURE;

	if (IsCarriedByLocalPlayer())
		return SHADOWS_NONE;

	return (m_iState != WEAPON_IS_CARRIED_BY_PLAYER) ? SHADOWS_RENDER_TO_TEXTURE : SHADOWS_NONE;
}
Пример #4
0
//-----------------------------------------------------------------------------
// Should this object cast shadows?
//-----------------------------------------------------------------------------
ShadowType_t C_BaseCombatWeapon::ShadowCastType()
{
	if ( IsEffectActive( /*EF_NODRAW |*/ EF_NOSHADOW ) )
		return SHADOWS_NONE;

	if (!IsBeingCarried())
		return SHADOWS_RENDER_TO_TEXTURE;

	if (IsCarriedByLocalPlayer() && !C_BasePlayer::ShouldDrawLocalPlayer())
		return SHADOWS_NONE;

	return SHADOWS_RENDER_TO_TEXTURE;
}
Пример #5
0
//------------------------------------------------------------------------------
// Is the enemy visible?
//------------------------------------------------------------------------------
bool CNPC_APCDriver::WeaponLOSCondition(const Vector &ownerPos, const Vector &targetPos, bool bSetConditions)
{
	if ( m_hAPC->m_lifeState != LIFE_ALIVE )
		return false;

	if ( IsBeingCarried() || m_bFiringDisabled )
		return false;

	float flTargetDist = ownerPos.DistTo( targetPos );
	if (flTargetDist > m_hAPC->MaxAttackRange())
		return false;

	return true;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bnewentity - 
//-----------------------------------------------------------------------------
void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged(updateType);

	CHandle< C_BaseCombatWeapon > handle;
	handle = this;

	// If it's being carried by the *local* player, on the first update,
	// find the registered weapon for this ID
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	if (!pPlayer || !IsBeingCarried() || (GetOwner() != pPlayer) )
	{
		// BRJ 10/14/02
		// FIXME: Remove when Yahn's client-side prediction is done
		// It's a hacky workaround for the model indices fighting
		// (GetRenderBounds uses the model index, which is for the view model)
		SetModelIndex( GetWorldModelIndex() );
		UpdateVisibility();
		m_iOldState = m_iState;
		return;
	}

	// If I was just picked up, or created & immediately carried, add myself to this client's list of weapons
	if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) )
	{
		// Tell the HUD this weapon's been picked up
		if ( ShouldDrawPickup() )
		{
			CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection();
			if ( pHudSelection )
			{
				pHudSelection->OnWeaponPickup( this );
			}

			pPlayer->EmitSound( "Player.PickupWeapon" );
		}
	}

	UpdateVisibility();

	m_iOldState = m_iState;

	m_bJustRestored = false;
}
Пример #7
0
bool CASW_Weapon::IsUsable(CBaseEntity *pUser)
{
	return (!IsBeingCarried() && pUser && pUser->GetAbsOrigin().DistTo(GetAbsOrigin()) < ASW_MARINE_USE_RADIUS);	// near enough?
}