コード例 #1
0
bool CASW_Mission_Manager::AllMarinesKnockedOut()
{
	if (!ASWGameRules() || !ASWGameResource())
		return false;

	// can't be all dead if we haven't left briefing yet!
	if (ASWGameRules()->GetGameState() < ASW_GS_INGAME)
		return false;

	int iMax = ASWGameResource()->GetMaxMarineResources();
	for (int i=0;i<iMax;i++)
	{
		CASW_Marine_Resource *pMarineResource = ASWGameResource()->GetMarineResource(i);
		if (pMarineResource)
		{
			CASW_Marine *m = pMarineResource->GetMarineEntity();
			if (m)
			{
				if (!m->m_bKnockedOut)
				{
					return false;
				}
			}
		}
	}
	return true;
}
コード例 #2
0
// uses the marine list to quickly find all marines within a box
int CASW_Game_Resource::EnumerateMarinesInBox(Vector &mins, Vector &maxs)
{
	m_iNumEnumeratedMarines = 0;
	for (int i=0;i<GetMaxMarineResources();i++)
	{
		CASW_Marine_Resource *pMR = GetMarineResource(i);
		if (!pMR)
			continue;

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

#ifdef CLIENT_DLL
		if (asw_debug_clientside_avoidance.GetBool())
		{
			Vector mid = (pMarine->WorldAlignMins() + pMarine->WorldAlignMaxs()) / 2.0f;
			Vector omin = pMarine->WorldAlignMins() - mid;
			Vector omax = pMarine->WorldAlignMaxs() - mid;
			debugoverlay->AddBoxOverlay( mid, omin, omax, vec3_angle, 0, 0, 255, true, 0 );
		}
#endif

		Vector omins = pMarine->WorldAlignMins() + pMarine->GetAbsOrigin();
		Vector omaxs = pMarine->WorldAlignMaxs() + pMarine->GetAbsOrigin();
		if (IsBoxIntersectingBox(mins, maxs, omins, omaxs))
		{
			m_pEnumeratedMarines[m_iNumEnumeratedMarines] = pMR->GetMarineEntity();
			m_iNumEnumeratedMarines++;
			if (m_iNumEnumeratedMarines >=12)
				break;
		}
	}
	return m_iNumEnumeratedMarines;
}
コード例 #3
0
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);
}
コード例 #4
0
ファイル: asw_director.cpp プロジェクト: BenLubar/riflemod
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?
}
コード例 #5
0
void CJaS_Marine_Jack::Spawn()
{
	CASW_Marine_Resource *pResource = dynamic_cast<CASW_Marine_Resource *>( CreateEntityByName( "asw_marine_resource" ) );
	pResource->SetProfileIndex( 6 );
	pResource->SetMarineEntity( this );
	SetMarineResource( pResource );
	pResource->Spawn();
	m_pProfileOverride = pResource->GetProfile();
	SelectModelFromProfile();
	SetModelFromProfile();

	CBaseCombatWeapon *pWeapon = dynamic_cast<CBaseCombatWeapon *>( CreateEntityByName( "asw_weapon_sniper_rifle" ) );
	if ( pWeapon )
	{
		pWeapon->Spawn();
		pWeapon->GiveDefaultAmmo();
		pWeapon->m_iClip1 = 9999;
		GiveAmmo(9999, pWeapon->GetPrimaryAmmoType());
		Weapon_Equip_In_Index( pWeapon, 0 );
		Weapon_Switch( pWeapon );
	}
	m_bConstantSlowHeal = true;

	m_hSquadFormation = static_cast<CASW_SquadFormation *>( CreateEntityByName( "asw_squadformation" ) );
	m_hSquadFormation->Leader( this );

	SetRenderColor( 0x99, 0x40, 0x40 );

	BaseClass::Spawn();
}
コード例 #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
CASW_Marine_Resource* CASW_Game_Resource::GetFirstMarineResourceForPlayer( CASW_Player *pPlayer )
{
	for ( int i=0; i < GetMaxMarineResources(); i++ )
	{
		CASW_Marine_Resource *pMR = GetMarineResource(i);
		if (!pMR)
			continue;

		if ( pMR->GetCommander() == pPlayer )
			return pMR;
	}
	return NULL;
}
コード例 #8
0
ファイル: stats_report.cpp プロジェクト: plaYer2k/client
void StatsReport::OnThink()
{
	int nMarine = 0;

	m_pObjectiveMap->ClearBlips();

	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 )
		{
			Vector vPos;
			vPos.x = pMR->m_TimelinePosX.GetValueAtInterp( m_pStatGraphPlayer->m_fTimeInterp );
			vPos.y = pMR->m_TimelinePosY.GetValueAtInterp( m_pStatGraphPlayer->m_fTimeInterp );
			vPos.z = 0.0f;

			bool bDead = ( pMR->m_TimelineHealth.GetValueAtInterp( m_pStatGraphPlayer->m_fTimeInterp ) <= 0.0f );
			
			m_pObjectiveMap->AddBlip( MapBlip_t( vPos, bDead ? Color( 255, 255, 255, 255 ) : getColorPerIndex(pMR->GetCommanderIndex()), bDead ? MAP_BLIP_TEXTURE_DEATH : MAP_BLIP_TEXTURE_NORMAL ) );

			if ( m_pReadyCheckImages[ nMarine ]->IsVisible() )
			{
				C_ASW_Player *pPlayer = pMR->GetCommander();
				if ( pPlayer )
				{
					if ( !pMR->IsInhabited() || ASWGameResource()->IsPlayerReady( pPlayer ) )
					{
						m_pReadyCheckImages[ i ]->SetImage( "swarm/HUD/TickBoxTicked" );
					}
					else if ( pPlayer == ASWGameResource()->GetLeader() )
					{
						m_pReadyCheckImages[ i ]->SetImage( "swarm/PlayerList/LeaderIcon" );
					}
					else
					{
						m_pReadyCheckImages[ i ]->SetImage( "swarm/HUD/TickBoxEmpty" );
					}
				}
			}

			nMarine++;
		}
	}

	for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		
	}
}
コード例 #9
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 );
}
コード例 #10
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;
		}
	}
}
コード例 #11
0
bool CASW_Game_Resource::AddMarineResource( CASW_Marine_Resource *m, int nPreferredSlot )
{
	if ( nPreferredSlot != -1 )
	{
		CASW_Marine_Resource *pExisting = static_cast<CASW_Marine_Resource*>( m_MarineResources[ nPreferredSlot ].Get() );
		if ( pExisting != NULL )
		{
			// if the existing is owned by someone else, then we abort
			if ( pExisting->GetCommander() != m->GetCommander() )
				return false;

			SetRosterSelected( pExisting->GetProfileIndex(), 0 );
			UTIL_Remove( pExisting );
		}

		m_MarineResources.Set( nPreferredSlot, m );

		// the above causes strange cases where the client copy of this networked array is incorrect
		// so we flag each element dirty to cause a complete update, which seems to fix the problem
		for (int k=0;k<ASW_MAX_MARINE_RESOURCES;k++)
		{
			m_MarineResources.GetForModify(k);
		}
		return true;
	}

	for (int i=0;i<ASW_MAX_MARINE_RESOURCES;i++)
	{
		if (m_MarineResources[i] == NULL)	// found a free slot
		{
			m_MarineResources.Set(i, m);

			// the above causes strange cases where the client copy of this networked array is incorrect
			// so we flag each element dirty to cause a complete update, which seems to fix the problem
			for (int k=0;k<ASW_MAX_MARINE_RESOURCES;k++)
			{
				m_MarineResources.GetForModify(k);
			}
			return true;
		}
	}
	Msg("Couldn't add new marine resource to list as no free slots\n");
	return false;
}
コード例 #12
0
bool CASW_Mission_Manager::AllMarinesDead()
{
	if (!ASWGameRules() || !ASWGameResource())
		return false;

	// can't be all dead if we haven't left briefing yet!
	if (ASWGameRules()->GetGameState() < ASW_GS_INGAME)
		return false;

	int iMax = ASWGameResource()->GetMaxMarineResources();
	for (int i=0;i<iMax;i++)
	{
		CASW_Marine_Resource *pMarineResource = ASWGameResource()->GetMarineResource(i);
		if (pMarineResource && pMarineResource->GetHealthPercent() > 0)
		{
			return false;	// we have a live marine, so they're not all dead
		}
	}
	return true;  // arg all dead!
}
コード例 #13
0
void CMOD_Player_Performance::WriteToHUD(const char* messagename, int rating)
{
#if 0
	for ( int i=0;i<ASWGameResource()->GetMaxMarineResources();i++ )
	{
		CASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i);
		if ( !pMR )
			continue;
				
		CASW_Player *pPlayer = pMR->GetCommander();
	
		if ( pPlayer && pPlayer->GetMarine() )
		{		
			CSingleUserRecipientFilter user( pPlayer );
			UserMessageBegin( user, messagename );
			WRITE_SHORT( rating );
			MessageEnd();			
		}	
	}
