//------------------------------------------------------------------------------
// Purpose: 
// Input  : 
// Output : 
//------------------------------------------------------------------------------
void CAI_ASW_FlickBehavior::Flick( )
{
#if 0
	for( int i = 0; i < ASWDirector()->GetNPCListCount(); i++ )
	{
		CASW_Alien	*pAlien = ASWDirector()->GetNPCFromList( i );

		if ( !pAlien || !pAlien->IsAlive() )
		{
			continue;
		}

		if ( GetOuter() != pAlien )
		{
			TryFlicking( pAlien );
		}
	}

	for ( int i = 0; i < ASW_MAX_READY_PLAYERS; i++ )
	{
		// found a connected player?
		CASW_Player *pOtherPlayer = dynamic_cast< CASW_Player * >( UTIL_PlayerByIndex( i + 1 ) );
		// if they're not connected, skip them
		if ( !pOtherPlayer || !pOtherPlayer->IsConnected() )
		{
			continue;
		}

		TryFlicking( pOtherPlayer );
	}
#else
	AIEnemiesIter_t iter;
	for( AI_EnemyInfo_t *pEMemory = GetEnemies()->GetFirst( &iter ); pEMemory != NULL; pEMemory = GetEnemies()->GetNext( &iter ) )
	{
		CBaseEntity	*pEntity = pEMemory->hEnemy;

		if ( pEntity->IsAlive() && GetOuter() != pEntity )
		{
			TryFlicking( pEntity );
		}
	}
#endif
	// turn this into an area of affect
	// reverse his velocity - if he is coming towards the shield bug, add that back into his outgoing to increase it
}
Exemplo n.º 2
0
// unselects a single marine
// tries to pick the player with the most marines selected
void CASW_Game_Resource::RemoveAMarine()
{
	int iHighest = 0;
	CASW_Player *pChosen = NULL;

	for ( int i = 1; i <= gpGlobals->maxClients; i++ )	
	{
		CASW_Player* pOtherPlayer = dynamic_cast<CASW_Player*>(UTIL_PlayerByIndex(i));

		if ( pOtherPlayer && pOtherPlayer->IsConnected() )
		{
			int iMarines = GetNumMarines(pOtherPlayer);
			if (iHighest == 0 || iMarines > iHighest)
			{
				iHighest = iMarines;
				pChosen = pOtherPlayer;
			}
		}		
	}
	RemoveAMarineFor(pChosen);
}
Exemplo n.º 3
0
void CASW_Button_Area::SetHackProgress(float f, CASW_Marine *pMarine)
{
	CBaseEntity *pActor = pMarine;
	if ( !pActor )
	{
		pActor = this;
	}

	if (m_fHackProgress <= 0 && f > 0 && m_fStartedHackTime == 0)
	{
		m_fStartedHackTime = gpGlobals->curtime;
	}
	if (m_fHackProgress < 0.25f && f >= 0.25f)
	{
		m_OnButtonHackAt25Percent.FireOutput(pActor, this);
	}
	if (m_fHackProgress < 0.5f && f >= 0.5f)
	{
		m_OnButtonHackAt50Percent.FireOutput(pActor, this);
		pMarine->GetMarineSpeech()->Chatter(CHATTER_HACK_HALFWAY);
	}
	if (m_fHackProgress < 0.75f && f >= 0.75f)
	{
		m_OnButtonHackAt75Percent.FireOutput(pActor, this);
	}
	if (m_fHackProgress < 1.0f && f >= 1.0f)
	{	
		if ( asw_simple_hacking.GetBool() )
		{
			pMarine->StopUsing();
		}

		float time_taken = gpGlobals->curtime - m_fStartedHackTime;
		// decide if this was a fast hack or not
		float fSpeedScale = 1.0f;
		if (pMarine)
			fSpeedScale *= MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_HACKING, ASW_MARINE_SUBSKILL_HACKING_SPEED_SCALE);
		float ideal_time = UTIL_ASW_CalcFastDoorHackTime(m_iWireRows, m_iWireColumns, m_iNumWires, m_iHackLevel, fSpeedScale);

		bool bFastHack = time_taken <= ideal_time;
		if (asw_debug_medals.GetBool())
		{
			Msg("Finished door hack, fast = %d.\n", bFastHack);
			Msg(" ideal time is %f you took %f\n", ideal_time, time_taken);
		}
		if (bFastHack && pMarine && pMarine->GetMarineResource())
		{
			pMarine->GetMarineResource()->m_iFastDoorHacks++;
			if ( pMarine->IsInhabited() && pMarine->GetCommander() )
			{
				pMarine->GetCommander()->AwardAchievement( ACHIEVEMENT_ASW_FAST_WIRE_HACKS );
			}
		}

		if ( GetCurrentHack() )
		{
			GetCurrentHack()->OnHackComplete();
		}

		if ( pMarine->GetMarineResource() && pMarine->GetMarineResource()->m_iDamageTakenDuringHack <= 0 )
		{
			int nAliensKilled = ASWGameResource() ? ASWGameResource()->GetAliensKilledInThisMission() : 0;
			if ( ( nAliensKilled - m_iAliensKilledBeforeHack ) > 10 )
			{
				for ( int i = 1; i <= gpGlobals->maxClients; i++ )	
				{
					CASW_Player *pPlayer = dynamic_cast<CASW_Player*>( UTIL_PlayerByIndex( i ) );
					if ( !pPlayer || !pPlayer->IsConnected() || !pPlayer->GetMarine() || pPlayer->GetMarine() == pMarine )
						continue;

					if ( pPlayer->GetMarine()->GetMarineResource() )
					{
						pPlayer->GetMarine()->GetMarineResource()->m_bProtectedTech = true;
					}
					pPlayer->AwardAchievement( ACHIEVEMENT_ASW_PROTECT_TECH );
				}
			}
		}

		// unlock it
		m_OnButtonHackCompleted.FireOutput(pActor, this);
		m_bIsLocked = false;
		UpdateWaitingForInput();
		UpdatePanelSkin();

		EmitSound("ASWComputer.HackComplete");

		if ( pMarine && bFastHack )
		{
			pMarine->GetMarineSpeech()->QueueChatter(CHATTER_HACK_BUTTON_FINISHED, gpGlobals->curtime + 2.0f, gpGlobals->curtime + 3.0f);
		}

		// if set to use on unlock, then do so
		if ( m_bUseAfterHack && pMarine )
		{
			ActivateUnlockedButton(pMarine);
		}

		if ( pMarine && !pMarine->IsInhabited() )
		{
			pMarine->StopUsing();
		}
	}

	m_fHackProgress = clamp( f, 0.0f, 1.0f );
}