예제 #1
0
void asw_mesh_emitter_test_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
	{
		C_ASW_Marine *pMarine = pPlayer->GetMarine();
		C_ASW_Mesh_Emitter *pEmitter = new C_ASW_Mesh_Emitter;
		if (pEmitter)
		{
			if (pEmitter->InitializeAsClientEntity( "models/swarm/DroneGibs/dronepart01.mdl", false ))
			{
				Vector vecForward;
				AngleVectors(pMarine->GetAbsAngles(), &vecForward);
				Vector vecEmitterPos = pMarine->GetAbsOrigin() + vecForward * 200.0f;
				Q_snprintf(pEmitter->m_szTemplateName, sizeof(pEmitter->m_szTemplateName), "dronegiblots");
				pEmitter->m_fScale = 1.0f;
				pEmitter->m_bEmit = true;
				pEmitter->SetAbsOrigin(vecEmitterPos);
				pEmitter->CreateEmitter(vec3_origin);
				pEmitter->SetAbsOrigin(vecEmitterPos);
				pEmitter->SetDieTime(gpGlobals->curtime + 15.0f);
			}
			else
			{
				pEmitter->Release();
			}
		}
	}
}
예제 #2
0
void asw_entindex_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer)
	{
		Msg("Hidehud is %d\n", pPlayer->m_Local.m_iHideHUD);		
		Msg("Local player entity index is %d\n", pPlayer->entindex());
		if (pPlayer->GetMarine())
		{
			Msg("  and your current marine's entity index is %d\n", pPlayer->GetMarine()->entindex());
			if (pPlayer->GetMarine()->GetMarineResource())
			{
				Msg("    and your current marine's marine info's entity index is %d\n", pPlayer->GetMarine()->GetMarineResource()->entindex());
			}
			else
			{
				Msg("    and your current marine has no marine info\n");
			}
		}
		else
		{
			Msg("  and you have no current marine\n");
		}
	}
	else
	{
		Msg("No local player!\n");
	}
}
예제 #3
0
void asw_marine_update_visibility_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
	{
		pPlayer->GetMarine()->UpdateVisibility();
	}
}
예제 #4
0
const char* C_ASW_Button_Area::GetHackIconText(C_ASW_Marine *pUser)
{
	if (m_bIsInUse)
	{
		C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
		if (pPlayer && pPlayer->GetMarine() && pPlayer->GetMarine()->m_hUsingEntity.Get() == this)
		{
			return "#asw_exit_panel";
		}
	}
	return "#asw_hack_panel";
}
예제 #5
0
void CASWHudCrosshair::DrawSniperScope( int x, int y )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;	

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if ( !pMarine )
		return;

	const int NUM_CIRCLE_POINTS = 40;
	static vgui::Vertex_t points[ NUM_CIRCLE_POINTS ];
	float width = YRES( asw_sniper_scope_radius.GetFloat() );
	float height = YRES( asw_sniper_scope_radius.GetFloat() );
	for ( int i = 0; i < NUM_CIRCLE_POINTS; i++ )
	{
		float flAngle = 2.0f * M_PI * ( (float) i / (float) NUM_CIRCLE_POINTS );
		points[ i ].Init( Vector2D( x + width * cos( flAngle ), y + height * sin( flAngle ) ), Vector2D( 0.5f + 0.5f * cos( flAngle ), 0.5f + 0.5f * sin( flAngle ) ) );
	}
	surface()->DrawSetColor( Color(255,255,255,255) );
	surface()->DrawSetTexture( m_nSniperMagnifyTexture );
	IMaterial *pMaterial = materials->FindMaterial( "effects/magnifyinglens", TEXTURE_GROUP_OTHER );
	IMaterialVar *pMagnificationCenterVar = pMaterial->FindVar( "$magnifyCenter", NULL );
	
	float flCenterX = ( ( float )x / ( float )ScreenWidth() ) - 0.5f;
	float flCenterY = ( ( float )y / ( float )ScreenHeight() ) - 0.5f;
	pMagnificationCenterVar->SetVecValue( flCenterX, flCenterY, 0, 0 );	

	vgui::surface()->DrawTexturedPolygon( NUM_CIRCLE_POINTS, points );
}
예제 #6
0
bool CASWHudUseArea::AddUseIconsFor(C_BaseEntity* pEnt)
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (!pPlayer)
		return false;
	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return false;

	if (g_asw_iGUIWindowsOpen > 0)	// don't show use icons while an info message is up
		return false;

	IASW_Client_Usable_Entity* pUsable = dynamic_cast<IASW_Client_Usable_Entity*>(pEnt);
	if (pUsable)
	{
		ASWUseAction action;
		if (!pUsable->GetUseAction(action, pMarine))
			return false;

		if (m_pUseIcon)
			m_pUseIcon->SetUseAction(action);

		pPlayer->UseIconTarget[0] = action.UseTarget;

		if (m_pUseIcon && m_pUseIcon->m_pUseText && m_pUseIcon->m_CurrentAction == action)
		{
			if (m_pCustomPaintPanel)
				m_pCustomPaintPanel->m_hUsable = pUsable->GetEntity();
		}
		return true;
	}	
	return false;
}
void CASWHud3DMarineNames::PaintMarineNameLabels()
{
	C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer();
	if ( !local )
		return;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	int count = 0;
	int my_count = 0;
	for ( int i = 0; i < pGameResource->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i );
		if ( pMR && pMR->GetHealthPercent() > 0 )
		{
			C_ASW_Marine *pMarine = pMR->GetMarineEntity();
			if ( pMarine )
			{
				if ( pMarine->GetCommander() == local )
				{
					PaintMarineLabel( my_count, pMarine, pMR, local->GetMarine() == pMarine );
					my_count++;
				}
				else
				{
					PaintMarineLabel( -1, pMarine, pMR, false );
				}

				count++;
			}
		}		
	}
}
예제 #8
0
//-----------------------------------------------------------------------------
// Purpose: Alien Swarm camera yaw.
//-----------------------------------------------------------------------------
float CASWInput::ASW_GetCameraYaw( const float *pfDeathCamInterp /*= NULL*/ )
{
	float fDeathCamInterp;
	if ( pfDeathCamInterp )
	{
		fDeathCamInterp = *pfDeathCamInterp;
	}
	else
	{
		fDeathCamInterp = ( ASWGameRules() ? ASWGameRules()->GetMarineDeathCamInterp() : 0.0f );
	}

	if ( fDeathCamInterp > 0.0f )
	{
		float fRotate = gpGlobals->curtime * asw_cam_marine_yaw_death_rate.GetFloat() + ASWGameRules()->m_fDeathCamYawAngleOffset;
		float fFullRotations = static_cast< int >( fRotate / 360.0f );
		fRotate -= fFullRotations * 360.0f;

		fRotate = AngleNormalize( fRotate );

		return ( 1.0f - fDeathCamInterp ) * asw_cam_marine_yaw.GetFloat() + fDeathCamInterp * ( asw_cam_marine_yaw.GetFloat() + fRotate );
	}

	// Check to see if we are in a camera volume.
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
	{
		C_ASW_Camera_Volume *pCameraVolume = C_ASW_Camera_Volume::IsPointInCameraVolume( pPlayer->GetMarine()->GetAbsOrigin() );
		if ( pCameraVolume )
		{
			m_fCurrentBlendCamYaw = ASW_ClampYaw( asw_cam_marine_yaw_rate.GetFloat(), m_fCurrentBlendCamYaw, pCameraVolume->m_fCameraYaw, MIN( 0.2f, gpGlobals->frametime ) );
		}
		else
		{
			m_fCurrentBlendCamYaw = ASW_ClampYaw( asw_cam_marine_yaw_rate.GetFloat(), m_fCurrentBlendCamYaw, asw_cam_marine_yaw.GetFloat(), MIN( 0.2f, gpGlobals->frametime ) );
		}
		if ( m_flLastYawSend + 0.2f < gpGlobals->curtime || m_flLastYawSend > gpGlobals->curtime )
		{
			m_flLastYawSend = gpGlobals->curtime;
			char buf[32];
			Q_snprintf( buf, sizeof( buf ), "cl_aswcamerayaw %f\n", m_fCurrentBlendCamYaw );
			engine->ServerCmd( buf, false );
		}
	}

	return m_fCurrentBlendCamYaw;
}
void CASWHud3DMarineNames::PaintBoxesAroundUseEntities()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer || !pPlayer->GetMarine() || pPlayer->GetMarine()->GetHealth() <= 0 )
		return;

	C_BaseEntity *pEnt = NULL;

	if ( pPlayer->GetNumUseEntities() > 0 )
	{
		pEnt = pPlayer->GetUseEntity();
		if ( !pEnt )
		{
			pEnt = pPlayer->GetUseEntity( 0 );
		}

		IASW_Client_Usable_Entity* pUsable = dynamic_cast< IASW_Client_Usable_Entity* >( pEnt );
		if ( !pUsable || !pUsable->ShouldPaintBoxAround() )
		{
			pEnt = NULL;
		}
	}

	if ( pEnt )
	{
		C_ASW_Use_Area *pArea = dynamic_cast< C_ASW_Use_Area* >( pEnt );
		if ( pArea )
		{
			if ( pArea->GetGlowEntity() )
			{
				ASWInput()->SetUseGlowEntity( pArea->GetGlowEntity() );
			}
			else
			{
				PaintBoxAround( pEnt, 6 );
			}
		}
		else
		{
			ASWInput()->SetUseGlowEntity( pEnt );
		}
	}
	else
	{
		ASWInput()->SetUseGlowEntity( NULL );
	}
}
예제 #10
0
void asw_camera_volume_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
	{
		Msg("Marine inside camera volume = %d\n", C_ASW_Camera_Volume::IsPointInCameraVolume(pPlayer->GetMarine()->GetAbsOrigin()));
	}
}
예제 #11
0
void ASW_ActivateExtra_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();

	if (pPlayer && pPlayer->GetMarine())
	{
		pPlayer->ActivateInventoryItem(2);
	}
}
예제 #12
0
void ASW_ActivateSecondary_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();

	if (pPlayer && pPlayer->GetMarine())
	{
		pPlayer->ActivateInventoryItem(1);
	}
}
예제 #13
0
void CASWHudPortraits::OnThink()
{
    VPROF_BUDGET( "CASWHudPortraits::OnThink", VPROF_BUDGETGROUP_ASW_CLIENT );

    int iNumMyMarines = 0;
    int iNumOtherMarines = 0;
    C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer();
    if ( local )
    {
        C_ASW_Game_Resource* pGameResource = ASWGameResource();
        if (pGameResource)
        {
            for (int i=0; i<pGameResource->GetMaxMarineResources(); i++)
            {
                C_ASW_Marine_Resource* pMR = pGameResource->GetMarineResource(i);
                if (pMR)
                {
                    if (pMR->GetCommander() == local)
                    {
                        m_hMyMarine[iNumMyMarines] = pMR;

                        iNumMyMarines++;
                        if (pMR->GetMarineEntity() == local->GetMarine())
                            m_hCurrentlySelectedMarineResource = pMR;
                    }
                    else if (!(ASWGameRules() && ASWGameRules()->IsTutorialMap()))	// in tutorial, don't show marines not under your command
                    {
                        m_hOtherMarine[iNumOtherMarines] = pMR;
                        iNumOtherMarines++;
                    }
                }
            }
            // clear out future slots
            for (int i=iNumMyMarines; i<ASW_MAX_MARINE_RESOURCES; i++)
            {
                m_hMyMarine[i] == NULL;
            }
            for (int i=iNumOtherMarines; i<ASW_MAX_MARINE_RESOURCES; i++)
            {
                m_hOtherMarine[i] == NULL;
            }
        }
    }
    // JOYPAD REMOVED
    //bool bJoypadModeChanged = (m_bLastJoypadMode != engine->ASW_IsJoypadMode());
    //m_bLastJoypadMode = engine->ASW_IsJoypadMode();
    bool bJoypadModeChanged = m_bLastJoypadMode = false;
    bool bResize = ((m_iNumMyMarines != iNumMyMarines) || (m_iNumOtherMarines != iNumOtherMarines) || bJoypadModeChanged);
    m_iNumMyMarines = iNumMyMarines;
    m_iNumOtherMarines = iNumOtherMarines;

    UpdatePortraits(bResize);
}
예제 #14
0
void C_ASW_Ammo_Drop::ClientThink()
{
	bool bShouldGlow = false;
	float flDistanceToMarineSqr = 0.0f;
	float flWithinDistSqr = (ASW_MARINE_USE_RADIUS*4)*(ASW_MARINE_USE_RADIUS*4);

	C_ASW_Player *pLocalPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( pLocalPlayer && pLocalPlayer->GetMarine() && ASWInput()->GetUseGlowEntity() != this && AllowedToPickup( pLocalPlayer->GetMarine() ) )
	{
		flDistanceToMarineSqr = (pLocalPlayer->GetMarine()->GetAbsOrigin() - WorldSpaceCenter()).LengthSqr();
		if ( flDistanceToMarineSqr < flWithinDistSqr )
			bShouldGlow = true;
	}

	m_GlowObject.SetRenderFlags( false, bShouldGlow );

	if ( m_GlowObject.IsRendering() )
	{
		m_GlowObject.SetAlpha( MIN( 0.7f, (1.0f - (flDistanceToMarineSqr / flWithinDistSqr)) * 1.0f) );
	}
}
예제 #15
0
//-----------------------------------------------------------------------------
// Purpose: Alien Swarm camera pitch.
//-----------------------------------------------------------------------------
float CASWInput::ASW_GetCameraPitch( const float *pfDeathCamInterp /*= NULL*/ )
{
	// Get the given pitch.
	float flPitch = asw_cam_marine_pitch.GetFloat();

	// Check to see if we are in a camera volume.
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
	{
		C_ASW_Camera_Volume *pCameraVolume = C_ASW_Camera_Volume::IsPointInCameraVolume( pPlayer->GetMarine()->GetAbsOrigin() );
		if ( pCameraVolume )
		{
			flPitch = pCameraVolume->m_fCameraPitch;
		}
	}

	float fDeathCamInterp;
	if ( pfDeathCamInterp )
	{
		fDeathCamInterp = *pfDeathCamInterp;
	}
	else
	{
		fDeathCamInterp = ( ASWGameRules() ? ASWGameRules()->GetMarineDeathCamInterp() : 0.0f );
	}

	if ( fDeathCamInterp > 0.0f )
	{
		flPitch = ( 1.0f - fDeathCamInterp ) * flPitch + fDeathCamInterp * asw_cam_marine_pitch_death.GetFloat();
	}

	if ( m_fCurrentCameraPitch != flPitch )
	{
		float flDelta = MIN( 0.2f, gpGlobals->frametime );
		m_fCurrentCameraPitch = ASW_ClampYaw( asw_cam_marine_pitch_rate.GetFloat(), m_fCurrentCameraPitch, flPitch, flDelta );
	}

	return m_fCurrentCameraPitch;
}
예제 #16
0
void CASW_Hud_Powerups::OnThink()
{
	//SetAlpha( 0 );

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (!pPlayer)
		return;

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if ( !pMarine )
		return;

	UpdatePowerupIcon( pMarine );	
}
예제 #17
0
void CASWNightVisionSelfIllumProxy::OnBind( void *pC_BaseEntity )
{
	Assert( m_pResult );
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer || !pC_BaseEntity )
	{
		SetFloatResult( 0.0f );
		return;
	}

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if ( !pMarine )
	{
		SetFloatResult( 0.0f );
		return;
	}

	if ( C_JaS_Alien_Controller::AutoList().Count() )
	{
		C_JaS_Alien_Controller *pAlienController = dynamic_cast<C_JaS_Alien_Controller *>( C_JaS_Alien_Controller::AutoList().Head()->GetEntity() );
		if ( pAlienController->m_hBuzzerOverride )
		{
			SetFloatResult( 255.0f );
			return;
		}
	}

	C_BaseCombatWeapon*	pExtraItem = pMarine->GetWeapon( 2 );
	if ( pExtraItem && pExtraItem->Classify() == CLASS_ASW_NIGHT_VISION )
	{
		C_ASW_Weapon_Night_Vision *pVision = assert_cast<CASW_Weapon_Night_Vision*>( pExtraItem );
		float flVisionAlpha = pVision->m_flVisionAlpha;
		if ( flVisionAlpha != 0.0f )
		{
			SetFloatResult( flVisionAlpha / 255.0f * asw_night_vision_self_illum_multiplier.GetFloat() );
			return;
		}
	}

	if ( pPlayer->IsSniperScopeActive() && g_bRenderingGlows )
	{
		SetFloatResult( asw_sniper_scope_self_illum_multiplier.GetFloat() );
		return;
	}

	SetFloatResult( 0.0f );
}
예제 #18
0
void CASWInput::SetMouseOverEntity( C_BaseEntity* pEnt )
{	
	// highlight the next entity
	m_hMouseOverEntity = pEnt;

	//m_MouseOverGlowObject.SetEntity( pEnt );

	if ( !pEnt )
		return;

	C_ASW_Marine *pOtherMarine = C_ASW_Marine::AsMarine( pEnt );
	if ( pOtherMarine )
		return;

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();	
	C_ASW_Marine *pMarine = pPlayer ? pPlayer->GetMarine() : NULL;
	if ( !pMarine )
		return;

	IASW_Client_Aim_Target* pAimEnt = dynamic_cast<IASW_Client_Aim_Target*>( pEnt );
	if ( pAimEnt )
	{
		// check we have LOS to the target
		CTraceFilterLOS traceFilter( pMarine, COLLISION_GROUP_NONE );
		trace_t tr2;
		Vector vecWeaponPos = pMarine->GetRenderOrigin() + Vector( 0,0, ASW_MARINE_GUN_OFFSET_Z );
		UTIL_TraceLine( vecWeaponPos, pAimEnt->GetAimTargetRadiusPos( vecWeaponPos ), MASK_OPAQUE, &traceFilter, &tr2 );
		//C_BaseEntity *pEnt = pAimEnt->GetEntity();
		//bool bHasLOS = (!tr2.startsolid && (tr2.fraction >= 1.0 || tr2.m_pEnt == pEnt));
		// we can't shoot it, so skip it
// 		if ( bHasLOS )
// 		{
// 			m_MouseOverGlowObject.SetRenderFlags( true, true );
// 			m_MouseOverGlowObject.SetColor( Vector( 0.65f, 0.45f, 0.15f ) );
// 			m_MouseOverGlowObject.SetAlpha( 0.875f );
// 		}
// 		else
// 		{
// 			m_MouseOverGlowObject.SetRenderFlags( true, true );
// 			m_MouseOverGlowObject.SetColor( Vector( 0.4f, 0.35f, 0.3f ) );
// 			m_MouseOverGlowObject.SetAlpha( 0.8f );
// 		}

	}
}
예제 #19
0
void CASWInput::SetUseGlowEntity( C_BaseEntity* pEnt )
{	
	// if we're currently highlighting something, stop
	if ( m_hUseGlowEntity.Get() )
	{
		C_BaseAnimating *pAnimating = dynamic_cast<C_BaseAnimating*>( m_hUseGlowEntity.Get() );
		if ( pAnimating )
		{
			// ASWTODO - put this back in when we have a material proxy that supports lighting a specific marine
			//pAnimating->SetHighlight(false);
		}
	}
	// highlight the next entity
	m_hUseGlowEntity = pEnt;
	bool bIsAllowed = true;
	if ( m_hUseGlowEntity.Get() )
	{
		C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
		if ( !pPlayer )
			return;

		C_ASW_Marine* pMarine = pPlayer->GetMarine();
		if ( !pMarine )
			return;

		C_ASW_Pickup *pPickup = dynamic_cast< C_ASW_Pickup * >( pEnt );
		if ( pPickup )
		{
			bIsAllowed = pPickup->AllowedToPickup( pMarine );
		}
		else
		{
			C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon * >( pEnt );
			if ( pWeapon )
			{
				bIsAllowed = pWeapon->AllowedToPickup( pMarine );
			}
		}
	}

	if ( bIsAllowed )
		m_UseGlowObject.SetEntity( pEnt );
	else
		m_UseGlowObject.SetEntity( NULL );
}
예제 #20
0
void asw_weapon_switch_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if ( !pMarine )
		return;

	C_BaseCombatWeapon *pCurrent = pMarine->GetActiveWeapon();
	C_BaseCombatWeapon *pPrimary = pMarine->GetWeapon( ASW_INVENTORY_SLOT_PRIMARY );
	if ( pCurrent != pPrimary && pPrimary )
	{
		::input->MakeWeaponSelection( pPrimary );
	}
	C_BaseCombatWeapon *pSecondary = pMarine->GetWeapon( ASW_INVENTORY_SLOT_SECONDARY );
	if ( pCurrent != pSecondary && pSecondary )
	{
		::input->MakeWeaponSelection( pSecondary );
	}
}
예제 #21
0
void CASWInput::UpdateHighlightEntity()
{
	// if we're currently brightening any entity, stop
	SetHighlightEntity( NULL, false );
	// clear any additional cursor icons
	CASWHudCrosshair *pCrosshair = GET_HUDELEMENT( CASWHudCrosshair );
	if ( pCrosshair )
	{
		pCrosshair->SetShowGiveAmmo(false, -1);
		pCrosshair->SetShowGiveHealth( false );
	}

	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	C_ASW_Marine* pMarine = pPlayer->GetMarine();
	if ( !pMarine )
		return;

	// see if the marine and his weapons want to highlight the current entity, or something near the cursor
	pMarine->MouseOverEntity( GetMouseOverEntity(), GetCrosshairAimingPos() );
}
예제 #22
0
bool CASW_VGUI_Stylin_Cam::ShouldShowStylinCam()
{
	if ( !ASWGameRules() )
		return false;

	if ( ASWGameRules()->ShouldShowCommanderFace() )
		return false;

	C_ASW_Player *pLocal = C_ASW_Player::GetLocalASWPlayer();
	bool bHasMarine = pLocal && pLocal->GetMarine();

	bool bAdrenalineActive = GameTimescale()->GetCurrentTimescale() <= asw_stim_cam_time.GetFloat() && ASWGameRules()->GetStimEndTime() >= gpGlobals->curtime;
	bool bShowCam = ASWGameRules()->ShouldForceStylinCam() ||
		( bAdrenalineActive && bHasMarine );

	if ( bShowCam && !ASWGameRules()->ShouldShowCommanderFace() )
	{
		// check if there's a mapper designed camera turned on
		C_PointCamera *pCameraEnt = GetPointCameraList();
		bool bMapperCam = false;
		for ( int cameraNum = 0; pCameraEnt != NULL; pCameraEnt = pCameraEnt->m_pNext )
		{
			if ( pCameraEnt != pLocal->GetStimCam() && pCameraEnt->IsActive() && !pCameraEnt->IsDormant()
				&& !(ASW_IsSecurityCam(pCameraEnt) && asw_stim_cam_time.GetFloat()!=2.0f))
			{							
				bMapperCam = true;
				break;
			}
			++cameraNum;
		}
		if ( !bMapperCam && !asw_spinning_stim_cam.GetBool() && !ASWGameRules()->ShouldShowCommanderFace() )	// don't show the cam if the mapper hasn't set a specific view, unless the convar is set
			bShowCam = false;
	}

	return bShowCam;
}
예제 #23
0
//-----------------------------------------------------------------------------
// Purpose: Alien Swarm camera distance.
//-----------------------------------------------------------------------------
float CASWInput::ASW_GetCameraDist( const float *pfDeathCamInterp /*= NULL*/ )
{
#ifdef VARIABLE_CAMERA
	// Are we using a valid FOV, if not use the default distance.
	float flFOV = fov_desired.GetFloat();
	if ( !( flFOV == 75.0f || flFOV == 50.0f  ) )
		return asw_cam_marine_dist.GetFloat();

	// Do we have a missionchooser, if not use the default distance.
	if ( !missionchooser || !missionchooser->RandomMissions() )
		return asw_cam_marine_dist.GetFloat();

	// Do we have a valid player and marine, if not use the default distance.
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer || !pPlayer->GetMarine() )
		return asw_cam_marine_dist.GetFloat();

	// Do we have a valid room, if not use the default distance.
	IASW_Room_Details *pRoom = missionchooser->RandomMissions()->GetRoomDetails( pPlayer->GetMarine()->GetAbsOrigin() );
	if ( !pRoom )
		return asw_cam_marine_dist.GetFloat();
	
	// Get the desired distance for the room.
	float flDesiredDist = s_flCameraHeights[pRoom->GetTileType()];
	if ( flFOV == 50 )
	{
		flDesiredDist = s_flCameraHeights55[pRoom->GetTileType()];
	}

	float flCameraDelta = fabs( m_flCurrentCameraDist - flDesiredDist );
	// Check against a tolerance so we don't oscillate forever.
	if ( flCameraDelta > 0.2f )
	{
		// Get frametime = delta time
		float flFrameTime = gpGlobals->frametime;

		float flAccel = fabs( flDesiredDist - m_flCurrentCameraDist ) * asw_cam_marine_spring_const.GetFloat();
		float flZDampening = asw_cam_marine_spring_dampening.GetFloat() * m_vecCameraVelocity.z;
		flAccel -= flZDampening;
		float flZVelocity = flAccel * flFrameTime;
		m_vecCameraVelocity.z += flZVelocity;
		m_vecCameraVelocity.z = clamp( m_vecCameraVelocity.z, 0.1f, asw_cam_marine_spring_vel_max.GetFloat() );
		if ( m_flCurrentCameraDist < flDesiredDist )
		{
			m_flCurrentCameraDist += m_vecCameraVelocity.z * flFrameTime;
		}
		else
		{
			m_flCurrentCameraDist -= m_vecCameraVelocity.z * flFrameTime;
		}
	}
	else
	{
		m_vecCameraVelocity.z = 0.0f;
		m_flCurrentCameraDist = flDesiredDist;
	}

	return m_flCurrentCameraDist;