#endif
}
コード例 #14
0
int CASW_Game_Resource::CountAllAliveMarines( void )
{
	int m = GetMaxMarineResources();
	int iMarines = 0;
	for ( int i = 0; i < m; i++ )
	{
		CASW_Marine_Resource *pMR = GetMarineResource( i );
		if ( !pMR )
			continue;

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

		if ( pMR->GetHealthPercent() > 0 )
		{
			iMarines++;
		}
	}
	return iMarines;
}
コード例 #15
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() );
		}
	}
}
コード例 #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 );
            }
        }
    }
}
コード例 #17
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++;
	}
}
コード例 #18
0
void CC_asw_teleport( const CCommand &args )
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( !pPlayer )
		return;

	Vector vTargetPos = pPlayer->GetAbsOrigin();

	// fires a command from the console
	if ( args.ArgC() < 2 )
	{
		trace_t tr;

		Vector vPlayerForward;
		pPlayer->EyeVectors( &vPlayerForward, NULL, NULL );

		UTIL_TraceLine( pPlayer->GetAbsOrigin(), pPlayer->GetAbsOrigin() + vPlayerForward * 10000.0f, MASK_SOLID, pPlayer, COLLISION_GROUP_NONE, &tr );
		
		if ( tr.DidHit() )
		{
			vTargetPos = tr.endpos;
		}
	}
	else
	{
		// find the named entity
		CBaseEntity *target = gEntList.FindEntityByName( NULL, args[1] );
		if ( !target )
		{
			int i = atoi( args[1] );
			if ( i != 0 )
			{
				target = CBaseEntity::Instance( i );
				if ( !target )
				{
					Msg( "Couldn't find entity!\n" );
					return;
				}
			}
			else
			{
				Msg( "Couldn't find entity!\n" );
				return;
			}
		}

		vTargetPos = target->GetAbsOrigin();
	}

	CASW_Marine *pMarine = pPlayer->GetMarine();

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

			if ( pMR->GetMarineEntity() && pMR->GetMarineEntity()->GetCommander() == pPlayer )
			{
				pMarine = pMR->GetMarineEntity();
				break;
			}
		}
	}

	if ( pMarine )
	{
		// Teleport the dude under our control
		Vector vecPos = vTargetPos;//pNearest->GetOrigin();
		pMarine->Teleport( &vecPos, NULL, NULL );
	}
}
コード例 #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;
}
コード例 #20
0
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 );
	}
}
コード例 #21
0
void CASW_Grenade_PRifle::Detonate()
{
	if ( !ASWGameResource() )
		return;

	m_takedamage	= DAMAGE_NO;	

	CPASFilter filter( GetAbsOrigin() );
						
	Vector vecForward = GetAbsVelocity();
	VectorNormalize(vecForward);
	trace_t		tr;

	Vector vecDir = -vecForward;
	//te->GaussExplosion( filter, 0.0,
				//GetAbsOrigin(), vecDir, 0 );
	CEffectData data;
	data.m_vOrigin = GetAbsOrigin();
	DispatchEffect( "aswstunexplo", data );

	EmitSound("ASW_Weapon_PRifle.StunGrenadeExplosion");

	UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() + 60*vecForward, MASK_SHOT, 
		this, COLLISION_GROUP_NONE, &tr);

	if ((tr.m_pEnt != GetWorldEntity()) || (tr.hitbox != 0))
	{
		// non-world needs smaller decals
		if( tr.m_pEnt && !tr.m_pEnt->IsNPC() )
		{
			UTIL_DecalTrace( &tr, "SmallScorch" );
		}
	}
	else
	{
		UTIL_DecalTrace( &tr, "Scorch" );
	}

	UTIL_ASW_ScreenShake( GetAbsOrigin(), 25.0, 150.0, 1.0, 750, SHAKE_START );

	int nPreviousStunnedAliens = ASWGameResource()->m_iElectroStunnedAliens;

	// do just 1 damage...
	CTakeDamageInfo info( this, GetOwnerEntity(), 1, DMG_SHOCK );
	info.SetWeapon( m_hCreatorWeapon );
	RadiusDamage ( info , GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL );

	// count as a shot fired
	CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>(GetOwnerEntity());
	if ( pMarine && pMarine->GetMarineResource() )
	{
		CASW_Marine_Resource *pMR = pMarine->GetMarineResource();
		pMR->UsedWeapon(NULL, 1);

		int nAliensStunned = ASWGameResource()->m_iElectroStunnedAliens - nPreviousStunnedAliens;
		if ( nAliensStunned >= 6 && pMR->IsInhabited() && pMR->GetCommander() )
		{
			 pMR->GetCommander()->AwardAchievement( ACHIEVEMENT_ASW_STUN_GRENADE );
			 pMR->m_bStunGrenadeMedal = true;
		}
	}

	UTIL_Remove( this );
}
コード例 #22
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;
}