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 );
}
//-----------------------------------------------------------------------------
// Purpose: Hide all the ASW hud in certain cases
//-----------------------------------------------------------------------------
bool CASW_HudElement::ShouldDraw( void )
{
	if (!CHudElement::ShouldDraw())
		return false;

	if (engine->IsLevelMainMenuBackground())
		return false;

	if (ASWGameRules())
	{
		if (ASWGameRules()->IsIntroMap() || ASWGameRules()->IsOutroMap())
			return false;
	}

	C_ASW_Player *pASWPlayer = C_ASW_Player::GetLocalASWPlayer();
	C_ASW_Marine *pMarine = pASWPlayer ? pASWPlayer->GetViewMarine() : NULL;
	// hide things due to turret control
	if ( ( m_iHiddenBits & HIDEHUD_REMOTE_TURRET ) && pMarine && pMarine->IsControllingTurret() )
		return false;
	if ( ( m_iHiddenBits & HIDEHUD_PLAYERDEAD ) && ( !pMarine || pMarine->GetHealth() <= 0 ) )
		return false;

	if ( !asw_draw_hud.GetBool() )
		return false;

	return true;
}
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++;
			}
		}		
	}
}
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();
			}
		}
	}
}
Exemple #5
0
bool CASW_Briefing::IsCommanderSpeaking( int nLobbySlot )
{
	if ( gpGlobals->maxClients <= 1 )
		return false;

	UpdateLobbySlotMapping();

	C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get();
	if ( !pPlayer )
		return false;

	CVoiceStatus *pVoiceMgr = GetClientVoiceMgr();	
	if ( !pVoiceMgr )
		return false;

	int index = pPlayer->entindex();
	bool bTalking = false;
	if ( pPlayer == C_ASW_Player::GetLocalASWPlayer() )
	{
		bTalking = pVoiceMgr->IsLocalPlayerSpeakingAboveThreshold( FirstValidSplitScreenSlot() );
	}
	else
	{
		bTalking = pVoiceMgr->IsPlayerSpeaking( index );
	}
	return bTalking;
}
void CASW_VGUI_Computer_Menu::OnCommand(char const* command)
{	
	if (!strnicmp(command, "Option", 6))
	{
		int iControl = atoi(command+6);
		ClickedMenuOption(iControl);
		return;
	}
	else if ( !Q_stricmp( command, "Cancel" ) )
	{
		if ( m_hCurrentPage.Get() )
		{
			SetHackOption( 0 );
		}
		else
		{
			C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
			if ( pPlayer )
			{
				pPlayer->StopUsing();
			}
		}
	}
	
	BaseClass::OnCommand(command);
}
void CASW_VGUI_Computer_Frame::OnCommand( const char *pCommand )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();

	if ( !Q_stricmp( pCommand, "Cancel" ) )
	{
		if ( m_pMenuPanel && m_pMenuPanel->m_hCurrentPage.Get() )
		{
			m_pMenuPanel->SetHackOption( 0 );
		}
		else
		{
			if ( pPlayer )
			{
				pPlayer->StopUsing();
			}
		}
	}
	else if ( !Q_stricmp( pCommand, "Logoff" ) )
	{
		if ( pPlayer )
		{
			pPlayer->StopUsing();
		}
	}

	BaseClass::OnCommand( pCommand );
}
Exemple #8
0
CSteamID CASW_Briefing::GetCommanderSteamID( int nLobbySlot )
{
	CSteamID invalid_result;
	if ( nLobbySlot < 0 || nLobbySlot >= NUM_BRIEFING_LOBBY_SLOTS )
		return invalid_result;

	UpdateLobbySlotMapping();

	C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get();
	if ( !pPlayer )
		return invalid_result;

	int iIndex = pPlayer->entindex();
	player_info_t pi;
	if ( engine->GetPlayerInfo(iIndex, &pi) )
	{
		if ( pi.friendsID )
		{
			CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual );
			return steamIDForPlayer;
		}
	}
	
	return invalid_result;
}
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 ASW_MessageLog_f(void)
{
	// find the asw player
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer)
		pPlayer->ShowMessageLog();
}
Exemple #11
0
void C_ASW_Alien::ClientThink()
{
	BaseClass::ClientThink();

	// asw temp fix demo playback 
	//ASWUpdateClientSideAnimation();

	m_vecLastRenderedPos = WorldSpaceCenter();
	m_vecAutoTargetRadiusPos = GetLocalAutoTargetRadiusPos();

	if ( GetHealth() > 0 && m_bElectroStunned && m_fNextElectroStunEffect <= gpGlobals->curtime)
	{
		// apply electro stun effect
		HACK_GETLOCALPLAYER_GUARD( "C_ASW_Alien::ClientThink FX_ElectroStun" );
		FX_ElectroStun(this);
		m_fNextElectroStunEffect = gpGlobals->curtime + RandomFloat( 0.3, 1.0 );
		//Msg( "%f - ElectroStunEffect\n", gpGlobals->curtime );
	}

	UpdateFireEmitters();

	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( pPlayer && pPlayer->IsSniperScopeActive() )
	{
		m_GlowObject.SetRenderFlags( true, true );
	}
	else
	{
		m_GlowObject.SetRenderFlags( false, false );
	}
}
void asw_credits_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer)
	{
		pPlayer->LaunchCredits();
	}
}
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()));
	}
}
void asw_marine_update_visibility_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
	{
		pPlayer->GetMarine()->UpdateVisibility();
	}
}
void asw_cain_mail_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer)
	{
		pPlayer->LaunchCainMail();
	}
}
Exemple #16
0
bool CASW_Briefing::IsWeaponUnlocked( const char *szWeaponClass )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return true;

	return pPlayer->IsWeaponUnlocked( szWeaponClass );
}
void ASW_ActivateSecondary_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();

	if (pPlayer && pPlayer->GetMarine())
	{
		pPlayer->ActivateInventoryItem(1);
	}
}
void ASW_ActivateExtra_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();

	if (pPlayer && pPlayer->GetMarine())
	{
		pPlayer->ActivateInventoryItem(2);
	}
}
bool CASWHudObjective::IsSpectating()
{
    C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
    if ( !pPlayer )
        return false;

    C_ASW_Marine *pSpectating = pPlayer->GetSpectatingMarine();
    return pSpectating != NULL;
}
void asw_show_xp_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( pPlayer )
	{
		Msg( "pPlayer->GetLevel() = %d\n", pPlayer->GetLevel() );
		Msg( "pPlayer->GetExperience() = %d\n", pPlayer->GetExperience() );
		Msg( "pPlayer->GetExperienceBeforeDebrief() = %d\n", pPlayer->GetExperienceBeforeDebrief() );
	}
}
Exemple #21
0
bool CASW_Briefing::AreOtherPlayersReady()
{
	if ( !ASWGameResource() )
		return false;

	C_ASW_Player *pLeader = ASWGameResource()->GetLeader();
	if ( !pLeader )
		return false;

	return ASWGameResource()->AreAllOtherPlayersReady( pLeader->entindex() );
}
Exemple #22
0
const char* CASW_Briefing::GetLeaderName()
{
	if ( !ASWGameResource() )
		return "";

	C_ASW_Player *pLeader = ASWGameResource()->GetLeader();
	if ( !pLeader )
		return "";

	return pLeader->GetPlayerName();
}
void CASW_VGUI_Message_Log::ShowLoggedMessage(int index)
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (!pPlayer)
		return;

	if (index < 0 || index >= GetClientModeASW()->m_InfoMessageLog.Count())
		return;

	pPlayer->ShowPreviousInfoMessage(GetClientModeASW()->m_InfoMessageLog[index].Get());
}
void CASW_VGUI_Computer_Menu::FadeCurrentPage()
{
	if (m_hCurrentPage.Get() == NULL)
		return;

	// request a return to main menu from the server
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	pPlayer->SelectHackOption(0);
	CLocalPlayerFilter filter;
	C_BaseEntity::EmitSound( filter, -1 /*SOUND_FROM_LOCAL_PLAYER*/, "ASWComputer.MenuBack" );
}
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);
}
bool CASW_VGUI_Computer_Frame::MouseClick(int x, int y, bool bRightClick, bool bDown)
{
	if (m_pLogoffLabel->IsCursorOver() && m_pLogoffLabel->IsVisible() )
	{
		C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
		if (pPlayer)
			pPlayer->StopUsing();
		return true;
	}

	return true;	// swallow click
}
void asw_make_jeep_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer)
	{
		C_ASW_PropJeep_Clientside* pJeep = C_ASW_PropJeep_Clientside::CreateNew(false);
		pJeep->SetAbsOrigin(pPlayer->GetAbsOrigin());
		pJeep->Initialize();
		g_pJeep = pJeep;
		// need to set player?
	}
}
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->GetViewMarine() && pPlayer->GetViewMarine()->m_hUsingEntity.Get() == this)
		{
			return "#asw_exit_panel";
		}
	}
	return "#asw_hack_panel";
}
Exemple #29
0
int CASW_Briefing::GetCommanderPromotion( int nLobbySlot )
{
	if ( nLobbySlot < 0 || nLobbySlot >= NUM_BRIEFING_LOBBY_SLOTS )
		return -1;

	UpdateLobbySlotMapping();

	C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get();
	if ( !pPlayer )
		return -1;

	return pPlayer->GetPromotion();
}
void MissionCompletePlayerStatsLine::UpdateLabels()
{
	C_ASW_Game_Resource* pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	if ( m_iPlayerIndex < 1 || m_iPlayerIndex>gpGlobals->maxClients )
	{
		m_pNameLabel->SetText("");
		if ( m_pMedalArea )
		{
			m_pMedalArea->SetProfileIndex( -1 );
		}

		m_wszCurrentName[ 0 ] = L'\0';
		return;
	}

	C_ASW_Player *pPlayer = dynamic_cast<C_ASW_Player*>( UTIL_PlayerByIndex( m_iPlayerIndex ) );
	if ( !pPlayer )
		return;

	wchar_t wszPlayerName[ 64 ];
	g_pVGuiLocalize->ConvertANSIToUnicode( g_PR->GetPlayerName( m_iPlayerIndex ), wszPlayerName, sizeof( wszPlayerName ) );

	wchar_t wszPlayerStatus[ 64 ];
	wszPlayerStatus[ 0 ] = L'\0';
	if ( m_iPlayerIndex == pGameResource->GetLeaderEntIndex() )
	{				
		V_wcsncpy( wszPlayerStatus, g_pVGuiLocalize->Find( "#asw_stats_player_status_leader" ), sizeof( wszPlayerStatus ) );
	}
	else if ( pGameResource->IsPlayerReady(m_iPlayerIndex) )
	{
		V_wcsncpy( wszPlayerStatus, g_pVGuiLocalize->Find( "#asw_stats_player_status_ready" ), sizeof( wszPlayerStatus ) );
	}

	char szPlayerXP[ 64 ];
	V_snprintf( szPlayerXP, sizeof( szPlayerXP ), "%d", pPlayer->GetExperience() );
	wchar_t wszPlayerXP[ 64 ];
	g_pVGuiLocalize->ConvertANSIToUnicode( szPlayerXP, wszPlayerXP, sizeof( wszPlayerXP ) );

	g_pVGuiLocalize->ConstructString( m_wszCurrentName, sizeof( m_wszCurrentName ), g_pVGuiLocalize->Find( "#asw_stats_player_name" ), 3, wszPlayerName, wszPlayerStatus, wszPlayerXP );
	m_pNameLabel->SetText( m_wszCurrentName );

	if ( m_pMedalArea )
	{
		m_pMedalArea->SetProfileIndex( m_iPlayerIndex - 1 );
	}

	SetBgColor( m_pBGColor );		
}