#else
	float fDeathCamInterp;
	if ( pfDeathCamInterp )
	{
		fDeathCamInterp = *pfDeathCamInterp;
	}
	else
	{
		fDeathCamInterp = ( ASWGameRules() ? ASWGameRules()->GetMarineDeathCamInterp() : 0.0f );
	}

	if ( fDeathCamInterp > 0.0f )
	{
		return ( 1.0f - fDeathCamInterp ) * asw_cam_marine_dist.GetFloat() + fDeathCamInterp * asw_cam_marine_dist_death.GetFloat();
	}

	// Check to see if we are in a camera volume.
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
	{
		C_ASW_Camera_Volume *pCameraVolume = C_ASW_Camera_Volume::IsPointInCameraVolume( pPlayer->GetMarine()->GetAbsOrigin() );
		float fDist;
		if ( pCameraVolume )
		{
			fDist = pCameraVolume->m_fCameraDistance;
		}
		else
		{
			fDist = asw_cam_marine_dist.GetFloat();
		}
		m_fCurrentBlendCamDist = Lerp<float>( MIN( 0.2f, gpGlobals->frametime ) * asw_cam_marine_dist_rate.GetFloat() / MAX( m_fCurrentBlendCamDist, fDist ), m_fCurrentBlendCamDist, fDist );
	}

	return m_fCurrentBlendCamDist;
