Beispiel #1
0
//------------------------------------------------------------------------------
// Purpose : Update beam more often then regular NPC think so it doesn't
//			 move so jumpily over the ground
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CNPC_Stalker::StalkerThink(void)
{
	DrawAttackBeam();
	if (gpGlobals->curtime >= m_flNextNPCThink)
	{
		NPCThink();
		m_flNextNPCThink = GetNextThink();
	}

	if ( m_pBeam )
	{
		SetNextThink( gpGlobals->curtime + g_StalkerBeamThinkTime );
		
		// sanity check?!
		const Task_t *pTask = GetTask();
		if ( !pTask || pTask->iTask != TASK_RANGE_ATTACK1 || !TaskIsRunning() )
		{
			KillAttackBeam();
		}
	}
	else
	{
		DevMsg( 2, "In StalkerThink() but no stalker beam found?\n" );
		SetNextThink( m_flNextNPCThink );
	}
}
Beispiel #2
0
void CASW_Use_Area::ActivateMultiTrigger( CBaseEntity *pActivator )
{
	if ( GetNextThink() > gpGlobals->curtime )
		return;         // still waiting for reset time

	if ( !RequirementsMet( pActivator ) )
	{
		if ( m_flWait > 0 )
		{
			SetThink( &CTriggerMultiple::MultiWaitOver );
			SetNextThink( gpGlobals->curtime + m_flWait );
		}

		return;
	}

	m_hActivator = pActivator;

	m_OnTrigger.FireOutput( m_hActivator, this );

	if ( m_flWait > 0 )
	{
		SetThink( &CTriggerMultiple::MultiWaitOver );
		SetNextThink( gpGlobals->curtime + m_flWait );
	}
}
//-----------------------------------------------------------------------------
// Purpose: Attach the player to the "Buff Station."
//-----------------------------------------------------------------------------
void CObjectBuffStation::AttachPlayer( CBaseTFPlayer *pPlayer )
{
	// Player shouldn't already be attached.
	Assert( !IsPlayerAttached( pPlayer ) );

	// Check to see if the player is alive and on the correct team.
	if ( !pPlayer->IsAlive() || !pPlayer->InSameTeam( this ) )
		return;

	// Check attachment availability.
	if ( m_nPlayerCount == BUFF_STATION_MAX_PLAYERS )
	{
		// Unless the player is the owner he cannot connect.
		if ( pPlayer != GetOwner() )
			return;

		// Kick a non-owning player off.
		DetachPlayerByIndex( BUFF_STATION_MAX_PLAYERS - 1 );
	}

	// This will disconnect the player from other Buff Stations, and keep track of important player events.
	g_pNotify->ReportNamedEvent( pPlayer, "PlayerAttachedToGenerator" );
	g_pNotify->AddEntity( this, pPlayer );

	// Connect player.
	// Find the nearest empty slot
	int iNearest = BUFF_STATION_MAX_PLAYERS;
	float flNearestDist = 9999*9999;
	for ( int iPlayer = 0; iPlayer < BUFF_STATION_MAX_PLAYERS; iPlayer++ )
	{
		if ( !m_hPlayers[iPlayer] )
		{
			Vector vecPoint;
			QAngle angPoint;
			GetAttachment( m_aPlayerAttachInfo[iPlayer].m_iAttachPoint, vecPoint, angPoint );
			float flDistance = ( vecPoint - pPlayer->GetAbsOrigin() ).LengthSqr();
			if ( flDistance < flNearestDist )
			{
				flNearestDist = flDistance;
				iNearest = iPlayer;
			}
		}
	}
	Assert( iNearest != BUFF_STATION_MAX_PLAYERS );

	m_hPlayers.Set( iNearest, pPlayer );
	m_aPlayerAttachInfo[iNearest].m_DamageModifier.SetModifier( obj_buff_station_damage_modifier.GetFloat() );
	m_aPlayerAttachInfo[iNearest].m_hRope = CreateRope( pPlayer, m_aPlayerAttachInfo[iNearest].m_iAttachPoint );
	m_nPlayerCount++;

	// Tell the player to constrain his movement.
	pPlayer->ActivateMovementConstraint( this, GetAbsOrigin(), obj_buff_station_range.GetFloat(), 75.0f, 0.15f );

	// Update think.
	if ( GetNextThink(BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT) > gpGlobals->curtime + BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL )
		SetNextThink( gpGlobals->curtime + BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL, BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT );

	// Update network state.
	NetworkStateChanged();
}
void CASW_Radiation_Volume::RadTouch( CBaseEntity *pOther )
{
	// if other is a valid entity to radiate, add it to our list
	if (IsValidRadTarget(pOther) && m_hRadTouching.Find(pOther) == m_hRadTouching.InvalidIndex())
	{
		m_hRadTouching.AddToTail(pOther);
		if (GetNextThink() == TICK_NEVER_THINK)
			SetNextThink( gpGlobals->curtime );
	}
}
//-----------------------------------------------------------------------------
// Purpose: Add time to the act's time
//-----------------------------------------------------------------------------
void CInfoAct::InputAddTime( inputdata_t &inputdata )
{
	float flNewTime = inputdata.value.Float();

	// Think again when the act ends, if we have a timelimit
	if ( flNewTime )
	{
		m_flActTimeLimit += flNewTime;
		SetNextThink( GetNextThink() + flNewTime );
	}
}
Beispiel #6
0
//-----------------------------------------------------------------------------
// Purpose: Input handler for toggling the on/off state of the sparks.
//-----------------------------------------------------------------------------
void CEnvSpark::InputToggleSpark( inputdata_t &inputdata )
{
	if (GetNextThink() == TICK_NEVER_THINK)
	{
		InputStartSpark( inputdata );
	}
	else
	{
		InputStopSpark( inputdata );
	}
}
//-----------------------------------------------------------------------------
// Compute next think time while active
//-----------------------------------------------------------------------------
void CShieldGrenade::ComputeActiveThinkTime( void )
{
	// Next think should be when we detonate, unless we un-EMP before then
	SetNextThink( gpGlobals->curtime + m_flDetonateTime );
	if (m_IsEMPed)
	{
		Assert( m_flEMPDamageEndTime != 0.0f );
		if ( m_flEMPDamageEndTime < GetNextThink() )
			SetNextThink( gpGlobals->curtime + m_flEMPDamageEndTime );
	}
}
//-----------------------------------------------------------------------------
// Purpose:  Override to get rid of EF_NODRAW
//-----------------------------------------------------------------------------
CBaseEntity* CTFBaseDMPowerup::Respawn( void )
{
	CBaseEntity *pRet = BaseClass::Respawn();

	RemoveEffects( EF_NODRAW );
	RemoveEffects( EF_ITEM_BLINK );
	SetRenderColorA( 80 );

	m_flRespawnAtTime = GetNextThink();

	return pRet;
}
void CMOD_Dynamic_Difficulty_Modifier_Trigger::ActivatePositionTrigger(CBaseEntity *pActivator)
{
	//if (m_bDisabled)
	//	return;

	if (GetNextThink() > gpGlobals->curtime)
		return;         // still waiting for reset time

	//Enforce Trigger Fire limits
	if (m_iMaxTriggerRecalculatePerformanceAndFire >= 0 &&
		m_iTriggerFireCount >= m_iMaxTriggerRecalculatePerformanceAndFire)
		return;

	m_iTriggerFireCount++;

	m_hActivator = pActivator;

	m_iDifficultyLevelOfMarines = GetDifficultyLevelOfMarines();
		
	if (PerformDifficultyCheck())		
		m_OnTrigger.FireOutput(m_hActivator, this);	

	switch (m_iDifficultyLevelOfMarines)
	{
		case 1: 
			m_TriggerEasy.FireOutput(m_hActivator, this);	
			m_TriggerAtleastEasy.FireOutput(m_hActivator, this);		
			break;
		case 2:
			m_TriggerMedium.FireOutput(m_hActivator, this);	
			m_TriggerAtleastEasy.FireOutput(m_hActivator, this);		
			m_TriggerAtleastMedium.FireOutput(m_hActivator, this);		
			break;
		case 3:
			m_TriggerHard.FireOutput(m_hActivator, this);
			m_TriggerAtleastEasy.FireOutput(m_hActivator, this);		
			m_TriggerAtleastMedium.FireOutput(m_hActivator, this);		
			m_TriggerAtleastHard.FireOutput(m_hActivator, this);		
			break;
	}		
	
			
	SetThink( &CMOD_Dynamic_Difficulty_Modifier_Trigger::MultiWaitOver );
	if (m_flWait > 0)
	{
		SetNextThink( gpGlobals->curtime + 0.1f );	
	}
	else
	{
		SetNextThink( gpGlobals->curtime + m_flWait );	
	}
}
//-----------------------------------------------------------------------------
// Purpose:  Override to get rid of EF_NODRAW
//-----------------------------------------------------------------------------
CBaseEntity* CWeaponSpawner::Respawn( void )
{
	CBaseEntity *pRet = BaseClass::Respawn();

	RemoveEffects( EF_NODRAW );
	RemoveEffects( EF_ITEM_BLINK );
	m_nRenderFX = kRenderFxDistort;
	//m_nRenderMode = kRenderTransColor;
	//SetRenderColor( 246, 232, 99, 128 );

	m_flRespawnAtTime = GetNextThink();

	return pRet;
}
Beispiel #11
0
//
// If an announcement is pending, cancel it.  If no announcement is pending, start one.
//
void CSpeaker::InputToggle( inputdata_t &inputdata )
{
	int fActive = (GetNextThink() > 0.0 );

	// fActive is true only if an announcement is pending
	if ( fActive )
	{
		// turn off announcements
		SetNextThink( TICK_NEVER_THINK );
	}
	else 
	{
		// turn on announcements
		SetNextThink( gpGlobals->curtime + 0.1f );
	} 
}
//-----------------------------------------------------------------------------
// Purpose: Attach the object to the "Buff Station."
//-----------------------------------------------------------------------------
void CObjectBuffStation::AttachObject( CBaseObject *pObject, bool bPlacing )
{
	// Check to see if the object is already attached.
	if ( IsObjectAttached( pObject ) )
		return;

	// Check to see if the object is on the correct team.
	if ( !pObject->InSameTeam( this ) )
		return;

	// Check to see if the object is already being buffed by another station.
	if ( pObject->IsHookedAndBuffed() )
		return;

	// Check attachment availability.
	if ( m_nObjectCount == BUFF_STATION_MAX_OBJECTS )
		return;

	// Attach cable to object - get the attachment point.
	int nObjectAttachPoint = pObject->LookupAttachment( "boostpoint" );
	if ( nObjectAttachPoint <= 0 )
		nObjectAttachPoint = 1;

	// Connect object.
	m_hObjects.Set( m_nObjectCount, pObject );
	m_aObjectAttachInfo[m_nObjectCount].m_DamageModifier.SetModifier( obj_buff_station_damage_modifier.GetFloat() );
	m_aObjectAttachInfo[m_nObjectCount].m_hRope = CreateRope( pObject, m_aObjectAttachInfo[m_nObjectCount].m_iAttachPoint, nObjectAttachPoint );
	m_nObjectCount += 1;

	// If we're placing, we're pretending to buff objects, but not really powering them
	pObject->SetBuffStation( this, bPlacing );

	// Update think.
	if ( GetNextThink(BUFF_STATION_BOOST_OBJECT_THINK_CONTEXT) > gpGlobals->curtime + BUFF_STATION_BOOST_OBJECT_THINK_INTERVAL )
		SetNextThink( gpGlobals->curtime + BUFF_STATION_BOOST_OBJECT_THINK_INTERVAL, BUFF_STATION_BOOST_OBJECT_THINK_CONTEXT );

	// Update network state.
	NetworkStateChanged();
}
Beispiel #13
0
void CNPC_Stalker::StartAttackBeam( void )
{
	if ( m_fBeamEndTime > gpGlobals->curtime || m_fBeamRechargeTime > gpGlobals->curtime )
	{
		// UNDONE: Debug this and fix!?!?!
		m_fBeamRechargeTime = gpGlobals->curtime;
	}
	// ---------------------------------------------
	//  If I don't have a beam yet, create one
	// ---------------------------------------------
	// UNDONE: Why would I ever have a beam already?!?!?!
	if (!m_pBeam)
	{
		Vector vecSrc = LaserStartPosition(GetAbsOrigin());
		trace_t tr;
		AI_TraceLine ( vecSrc, vecSrc + m_vLaserDir * MAX_STALKER_FIRE_RANGE, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr);
		if ( tr.fraction >= 1.0 )
		{
			// too far
			TaskComplete();
			return;
		}

		m_pBeam = CBeam::BeamCreate( "sprites/laser.vmt", 2.0 );
		m_pBeam->PointEntInit( tr.endpos, this );
		m_pBeam->SetEndAttachment( STALKER_LASER_ATTACHMENT );  
		m_pBeam->SetBrightness( 255 );
		m_pBeam->SetNoise( 0 );

		switch (m_eBeamPower)
		{
			case STALKER_BEAM_LOW:
				m_pBeam->SetColor( 255, 0, 0 );
				m_pLightGlow = CSprite::SpriteCreate( "sprites/redglow1.vmt", GetAbsOrigin(), FALSE );
				break;
			case STALKER_BEAM_MED:
				m_pBeam->SetColor( 255, 50, 0 );
				m_pLightGlow = CSprite::SpriteCreate( "sprites/orangeglow1.vmt", GetAbsOrigin(), FALSE );
				break;
			case STALKER_BEAM_HIGH:
				m_pBeam->SetColor( 255, 150, 0 );
				m_pLightGlow = CSprite::SpriteCreate( "sprites/yellowglow1.vmt", GetAbsOrigin(), FALSE );
				break;
		}

		// ----------------------------
		// Light myself in a red glow
		// ----------------------------
		m_pLightGlow->SetTransparency( kRenderGlow, 255, 200, 200, 0, kRenderFxNoDissipation );
		m_pLightGlow->SetAttachment( this, 1 );
		m_pLightGlow->SetBrightness( 255 );
		m_pLightGlow->SetScale( 0.65 );

#if 0
		CBaseEntity *pEnemy = GetEnemy();
		// --------------------------------------------------------
		// Play start up sound - client should always hear this!
		// --------------------------------------------------------
		if (pEnemy != NULL && (pEnemy->IsPlayer()) ) 
		{
			EmitAmbientSound( 0, pEnemy->GetAbsOrigin(), "NPC_Stalker.AmbientLaserStart" );
		}
		else
		{
			EmitAmbientSound( 0, GetAbsOrigin(), "NPC_Stalker.AmbientLaserStart" );
		}
#endif
	}

	SetThink( &CNPC_Stalker::StalkerThink );

	m_flNextNPCThink = GetNextThink();
	SetNextThink( gpGlobals->curtime + g_StalkerBeamThinkTime );
	m_fBeamEndTime = gpGlobals->curtime + STALKER_LASER_DURATION;
}
Beispiel #14
0
bool CRagdollProp::IsFading()
{
	return ( GetNextThink( s_pFadeOutContext ) >= gpGlobals->curtime );
}