コード例 #1
0
void listroster_server_f(void)
{
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	for (int i=0;i<ASW_NUM_MARINE_PROFILES;i++)
	{
		Msg("[S]Roster %d selected=%d\n", i, pGameResource->IsRosterSelected(i));
	}
}
コード例 #2
0
ファイル: asw_briefing.cpp プロジェクト: Au-heppa/swarm-sdk
bool CASW_Briefing::IsProfileSelected( int nProfileIndex )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return false;

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

		if ( pMR->GetProfileIndex() == nProfileIndex )
		{
			return true;
		}
	}

	return false;
}
コード例 #3
0
ファイル: asw_briefing.cpp プロジェクト: Au-heppa/swarm-sdk
const char* CASW_Briefing::GetPlayerNameForMarineProfile( int nProfileIndex )
{
	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetProfileIndex() == nProfileIndex )
		{
			C_ASW_Player *pPlayer = pMR->GetCommander();
			if ( pPlayer )
			{
				return pPlayer->GetPlayerName();
			}
			break;
		}
	}
	return "";
}
コード例 #4
0
ファイル: asw_briefing.cpp プロジェクト: Au-heppa/swarm-sdk
void CASW_Briefing::SelectWeapon( int nProfileIndex, int nInventorySlot, int nEquipIndex )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

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

		if ( pMR->GetProfileIndex() == nProfileIndex )
		{
			int nMarineResourceIndex = ASWGameResource()->GetIndexFor( pMR );
			pPlayer->LoadoutSelectEquip( nMarineResourceIndex, nInventorySlot, nEquipIndex );
			return;
		}
	}
}
コード例 #5
0
// This is used by the PlayerListPanel when the player clicks the restart mission button
void asw_restart_mission_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if (!pPlayer || !ASWGameResource())
		return;

	if (ASWGameResource()->GetLeader() != pPlayer)
		return;
	if (ASWGameRules())
	{
		if ( gpGlobals->maxClients > 1)
		{
			ASWGameRules()->RestartMissionCountdown( pPlayer );
		}
		else
		{
			// restart instantly in singleplayer
			ASWGameRules()->RestartMission( pPlayer );
		}
	}
}
コード例 #6
0
bool CASW_Spawn_Manager::ValidSpawnPoint( const Vector &vecPosition, const Vector &vecMins, const Vector &vecMaxs, bool bCheckGround, float flMarineNearDistance )
{
    // check if we can fit there
    trace_t tr;
    UTIL_TraceHull( vecPosition,
                    vecPosition + Vector( 0, 0, 1 ),
                    vecMins,
                    vecMaxs,
                    MASK_NPCSOLID,
                    NULL,
                    COLLISION_GROUP_NONE,
                    &tr );

    if( tr.fraction != 1.0 )
        return false;

    // check there's ground underneath this point
    if ( bCheckGround )
    {
        UTIL_TraceHull( vecPosition + Vector( 0, 0, 1 ),
                        vecPosition - Vector( 0, 0, 64 ),
                        vecMins,
                        vecMaxs,
                        MASK_NPCSOLID,
                        NULL,
                        COLLISION_GROUP_NONE,
                        &tr );

        if( tr.fraction == 1.0 )
            return false;
    }

    if ( flMarineNearDistance > 0 )
    {
        CASW_Game_Resource* pGameResource = ASWGameResource();
        float distance = 0.0f;
        for ( int i=0 ; i < pGameResource->GetMaxMarineResources() ; i++ )
        {
            CASW_Marine_Resource* pMR = pGameResource->GetMarineResource(i);
            if ( pMR && pMR->GetMarineEntity() && pMR->GetMarineEntity()->GetHealth() > 0 )
            {
                distance = pMR->GetMarineEntity()->GetAbsOrigin().DistTo( vecPosition );
                if ( distance < flMarineNearDistance )
                {
                    return false;
                }
            }
        }
    }

    return true;
}
コード例 #7
0
ファイル: asw_briefing.cpp プロジェクト: Au-heppa/swarm-sdk
bool CASW_Briefing::IsLeader( 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 true;

	return ( pPlayer == ASWGameResource()->GetLeader() );
}
コード例 #8
0
ファイル: asw_briefing.cpp プロジェクト: Au-heppa/swarm-sdk
bool CASW_Briefing::IsLobbySlotBot( int nLobbySlot )
{
	if ( nLobbySlot < 0 || nLobbySlot >= NUM_BRIEFING_LOBBY_SLOTS || !IsLobbySlotOccupied( nLobbySlot ) )
		return false;

	int nMarineResourceIndex = LobbySlotToMarineResourceIndex( nLobbySlot );
	C_ASW_Marine_Resource *pMR = ASWGameResource() ? ASWGameResource()->GetMarineResource( nMarineResourceIndex ) : NULL;

	bool bHuman = ( pMR == NULL );

	if ( pMR )
	{
		C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get();
		C_ASW_Marine_Resource *pFirstMR = pPlayer ? ASWGameResource()->GetFirstMarineResourceForPlayer( pPlayer ) : NULL;

		if ( pFirstMR == pMR )
		{
			bHuman = true;
		}
	}
	return !bHuman;
}
コード例 #9
0
ファイル: asw_briefing.cpp プロジェクト: Au-heppa/swarm-sdk
int CASW_Briefing::GetCommanderReady( 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 true;

	return ASWGameResource()->IsPlayerReady( pPlayer );
}
コード例 #10
0
ファイル: asw_director.cpp プロジェクト: BenLubar/riflemod
// increase intensity as aliens are killed (particularly if they're close to the marines)
void CASW_Director::Event_AlienKilled( CBaseEntity *pAlien, const CTakeDamageInfo &info )
{
	if ( !pAlien )
		return;

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

	bool bDangerous = pAlien->Classify() == CLASS_ASW_SHIELDBUG;       // shieldbug
	bool bVeryDangerous = pAlien->Classify() == CLASS_ASW_QUEEN;		// queen

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

		CASW_Marine *pMarine = pMR->GetMarineEntity();
		if ( !pMarine || pMarine->GetHealth() <= 0 )
			continue;

		CASW_Intensity::IntensityType stress = CASW_Intensity::MILD;

		if ( bVeryDangerous )
		{
			stress = CASW_Intensity::EXTREME;
		}
		else if ( bDangerous )
		{
			stress = CASW_Intensity::HIGH;
		}
		else
		{
			float distance = pMarine->GetAbsOrigin().DistTo( pAlien->GetAbsOrigin() );
			if ( distance > asw_intensity_far_range.GetFloat() )
			{
				stress = CASW_Intensity::MILD;
			}
			else
			{
				stress = CASW_Intensity::MODERATE;
			}
		}

		pMR->GetIntensity()->Increase( stress );
	}

	ASWArena()->Event_AlienKilled( pAlien, info );
}
コード例 #11
0
void CASW_Campaign_Save::PlayerSpectating(CASW_Player* pPlayer)
{
	if (!ASWGameRules() || !pPlayer)
		return;
	if (ASWGameRules()->GetGameState() != ASW_GS_CAMPAIGNMAP)
		return;
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	if (m_bNextMissionVoteEnded)	// don't allow votes if the mission has already been chosen
		return;

	pPlayer->m_bRequestedSpectator = true;
	// if player is ready, that means he's already voted or a spectator
	int iPlayer = pPlayer->entindex() -1 ;
	if (iPlayer<0 ||iPlayer>ASW_MAX_READY_PLAYERS-1)
		return;
	if (pGameResource->IsPlayerReady(pPlayer->entindex()))
	{
		// subtract his old vote
		int iVotedFor = pGameResource->m_iCampaignVote[iPlayer];
		if (iVotedFor >=0 && iVotedFor < ASW_MAX_MISSIONS_PER_CAMPAIGN)
		{
			int iVotes = m_NumVotes[iVotedFor] - 1;
			m_NumVotes.Set(iVotedFor, iVotes);
		}
	}
	// clear his chosen mission and flag him as ready
	pGameResource->m_iCampaignVote[iPlayer] = -1;
	pGameResource->m_bPlayerReady.Set(iPlayer, true);

	if (pGameResource->AreAllOtherPlayersReady(pPlayer->entindex()))
	{
		if ( gpGlobals->maxClients > 1 )
		{
			if (!m_fVoteEndTime != 0)
			{	
				m_fVoteEndTime = gpGlobals->curtime + 4.0f;
			}
			SetThink( &CASW_Campaign_Save::VoteEndThink );
			SetNextThink( m_fVoteEndTime );
		}
		else
		{
			VoteEnded();
		}
	}
}
コード例 #12
0
void asw_gimme_health_f(void)
{
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
	{
		if (pGameResource->GetMarineResource(i) != NULL && pGameResource->GetMarineResource(i)->GetMarineEntity())
		{
			CASW_Marine *pMarine = pGameResource->GetMarineResource(i)->GetMarineEntity();
			pMarine->AddSlowHeal( pMarine->GetMaxHealth() - pMarine->GetHealth(), 3, NULL );
		}
	}
}
コード例 #13
0
void CASW_Campaign_Save::PlayerDisconnected(CASW_Player *pPlayer)
{
	if (!ASWGameRules() || !pPlayer)
		return;
	if (ASWGameRules()->GetGameState() != ASW_GS_CAMPAIGNMAP)
		return;
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	if (m_bNextMissionVoteEnded)	// don't allow votes if the mission has already been chosen
		return;

	// if player is ready, that means he's already voted or a spectator
	int iPlayer = pPlayer->entindex() -1 ;
	if (iPlayer<0 ||iPlayer>ASW_MAX_READY_PLAYERS-1)
		return;
	if (pGameResource->IsPlayerReady(pPlayer->entindex()))
	{
		// subtract his old vote
		int iVotedFor = pGameResource->m_iCampaignVote[iPlayer];
		if (iVotedFor >=0 && iVotedFor < ASW_MAX_MISSIONS_PER_CAMPAIGN)
		{
			int iVotes = m_NumVotes[iVotedFor] - 1;
			m_NumVotes.Set(iVotedFor, iVotes);
		}
	}

	// check for ending the vote
	if (pGameResource->AreAllOtherPlayersReady(pPlayer->entindex()))
	{
		if ( gpGlobals->maxClients > 1 )
		{
			//softcopy:test debug mission can't continue if one of the player disconnected
			/*if (!m_fVoteEndTime != 0)
			{	
				m_fVoteEndTime = gpGlobals->curtime + 4.0f;
			}
			SetThink( &CASW_Campaign_Save::VoteEndThink );
			SetNextThink( m_fVoteEndTime );*/
			VoteEnded();
		}
		else 
		{
			VoteEnded();
		}
	}
}
コード例 #14
0
void CASW_Campaign_Save::UpdateLastCommanders()
{
	// save which marines the players have selected
	// add which marines he has selected
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	// first check there were some marines selected (i.e. we're not in the campaign lobby map)
	int iNumMarineResources = 0;
	for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
	{
		if (pGameResource->GetMarineResource(i))
			iNumMarineResources++;
	}
	if ( iNumMarineResources <= 0 )
		return;
	
	char buffer[256];
	for (int i=0;i<ASW_NUM_MARINE_PROFILES;i++)
	{
		// look for a marine info for this marine
		bool bFound = false;
		for (int k=0;k<pGameResource->GetMaxMarineResources();k++)
		{
			CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(k);
			if (pMR && pMR->GetProfileIndex() == i && pMR->GetCommander())
			{
				CASW_Player *pPlayer = pMR->GetCommander();
				if (pPlayer)
				{
					// store the commander who has this marine
					Q_snprintf(buffer, sizeof(buffer), "%s%s",pPlayer->GetPlayerName(), pPlayer->GetASWNetworkID());
					m_LastCommanders[i] = AllocPooledString(buffer);
					m_LastMarineResourceSlot[i] = k;
					m_LastPrimaryMarines[i] = pPlayer->IsPrimaryMarine(i);
					bFound = true;
					break;
				}
			}
		}
		if (!bFound)
		{
			m_LastCommanders[i] = AllocPooledString("");
			m_LastMarineResourceSlot[i] = 0;
		}
	}
}
コード例 #15
0
CASW_Objective_Escape* CASW_Mission_Manager::GetEscapeObjective()
{
	if ( m_hEscapeObjective.Get() )
		return m_hEscapeObjective.Get();

	for ( int i=0; i < ASW_MAX_OBJECTIVES; i++ )  // 12 is max number of objectives 
	{
		CASW_Objective_Escape *pEscape = dynamic_cast<CASW_Objective_Escape*>( ASWGameResource()->GetObjective( i ) );
		if ( pEscape )
		{
			m_hEscapeObjective = pEscape;
			return pEscape;
		}
	}
	return NULL;
}
コード例 #16
0
	// if the player has his mouse over another marine, highlight it, cos he's the one we can give health to
	void CASW_Weapon_Medical_Satchel::MouseOverEntity(C_BaseEntity *pEnt, Vector vecWorldCursor)
	{
		C_ASW_Marine* pOtherMarine = C_ASW_Marine::AsMarine( pEnt );
		CASW_Player *pOwner = GetCommander();
		CASW_Marine *pMarine = GetMarine();
		if (!pOwner || !pMarine)
			return;

		float fOtherHealth = 1.0f;
		if (pOtherMarine && pOtherMarine->GetMarineResource())
			fOtherHealth = pOtherMarine->GetMarineResource()->GetHealthPercent();
		if (!pOtherMarine)
		{
			C_ASW_Game_Resource *pGameResource = ASWGameResource();
			if (pGameResource)
			{
				// find marine closest to world cursor
				const float fMustBeThisClose = 70;
				const C_ASW_Game_Resource::CMarineToCrosshairInfo::tuple_t &info = pGameResource->GetMarineCrosshairCache()->GetClosestMarine();
				if ( info.m_fDistToCursor <= fMustBeThisClose )
				{
					pOtherMarine = info.m_hMarine.Get();
				}
			}
		}

		// if the marine our cursor is over is near enough, highlight him
		if (pOtherMarine)
		{
			float dist = (pMarine->GetAbsOrigin() - pOtherMarine->GetAbsOrigin()).Length2D();
			if (dist < MAX_HEAL_DISTANCE)
			{
				bool bCanGiveHealth = ( fOtherHealth < 1.0f && m_iClip1 > 0 );
				ASWInput()->SetHighlightEntity( pOtherMarine, bCanGiveHealth );
				if ( bCanGiveHealth )		// if he needs healing, show the give health cursor
				{
					CASWHudCrosshair *pCrosshair = GET_HUDELEMENT( CASWHudCrosshair );
					if ( pCrosshair )
					{
						pCrosshair->SetShowGiveHealth(true);
					}
				}
			}
		}		
	}