#endif
}
예제 #24
0
void CASWViewRender::PerformNightVisionEffect( const CViewSetup &view )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if ( !pMarine )
		return;

	float flVisionAlpha = 0.0f;
	float flFlashAlpha = 0.0f;
	C_BaseCombatWeapon*	pExtraItem = pMarine->GetWeapon( 2 );
	if ( pExtraItem && pExtraItem->Classify() == CLASS_ASW_NIGHT_VISION )
	{
		C_ASW_Weapon_Night_Vision *pVision = assert_cast<CASW_Weapon_Night_Vision*>( pExtraItem );
		flVisionAlpha = pVision->UpdateVisionAlpha();
		flFlashAlpha = pVision->UpdateFlashAlpha();
	}

	if ( flVisionAlpha > 0 )
	{
		IMaterial *pMaterial = materials->FindMaterial( "effects/nightvision", TEXTURE_GROUP_CLIENT_EFFECTS, true );

		if ( pMaterial )
		{
			byte overlaycolor[4] = { 0, 255, 0, 255 };

			UpdateScreenEffectTexture( 0, view.x, view.y, view.width, view.height );

			overlaycolor[3] = flVisionAlpha;

			render->ViewDrawFade( overlaycolor, pMaterial );

			CMatRenderContextPtr pRenderContext( materials );
			pRenderContext->DrawScreenSpaceQuad( pMaterial );
			render->ViewDrawFade( overlaycolor, pMaterial );
			pRenderContext->DrawScreenSpaceQuad( pMaterial );
		}
		IMaterial *pNoiseMaterial = materials->FindMaterial( "effects/nightvision_noise", TEXTURE_GROUP_CLIENT_EFFECTS, true );

		if ( pNoiseMaterial )
		{
			byte overlaycolor[4] = { 255, 255, 255, 255 };
			overlaycolor[3] = MAX( flFlashAlpha, 16.0f );
			CMatRenderContextPtr pRenderContext( materials );
			render->ViewDrawFade( overlaycolor, pNoiseMaterial );
		}
	}
	if ( flFlashAlpha > 0 )
	{
		IMaterial *pMaterial = materials->FindMaterial( "effects/nightvision_flash", TEXTURE_GROUP_CLIENT_EFFECTS, true );

		if ( pMaterial )
		{
			byte overlaycolor[4] = { 255, 255, 255, 255 };
			overlaycolor[3] = flFlashAlpha;
			CMatRenderContextPtr pRenderContext( materials );
			render->ViewDrawFade( overlaycolor, pMaterial );
		}		
	}
}
예제 #25
0
bool CScriptedIconLesson::Mod_ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam, bool &bModHandled )
{
	// Assume we're going to handle the action
	bModHandled = true;

	C_BaseEntity *pVar = hVar.Get();

	switch ( iAction )
	{
		case LESSON_ACTION_IS_ALLOWED_ITEM:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->AllowedToPickup( [%s] )", pchParamName->String(), pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bIsAllowed = false;

			C_ASW_Pickup *pPickup = dynamic_cast< C_ASW_Pickup * >( pParam );
			if ( !pPickup )
			{
				C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon * >( pParam );

				if ( !pWeapon )
				{
					if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
					{
						ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->AllowedToPickup( [%s] )", pchParamName->String(), pchVarName );
						ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
						ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
						ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tParam handle as ASW_Weapon and ASW_Pickup returned NULL!\n" );
					}

					return false;
				}
				else
				{
					bIsAllowed = pWeapon->AllowedToPickup( pMarine );
				}
			}
			else
			{
				bIsAllowed = pPickup->AllowedToPickup( pMarine );
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->AllowedToPickup( [%s] )", pchParamName->String(), pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsAllowed ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsAllowed ) : ( bIsAllowed );
		}

		case LESSON_ACTION_ITEM_WILL_SWAP:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WillSwap( [%s] )", pchParamName->String(), pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bWillSwap = false;

			C_ASW_Pickup_Weapon *pPickup = dynamic_cast< C_ASW_Pickup_Weapon * >( pParam );
			if ( !pPickup )
			{
				C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon * >( pParam );

				if ( !pWeapon )
				{
					if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
					{
						ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WillSwap( [%s] )", pchParamName->String(), pchVarName );
						ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
						ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
						ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tParam handle as ASW_Weapon and ASW_Pickup returned NULL!\n" );
					}

					return false;
				}
				else
				{
					int nSlot = pMarine->GetWeaponPositionForPickup( pWeapon->GetClassname() );
					bWillSwap = ( pMarine->GetASWWeapon( nSlot ) != NULL );
				}
			}
			else
			{
				int nSlot = pMarine->GetWeaponPositionForPickup( pPickup->GetWeaponClass() );
				bWillSwap = ( pMarine->GetASWWeapon( nSlot ) != NULL );
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WillSwap( [%s] )", pchParamName->String(), pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bWillSwap ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bWillSwap ) : ( bWillSwap );
		}

		case LESSON_ACTION_CAN_HACK:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->CanHack()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bCanHack = pMarine->GetMarineProfile()->CanHack();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->AllowedToPickup()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bCanHack ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bCanHack ) : ( bCanHack );
		}

		case LESSON_ACTION_CAN_OFFHAND:
		{
			C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon* >( pVar );
			if ( !pWeapon )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->CanOffhand()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Weapon returned NULL!\n" );
				}

				return false;
			}

			bool bCanOffhand = pWeapon->GetWeaponInfo()->m_bOffhandActivate;

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->CanOffhand()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bCanOffhand ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bCanOffhand ) : ( bCanOffhand );
		}

		case LESSON_ACTION_HAS_SECONDARY:
		{
			C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon* >( pVar );
			if ( !pWeapon )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSecondary()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Weapon returned NULL!\n" );
				}

				return false;
			}

			bool bHasSecondary = pWeapon->UsesSecondaryAmmo();

			if ( bHasSecondary )
			{
				bHasSecondary = !( ( pWeapon->UsesClipsForAmmo2() && pWeapon->m_iClip2 <= 0 ) ||
								   ( !pWeapon->UsesClipsForAmmo2() && pWeapon->GetOwner() && pWeapon->GetOwner()->GetAmmoCount( pWeapon->m_iSecondaryAmmoType ) <= 0 ) );
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSecondary()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasSecondary ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bHasSecondary ) : ( bHasSecondary );
		}

		case LESSON_ACTION_HAS_SECONDARY_EXPLOSIVES:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasAnySecondary()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bHasAnySecondary = false;

			for ( int i = 0; i < ASW_MAX_EQUIP_SLOTS; ++i )
			{
				C_ASW_Weapon *pWeapon = static_cast< C_ASW_Weapon* >( pMarine->GetWeapon( i ) );
				if ( pWeapon && pWeapon->HasSecondaryExplosive() )
				{
					if ( !( ( pWeapon->UsesClipsForAmmo2() && pWeapon->m_iClip2 <= 0 ) || 
							( !pWeapon->UsesClipsForAmmo2() && pWeapon->GetOwner() && pWeapon->GetOwner()->GetAmmoCount( pWeapon->m_iSecondaryAmmoType ) <= 0 ) ) )
					{
						bHasAnySecondary = true;
						break;
					}
				}
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasAnySecondary()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasAnySecondary ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bHasAnySecondary ) : ( bHasAnySecondary );
		}

		case LESSON_ACTION_GET_MARINE:
		{
			int iTemp = static_cast<int>( fParam );

			if ( iTemp <= 0 || iTemp > 2 )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[entityINVALID] = [%s]->GetMarine()\n", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tParam selecting string is out of range!\n" );
				}

				return false;
			}

			CHandle<C_BaseEntity> *pHandle;

			char const *pchParamNameTemp = NULL;

			if ( iTemp == 2 )
			{
				pHandle = &m_hEntity2;
				pchParamNameTemp = "entity2";
			}
			else
			{
				pHandle = &m_hEntity1;
				pchParamNameTemp = "entity1";
			}

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( !pPlayer )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s] = [%s]->GetMarine()", pchParamNameTemp, pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "...\n" );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Player returned NULL!\n" );
				}

				return false;
			}

			C_ASW_Marine *pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );

			pHandle->Set( pMarine );

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s] = [%s]->GetMarine()\n", pchParamNameTemp, pchVarName );
			}

			return true;
		}

		case LESSON_ACTION_IS_BOT:
		{
			C_ASW_Marine *pMarine = dynamic_cast< C_ASW_Marine* >( pVar );

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t![%s]->IsInhabited()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bIsBot = !pMarine->IsInhabited();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t![%s]->IsInhabited()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsBot ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsBot ) : ( bIsBot );
		}

		case LESSON_ACTION_WEAPON_HAS_SPARE:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSpareWeapon()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			int nOffensiveWeaponCount = 0;

			for ( int i = 0; i < ASW_MAX_EQUIP_SLOTS; ++i )
			{
				C_ASW_Weapon *pWeapon = static_cast< C_ASW_Weapon* >( pMarine->GetWeapon( i ) );
				if ( pWeapon && pWeapon->IsOffensiveWeapon() )
				{
					if ( !( ( pWeapon->UsesClipsForAmmo1() && pWeapon->m_iClip1 <= 0 ) || 
						 ( !pWeapon->UsesClipsForAmmo1() && pWeapon->GetOwner() && pWeapon->GetOwner()->GetAmmoCount( pWeapon->m_iPrimaryAmmoType ) <= 0 ) ) )
					{
						nOffensiveWeaponCount++;
					}
				}
			}

			bool bHasSpare = ( nOffensiveWeaponCount > 1 );

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSpareWeapon()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasSpare ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bHasSpare ) : ( bHasSpare );
		}

		case LESSON_ACTION_WEAPON_IS_OFFENSIVE:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WeaponIsOffensive()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bIsOffensive = false;

			C_ASW_Weapon *pWeapon = pMarine->GetActiveASWWeapon();
			if ( pWeapon && pWeapon->IsOffensiveWeapon() )
			{
				if ( !( ( pWeapon->UsesClipsForAmmo1() && pWeapon->m_iClip1 <= 0 ) || 
					( !pWeapon->UsesClipsForAmmo1() && pWeapon->GetOwner() && pWeapon->GetOwner()->GetAmmoCount( pWeapon->m_iPrimaryAmmoType ) <= 0 ) ) )
				{
					bIsOffensive = true;
				}
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WeaponIsOffensive()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsOffensive ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsOffensive ) : ( bIsOffensive );
		}

		case LESSON_ACTION_WEAPON_LOCAL_HOTBAR_SLOT:
		{
			CASW_Hud_Master *pHUDMaster = GET_HUDELEMENT( CASW_Hud_Master );
			if ( pHUDMaster )
			{
				m_fOutput = pHUDMaster->GetHotBarSlot( pchParam );

				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tm_fOutput = GET_HUDELEMENT( CASW_Hud_Squad_Hotbar )->GetHotBarSlot( [%s] ", pchParamName->String() );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "\"%s\"", pchParam );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ")\n" );
				}
			}

			return true;
		}

		case LESSON_ACTION_OWNS_HOTBAR_SLOT:
		{
			int iTemp = static_cast<int>( fParam );

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( !pPlayer )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tGET_HUDELEMENT( CASW_Hud_Squad_Hotbar )->OwnsHotBarSlot( [%s] ", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "..." );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ", [%s] ", pchParamName->String() );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "\"%i\" ", iTemp );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ") " );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Player returned NULL!\n" );
				}

				return false;
			}

			bool bOwnsHotBarSlot = false;

			CASW_Hud_Master *pHUDMaster = GET_HUDELEMENT( CASW_Hud_Master );
			if ( pHUDMaster )
			{
				bOwnsHotBarSlot = pHUDMaster->OwnsHotBarSlot( pPlayer, iTemp );

				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tGET_HUDELEMENT( CASW_Hud_Squad_Hotbar )->OwnsHotBarSlot( [%s], [%s] ", pchVarName, pchParamName->String() );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "\"%i\" ", iTemp );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ") " );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bOwnsHotBarSlot ? "true" : "false" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
				}
			}

			return ( bNot ) ? ( !bOwnsHotBarSlot ) : ( bOwnsHotBarSlot );
		}

		case LESSON_ACTION_SENTRY_WANTS_DISMANTLE:
		{
			C_ASW_Sentry_Base *pSentry = dynamic_cast< C_ASW_Sentry_Base* >( pVar );
			if ( !pSentry )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WantsDismantle()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Sentry_Base returned NULL!\n" );
				}

				return false;
			}

			bool bWantsDismantle = pSentry->WantsDismantle();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WantsDismantle()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bWantsDismantle ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bWantsDismantle ) : ( bWantsDismantle );
		}

		case LESSON_ACTION_IS_TUTORIAL:
		{
			bool bIsTutorial = ASWGameRules()->IsTutorialMap();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tASWGameRules()->IsTutorialMap()" );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsTutorial ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsTutorial ) : ( bIsTutorial );
		}

		case LESSON_ACTION_IS_SINGLEPLAYER:
		{
			bool bIsSingleplayer = ASWGameRules()->IsOfflineGame();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tASWGameRules()->IsOfflineGame()" );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsSingleplayer ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsSingleplayer ) : ( bIsSingleplayer );
		}

		default:
			// Didn't handle this action
			bModHandled = false;
			break;
	}

	return false;
}
예제 #26
0
void CASWHudCrosshair::DrawDirectionalCrosshair( int x, int y, int iSize )
{
	C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer();
	if (!local)
		return;	
	
	C_ASW_Marine *pMarine = local->GetMarine();
	if (!pMarine)
		return;

	Vector MarinePos = pMarine->GetRenderOrigin();
	Vector screenPos;
	debugoverlay->ScreenPosition( MarinePos + Vector( 0, 0, 45 ), screenPos );

	int cx, cy, dx, dy;
	ASWInput()->ASW_GetWindowCenter(cx, cy);
	dx = x - cx;
	dy = y - cy;
	float flDistance = FastSqrt( dx * dx + dy * dy );

	//CASWScriptCreatedItem *pItem = static_cast<CASWScriptCreatedItem*>( pMarine->GetActiveASWWeapon()->GetAttributeContainer()->GetItem() );
	//if ( !m_bIsCastingSuitAbility )//pItem && pItem->IsMeleeWeapon() &&
	//{
		// here is where we do the crosshair scaling
		int iMax = YRES(54);
		int iMin = YRES(16);
		// clamp the min and max distance the cursor is from the marine on screen
		float flSizeDist = clamp( flDistance, iMin, iMax );

		// this is the full percentage to scale by
		float flTemp = (flSizeDist - iMin) / ( iMax - iMin );
		
		float flMinTexScale = 0.8;
		float flMaxTexScale = 1.0;
		// this is the final percentage to scale by based on the clamping we want for the min and max texture scaling
		float flAdjust = flTemp * (flMaxTexScale - flMinTexScale) + flMinTexScale;

		iSize *= flAdjust;
		m_pAmmoProgress->SetScale( flAdjust );
	//}

	iSize *= 2;
	int iXHairHalfSize = iSize / 2;
	// draw a red pointing, potentially blinking, arrow
	//Vector vecFacing(screenPos.x - (ScreenWidth() * 0.5f), screenPos.y - (ScreenHeight() * 0.5f), 0);
	//float fFacingYaw = -UTIL_VecToYaw(vecFacing);

	Vector2D vXHairCenter( x , y );

	Vector vecCornerTL(-iXHairHalfSize, -iXHairHalfSize, 0);
	Vector vecCornerTR(iXHairHalfSize, -iXHairHalfSize, 0);
	Vector vecCornerBR(iXHairHalfSize, iXHairHalfSize, 0);
	Vector vecCornerBL(-iXHairHalfSize, iXHairHalfSize, 0);
	Vector vecCornerTL_rotated, vecCornerTR_rotated, vecCornerBL_rotated, vecCornerBR_rotated;	

	int current_posx = 0;
	int current_posy = 0;
	ASWInput()->GetSimulatedFullscreenMousePos( &current_posx, &current_posy );
	Vector vecFacing( 0, 0, 0 );
	vecFacing.x = screenPos.x - current_posx;
	vecFacing.y = screenPos.y - current_posy;
	float fFacingYaw = -UTIL_VecToYaw( vecFacing );

	/*
	if ( ASWInput()->ControllerModeActive() )
	{
		int current_posx = 0;
		int current_posy = 0;
		ASWInput()->GetSimulatedFullscreenMousePos( &current_posx, &current_posy );
		vecFacing.x = screenPos.x - current_posx;
		vecFacing.y = screenPos.y - current_posy;
		fFacingYaw = -UTIL_VecToYaw( vecFacing );
	}
	*/

	// rotate it by our facing yaw
	QAngle angFacing(0, -fFacingYaw + 90.0, 0);
	VectorRotate(vecCornerTL, angFacing, vecCornerTL_rotated);
	VectorRotate(vecCornerTR, angFacing, vecCornerTR_rotated);
	VectorRotate(vecCornerBR, angFacing, vecCornerBR_rotated);
	VectorRotate(vecCornerBL, angFacing, vecCornerBL_rotated);
	//


	float flAlpha = 245;

	// fade the crosshair out when it is very close to the marine
	float flAdjust2 = flDistance / YRES(28);
	flAdjust2 = clamp( flAdjust2, 0.1f, 1.0f );

	bool bShotWarn = false;
	Color colorCross = Color(255,255,255,flAlpha*flAdjust2);
	C_ASW_Weapon* pWeapon = pMarine->GetActiveASWWeapon();
	if ( pWeapon && pWeapon->IsOffensiveWeapon() )
	{
		C_BaseEntity *pEnt = pWeapon->GetLaserTargetEntity();
		if ( pEnt && pEnt->Classify() == CLASS_ASW_MARINE )
		{
			bShotWarn = true;
			colorCross = Color(255,0,0,flAlpha*flAdjust2);
		}
	}
	
	surface()->DrawSetColor( colorCross );
	
	if ( !asw_crosshair_use_perspective.GetBool() )
	{
		surface()->DrawSetTexture( m_nDirectCrosshairTexture2 );
	}
	else
	{
		if ( bShotWarn )
			surface()->DrawSetTexture( m_nDirectCrosshairTextureX );
		else
			surface()->DrawSetTexture( m_nDirectCrosshairTexture );
	}
	

	Vertex_t points[4] = 
	{ 
		Vertex_t( Vector2D(vXHairCenter.x + vecCornerTL_rotated.x, vXHairCenter.y + vecCornerTL_rotated.y), 
		Vector2D(0,0) ), 
		Vertex_t( Vector2D(vXHairCenter.x + vecCornerTR_rotated.x, vXHairCenter.y + vecCornerTR_rotated.y), 
		Vector2D(1,0) ), 
		Vertex_t( Vector2D(vXHairCenter.x + vecCornerBR_rotated.x, vXHairCenter.y + vecCornerBR_rotated.y), 
		Vector2D(1,1) ), 
		Vertex_t( Vector2D(vXHairCenter.x + vecCornerBL_rotated.x, vXHairCenter.y + vecCornerBL_rotated.y), 
		Vector2D(0,1) ) 
	}; 
	surface()->DrawTexturedPolygon( 4, points );

	// draw the center
	if ( !asw_crosshair_use_perspective.GetBool() )
	{
		surface()->DrawSetColor( colorCross );
		surface()->DrawSetTexture( m_nCrosshairTexture );
		surface()->DrawTexturedRect(vXHairCenter.x - iXHairHalfSize, vXHairCenter.y - iXHairHalfSize, vXHairCenter.x + iXHairHalfSize, vXHairCenter.y + iXHairHalfSize);
	}
}
예제 #27
0
void CASWHudWeapons::Paint()
{
	VPROF_BUDGET( "CASWHudWeapons::Paint", VPROF_BUDGETGROUP_ASW_CLIENT );
	GetSize(m_iFrameWidth,m_iFrameHeight);
	BaseClass::Paint();

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (!pPlayer)
		return;

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return;		
	char cbuffer[64];

	if ( !m_hUseArea.Get() )
	{
		m_hUseArea = ( CASWHudUseArea * )GET_HUDELEMENT( CASWHudUseArea );
	}

	ASWUseAction* pUseAction = NULL;
	if ( m_hUseArea.Get() && m_hUseArea->m_pUseIcon )
	{
		pUseAction = m_hUseArea->m_pUseIcon->GetCurrentUseAction();
	}
	
	int r, g, b;
	
	int tall = m_iFrameHeight * 0.25f * asw_hud_scale.GetFloat();	// how tall to draw the weapon icons
	int spacing_y = tall * 0.7f;
	int nWeaponsToShow = asw_hotbar_self.GetBool() ? ASW_NUM_INVENTORY_SLOTS - 1 : ASW_NUM_INVENTORY_SLOTS;
	bool bPowOnWeapon = false;
	for ( int k = 0; k < nWeaponsToShow; k++ )
	{
		C_ASW_Weapon* pWeapon = pMarine->GetASWWeapon(k);
		// set draw color
		bool bActiveWeapon = (pWeapon && pWeapon == pMarine->GetActiveWeapon());
		if ( bActiveWeapon )
		{
			r = 255;
			g = 255;
			b = 255;
		}
		else
		{
			r = 66;	// light blue
			g = 142;
			b = 192;
		}
		
		if (asw_debug_hud.GetInt()!=0)
		{
			if (pWeapon)
			{
				Q_snprintf(cbuffer, sizeof(cbuffer), "%d:%s %d(%d)", k, pWeapon->GetClassname(),
					pWeapon->GetEffects(), pWeapon->IsEffectActive(EF_NODRAW));
			}
			else
			{
				b = 255;
				Q_snprintf(cbuffer, sizeof(cbuffer), "%d:Empty", k);
			}		
			g_pMatSystemSurface->DrawColoredText(m_hWeaponHUDFont, 0, k*tall, r, g, 
				b, 200, &cbuffer[0]);
		}

		// draw icon
		if (pWeapon && ASWEquipmentList())
		{
			int list_index = pWeapon->GetEquipmentListIndex();
			int iTexture = ASWEquipmentList()->GetEquipIconTexture(!pWeapon->GetWeaponInfo()->m_bExtra, list_index);
			if (iTexture != -1)
			{				
				surface()->DrawSetColor(Color(r,g,b,255));
				surface()->DrawSetTexture(iTexture);

				int icon_x_offset = pWeapon->GetWeaponInfo()->m_iHUDIconOffsetX * (m_iFrameWidth / 160.0f) * asw_hud_scale.GetFloat();
				int icon_y_offset = pWeapon->GetWeaponInfo()->m_iHUDIconOffsetY * (m_iFrameHeight / 160.0f) * asw_hud_scale.GetFloat();
				int text_x_offset = pWeapon->GetWeaponInfo()->m_iHUDNumberOffsetX * (m_iFrameWidth / 160.0f) * asw_hud_scale.GetFloat();
				int text_y_offset = pWeapon->GetWeaponInfo()->m_iHUDNumberOffsetY * (m_iFrameHeight / 160.0f) * asw_hud_scale.GetFloat();

				// drop shadow
				/*
				surface()->DrawSetColor(Color(0,0,0,255));
				if (pWeapon->GetWeaponInfo()->m_bExtra)
					surface()->DrawTexturedRect(icon_x_offset + 1, k*spacing_y + 1 + icon_y_offset,
												icon_x_offset + 1 + tall, k*spacing_y + tall + 1 + icon_y_offset);
				else
					surface()->DrawTexturedRect(icon_x_offset + 1, k*spacing_y + 1 + icon_y_offset,
												icon_x_offset + 1 + tall * 2, k*spacing_y + tall + 1 + icon_y_offset);
				*/

				//todo: set glow vars to make the weapon glow when it's currently selected
				/*
				bool foundVar;
				MaterialVar* pTextureVar = pMaterial->FindVar( "$basetexture", &foundVar, false );
				if (foundVar)
				{
					if ( bActiveWeapon )
					{

					}
					else
					{

					}
				}
				*/

				surface()->DrawSetColor(Color(r,g,b,255));
				if ( pWeapon->GetWeaponInfo()->m_bExtra )
				{
					surface()->DrawTexturedRect(icon_x_offset, k*spacing_y + icon_y_offset,
												icon_x_offset + tall, k*spacing_y + tall + icon_y_offset);
				}
				else
				{
					surface()->DrawTexturedRect(icon_x_offset, k*spacing_y + icon_y_offset,
												icon_x_offset + tall * 2, k*spacing_y + tall + icon_y_offset);
				}

				pWeaponPos[ k ]->SetBounds( icon_x_offset, k * spacing_y + icon_y_offset, tall * 2, tall );

				if ( pWeapon->m_bPoweredUp )
				{
					int iPowBuffer = m_iFrameHeight/20;
					m_pPowerups->SetBounds(icon_x_offset + (tall*2) + iPowBuffer, (k * spacing_y + icon_y_offset) + iPowBuffer, (tall*2), tall - (iPowBuffer*2));
					bPowOnWeapon = true;
				}

				// show charges?
				if (pWeapon->GetWeaponInfo()->m_bShowCharges)
				{
					Q_snprintf(cbuffer, sizeof(cbuffer), "%d", pWeapon->GetChargesForHUD() );
					g_pMatSystemSurface->DrawColoredText(m_hWeaponHUDFont, text_x_offset, 
						k*spacing_y + text_y_offset, r, g, 	b, 200, &cbuffer[0]); 
				}
				// show weapon swaps
				if ( asw_hud_swaps.GetBool() && pUseAction && pUseAction->iInventorySlot == k )
				{
					const CASW_WeaponInfo* pWeaponData = NULL;
					const char *szWeaponClass = NULL;
					C_ASW_Pickup_Weapon *pPickup = dynamic_cast<C_ASW_Pickup_Weapon*>( pUseAction->UseTarget.Get());
					if ( pPickup )
					{
						pWeaponData = ASWEquipmentList()->GetWeaponDataFor( pPickup->GetWeaponClass() );
						szWeaponClass = pPickup->GetWeaponClass();
					}
					else
					{
						C_ASW_Weapon *pWeapon = dynamic_cast<C_ASW_Weapon*>( pUseAction->UseTarget.Get() );
						if ( pWeapon )
						{
							pWeaponData = pWeapon->GetWeaponInfo();
							szWeaponClass = pWeapon->GetClassname();
						}
					}
					if ( pWeaponData )
					{
						int iEquipListIndex = pWeaponData->m_bExtra ? ASWEquipmentList()->GetExtraIndex( szWeaponClass )
							: ASWEquipmentList()->GetRegularIndex( szWeaponClass );
						int iSwapWeaponTexture = ASWEquipmentList()->GetEquipIconTexture( !pWeaponData->m_bExtra, iEquipListIndex );
						if ( m_nSwapArrowTexture != -1 && iSwapWeaponTexture != -1 )
						{
							surface()->DrawSetColor( Color( r,g,b,m_hUseArea->m_pUseIcon->m_pUseText->GetAlpha() ) );	// fade in along with the use icon
							icon_x_offset = tall * 2.0f;
							icon_y_offset = 0;
							surface()->DrawSetTexture( m_nSwapArrowTexture );
							surface()->DrawTexturedRect( icon_x_offset, k*spacing_y + icon_y_offset,
								icon_x_offset + tall, k*spacing_y + tall + icon_y_offset );

							icon_x_offset = tall * 3.0f + pWeaponData->m_iHUDIconOffsetX;
							icon_y_offset = pWeaponData->m_iHUDIconOffsetY;
							surface()->DrawSetTexture( iSwapWeaponTexture );
							surface()->DrawTexturedRect( icon_x_offset, k*spacing_y + icon_y_offset,
								icon_x_offset + ( pWeaponData->m_bExtra ? tall : tall * 2.0f ) , k*spacing_y + tall + icon_y_offset );
						}
					}
				}
			}
		}		
	}

	if ( !bPowOnWeapon )
	{
		//int iPowBuffer = m_iFrameHeight/20;
		int xpos = 12 * (m_iFrameWidth / 160.0f) * asw_hud_scale.GetFloat();
		//int ypos = 2 * (m_iFrameWidth / 160.0f) * asw_hud_scale.GetFloat();
		m_pPowerups->SetBounds(xpos, (spacing_y*nWeaponsToShow) + (spacing_y/3), tall, tall*0.75f );
	}
}
예제 #28
0
void CASWHudCrosshair::PaintReloadProgressBar( void )
{
	if ( !engine->IsActiveApp() )
	{
		m_pAmmoProgress->SetVisible( false );
		m_pFastReloadBar->SetVisible( false );
		return;
	}

	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	C_ASW_Marine* pMarine = pPlayer->GetMarine();
	if ( !pMarine )
		return;

	C_ASW_Weapon* pWeapon = pMarine->GetActiveASWWeapon();
	if ( !pWeapon || !asw_crosshair_use_perspective.GetBool() )
	{
		m_pAmmoProgress->SetVisible( false );
		m_pFastReloadBar->SetVisible( false );
		return;
	}

	int x, y;
	GetCurrentPos( x, y );
	int nCrosshair = GetCurrentCrosshair( x, y );

	if ( pWeapon && pWeapon->IsReloading() )
	{	
		m_bIsReloading = true;

		float flProgress = 0.0;

		float fStart = pWeapon->m_fReloadStart;
		float fNext = pWeapon->m_flNextPrimaryAttack;
		float fTotalTime = fNext - fStart;
		if (fTotalTime <= 0)
			fTotalTime = 0.1f;

		// if we're in single player, the progress code in the weapon doesn't run on the client because we aren't predicting
		if ( !cl_predict->GetInt() )
			flProgress = RescaleProgessForArt( (gpGlobals->curtime - fStart) / fTotalTime );
		else
			flProgress = RescaleProgessForArt( pWeapon->m_fReloadProgress );

		if ((int(gpGlobals->curtime*10) % 2) == 0)
			m_pAmmoProgress->SetFgColor( Color( 215, 205, 80, 255) );
		else
			m_pAmmoProgress->SetFgColor( Color( 175, 80, 80, 255) );

		if ( asw_fast_reload_enabled.GetBool() )
		{
			m_pFastReloadBar->SetFgColor( Color( 235, 235, 235, 100) );
			m_pFastReloadBar->SetBgColor( Color( 0, 0, 0, 0 ) );
			// fractions of ammo wide for fast reload start/end
			float fFastStart = RescaleProgessForArt( (pWeapon->m_fFastReloadStart - fStart) / fTotalTime );
			float fFastEnd = RescaleProgessForArt( (pWeapon->m_fFastReloadEnd - fStart) / fTotalTime );
			m_pFastReloadBar->SetStartProgress( fFastStart );
			m_pFastReloadBar->SetProgress( fFastEnd );
			m_pFastReloadBar->SetVisible( true );
		}

		m_pAmmoProgress->SetProgress( flProgress );
		m_pAmmoProgress->SetAlpha( 255 );
		m_pAmmoProgress->SetBgColor( Color( 100, 100, 100, 160*m_pAmmoProgress->GetScale() ) );
		m_pAmmoProgress->SetVisible( true );
	}
	/*else if ( m_bIsReloading )
	{
		m_bIsReloading = false;
		m_pAmmoProgress->SetFgColor( Color( 200, 200, 200, 255 ) );
		m_pAmmoProgress->SetProgress( 1.0 );
		vgui::GetAnimationController()->RunAnimationCommand( m_pAmmoProgress, "alpha",	0,		0, 0.5f, vgui::AnimationController::INTERPOLATOR_ACCEL );
	}
	*/
	else
	{
		float flScale = m_pAmmoProgress->GetScale();
		m_bIsReloading = false;
		m_pAmmoProgress->SetFgColor( Color( 220, 220, 220, 140*flScale ) );
		m_pFastReloadBar->SetVisible( false );

		int	nClip1 = pWeapon->Clip1();
		if ( nClip1 < 0 )
		{
			m_pAmmoProgress->SetVisible( false );
			return;
		}

		float flProgress = RescaleProgessForArt( float(nClip1) / float(pWeapon->GetMaxClip1()) ); 

		m_pAmmoProgress->SetProgress( flProgress );
		if ( flProgress < 0.25 && (int(gpGlobals->curtime*10) % 2) == 0 )
		{
			m_pAmmoProgress->SetBgColor( Color( 130, 90, 50, 160*flScale ) );
		}
		else
		{
			m_pAmmoProgress->SetBgColor( Color( 80, 80, 80, 130*flScale ) );
		}

		m_pAmmoProgress->SetVisible( !pPlayer->IsSniperScopeActive() && nCrosshair == m_nCrosshairTexture );
	}
};
예제 #29
0
void CASWHudUseArea::Paint()
{
	VPROF_BUDGET( "CASWHudUseArea::Paint", VPROF_BUDGETGROUP_ASW_CLIENT );
	GetSize(m_iFrameWidth,m_iFrameHeight);
	m_iFrameWidth = ScreenWidth();
	BaseClass::Paint();

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (!pPlayer)
		return;

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return;
	int r, g, b;
	r = g = b = 255;
	if (asw_debug_hud.GetBool())
	{
		char cbuffer[20];
		Q_snprintf(cbuffer, sizeof(cbuffer), "Usable = %d", pPlayer->m_iUseEntities);		
		g_pMatSystemSurface->DrawColoredText(m_hUseAreaFont, 0, 0, r, g, 
				b, 200, &cbuffer[0]);
	}
	
	for (int k=0; k<3; k++)
	{
		pPlayer->UseIconTarget[k] = NULL;
	}

	m_iNumUseIcons = 0;
	pPlayer->FindUseEntities();

	// don't add any icons if our marine is dead
	if (!pPlayer->GetMarine() || !pPlayer->GetMarine()->IsAlive())
	{
		pPlayer->UseIconTarget[0] = NULL;
		if (m_pUseIcon)
			m_pUseIcon->ClearUseAction();
		return;
	}

	int iNumToDraw = MIN(1, pPlayer->m_iUseEntities);
	int iDrew = 0;
	for (int i=0; i<iNumToDraw; i++)
	{	
		if (AddUseIconsFor(pPlayer->GetUseEntity(i)))
			iDrew++;
		
		if (asw_debug_hud.GetBool())
		{
			char buffer[20];
			C_BaseEntity *pEnt = pPlayer->GetUseEntity(i);
			Q_snprintf(buffer, sizeof(buffer), "Use:%d", pEnt->entindex());
			//int wide = g_pMatSystemSurface->DrawTextLen(m_hUseAreaFont, &buffer[0]);
			int tall = vgui::surface()->GetFontTall( m_hUseAreaFont );
			float xPos		= 0;
			float yPos		= (i+1) * tall;
			
			// actual text
			g_pMatSystemSurface->DrawColoredText(m_hUseAreaFont, xPos, yPos, r, g, 
				b, 200, &buffer[0]);
		}
	}
	if (iDrew < 1)
	{
		if (m_pUseIcon)
			m_pUseIcon->ClearUseAction();
	}
}
void CASW_Hud_Squad_Hotbar::UpdateList()
{
	if ( !ASWGameResource() )
		return;

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();

	int iEntry = 0;
	bool bHasItem = false;
	if ( asw_hotbar_self.GetBool() )
	{
		if ( iEntry >= m_pEntries.Count() )
		{
			CASW_Hotbar_Entry *pPanel = new CASW_Hotbar_Entry( this, "SquadInventoryPanelEntry" );
			m_pEntries.AddToTail( pPanel );
			InvalidateLayout();
		}

		// add your offhand item to the hotbar first
		CASW_Marine *pPlayerMarine = pPlayer->GetMarine();
		if ( pPlayerMarine )
		{
			C_ASW_Weapon *pWeapon = pPlayerMarine->GetASWWeapon( ASW_INVENTORY_SLOT_EXTRA );
			if ( pWeapon )
			{
				m_pEntries[ iEntry ]->m_iHotKeyIndex = -1;
				m_pEntries[ iEntry ]->SetVisible( true );
				m_pEntries[ iEntry ]->SetDetails( pPlayerMarine, ASW_INVENTORY_SLOT_EXTRA );
				bHasItem = true;
			}
		}

		if ( !bHasItem )	// blank it out if there's no item in that slot
		{
			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetDetails( NULL, -1 );
			m_pEntries[ iEntry ]->SetVisible( false );
		}

		iEntry++;
	}

	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource* pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetCommander() != pPlayer )
			continue;

		C_ASW_Marine *pMarine = pMR->GetMarineEntity();
		if ( !pMarine )
			continue;

		if ( pMarine->IsInhabited() )
			continue;

		if ( iEntry >= m_pEntries.Count() )
		{
			CASW_Hotbar_Entry *pPanel = new CASW_Hotbar_Entry( this, "SquadInventoryPanelEntry" );
			m_pEntries.AddToTail( pPanel );
			InvalidateLayout();
		}

		bHasItem = false;
		for ( int k = 0; k < ASW_NUM_INVENTORY_SLOTS; k++ )
		{
			C_ASW_Weapon *pWeapon = pMarine->GetASWWeapon( k );
			if ( !pWeapon )
				continue;

			const CASW_WeaponInfo* pInfo = pWeapon->GetWeaponInfo();
			if ( !pInfo || !pInfo->m_bOffhandActivate )		// TODO: Fix for sentry guns
				continue;

			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetVisible( true );
			m_pEntries[ iEntry ]->SetDetails( pMarine, k );
			bHasItem = true;

			if ( asw_hotbar_simple.GetBool() )		// only 1 item per marine
				break;
		}

		if ( !bHasItem )	// blank it out if there's no item in that slot
		{
			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetDetails( NULL, -1 );
			m_pEntries[ iEntry ]->SetVisible( false );
		}

		iEntry++;
	}

	for ( int i = iEntry; i < m_pEntries.Count(); i++ )
	{
		m_pEntries[ i ]->SetVisible( false );
	}
}