void COsprey::FlyThink( void )
{
	StudioFrameAdvance( );
	SetNextThink( 0.1 );

	if ( m_pGoalEnt == NULL && !FStringNull(pev->target) )// this monster has a target
	{
		m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( pev->target ) );
		UpdateGoal( );
	}

	if (gpGlobals->time > m_startTime + m_dTime)
	{
		if (m_pGoalEnt->pev->speed == 0)
		{
			SetThink(&COsprey:: DeployThink );
		}
		int loopbreaker = 100; //LRC - <slap> don't loop indefinitely!
		do {
			m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( m_pGoalEnt->pev->target ) );
			loopbreaker--; //LRC
		} while (m_pGoalEnt->pev->speed < 400 && !HasDead() && loopbreaker > 0);
		UpdateGoal( );
	}

	Flight( );
	ShowDamage( );
}
Exemplo n.º 2
0
void CNihilanth::StartupThink( void )
{
	m_irritation = 0;
	m_flAdj = 512;

	CBaseEntity *pEntity;

	pEntity = UTIL_FindEntityByTargetname( NULL, "n_min");
	if (pEntity)
		m_flMinZ = pEntity->pev->origin.z;
	else
		m_flMinZ = -4096;

	pEntity = UTIL_FindEntityByTargetname( NULL, "n_max");
	if (pEntity)
		m_flMaxZ = pEntity->pev->origin.z;
	else
		m_flMaxZ = 4096;

	m_hRecharger = this;
	for (int i = 0; i < N_SPHERES; i++)
	{
		EmitSphere( );
	}
	m_hRecharger = NULL;

	SetThink( &CNihilanth::HuntThink);
	SetUse( &CNihilanth::CommandUse );
	pev->nextthink = gpGlobals->time + 0.1;
}
Exemplo n.º 3
0
bool AvHToggleUseable(CBaseEntity* inUser, const vec3_t& inOrigin, const vec3_t& inNormRay)
{
	bool	theSuccess = false;
	vec3_t	theTraceStart;
	vec3_t	theTraceEnd;
	
	// Offset a little so we don't hit the commander
	VectorMA(inOrigin, 100, inNormRay, theTraceStart);
	
	VectorMA(inOrigin, kSelectionEndRange, inNormRay, theTraceEnd);
	int theFoundIndex = -1;
	vec3_t theFoundLocation;
	AvHTeamNumber theTeamOfThingHit;
	bool thePlayerHit = false;
	int theUserThree = 0;
	int theUserFour = 0;
	
	if(AvHSHUTraceTangible(theTraceStart, theTraceEnd, theFoundIndex, theFoundLocation, theTeamOfThingHit, thePlayerHit, theUserThree, theUserFour))
	{
		if(!thePlayerHit && (theUserThree == AVH_USER3_USEABLE))
		{
			// Find entity we clicked on, use it
			//CBaseEntity* theEntity = CBaseEntity::Instance(ENT(theFoundIndex));
			CBaseEntity* theEntity = CBaseEntity::Instance(g_engfuncs.pfnPEntityOfEntIndex(theFoundIndex));
			if(theEntity)
			{
				// For each entity with this target name (including this one), use it
				if(theEntity->pev->targetname)
				{
					CBaseEntity* theTarget = NULL;
					while((theTarget = UTIL_FindEntityByTargetname(theTarget, STRING(theEntity->pev->targetname))) != NULL)
					{
						int	theObjectCaps = theTarget->ObjectCaps();
						if((theObjectCaps & FCAP_IMPULSE_USE) || (FCAP_ONOFF_USE))
						{
							theTarget->Use(inUser, inUser, USE_TOGGLE, 0);
						}
					}
				}
				else if(FClassnameIs(theEntity->edict(), "func_button") && theEntity->pev->target) ////voogru: Its probably a button!, classname check to prevent any possible exploits
				{
					CBaseEntity* theTarget = NULL;
					while((theTarget = UTIL_FindEntityByTargetname(theTarget, STRING(theEntity->pev->target))) != NULL)
					{
						int	theObjectCaps = theTarget->ObjectCaps();
						if((theObjectCaps & FCAP_IMPULSE_USE) || (FCAP_ONOFF_USE))
						{
							theTarget->Use(inUser, inUser, USE_TOGGLE, 0);
						}
					}
				}
				theSuccess = true;
			}
		}
	}
	return theSuccess;	
}
Exemplo n.º 4
0
CBaseMonster *CScriptedSentence::FindEntity( void )
{
	CBaseEntity* pTargetEnt = nullptr;

	CBaseMonster* pMonster = nullptr;

	while( (pTargetEnt = UTIL_FindEntityByTargetname( pTargetEnt, STRING( m_iszEntity ) )) )
	{
		if( (pMonster = pTargetEnt->MyMonsterPointer()) )
		{
			if( AcceptableSpeaker( pMonster ) )
				return pMonster;

			//ALERT( at_console, "%s (%s), not acceptable\n", pMonster->GetClassname(), pMonster->GetTargetname() );
		}
	}

	pTargetEnt = nullptr;

	while( (pTargetEnt = UTIL_FindEntityInSphere( pTargetEnt, GetAbsOrigin(), m_flRadius )) )
	{
		if( pTargetEnt->ClassnameIs( m_iszEntity ) )
		{
			if( pTargetEnt->GetFlags().Any( FL_MONSTER ) )
			{
				pMonster = pTargetEnt->MyMonsterPointer();

				if( AcceptableSpeaker( pMonster ) )
					return pMonster;
			}
		}
	}

	return nullptr;
}
Exemplo n.º 5
0
void CTriggerChangeAlias::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	CBaseEntity *pTarget = UTIL_FindEntityByTargetname( NULL, STRING( pev->target ), pActivator );

	if (pTarget && pTarget->IsAlias())
	{
		CBaseEntity *pValue;

		if (FStrEq(STRING(pev->netname), "*locus"))
		{
			pValue = pActivator;
		}
		else if (pev->spawnflags & SF_CHANGEALIAS_RESOLVE)
		{
			pValue = UTIL_FollowReference(NULL, STRING(pev->netname));
		}

		if (pValue)
			((CBaseAlias*)pTarget)->ChangeValue(pValue);
		else
			((CBaseAlias*)pTarget)->ChangeValue(pev->netname);
	}
	else
	{
		ALERT(at_error, "trigger_changealias %s: alias \"%s\" was not found or not an alias!", STRING(pev->targetname), STRING(pev->target));
	}
}
Exemplo n.º 6
0
void CFuncTrain::Activate( void )
{
	// Not yet active, so teleport to first target
	if( !m_activated )
	{
		m_activated = true;

		CBaseEntity* pTarg = UTIL_FindEntityByTargetname( nullptr, GetTarget() );

		//Use the world if no target was found. Replicates SDK behavior. - Solokiller
		if( !pTarg )
		{
			pTarg = CWorld::GetInstance();
		}

		pev->target = MAKE_STRING( pTarg->GetTarget() );
		//TODO change to EHANDLE - Solokiller
		m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us.

		SetAbsOrigin( pTarg->GetAbsOrigin() - ( pev->mins + pev->maxs ) * 0.5 );

		if( !HasTargetname() )
		{	// not triggered, so start immediately
			pev->nextthink = pev->ltime + 0.1;
			SetThink( &CFuncTrain::Next );
		}
		else
			pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER;
	}
}
Exemplo n.º 7
0
Vector CCalcSubVelocity::CalcVelocity( CBaseEntity *pLocus )
{
	pLocus = UTIL_FindEntityByTargetname( NULL, STRING(pev->netname), pLocus );

	Vector vecAngles;
	Vector vecJunk;

	switch (pev->impulse)
	{
	case 1: //angles
		return ConvertAngles( pLocus, pLocus->pev->angles );
	case 2: //v_angle
		return ConvertAngles( pLocus, pLocus->pev->v_angle );
	case 5:
		// this could cause problems.
		// is there a good way to check whether it's really a CBaseAnimating?
		((CBaseAnimating*)pLocus)->GetAttachment( 0, vecJunk, vecAngles );
		return ConvertAngles( pLocus, vecAngles );
	case 6:
		((CBaseAnimating*)pLocus)->GetAttachment( 1, vecJunk, vecAngles );
		return ConvertAngles( pLocus, vecAngles );
	case 7:
		((CBaseAnimating*)pLocus)->GetAttachment( 2, vecJunk, vecAngles );
		return ConvertAngles( pLocus, vecAngles );
	case 8:
		((CBaseAnimating*)pLocus)->GetAttachment( 3, vecJunk, vecAngles );
		return ConvertAngles( pLocus, vecAngles );
	default:
		return Convert( pLocus, pLocus->pev->velocity );
	}
}
Exemplo n.º 8
0
void CPys_Rope::Think( void )
{
	ALERT(at_console, "CPys_Rope Think!\n");

	CBaseEntity *pTarget = NULL;
	pTarget = UTIL_FindEntityByTargetname( pTarget, STRING(pev->target) );

	if ( pTarget != NULL )
	{
	//	if ( m_flNextChatTime > gpGlobals->time )
	//	{
			MESSAGE_BEGIN( MSG_ALL, gmsgAddRope,NULL);

			WRITE_BYTE(entindex());
			//WRITE_BYTE( pTarget->entindex() );

			WRITE_STRING(STRING(pev->message) );

			MESSAGE_END();
						
	//		m_flNextChatTime = gpGlobals->time + 20;
	//	}
	}

	SetNextThink( 5 );
}
Exemplo n.º 9
0
// lists all doors in the same movement group as this one
int CBaseDoor :: GetDoorMovementGroup( CBaseDoor *pDoorList[], int listMax )
{
	CBaseEntity *pTarget = NULL;
	int count = 0;

	// block all door pieces with the same targetname here.
	if( !FStringNull( pev->targetname ))
	{
		while(( pTarget = UTIL_FindEntityByTargetname( pTarget, STRING( pev->targetname ))) != NULL )
		{
			if( pTarget != this && FClassnameIs( pTarget, GetClassname() ))
			{
				CBaseDoor *pDoor = (CBaseDoor *)pTarget;

				if( pDoor && count < listMax )
				{
					pDoorList[count] = pDoor;
					count++;
				}
			}
		}
	}

	return count;
}
Exemplo n.º 10
0
Vector CCalcPosition::CalcPosition( CBaseEntity *pLocus )
{
	CBaseEntity *pSubject = UTIL_FindEntityByTargetname(NULL, STRING(pev->netname), pLocus);

	Vector vecOffset = CalcLocus_Velocity( this, pLocus, STRING(pev->message));

	Vector vecPosition;
	Vector vecJunk;

	Vector vecResult;
	switch (pev->impulse)
	{
	case 1: //eyes
		vecResult = vecOffset + pSubject->EyePosition();
		//ALERT(at_console, "calc_subpos returns %f %f %f\n", vecResult.x, vecResult.y, vecResult.z);
		return vecResult;
		//return vecOffset + pLocus->EyePosition();
	case 2: // top
		return vecOffset + pSubject->pev->origin + Vector(
			(pSubject->pev->mins.x + pSubject->pev->maxs.x)/2,
			(pSubject->pev->mins.y + pSubject->pev->maxs.y)/2,
			pSubject->pev->maxs.z
		);
	case 3: // centre
		return vecOffset + pSubject->pev->origin + Vector(
			(pSubject->pev->mins.x + pSubject->pev->maxs.x)/2,
			(pSubject->pev->mins.y + pSubject->pev->maxs.y)/2,
			(pSubject->pev->mins.z + pSubject->pev->maxs.z)/2
		);
	case 4: // bottom
		return vecOffset + pSubject->pev->origin + Vector(
			(pSubject->pev->mins.x + pSubject->pev->maxs.x)/2,
			(pSubject->pev->mins.y + pSubject->pev->maxs.y)/2,
			pSubject->pev->mins.z
		);
	case 5:
		// this could cause problems.
		// is there a good way to check whether it's really a CBaseAnimating?
		((CBaseAnimating*)pSubject)->GetAttachment( 0, vecPosition, vecJunk );
		return vecOffset + vecPosition;
	case 6:
		((CBaseAnimating*)pSubject)->GetAttachment( 1, vecPosition, vecJunk );
		return vecOffset + vecPosition;
	case 7:
		((CBaseAnimating*)pSubject)->GetAttachment( 2, vecPosition, vecJunk );
		return vecOffset + vecPosition;
	case 8:
		((CBaseAnimating*)pSubject)->GetAttachment( 3, vecPosition, vecJunk );
		return vecOffset + vecPosition;
	case 9:
		return vecOffset + pSubject->pev->origin + Vector(
			RANDOM_FLOAT(pSubject->pev->mins.x, pSubject->pev->maxs.x),
			RANDOM_FLOAT(pSubject->pev->mins.y, pSubject->pev->maxs.y),
			RANDOM_FLOAT(pSubject->pev->mins.z, pSubject->pev->maxs.z)
		);
	default:
		return vecOffset + pSubject->pev->origin;
	}
}
Exemplo n.º 11
0
const char *CGamePlayerTeam::TargetTeamName(const char *pszTargetName)
{
	CBaseEntity *pTeamEntity = NULL;

	while ((pTeamEntity = UTIL_FindEntityByTargetname(pTeamEntity, pszTargetName)) != NULL)
	{
		if (FClassnameIs(pTeamEntity->pev, "game_team_master"))
			return pTeamEntity->TeamID();
	}

	return NULL;
}
Exemplo n.º 12
0
CBaseEntity *CInfoAlias::FollowAlias( CBaseEntity *pFrom )
{
	CBaseEntity *pFound = UTIL_FindEntityByTargetname( pFrom, STRING(pev->message) );
	
	if (pev->spawnflags & SF_ALIAS_DEBUG){ // More excessive debug info
			ALERT(at_debug,"DEBUG: info_alias %s  refers to target %d \n",STRING(pev->targetname),m_iCurrentTarget);
			ALERT(at_debug,"DEBUG: info_alias %s  refers to target entity %s \n",STRING(pev->targetname),STRING(pev->message));
		
			if (pFound)
				ALERT(at_debug,"DEBUG: info_alias %s  refers to target entity %s \n",STRING(pev->targetname),STRING(pFound->pev->targetname));
	}
	return pFound;
}
Exemplo n.º 13
0
void CBaseButton::ButtonBackHome( void )
{
	ASSERT( m_iState == STATE_TURN_OFF );
	m_iState = STATE_OFF;

	if( FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ))
	{
		SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
	}

	if( !FStringNull( pev->target ))
	{
		CBaseEntity *pTarget = NULL;
		while( 1 )
		{
			pTarget = UTIL_FindEntityByTargetname( pTarget, STRING( pev->target ));

			if( FNullEnt( pTarget ))
				break;

			if( !FClassnameIs( pTarget->pev, "multisource" ))
				continue;

			pTarget->Use( m_hActivator, this, USE_TOGGLE, 0 );
		}
	}

	// Re-instate touch method, movement cycle is complete.

	// this button only works if USED, not touched!
	if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ))
	{
		// all buttons are now use only	
		SetTouch( NULL );
	}
	else
	{
		SetTouch( &CBaseButton::ButtonTouch );
	}

	// reset think for a sparking button
	if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ))
	{
		SetThink( &CBaseButton::ButtonSpark );
		SetNextThink( 0.5 );
	}
	else
	{
		DontThink();
	}
}
Exemplo n.º 14
0
CBaseEntity *CNihilanth::RandomTargetname( const char *szName )
{
	int total = 0;

	CBaseEntity *pEntity = NULL;
	CBaseEntity *pNewEntity = NULL;
	while ((pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName )) != NULL)
	{
		total++;
		if (RANDOM_LONG(0,total-1) < 1)
			pEntity = pNewEntity;
	}
	return pEntity;
}
Exemplo n.º 15
0
CBaseEntity *CBeam::RandomTargetname( const char *szName )
{
	int total = 0;

	CBaseEntity *pEntity = nullptr;
	CBaseEntity *pNewEntity = nullptr;
	while ((pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName )) != nullptr)
	{
		total++;
		if (RANDOM_LONG(0,total-1) < 1)
			pEntity = pNewEntity;
	}
	return pEntity;
}
Exemplo n.º 16
0
// this function needs to be called when the game is loaded, not just when the entity spawns.
// Don't make this a PostSpawn function.
void CAmbientGeneric :: Precache( void )
{
	char* szSoundFile = (char*) STRING(pev->message);

	if ( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 )
	{
		if (*szSoundFile != '!')
			PRECACHE_SOUND(szSoundFile);
	}
	// init all dynamic modulation parms
	InitModulationParms();

	if ( !FBitSet (pev->spawnflags, AMBIENT_SOUND_START_SILENT ) )
	{
		// start the sound ASAP
		if (m_fLooping)
			m_fActive = TRUE;
	}

	if( pev->target )
	{
		CBaseEntity *pTarget = UTIL_FindEntityByTargetname( NULL, STRING(pev->target));

		if( !pTarget )
		{
			ALERT( at_warning, "ambient_generic \"%s\" can't find \"%s\", its entity to play from.\n",
					STRING(pev->targetname), STRING(pev->target));
		}
		else m_pPlayFrom = ENT( pTarget->pev );
	}

	if ( m_fActive )
	{
		if (m_pPlayFrom)
		{
			SetThink(&CAmbientGeneric ::StartPlayFrom); //LRC
//			EMIT_SOUND_DYN( m_pPlayFrom, m_iChannel, szSoundFile, //LRC
//					(m_dpv.vol * 0.01), m_flAttenuation, SND_SPAWNING, m_dpv.pitch);

//			ALERT(at_console, "AMBGEN: spawn start\n");
		}
		else
		{
		UTIL_EmitAmbientSound ( ENT(pev), pev->origin, szSoundFile, 
				(m_dpv.vol * 0.01), m_flAttenuation, SND_SPAWNING, m_dpv.pitch);
		}
		SetNextThink( 0.1 );
	}
}
Exemplo n.º 17
0
float CalcLocus_Ratio( CBaseEntity *pLocus, const char *szText )
{
	if ((*szText >= '0' && *szText <= '9') || *szText == '-')
	{ // assume it's a float
		return atof( szText );
	}

	CBaseEntity *pCalc = UTIL_FindEntityByTargetname(NULL, szText, pLocus);

	if (pCalc != NULL)
		return pCalc->CalcRatio( pLocus );

	ALERT(at_error, "Bad or missing calc_ratio entity \"%s\"\n", szText);
	return 0; // we need some signal for "fail". NaN, maybe?
}
Exemplo n.º 18
0
void CBaseTrainDoor :: FindTrain( void )
{
	CBaseEntity *pEntity = NULL;

	while(( pEntity = UTIL_FindEntityByTargetname( pEntity, STRING( m_iParent ))) != NULL )
	{
		// found the tracktrain
		if( FClassnameIs( pEntity->pev, "func_tracktrain" ) )
		{
			m_pTrain = (CFuncTrackTrain *)pEntity;
			m_pTrain->SetTrainDoor( this ); // tell train about door
			break;
		}
	}
}
Exemplo n.º 19
0
void CInfoGroup::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	CBaseEntity *pTarget = UTIL_FindEntityByTargetname( NULL, STRING( pev->target ) );

	if (pTarget && pTarget->IsAlias())
	{
		if (pev->spawnflags & SF_GROUP_DEBUG)
			ALERT(at_debug, "DEBUG: info_group %s changes the contents of %s \"%s\"\n",STRING(pev->targetname), STRING(pTarget->pev->classname), STRING(pTarget->pev->targetname));
		((CBaseAlias*)pTarget)->ChangeValue(this);
	}
	else if (pev->target)
	{
		ALERT(at_debug, "info_group \"%s\": alias \"%s\" was not found or not an alias!", STRING(pev->targetname), STRING(pev->target));
	}
}
Exemplo n.º 20
0
void CMomentaryRotButton :: UpdateTarget( float value )
{
	if( !FStringNull( pev->target ) && m_bUpdateTarget )
	{
		CBaseEntity *pTarget = NULL;
		while( 1 )
		{
			pTarget = UTIL_FindEntityByTargetname( pTarget, STRING( pev->target ));

			if( FNullEnt( pTarget ))
				break;

			pTarget->Use( this, this, USE_SET, value );
		}
	}
}
Exemplo n.º 21
0
// find a viable entity
bool CCineMonster::FindEntity()
{
	m_hTargetEnt = nullptr;

	CBaseEntity* pTargetEnt = nullptr;
	CBaseMonster* pTarget = nullptr;

	while( ( pTargetEnt = UTIL_FindEntityByTargetname( pTargetEnt, STRING( m_iszEntity ) ) ) != nullptr )
	{
		if( pTargetEnt->GetFlags().Any( FL_MONSTER ) )
		{
			pTarget = pTargetEnt->MyMonsterPointer();

			if( pTarget && pTarget->CanPlaySequence( FCanOverrideState(), SS_INTERRUPT_BY_NAME ) )
			{
				m_hTargetEnt = pTarget;
				return true;
			}

			ALERT( at_console, "Found %s, but can't play!\n", STRING( m_iszEntity ) );
		}

		pTarget = nullptr;
	}

	if( !pTarget )
	{
		pTargetEnt = nullptr;
		while( ( pTargetEnt = UTIL_FindEntityInSphere( pTargetEnt, GetAbsOrigin(), m_flRadius ) ) != nullptr )
		{
			if( pTargetEnt->ClassnameIs( STRING( m_iszEntity ) ) )
			{
				if( pTargetEnt->GetFlags().Any( FL_MONSTER ) )
				{
					pTarget = pTargetEnt->MyMonsterPointer();
					if( pTarget && pTarget->CanPlaySequence( FCanOverrideState(), SS_INTERRUPT_IDLE ) )
					{
						m_hTargetEnt = pTarget;
						return true;
					}
				}
			}
		}
	}
	m_hTargetEnt = nullptr;
	return false;
}
Exemplo n.º 22
0
// find all the cinematic entities with my targetname and stop them from playing
void CCineMonster::CancelScript( void )
{
	ALERT( at_aiconsole, "Cancelling script: %s\n", STRING( m_iszPlay ) );

	if( !HasTargetname() )
	{
		ScriptEntityCancel( this );
		return;
	}

	CBaseEntity* pCineTarget = nullptr;

	while( ( pCineTarget = UTIL_FindEntityByTargetname( pCineTarget, GetTargetname() ) ) != nullptr )
	{
		ScriptEntityCancel( pCineTarget );
	}
}
Exemplo n.º 23
0
Vector CalcLocus_Velocity( CBaseEntity *pEntity, CBaseEntity *pLocus, const char *szText )
{
	if ((*szText >= '0' && *szText <= '9') || *szText == '-')
	{ // it's a vector
		Vector tmp;
		UTIL_StringToRandomVector( (float *)tmp, szText );
		return tmp;
	}

	CBaseEntity *pCalc = UTIL_FindEntityByTargetname(NULL, szText, pLocus);
		
	if (pCalc != NULL)
		return pCalc->CalcVelocity( pLocus );
		
	ALERT(at_error, "%s \"%s\" has bad or missing calc_velocity value \"%s\"\n", STRING(pEntity->pev->classname), STRING(pEntity->pev->targetname), szText);
	return g_vecZero;
}
Exemplo n.º 24
0
void CFuncVehicleControls::Find()
{
	CFuncVehicle *pVehicle = nullptr;
	while ((pVehicle = UTIL_FindEntityByTargetname(pVehicle, pev->target)))
	{
		if (FClassnameIs(pVehicle->pev, "func_vehicle"))
			break;
	}

	if (FNullEnt(pVehicle))
	{
		ALERT(at_console, "No vehicle %s\n", STRING(pev->target));
		return;
	}

	pVehicle->SetControls(pev);
	UTIL_Remove(this);
}
Exemplo n.º 25
0
void CFuncTankControls::Think()
{
	CBaseEntity* pTarget = nullptr;

	do
	{
		pTarget = UTIL_FindEntityByTargetname( pTarget, GetTarget() );
	}
	while( !FNullEnt( pTarget ) && strncmp( pTarget->GetClassname(), "func_tank", 9 ) );

	if( FNullEnt( pTarget ) )
	{
		ALERT( at_console, "No tank %s\n", GetTarget() );
		return;
	}

	m_pTank = static_cast<CFuncTank*>( pTarget );
}
Exemplo n.º 26
0
CBaseEntity* UTIL_RandomTargetname( const char* const pszName )
{
	int total = 0;

	CBaseEntity *pEntity = nullptr;
	CBaseEntity *pNewEntity = nullptr;

	//Enumerate all entities with the given name and assign it to pEntity if a random check succeeds.
	while( ( pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, pszName ) ) != nullptr )
	{
		++total;

		if( RANDOM_LONG( 0, total - 1 ) < 1 )
			pEntity = pNewEntity;
	}

	return pEntity;
}
Exemplo n.º 27
0
// string inEntityName
static int getEntityIndexWithName(lua_State* inState)
{
	// Get entity name
	int theEntityIndex = -1;

	const char* theEntityName = lua_tostring(inState, 1);
	if(theEntityName)
	{
		CBaseEntity* theEntity = UTIL_FindEntityByTargetname(NULL, theEntityName);
		if(theEntity)
		{
			theEntityIndex = theEntity->entindex();
		}
	}

	lua_pushnumber(inState, theEntityIndex);

	return 1;
}
Exemplo n.º 28
0
	void PostActivate( void )
	{
		Vector		dir;
		CBaseEntity	*pOwner;
	
		if( FStringNull( pev->target ))
			return;	// dir set with angles

		pOwner = UTIL_FindEntityByTargetname( NULL, STRING( pev->target ));
		if( !pOwner ) return; // dir set with angles

		if( pOwner->pFlags & PF_POINTENTITY )
		{
			// xash allows to precache from random place
			UTIL_PrecacheSound( "world/jumppad.wav" );

			pev->owner = pOwner->edict();
			pev->button = TRUE;	// Q3A trigger_push
		}
	}