コード例 #17
0
void listmarineresources_server_f(void)
{
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
	{
		if (pGameResource->GetMarineResource(i) == NULL)
			Msg("MarineResource %d = empty\n", i);
		else
		{
			Msg("MarineResource %d = present, profileindex %d, commander %d commander index %d\n",
				i, pGameResource->GetMarineResource(i)->m_MarineProfileIndex,
				pGameResource->GetMarineResource(i)->GetCommander(),
				pGameResource->GetMarineResource(i)->m_iCommanderIndex.Get());
		}
	}
}
コード例 #18
0
void CASW_Campaign_Save::StartingCampaignVote()
{
	if (!ASWGameRules())
		return;
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	// clear votes and ready
	m_fVoteEndTime = 0;
	m_bNextMissionVoteEnded = false;
	for (int i=0;i<ASW_MAX_MISSIONS_PER_CAMPAIGN;i++)
	{
		m_NumVotes.Set(i, 0);
	}	
	for (int i=0;i<ASW_MAX_READY_PLAYERS;i++)
	{
		pGameResource->m_bPlayerReady.Set(i, false);
	}
}
コード例 #19
0
ファイル: asw_director.cpp プロジェクト: BenLubar/riflemod
// randomly generated levels provide data about each room in the level
// we check that here to react to special rooms
void CASW_Director::UpdateMarineRooms()
{
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource || !missionchooser || !missionchooser->RandomMissions())
		return;

	for ( int i=0;i<pGameResource->GetMaxMarineResources();i++ )
	{
		CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
		if ( !pMR || !pMR->GetMarineEntity() || pMR->GetMarineEntity()->GetHealth() <= 0 )
			continue;

		IASW_Room_Details* pRoom = missionchooser->RandomMissions()->GetRoomDetails( pMR->GetMarineEntity()->GetAbsOrigin() );
		if ( !pRoom )
			continue;

		if ( !m_bFinale && pRoom->HasTag( "Escape" ) )
		{
			UpdateMarineInsideEscapeRoom( pMR->GetMarineEntity() );
		}
	}
}
コード例 #20
0
void asw_medal_info_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());	

	if (!ASWGameRules())
		return;
	if (!pPlayer || !pPlayer->GetMarine())
		return;
	CASW_Game_Resource* pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	if ( args.ArgC() < 2 )
	{
		Msg("Usage: asw_medal_info [marine info num from 0-3]");
		return;
	}

	int i = atoi(args[1]);
	if (pGameResource->GetMarineResource(i))
		pGameResource->GetMarineResource(i)->DebugMedalStats();
}
コード例 #21
0
void asw_corpse_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());	

	if (!ASWGameRules())
		return;
	if (!pPlayer || !pPlayer->GetMarine())
		return;
	CASW_Game_Resource* pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

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

	QAngle facing = pMarine->GetAbsAngles();
	Vector forward;
	AngleVectors(facing, &forward);
	Vector pos = pMarine->GetAbsOrigin() + forward * 100.0f;
	//CBaseEntity *pGib = 
	CreateRagGib( "models/swarm/colonist/male/malecolonist.mdl", pos, facing, Vector(0,0,0) );
}
コード例 #22
0
ファイル: asw_arena.cpp プロジェクト: BenLubar/SwarmDirector2
void CASW_Arena::TeleportPlayersToSpawn()
{
	if ( !ASWGameRules() )
		return;

	CBaseEntity *pSpot = NULL;
	CASW_Game_Resource *pGameResource = ASWGameResource();
	for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
	{
		if (pGameResource->GetMarineResource(i) != NULL && pGameResource->GetMarineResource(i)->GetMarineEntity())
		{
			CASW_Marine *pMarine = pGameResource->GetMarineResource(i)->GetMarineEntity();
			if ( pMarine->GetHealth() > 0 )
			{
				pSpot = ASWGameRules()->GetMarineSpawnPoint( pSpot );
				if ( pSpot )
				{
					pMarine->Teleport( &pSpot->GetAbsOrigin(), &pSpot->GetAbsAngles(), &vec3_origin );
				}
			}
		}
	}
}
コード例 #23
0
void asw_conv_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());	

	if (!ASWGameRules())
		return;
	if (!pPlayer || !pPlayer->GetMarine())
		return;
	CASW_Game_Resource* pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

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

	if ( args.ArgC() < 2 )
	{
		Msg("Usage: asw_conv [conv num]	");
		return;
	}

	CASW_MarineSpeech::StartConversation(atoi(args[1]), pMarine);		
}
コード例 #24
0
/// @TODO can use a more optimal sorting strategy
void C_ASW_Game_Resource::CMarineToCrosshairInfo::RecomputeCache()
{
	VPROF("C_ASW_Game_Resource::CMarineToCrosshairInfo::RecomputeCache()");
	C_ASW_Game_Resource * RESTRICT  pGameResource = ASWGameResource();
	// purge the array.
	m_tMarines.RemoveAll();

	const Vector vecCrosshairAimingPos = ASWInput()->GetCrosshairAimingPos();

	for ( int i=0; i<pGameResource->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
		C_ASW_Marine *pMarine;
		if ( pMR && (pMarine = pMR->GetMarineEntity()) )
		{
			float dist = (vecCrosshairAimingPos - pMR->GetMarineEntity()->GetAbsOrigin()).Length2D();
			m_tMarines.AddToTail( tuple_t(pMarine, dist) );
		}
	}

	m_tMarines.Sort( &MarineTupleComparator );

	m_iLastFrameCached = gpGlobals->framecount;
}
コード例 #25
0
void CASW_Voting_Missions::ScanThink()
{
	if (m_iListType == 0)		// if the player isn't looking at any particular list at the moment, don't bother updating our strings
	{
		SetThink( NULL );
		return;
	}

	if (!missionchooser || !missionchooser->LocalMissionSource())
		return;

	IASW_Mission_Chooser_Source* pMissionSource = missionchooser->LocalMissionSource();

	// let the source think, in case it needs to be scanning folders
	pMissionSource->Think();

	// player is looking at the list of missions
	if (m_iListType == 1)
	{
		if ( m_nCampaignIndex == -1 )
		{
			// make sure the source is setup to be looking at our page of missions (need to do this every time in case someone else is using the source too)
			pMissionSource->FindMissions(m_nOffset, m_iNumSlots, true);
			// copy them from the local source into our networked array
			ASW_Mission_Chooser_Mission* missions = pMissionSource->GetMissions();
			bool bChanged = false;
			for (int i=0;i<m_iNumSlots;i++)
			{
				if (i<ASW_SAVES_PER_PAGE && Q_strcmp(missions[i].m_szMissionName, STRING(m_iszMissionNames[i])))
				{
					bChanged = true;
					m_iszMissionNames.Set(i, AllocPooledString(missions[i].m_szMissionName));
					m_iszMissionNames.GetForModify(i);
				}
			}
			m_iNumMissions = pMissionSource->GetNumMissions(false);
			m_iNumOverviewMissions = pMissionSource->GetNumMissions(true);
		}
		else
		{
			// make sure the source is setup to be looking at our page of missions (need to do this every time in case someone else is using the source too)
			pMissionSource->FindMissionsInCampaign(m_nCampaignIndex, m_nOffset, m_iNumSlots);
			// copy them from the local source into our networked array
			ASW_Mission_Chooser_Mission* missions = pMissionSource->GetMissions();
			bool bChanged = false;
			for (int i=0;i<m_iNumSlots;i++)
			{
				if (i<ASW_SAVES_PER_PAGE && Q_strcmp(missions[i].m_szMissionName, STRING(m_iszMissionNames[i])))
				{
					bChanged = true;
					m_iszMissionNames.Set(i, AllocPooledString(missions[i].m_szMissionName));
					m_iszMissionNames.GetForModify(i);
				}
			}
			m_iNumMissions = pMissionSource->GetNumMissionsInCampaign( m_nCampaignIndex );
			m_iNumOverviewMissions = m_iNumMissions;
		}
	}
	else if (m_iListType == 2)	// player is looking at a list of campaigns
	{
		// make sure the source is setup to be looking at our page of campaign (need to do this every time in case someone else is using the source too)
		pMissionSource->FindCampaigns(m_nOffset, m_iNumSlots);
		// copy them from the local source into our networked array
		ASW_Mission_Chooser_Mission* campaigns = pMissionSource->GetCampaigns();
		for (int i=0;i<m_iNumSlots;i++)
		{
			if (i<ASW_CAMPAIGNS_PER_PAGE && Q_strcmp(campaigns[i].m_szMissionName, STRING(m_iszCampaignNames[i])))
			{
				m_iszCampaignNames.Set(i, AllocPooledString(campaigns[i].m_szMissionName));
			}
		}
		m_iNumCampaigns = pMissionSource->GetNumCampaigns();
	}
	else if (m_iListType == 3)	// player is looking at a list of saved campaign games
	{
		// make sure the source is setup to be looking at our page of saves (need to do this every time in case someone else is using the source too)
		bool bMulti = !( ASWGameResource() && ASWGameResource()->IsOfflineGame() );
		pMissionSource->FindSavedCampaigns(m_nOffset, m_iNumSlots, bMulti, (m_hPlayer.Get() && bMulti) ? m_hPlayer->GetASWNetworkID() : NULL);
		m_iNumSavedCampaigns = pMissionSource->GetNumSavedCampaigns(bMulti, (m_hPlayer.Get() && bMulti) ? m_hPlayer->GetASWNetworkID() : NULL);
		// copy them from the local source into our networked array
		ASW_Mission_Chooser_Saved_Campaign* saved = pMissionSource->GetSavedCampaigns();
		for (int i=0;i<m_iNumSlots;i++)
		{
			if (i<ASW_SAVES_PER_PAGE && Q_strcmp(saved[i].m_szSaveName, STRING(m_iszSaveNames[i])))
			{
				m_iszSaveNames.Set(i, AllocPooledString(saved[i].m_szSaveName));
				m_iszSaveCampaignNames.Set(i, AllocPooledString(saved[i].m_szCampaignName));
				m_iszSaveDateTimes.Set(i, AllocPooledString(saved[i].m_szDateTime));
				m_iszSavePlayerNames.Set(i, AllocPooledString(saved[i].m_szPlayerNames));
				m_iSaveMissionsComplete.Set(i, saved[i].m_iMissionsComplete);
			}
		}
	}
	
	SetThink( &CASW_Voting_Missions::ScanThink );
	SetNextThink(gpGlobals->curtime + 0.1f);
}
コード例 #26
0
void CNB_Select_Marine_Panel::OnCommand( const char *command )
{
	if ( !Q_stricmp( command, "BackButton" ) )
	{
		Briefing()->SetChangingWeaponSlot( 0 );
		MarkForDeletion();

		CLocalPlayerFilter filter;
		C_BaseEntity::EmitSound( filter, -1, "ASWComputer.MenuBack" );

		return;
	}
	else if ( !Q_stricmp( command, "AcceptButton" ) )
	{
		CNB_Select_Marine_Entry *pHighlighted = dynamic_cast<CNB_Select_Marine_Entry*>( GetHighlightedEntry() );
		if ( pHighlighted )
		{
			int nProfileIndex = pHighlighted->GetProfileIndex();
			if ( !Briefing()->IsProfileSelectedBySomeoneElse( nProfileIndex ) )
			{
				Briefing()->SelectMarine( 0, nProfileIndex, m_nPreferredLobbySlot );

				// is this the first marine we've selected?
				if ( Briefing()->IsOfflineGame() && ASWGameResource() && ASWGameResource()->GetNumMarines( NULL ) <= 0 )
				{
					//Briefing()->AutoSelectFullSquadForSingleplayer( nProfileIndex );
				}

				bool bHasPointsToSpend = Briefing()->IsCampaignGame() && !Briefing()->UsingFixedSkillPoints() && ( Briefing()->GetProfileSkillPoints( nProfileIndex, ASW_SKILL_SLOT_SPARE ) > 0 );

				if ( bHasPointsToSpend )
				{
					CNB_Main_Panel *pPanel = dynamic_cast<CNB_Main_Panel*>( GetParent() );
					if ( pPanel )
					{
						pPanel->SpendSkillPointsOnMarine( nProfileIndex );
					}
				}
				else
				{
					MarkForDeletion();
					Briefing()->SetChangingWeaponSlot( 0 );
				}

				CASW_Marine_Profile* pProfile = Briefing()->GetMarineProfileByProfileIndex( nProfileIndex );
				if ( pProfile )
				{
					engine->ClientCmd_Unrestricted(VarArgs("exec configloader/chars/%s\n", pProfile->m_PortraitName));
					switch (pProfile->GetMarineClass())
					{
					case MARINE_CLASS_NCO:
						engine->ClientCmd_Unrestricted("exec configloader/chars/Officer\n");
						break;
					case MARINE_CLASS_SPECIAL_WEAPONS:
						engine->ClientCmd_Unrestricted("exec configloader/chars/SpecialWeapons\n");
						break;
					case MARINE_CLASS_MEDIC:
						engine->ClientCmd_Unrestricted("exec configloader/chars/Medic\n");
						break;
					case MARINE_CLASS_TECH:
						engine->ClientCmd_Unrestricted("exec configloader/chars/Tech\n");
						break;
					default:
						Assert(0);
					}
				}
			}
			else
			{
				CLocalPlayerFilter filter;
				C_BaseEntity::EmitSound( filter, -1, "ASWComputer.TimeOut" );
			}
		}		
		return;
	}
	BaseClass::OnCommand( command );
}
コード例 #27
0
void CNB_Mission_Summary::OnThink()
{
	BaseClass::OnThink();

	if ( !ASWGameResource() )
		return;

	int nSkillLevel = ASWGameRules()->GetSkillLevel();
	const wchar_t *pDifficulty = NULL;
	switch( nSkillLevel )
	{
		case 1: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_easy" ); break;
		default:
		case 2: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_normal" ); break;
		case 3: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_hard" ); break;
		case 4: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_insane" ); break;
		case 5: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_imba" ); break;
	}
	if ( !pDifficulty )
	{
		pDifficulty = L"";
	}

	if ( CAlienSwarm::IsOnslaught() )
	{
		wchar_t wszText[ 128 ];
		_snwprintf( wszText, sizeof( wszText ), L"%s %s", pDifficulty, g_pVGuiLocalize->FindSafe( "#nb_onslaught_title" ) );
		m_pDifficultyLabel->SetText( wszText );
	}
	else
	{
		m_pDifficultyLabel->SetText( pDifficulty );
	}

	CASWHudMinimap *pMap = GET_HUDELEMENT( CASWHudMinimap );
	if ( pMap )
	{
		m_pMissionLabel->SetText(pMap->m_szMissionTitle);
	}

	// compose objectives list
	wchar_t wszObjectivesBuffer[ 1024 ];
	wchar_t wszBuffer[ 1024 ];

	wszObjectivesBuffer[ 0 ] = 0;

	int nObjectives = 0;
	for ( int i = 0 ; i < ASW_MAX_OBJECTIVES; i++ )
	{
		C_ASW_Objective* pObjective = ASWGameResource()->GetObjective(i);
		if ( pObjective && !pObjective->IsObjectiveHidden() && !pObjective->IsObjectiveDummy() )
		{
			if ( nObjectives == 0 )
			{
				_snwprintf( wszObjectivesBuffer, sizeof( wszObjectivesBuffer ), L"- %s", pObjective->GetObjectiveTitle() );
			}
			else
			{
				_snwprintf( wszBuffer, sizeof( wszBuffer ), L"%s\n- %s", wszObjectivesBuffer, pObjective->GetObjectiveTitle() );
				_snwprintf( wszObjectivesBuffer , sizeof( wszObjectivesBuffer ), L"%s", wszBuffer );
			}
			nObjectives++;
		}
	}
	m_pObjectivesLabel->SetText( wszObjectivesBuffer );

	int nLabelWidth = YRES( 168 );
	m_pObjectivesLabel->SetSize( nLabelWidth, 400 );
	m_pObjectivesLabel->GetTextImage()->SetDrawWidth( nLabelWidth );
	m_pObjectivesLabel->InvalidateLayout( true );
	int texwide, texttall;	
	m_pObjectivesLabel->GetTextImage()->ResizeImageToContentMaxWidth( nLabelWidth );
	m_pObjectivesLabel->SetWrap( true );
	m_pObjectivesLabel->GetTextImage()->GetContentSize( texwide, texttall );	
	//m_pObjectivesLabel->SetSize( texwide, texttall );
	m_pObjectivesLabel->InvalidateLayout( true );
	m_pObjectivesLabel->GetTextImage()->GetContentSize( texwide, texttall );
	m_pObjectivesLabel->InvalidateLayout( true );
}
コード例 #28
0
ファイル: stats_report.cpp プロジェクト: plaYer2k/client
void StatsReport::SetPlayerNames( void )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	int nMarine = 0;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();

	for ( int i = 0; i < pGameResource->GetMaxMarineResources() && nMarine < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		CASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i );
		if ( pMR )
		{
			C_ASW_Player *pCommander = pMR->GetCommander();

			Color color = getColorPerIndex(pMR->GetCommanderIndex());

			if ( pPlayer != pCommander )
			{
				color[ 3 ] = 128;
			}

			m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetLineColor( color );
			m_pPlayerNames[ nMarine ]->SetFgColor( color );

			wchar_t wszMarineName[ 32 ];
			pMR->GetDisplayName( wszMarineName, sizeof( wszMarineName ) );

			m_pPlayerNames[ nMarine ]->SetText( wszMarineName );

			if ( gpGlobals->maxClients == 1 )
			{
				// Don't need these in singleplayer
				m_pAvatarImages[ nMarine ]->SetVisible( false );
				m_pReadyCheckImages[ nMarine ]->SetVisible( false );
			}
			else
			{
#if !defined(NO_STEAM)
				CSteamID steamID;

				if ( pCommander )
				{
					player_info_t pi;
					if ( engine->GetPlayerInfo( pCommander->entindex(), &pi ) )
					{
						if ( pi.friendsID )
						{
							CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual );
							steamID = steamIDForPlayer;
						}
					}
				}

				if ( steamID.IsValid() )
				{
					m_pAvatarImages[ nMarine ]->SetAvatarBySteamID( &steamID );

					int wide, tall;
					m_pAvatarImages[ nMarine ]->GetSize( wide, tall );

					CAvatarImage *pImage = static_cast< CAvatarImage* >( m_pAvatarImages[ nMarine ]->GetImage() );
					if ( pImage )
					{
						pImage->SetAvatarSize( wide, tall );
						pImage->SetPos( -AVATAR_INDENT_X, -AVATAR_INDENT_Y );
					}
				}
#endif
			}

			nMarine++;
		}
	}

	while ( nMarine < ASW_STATS_REPORT_MAX_PLAYERS )
	{
		m_pAvatarImages[ nMarine ]->SetVisible( false );
		m_pReadyCheckImages[ nMarine ]->SetVisible( false );
		nMarine++;
	}
}
コード例 #29
0
ファイル: stats_report.cpp プロジェクト: plaYer2k/client
// fills in all the bars and labels with the current players and their XP values
void StatsReport::SetStatCategory( int nCategory )
{
	for ( int i = 0; i < ASW_STATS_REPORT_CATEGORIES; ++i )
	{
		m_pCategoryButtons[ i ]->SetDefaultColor( Color( 100, 100, 100, 255 ), Color( 35, 41, 57, 90 ) );
	}

	m_pCategoryButtons[ nCategory ]->SetDefaultColor( Color( 255, 255, 255, 255 ), Color( 35, 41, 57, 192 ) );

	int nRankOrder[ ASW_STATS_REPORT_MAX_PLAYERS ];
	float fBestValues[ ASW_STATS_REPORT_MAX_PLAYERS ];

	for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; ++i )
	{
		nRankOrder[ i ] = i;
	}

	//float fMinValue = FLT_MAX;
	float fMaxValue = -FLT_MAX;

	int nMarine = 0;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();

	for ( int i = 0; i < pGameResource->GetMaxMarineResources() && nMarine < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		CASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i );
		if ( pMR )
		{
			switch ( nCategory )
			{
			case 0:
				m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetTimeline( &pMR->m_TimelineFriendlyFire );
				fMaxValue = MAX( fMaxValue, 50.0f );
				break;

			case 1:
				m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetTimeline( &pMR->m_TimelineKillsTotal );
				break;

			case 2:
				m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetTimeline( &pMR->m_TimelineHealth );
				break;

			case 3:
				m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetTimeline( &pMR->m_TimelineAmmo );
				break;
			}

			fBestValues[ nMarine ] = m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->GetFinalValue();

			//fMinValue = MIN( fMinValue, m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->GetTroughValue() );
			fMaxValue = MAX( fMaxValue, m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->GetCrestValue() );

			nMarine++;
		}
	}
	
	// Sort the names based on who did the best in this category
	for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS - 1; ++i )
	{
		for ( int j = 0; j < ASW_STATS_REPORT_MAX_PLAYERS - 1 - i; ++j )
		{
			if ( fBestValues[ j ] < fBestValues[ j + 1 ] )
			{
				float fTemp = fBestValues[ j ];
				fBestValues[ j ] = fBestValues[ j + 1 ];
				fBestValues[ j + 1 ] = fTemp;

				int nTemp = nRankOrder[ j ];
				nRankOrder[ j ] = nRankOrder[ j + 1 ];
				nRankOrder[ j + 1 ] = nTemp;
			}
		}
	}

	// Physically position all the marine names in their ranked order
	for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; ++i )
	{
		m_pStatGraphPlayer->m_pStatGraphs[ i ]->SetMinMaxValues( 0.0f, fMaxValue );
		vgui::GetAnimationController()->RunAnimationCommand( m_pPlayerNames[ nRankOrder[ i ] ], "ypos", m_fPlayerNamePosY[ i ], 0, 0.25f, vgui::AnimationController::INTERPOLATOR_LINEAR );
		vgui::GetAnimationController()->RunAnimationCommand( m_pAvatarImages[ nRankOrder[ i ] ], "ypos", m_fPlayerNamePosY[ i ], 0, 0.25f, vgui::AnimationController::INTERPOLATOR_LINEAR );
		vgui::GetAnimationController()->RunAnimationCommand( m_pReadyCheckImages[ nRankOrder[ i ] ], "ypos", m_fPlayerNamePosY[ i ], 0, 0.25f, vgui::AnimationController::INTERPOLATOR_LINEAR );
	}

	m_pStatGraphPlayer->InvalidateLayout( true );
}
コード例 #30
0
bool CASW_Mission_Manager::CheckMissionComplete()
{
	bool bFailed = false;
	bool bSuccess = true;
	bool bAtLeastOneObjective = false;

	// notify all objectives about this event
	if ( !ASWGameResource() )
		return false;

	int iIncomplete = 0;
	int iNumObjectives = 0;
	bool bEscapeIncomplete = false;
	for (int i=0;i<ASW_MAX_OBJECTIVES;i++)
	{
		CASW_Objective* pObjective = ASWGameResource()->GetObjective(i);
		if (pObjective)
		{
			bAtLeastOneObjective = true;
			iNumObjectives++;
			if (!pObjective->IsObjectiveComplete() && !pObjective->IsObjectiveOptional())
			{
				bSuccess = false;
				iIncomplete++;
				if (iIncomplete == 1 && !m_bDoneLeavingChatter)
				{
					CASW_Objective_Escape *pEscape = dynamic_cast<CASW_Objective_Escape*>(pObjective);
					if (pEscape)
						bEscapeIncomplete = true;
				}
			}
			if (pObjective->IsObjectiveFailed())
			{
				bFailed = true;					
			}
		}
	}

	m_bAllMarinesDead = AllMarinesDead();

	if ( m_bAllMarinesDead && ( gpGlobals->curtime > m_flLastMarineDeathTime + asw_last_marine_dead_delay.GetFloat() || GameTimescale()->GetCurrentTimescale() < 1.0f ) )
	{
		bFailed = true;
	}
	
	m_bAllMarinesKnockedOut = AllMarinesKnockedOut();
	if (m_bAllMarinesKnockedOut)
		bFailed = true;

	if (bSuccess && bAtLeastOneObjective)
	{
		MissionSuccess();
		return true;
	}
	else if (bFailed)
	{
		MissionFail();
		return true;
	}
	else
	{
		if (bEscapeIncomplete && iIncomplete)
		{
			// make a marine do the 'time to leave' speech
			if ( ASWGameResource() )
			{
				CASW_Game_Resource *pGameResource = ASWGameResource();
				// count how many live marines we have
				int iNearby = 0;						
				for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
				{
					CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
					CASW_Marine *pMarine = pMR ? pMR->GetMarineEntity() : NULL;
					if (pMarine && pMarine->GetHealth() > 0)
								iNearby++;
				}
				int iChatter = random->RandomInt(0, iNearby-1);
				for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
				{
					CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
					CASW_Marine *pMarine = pMR ? pMR->GetMarineEntity() : NULL;
					if (pMarine && pMarine->GetHealth() > 0)
					{
						if (iChatter <= 0)
						{
							pMarine->GetMarineSpeech()->QueueChatter(CHATTER_TIME_TO_LEAVE, gpGlobals->curtime + 3.0f, gpGlobals->curtime + 6.0f);
							break;
						}
						iChatter--;
					}
				}						
			}
			m_bDoneLeavingChatter = true;
		}
	}
	return false;
}