void asw_gimme_ammo_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();
			for (int k=0;k<ASW_MAX_MARINE_WEAPONS;k++)
			{
				CASW_Weapon *pWeapon = pMarine->GetASWWeapon(k);
				if (!pWeapon)
					continue;

				// refill bullets in the gun
				pWeapon->m_iClip1 = pWeapon->GetMaxClip1();
				pWeapon->m_iClip2 = pWeapon->GetMaxClip2();

				// give the marine a load of ammo of that type
				pMarine->GiveAmmo(10000, pWeapon->GetPrimaryAmmoType());
				pMarine->GiveAmmo(10000, pWeapon->GetSecondaryAmmoType());
			}
		}
	}
}
Example #2
0
void CASW_Director::OnMarineStartedHack( CASW_Marine *pMarine, CBaseEntity *pComputer )
{
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	//Msg( " Marine started hack!\n" );

	// reset intensity so we can have a big fight without relaxing immediately
	for ( int i=0;i<pGameResource->GetMaxMarineResources();i++ )
	{
		CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
		if ( !pMR )
			continue;

		pMR->GetIntensity()->Reset();
	}

	float flQuickStart = RandomFloat( 2.0f, 5.0f );
	if ( m_HordeTimer.GetRemainingTime() > flQuickStart )
	{
		m_HordeTimer.Start( flQuickStart );
	}

	// TODO: Instead have some kind of 'is in a big fight' state?
}
void asw_marine_spectate_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( args.ArgC() < 2 )
	{
		Msg( "Usage: asw_marine_spectate [marine_num]\n" );
		return;
	}

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

	int iMarine = atof(args[1]);
	if (iMarine < 0 || iMarine >= pGameResource->GetMaxMarineResources())
		return;

	CASW_Marine_Resource* pMR = pGameResource->GetMarineResource(iMarine);
	if (!pMR)
	{
		Msg("No marine resource in that index\n");
		return;
	}

	CASW_Marine *pMarine = pMR->GetMarineEntity();
	if (!pMarine)
	{
		Msg("No live marine in that slot\n");
		return;
	}
		
	pPlayer->SetSpectatingMarine(pMarine);
}
void asw_check_campaign_f(void)
{
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;
	
	Msg("IsInCampaignMap = %d\n", pGameResource->IsCampaignGame());
}
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));
	}
}
Example #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;
}
Example #7
0
// 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 );
}
Example #8
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();
		}
	}
}
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 );
		}
	}
}
Example #10
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();
		}
	}
}
Example #11
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;
		}
	}
}
Example #12
0
// 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() );
		}
	}
}
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();
}
Example #14
0
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 );
				}
			}
		}
	}
}
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());
		}
	}
}
Example #16
0
void CASW_Spawn_Manager::UpdateCandidateNodes()
{
    // don't update too frequently
    if ( m_CandidateUpdateTimer.HasStarted() && !m_CandidateUpdateTimer.IsElapsed() )
        return;

    m_CandidateUpdateTimer.Start( asw_candidate_interval.GetFloat() );

    if ( !GetNetwork() || !GetNetwork()->NumNodes() )
    {
        m_vecHordePosition = vec3_origin;
        if ( asw_director_debug.GetBool() )
            Msg("Error: Can't spawn hordes as this map has no node network\n");
        return;
    }

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

    Vector vecSouthMarine = vec3_origin;
    Vector vecNorthMarine = vec3_origin;
    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;

        if ( vecSouthMarine == vec3_origin || vecSouthMarine.y > pMarine->GetAbsOrigin().y )
        {
            vecSouthMarine = pMarine->GetAbsOrigin();
        }
        if ( vecNorthMarine == vec3_origin || vecNorthMarine.y < pMarine->GetAbsOrigin().y )
        {
            vecNorthMarine = pMarine->GetAbsOrigin();
        }
    }
    if ( vecSouthMarine == vec3_origin || vecNorthMarine == vec3_origin )		// no live marines
        return;

    int iNumNodes = GetNetwork()->NumNodes();
    m_northCandidateNodes.Purge();
    m_southCandidateNodes.Purge();
    for ( int i=0 ; i<iNumNodes; i++ )
    {
        CAI_Node *pNode = GetNetwork()->GetNode( i );
        if ( !pNode || pNode->GetType() != NODE_GROUND )
            continue;

        Vector vecPos = pNode->GetPosition( CANDIDATE_ALIEN_HULL );

        // find the nearest marine to this node
        float flDistance = 0;
        CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>(UTIL_ASW_NearestMarine( vecPos, flDistance ));
        if ( !pMarine )
            return;

        if ( flDistance > asw_horde_max_distance.GetFloat() || flDistance < asw_horde_min_distance.GetFloat() )
            continue;

        // check node isn't in an exit trigger
        bool bInsideEscapeArea = false;
        for ( int d=0; d<m_EscapeTriggers.Count(); d++ )
        {
            if ( m_EscapeTriggers[d]->CollisionProp()->IsPointInBounds( vecPos ) )
            {
                bInsideEscapeArea = true;
                break;
            }
        }
        if ( bInsideEscapeArea )
            continue;

        if ( vecPos.y >= vecSouthMarine.y )
        {
            if ( asw_director_debug.GetInt() == 3 )
            {
                NDebugOverlay::Box( vecPos, -Vector( 5, 5, 5 ), Vector( 5, 5, 5 ), 32, 32, 128, 10, 60.0f );
            }
            m_northCandidateNodes.AddToTail( i );
        }
        if ( vecPos.y <= vecNorthMarine.y )
        {
            m_southCandidateNodes.AddToTail( i );
            if ( asw_director_debug.GetInt() == 3 )
            {
                NDebugOverlay::Box( vecPos, -Vector( 5, 5, 5 ), Vector( 5, 5, 5 ), 128, 32, 32, 10, 60.0f );
            }
        }
    }
}
Example #17
0
void CASW_Campaign_Save::PlayerVote(CASW_Player* pPlayer, int iMission)
{
	if (!ASWGameRules() || !pPlayer || pPlayer->m_bRequestedSpectator)
		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);
		}
	}
	if (iMission < 0 || iMission >= ASW_MAX_MISSIONS_PER_CAMPAIGN)
		return;

	// don't allow vote for this mission if this mission was already completed, or if it's the dropzone
	if (m_MissionComplete[iMission] != 0 || iMission <= 0)
		return;

	// make sure the mission they want to vote for is reachable
	if (!IsMissionLinkedToACompleteMission(iMission, ASWGameRules()->GetCampaignInfo()))
		return;	

	// add his vote to the chosen map
	pGameResource->m_iCampaignVote[iPlayer] = iMission;
	int iVotes = m_NumVotes[iMission] + 1;
	m_NumVotes.Set(iMission, iVotes);
	// flag him as ready
	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();
		}
	}
}
Example #18
0
bool CASW_Base_Spawner::CanSpawn( const Vector &vecHullMins, const Vector &vecHullMaxs )
{
	if ( !m_bEnabled )
		return false;

	// is a marine too near?
	if ( !m_bSpawnIfMarinesAreNear && m_flNearDistance > 0 )
	{		
		CASW_Game_Resource* pGameResource = ASWGameResource();
		float distance = 0.0f;
		for ( int i = 0; i < ASW_MAX_MARINE_RESOURCES; i++ )
		{
			CASW_Marine_Resource* pMR = pGameResource->GetMarineResource(i);
			if ( pMR && pMR->GetMarineEntity() && pMR->GetMarineEntity()->GetHealth() > 0 )
			{
				distance = pMR->GetMarineEntity()->GetAbsOrigin().DistTo( GetAbsOrigin() );
				if ( distance < m_flNearDistance )
				{
					if ( asw_debug_spawners.GetBool() )
						Msg("asw_spawner(%s): Alien can't spawn because a marine (%d) is %f away\n", GetEntityName(), i, distance);
					return false;
				}
			}
		}
	}

	Vector mins = GetAbsOrigin() - Vector( 23, 23, 0 );
	Vector maxs = GetAbsOrigin() + Vector( 23, 23, 0 );
	CBaseEntity *pList[128];
	int count = UTIL_EntitiesInBox( pList, 128, mins, maxs, FL_CLIENT|FL_NPC );
	if ( count )
	{
		//Iterate through the list and check the results
		for ( int i = 0; i < count; i++ )
		{
			//Don't build on top of another entity
			if ( pList[i] == NULL )
				continue;

			//If one of the entities is solid, then we may not be able to spawn now
			if ( ( pList[i]->GetSolidFlags() & FSOLID_NOT_SOLID ) == false )
			{
				// Since the outer method doesn't work well around striders on account of their huge bounding box.
				// Find the ground under me and see if a human hull would fit there.
				trace_t tr;
				UTIL_TraceHull( GetAbsOrigin() + Vector( 0, 0, 1 ),
								GetAbsOrigin() - Vector( 0, 0, 1 ),
								vecHullMins,
								vecHullMaxs,
								MASK_NPCSOLID,
								NULL,
								COLLISION_GROUP_NONE,
								&tr );

				if (tr.fraction < 1.0f && tr.DidHitNonWorldEntity())
				{
					// some non-world entity is blocking the spawn point, so don't spawn
					if (tr.m_pEnt)
					{
						if ( m_iMoveAsideCount < 6 )	// don't send 'move aside' commands more than 5 times in a row, else you'll stop blocked NPCs going to sleep.
						{
							IASW_Spawnable_NPC *pSpawnable = dynamic_cast<IASW_Spawnable_NPC*>(tr.m_pEnt);
							if (pSpawnable)
							{
								pSpawnable->MoveAside();		// try and make him move aside
								m_iMoveAsideCount++;
							}
						}
						if (asw_debug_spawners.GetBool())
							Msg("asw_spawner(%s): Alien can't spawn because a non-world entity is blocking the spawn point: %s\n", GetEntityName(), tr.m_pEnt->GetClassname());
					}
					else
					{
						if (asw_debug_spawners.GetBool())
							Msg("asw_spawner(%s): Alien can't spawn because a non-world entity is blocking the spawn point.\n", GetEntityName());
					}
						
					return false;
				}
			}
		}
	}

	// is there something blocking the spawn point?
	if ( m_bCheckSpawnIsClear )
	{
		if ( asw_debug_spawners.GetBool() )
		{
			Msg("Checking spawn is clear...\n");
		}

		trace_t tr;
		UTIL_TraceHull( GetAbsOrigin(),
					GetAbsOrigin() + Vector( 0, 0, 1 ),
					vecHullMins,
					vecHullMaxs,
					MASK_NPCSOLID,
					this,
					COLLISION_GROUP_NONE,
					&tr );

		if( tr.fraction != 1.0 )
		{
			if ( asw_debug_spawners.GetBool() )
				Msg("asw_spawner(%s): Alien can't spawn because he wouldn't fit in the spawn point.\n", GetEntityName());
			// TODO: If we were trying to spawn an uber, change to spawning a regular instead
			return false;
		}
	}

	m_iMoveAsideCount = 0;
	return true;
}
Example #19
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;
}
void asw_marine_skill_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());	

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

	CASW_Marine_Profile *pProfile = NULL;
	CASW_Marine *pMarine = pPlayer->GetMarine();
	if (pMarine)
	{
		pProfile = pMarine->GetMarineProfile();
	}
	else
	{
		// find the first marine info that belongs to us
		for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
		{
			CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
			if (pMR && pMR->GetCommander() == pPlayer)
			{
				pProfile = pMR->GetProfile();
				break;
			}
		}
	}
	
	if ( !pProfile )
		return;

	if ( args.ArgC() < 2 )
	{
		Msg("Usage: asw_marine_skill [SkillSlot]  - reports the number of skill points of the current marine in that skill\n  asw_marine_skill [SkillSlot] [x]  - sets that skill to the specified number of skill points (0-5)\n");
		Msg("SkillSlot goes from 0 to 4 for your skills, slot 5 is spare skill points.\n");
		return;
	}

	int nSkillSlot = atoi(args[1]);
	if ( nSkillSlot < 0 || nSkillSlot >= ASW_NUM_SKILL_SLOTS )
	{
		Msg("nSkillSlot out of bounds\n");
		return;
	}

	if ( args.ArgC() < 3 )
	{
		int iSkillPoints = ASWGameResource()->GetMarineSkill( pProfile->m_ProfileIndex, nSkillSlot );
		Msg( "Marine skill[%d] is %s = %d\n", nSkillSlot, SkillToString( pProfile->GetSkillMapping( nSkillSlot ) ), iSkillPoints );
	}
	else
	{
		int iNewPoints = atoi(args[2]);
		ASWGameResource()->SetMarineSkill( pProfile->m_ProfileIndex, nSkillSlot, iNewPoints );	
		int iSkillPoints = ASWGameResource()->GetMarineSkill( pProfile->m_ProfileIndex, nSkillSlot );
		Msg( "Marine skill[%d] is now %s = %d\n", nSkillSlot, SkillToString( pProfile->GetSkillMapping( nSkillSlot ) ), iSkillPoints );
	}
}