Exemplo n.º 29
0
void CBaseDoor :: ChainTouch( CBaseEntity *pOther )
{
	// to prevent recursion
	if( m_isChaining ) return;

	CBaseEntity *pEnt = NULL;

	while(( pEnt = UTIL_FindEntityByTargetname( pEnt, STRING( m_iChainTarget ))) != NULL )
	{
		if( pEnt == this ) continue;

		CBaseDoor *pDoor = (CBaseDoor *)pEnt;

		if( pDoor )
		{
			pDoor->SetChaining( true );
			pDoor->Touch( pOther );
			pDoor->SetChaining( false );
		}
	}
}
Exemplo n.º 30
0
void CBaseDoor :: ChainUse( USE_TYPE useType, float value )
{
	// to prevent recursion
	if( m_isChaining ) return;

	CBaseEntity *pEnt = NULL;

	while(( pEnt = UTIL_FindEntityByTargetname( pEnt, STRING( m_iChainTarget ))) != NULL )
	{
		if( pEnt == this ) continue;

		CBaseDoor *pDoor = (CBaseDoor *)pEnt;

		if( pDoor )
		{
			pDoor->SetChaining( true );
			pDoor->Use( m_hActivator, this, useType, value );
			pDoor->SetChaining( false );
		}
	}
}