Esempio n. 1
0
void CHeadQuartersRules :: SpawnNextBase( void )
{
	if( CurrentBase )
		CurrentBase->pev->effects |= EF_NODRAW;
	CurrentBase = UTIL_FindEntityByClassname( CurrentBase, "func_headq" );
	if( !CurrentBase )
		CurrentBase = UTIL_FindEntityByClassname( CurrentBase, "func_headq" );
	CurrentBase->pev->effects &= ~EF_NODRAW;
	SpawnTime = gpGlobals->time;
}
Esempio n. 2
0
void RemoveAllNodeEntity()
{
   CEntity *pFoundNode = UTIL_FindEntityByClassname(NULL, "info_node");
   if (pFoundNode == NULL)
      return; // No node entities

   do {
      CEntity *pNextNode = UTIL_FindEntityByClassname(pFoundNode, "info_node");
      REMOVE_ENTITY(pFoundNode->edict());
      pFoundNode = pNextNode;
   } while (pFoundNode != NULL);
}
Esempio n. 3
0
void CHostage::SendHostageEventMsg(void)
{
	CBaseEntity *pEntity = NULL;

	while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL)
	{
		if (FNullEnt(pEntity->edict()))
			break;

		if (!pEntity->IsPlayer())
			continue;

		if (pEntity->pev->flags == FL_DORMANT)
			continue;

		CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev);

		if (pPlayer->pev->deadflag == DEAD_NO && pPlayer->m_iTeam == TEAM_CT)
		{
			MESSAGE_BEGIN(MSG_ONE, gmsgHostageK, NULL, pPlayer->pev);
			WRITE_BYTE(m_iHostageIndex);
			MESSAGE_END();
		}

		if (pPlayer->pev->deadflag == DEAD_NO)
			pPlayer->SendHostageIcons();
	}
}
Esempio n. 4
0
/* <18b79c> ../cstrike/dlls/training_gamerules.cpp:151 */
void CHalfLifeTraining::__MAKE_VHOOK(PlayerSpawn)(CBasePlayer *pPlayer)
{
	if (pPlayer->m_bNotKilled)
		return;

	fInBuyArea = TRUE;
	fVisitedBuyArea = FALSE;
	FillAccountTime = 0;

	pPlayer->m_iJoiningState = JOINED;
	pPlayer->m_iTeam = CT;
	pPlayer->m_bNotKilled = true;
	pPlayer->pev->body = 0;
	pPlayer->m_iModelName = MODEL_URBAN;

	fVGUIMenus = pPlayer->m_bVGUIMenus;
	SET_MODEL(ENT(pPlayer->pev), "models/player.mdl");

	CBaseEntity *pWeaponEntity = NULL;

	while ((pWeaponEntity = UTIL_FindEntityByClassname(pWeaponEntity, "game_player_equip")) != NULL)
	{
		pWeaponEntity->Touch(pPlayer);
	}

	pPlayer->SetPlayerModel(false);
	pPlayer->Spawn();
	pPlayer->m_iHideHUD |= (HIDEHUD_WEAPONS | HIDEHUD_HEALTH | HIDEHUD_TIMER | HIDEHUD_MONEY);
}
Esempio n. 5
0
//=========================================================
//=========================================================
void CHalfLifeMultiplay :: PlayerSpawn( CBasePlayer *pPlayer )
{
	BOOL		addDefault;
	CBaseEntity	*pWeaponEntity = NULL;

	pPlayer->pev->weapons |= (1<<IT_AXE);
	
	addDefault = TRUE;

	while ( pWeaponEntity = UTIL_FindEntityByClassname( pWeaponEntity, "game_player_equip" ))
	{
		pWeaponEntity->Touch( pPlayer );
		addDefault = FALSE;
	}

	if ( addDefault )
	{
		// Start with init ammoload
		pPlayer->m_iAmmoShells = 25;

		// Start with shotgun and axe
		pPlayer->GiveNamedItem( "weapon_quakegun" );
		pPlayer->m_iQuakeItems |= (IT_SHOTGUN | IT_AXE);
		pPlayer->m_iQuakeWeapon = pPlayer->W_BestWeapon();
		pPlayer->W_SetCurrentAmmo();
	}
}
Esempio n. 6
0
void CRadiomsg :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{

	CBaseEntity *pPlayer = UTIL_FindEntityByClassname ( NULL,"player" );

	char	txt [256];
	sprintf ( txt, STRING(m_iszText));
	int		len = strlen ( txt );


	MESSAGE_BEGIN( MSG_ONE, gmsgRadioMsg, NULL, pPlayer->pev );

		WRITE_COORD ( gpGlobals->time );
		WRITE_LONG	( m_iHead );
		WRITE_LONG	( len );

		for ( int i=0; i<180; i++ ) {
			WRITE_BYTE	( txt[i] );	}


	MESSAGE_END();


	if ( FStringNull ( m_iszSentence ) )
		return;

//	EMIT_SOUND_SUIT(pPlayer->edict(), STRING(m_iszSentence) );

	EMIT_SOUND_DYN(pPlayer->edict(), CHAN_STATIC, STRING(m_iszSentence), 1.0, ATTN_NORM, 0, 100);


}
Esempio n. 7
0
//-----------------------------------------------------------------------------
// Purpose: Setup the item's respawn in the time set
//-----------------------------------------------------------------------------
void CItem::Respawn( float flTime )
{
	pev->effects |= EF_NODRAW;
	SetTouch( NULL );

	if (!m_flMoneyRandomRespawn)
	{
		UTIL_SetOrigin( pev, pev->origin );
	}
		else
	{
		CBaseEntity *pSpot = NULL;
		for ( int i = RANDOM_LONG(1,5); i > 0; i-- )

		pSpot = UTIL_FindEntityByClassname( pSpot, "info_money_start" );

	if (pSpot)
	{
		Vector tmp = pSpot->pev->origin;
		UTIL_SetOrigin( pev, tmp );
		DROP_TO_FLOOR ( ENT(pev) );
	}
}

	// Come back in time
	SetThink ( Materialize );
	pev->nextthink = gpGlobals->time + flTime;
}
Esempio n. 8
0
/*
================
SetupVisibility

A client can have a separate "view entity" indicating that his/her view should depend on the origin of that
view entity.  If that's the case, then pViewEntity will be non-NULL and will be used.  Otherwise, the current
entity's origin is used.  Either is offset by the view_ofs to get the eye position.

From the eye position, we set up the PAS and PVS to use for filtering network messages to the client.  At this point, we could
 override the actual PAS or PVS values, or use a different origin.

NOTE:  Do not cache the values of pas and pvs, as they depend on reusable memory in the engine, they are only good for this one frame
================
*/
void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas )
{
	Vector org;
	edict_t *pView = pClient;

	// Find the client's PVS
	if ( pViewEntity )
	{
		pView = pViewEntity;
	}

	// modif de Julien
	// camera du tank

	CBaseEntity *pEnt = CBaseEntity::Instance(pClient);
	if ( pEnt->IsPlayer() )
	{
		CBasePlayer *pPlayer = (CBasePlayer*)pEnt;
		if( pPlayer->m_iDrivingTank == TRUE )
		{
			// origine de la camera et non pas du joueur
			pView = UTIL_FindEntityByClassname(NULL, "info_tank_camera" )->edict();
		}
	}

	org = pView->v.origin + pView->v.view_ofs;
	if ( pView->v.flags & FL_DUCKING )
	{
		org = org + ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN );
	}

	*pvs = ENGINE_SET_PVS ( (float *)&org );
	*pas = ENGINE_SET_PAS ( (float *)&org );
}
Esempio n. 9
0
// Periodic check of hostage count in case we lost some
void CCSBot::UpdateHostageEscortCount()
{
	const float updateInterval = 1.0f;
	if (m_hostageEscortCount == 0 || gpGlobals->time - m_hostageEscortCountTimestamp < updateInterval)
		return;

	m_hostageEscortCountTimestamp = gpGlobals->time;

	// recount the hostages in case we lost some
	m_hostageEscortCount = 0;

	CHostage *pHostage = nullptr;
	while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
	{
		if (FNullEnt(pHostage->edict()))
			break;

		// skip dead or rescued hostages
		if (!pHostage->IsAlive())
			continue;

		// check if hostage has targeted us, and is following
		if (pHostage->IsFollowing(this))
			m_hostageEscortCount++;
	}
}
Esempio n. 10
0
void CCSBot::UpdateHostageEscortCount()
{
	const float updateInterval = 1.0f;
	if (m_hostageEscortCount == 0 || gpGlobals->time - m_hostageEscortCountTimestamp < updateInterval)
		return;

	m_hostageEscortCountTimestamp = gpGlobals->time;

	// recount the hostages in case we lost some
	m_hostageEscortCount = 0;

	CHostage *hostage = NULL;
	while ((hostage = static_cast<CHostage *>(UTIL_FindEntityByClassname(hostage, "hostage_entity"))) != NULL)
	{
		if (FNullEnt(hostage->edict()))
			break;

		// skip dead or rescued hostages
		if (!hostage->IsValid())
			continue;

		// check if hostage has targeted us, and is following
		if (hostage->IsFollowing(this))
			++m_hostageEscortCount;
	}
}
Esempio n. 11
0
void CC4::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
	if (m_pPlayer)
		return;

	CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(1);

	if (pPlayer)
	{
		edict_t *target = pPlayer->m_pentCurBombTarget;
		pPlayer->m_pentCurBombTarget = NULL;

#ifndef CLIENT_WEAPONS
		if (pev->speed != 0 && g_pGameRules)
			g_pGameRules->m_iC4Timer = (int)pev->speed;
#endif
		EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM);
		CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0));
		CGrenade *pGrenade = NULL;

		while ((pGrenade = (CGrenade *)UTIL_FindEntityByClassname(pGrenade, "grenade")) != NULL)
		{
			if (pGrenade->m_bIsC4 && pGrenade->m_flNextFreq == gpGlobals->time)
			{
				pGrenade->pev->target = pev->target;
				pGrenade->pev->noise1 = pev->noise1;
				break;
			}
		}

		pPlayer->m_pentCurBombTarget = target;
		SUB_Remove();
	}
}
Esempio n. 12
0
edict_t *CMTalkMonster::EnumFriends( edict_t *pPrevious, int listNumber, BOOL bTrace )
{
	edict_t *pFriend = pPrevious;
	char *pszFriend;
	TraceResult tr;
	Vector vecCheck;

	pszFriend = m_szFriends[ FriendNumber(listNumber) ];
	while (pFriend = UTIL_FindEntityByClassname( pFriend, pszFriend ))
	{
		if (pFriend == this->edict() || !UTIL_IsAlive(pFriend))
			// don't talk to self or dead people
			continue;
		if ( bTrace )
		{
			vecCheck = pFriend->v.origin;
			vecCheck.z = pFriend->v.absmax.z;

			UTIL_TraceLine( pev->origin, vecCheck, ignore_monsters, ENT(pev), &tr);
		}
		else
			tr.flFraction = 1.0;

		if (tr.flFraction == 1.0)
		{
			return pFriend;
		}
	}

	return NULL;
}
Esempio n. 13
0
void COsprey :: FindAllThink( void )
{
	CBaseEntity *pEntity = NULL;

	m_iUnits = 0;
	while (m_iUnits < MAX_CARRY && (pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" )) != NULL)
	{
		if (pEntity->IsAlive())
		{
			m_hGrunt[m_iUnits]		= pEntity;
			m_vecOrigin[m_iUnits]	= pEntity->pev->origin;
			m_iUnits++;
		}
	}

	if (m_iUnits == 0)
	{
		ALERT( at_console, "osprey error: no grunts to resupply\n");
		UTIL_Remove( this );
		return;
	}
	SetThink( FlyThink );
	pev->nextthink = gpGlobals->time + 0.1;
	m_startTime = gpGlobals->time;
}
void COsprey :: FindAllThink( void )
{
	CBaseEntity *pEntity = NULL;

	m_iUnits = 0;
	while (m_iUnits < MAX_CARRY && (pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" )) != NULL)
	{
		if (pEntity->IsAlive())
		{
			m_hGrunt[m_iUnits]		= pEntity;
			m_vecOrigin[m_iUnits]	= pEntity->pev->origin;
			m_iUnits++;
		}
	}

	if (m_iUnits == 0)
	{
		m_iUnits = 4; //LRC - stop whining, just make the damn grunts...

//		ALERT( at_console, "osprey error: no grunts to resupply\n");
//		UTIL_Remove( this );
//		return;
	}
	SetThink(&COsprey :: FlyThink );
	SetNextThink( 0.1 );
	m_startTime = gpGlobals->time;
}
Esempio n. 15
0
CBaseEntity	*CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, const bool bTrace )
{
	CBaseEntity *pFriend = pPrevious;
	const char* pszFriend;
	TraceResult tr;
	Vector vecCheck;

	pszFriend = m_szFriends[ FriendNumber(listNumber) ];
	while( ( pFriend = UTIL_FindEntityByClassname( pFriend, pszFriend ) ) != nullptr )
	{
		if (pFriend == this || !pFriend->IsAlive())
			// don't talk to self or dead people
			continue;
		if ( bTrace )
		{
			vecCheck = pFriend->GetAbsOrigin();
			vecCheck.z = pFriend->GetAbsMax().z;

			UTIL_TraceLine( GetAbsOrigin(), vecCheck, ignore_monsters, ENT(pev), &tr);
		}
		else
			tr.flFraction = 1.0;

		if (tr.flFraction == 1.0)
		{
			return pFriend;
		}
	}

	return NULL;
}
Esempio n. 16
0
void CMultiSource::Register( void )
{
	m_iTotal = 0;
	memset( m_rgEntities, 0, MS_MAX_TARGETS * sizeof( EHANDLE ) );

	SetThink( &CMultiSource::SUB_DoNothing );

	// search for all entities which target this multisource (GetTargetname())

	CBaseEntity* pTarget = nullptr;

	while( ( pTarget = UTIL_FindEntityByTarget( pTarget, GetTargetname() ) ) != nullptr && ( m_iTotal < MS_MAX_TARGETS ) )
	{
		m_rgEntities[ m_iTotal++ ] = pTarget;
	}

	pTarget = nullptr;

	while( ( pTarget = UTIL_FindEntityByClassname( pTarget, "multi_manager" ) ) != nullptr && ( m_iTotal < MS_MAX_TARGETS ) )
	{
		if( pTarget->HasTarget( GetTargetname() ) )
			m_rgEntities[ m_iTotal++ ] = pTarget;
	}

	GetSpawnFlags().ClearFlags( SF_MULTI_INIT );
}
Esempio n. 17
0
//-----------------------------------------------------------------------------
// Purpose: Countdown to the round start
//-----------------------------------------------------------------------------
void CDiscArena::CountDownThink( void )
{
	// Freeze everyone until there's 3 seconds to go
	if ( m_iSecondsTillStart == 3 )
	{
		for ( int i = 0; i < (m_iPlayersPerTeam * 2); i++ )
		{
			if (m_hCombatants[i])
				((CBaseEntity*)m_hCombatants[i])->pev->maxspeed = 320;
		}
	}

	m_iSecondsTillStart--;

	// Play countdown VOX
	if (m_iSecondsTillStart < 5)
	{
		// Speech
		for ( int i = 0; i < (m_iPlayersPerTeam * 2); i++ )
		{
			if (m_hCombatants[i])
				((CBasePlayer*)(CBaseEntity*)m_hCombatants[i])->ClientHearVox( g_szCountDownVox[ m_iSecondsTillStart ] );
		}
	}

	// Send the message to the clients in the arena
	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i );

		if (pPlayer && (pPlayer->pev->groupinfo & pev->groupinfo) && pPlayer->m_bHasDisconnected != TRUE)
		{
			MESSAGE_BEGIN( MSG_ONE, gmsgStartRnd, NULL, pPlayer->edict() );
				WRITE_BYTE( m_iCurrRound );
				WRITE_BYTE( m_iSecondsTillStart );
				WRITE_BYTE( 0 );
			MESSAGE_END();
		}
	}

	if (m_iSecondsTillStart)
	{
		pev->nextthink = gpGlobals->time + 1.0;
	}
	else
	{
		m_iArenaState = ARENA_BATTLE_IN_PROGRESS;

		// Enable powerups
		CBaseEntity *pFunc = NULL;
		while ((pFunc = UTIL_FindEntityByClassname( pFunc, "item_powerup" )) != NULL)
		{
			((CDiscwarPowerup*)pFunc)->Enable();
		}

		pev->nextthink = gpGlobals->time + 1.0;
		SetThink( &CDiscArena::BattleThink );
	}
}
Esempio n. 18
0
/* <1efc6c> ../cstrike/dlls/career_tasks.cpp:268 */
void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim)
{
	if (m_isComplete || m_event != EVENT_KILL && (m_event != EVENT_HEADSHOT || !headshot))
	{
		return;
	}

	if (!pVictim || (m_defuser && !pVictim->m_bIsDefusing) || (m_vip && !pVictim->m_bIsVIP))
	{
		return;
	}

	if (m_rescuer)
	{
		int hostages_ = 0;
		CBaseEntity *hostageEntity = NULL;

		while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL)
		{
			CHostage *hostage = (CHostage *)hostageEntity;

			if (!hostage || hostage->pev->takedamage != DAMAGE_YES)
				continue;

			if (hostage->m_improv)
			{
				if (!hostage->IsFollowingSomeone())
					continue;
			}
			else if (!hostage->m_hTargetEnt || hostage->m_State != CHostage::FOLLOW)
				continue;

			if (hostage->IsValid() && hostage->m_target == pAttacker)
				++hostages_;
		}

		if (!hostages_)
			return;	
	}

	if (m_weaponId == WEAPON_SHIELDGUN)
	{
		if (!killerHasShield)
			return;
	}
	else if (m_weaponId)
	{
		if (m_weaponId != weaponId)
			return;
	}
	else if (m_weaponClassId)
	{
		if (m_weaponClassId != weaponClassId)
			return;
	}

	++m_eventsSeen;
	SendPartialNotification();
}
Esempio n. 19
0
//-----------------------------------------------------------------------------
// Purpose: Restore all the world objects
//-----------------------------------------------------------------------------
void CDiscArena::RestoreWorldObjects( void )
{
	CBaseEntity *pFunc = NULL;
	while ((pFunc = UTIL_FindEntityByClassname( pFunc, "func_plat_toggleremove" )) != NULL)
	{
		((CPlatToggleRemove*)pFunc)->Reset();
	}
	while ((pFunc = UTIL_FindEntityByClassname( pFunc, "func_disctoggle" )) != NULL)
	{
		((CDiscTarget*)pFunc)->Reset();
	}

	// Disable powerups
	while ((pFunc = UTIL_FindEntityByClassname( pFunc, "item_powerup" )) != NULL)
	{
		((CDiscwarPowerup*)pFunc)->Disable();
	}
}
Esempio n. 20
0
void UTIL_HostSay( edict_t *pEntity, char *message )
{
   int   j;
   char  text[128];
   char *pc;
   edict_t *client;

   // make sure the text has content
   for ( pc = message; pc != NULL && *pc != 0; pc++ )
   {
      if ( isprint( *pc ) && !isspace( *pc ) )
      {
         pc = NULL;   // we've found an alphanumeric character,  so text is valid
         break;
      }
   }

   if ( pc != NULL )
      return;  // no character found, so say nothing

   // turn on color set 2  (color on,  no sound)
   sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) );

   j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
   if ( (int)strlen(message) > j )
      message[j] = 0;

   strcat( text, message );
   strcat( text, "\n" );

   // loop through all players
   // Start with the first player.
   // This may return the world in single player if the client types something between levels or during spawn
   // so check it, or it will infinite loop

   if (gmsgSayText == 0)
      gmsgSayText = REG_USER_MSG( "SayText", -1 );

   client = NULL;
   while ( ((client = UTIL_FindEntityByClassname( client, "player" )) != NULL) &&
           (!FNullEnt(client)) ) 
   {
      if ( client == pEntity )  // skip sender of message
         continue;

      MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, gmsgSayText, NULL, client );
         WRITE_BYTE( ENTINDEX(pEntity) );
         WRITE_STRING( text );
      MESSAGE_END();
   }

   // print to the sending client
   MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, gmsgSayText, NULL, pEntity );
      WRITE_BYTE( ENTINDEX(pEntity) );
      WRITE_STRING( text );
   MESSAGE_END();
}
Esempio n. 21
0
void ShowNodeEntity(bool show)
{
   CEntity *pFoundNode = NULL;
   while ((pFoundNode = UTIL_FindEntityByClassname(pFoundNode, "info_node")) != NULL) {
      if (show)
         pFoundNode->pev->effects &= ~EF_NODRAW;
      else
         pFoundNode->pev->effects |= EF_NODRAW;
   }
}
Esempio n. 22
0
void CBasePlayer::SendWeatherUpdate()
{
	WeatherType::WeatherType type = WeatherType::NONE;

	if( UTIL_FindEntityByClassname( nullptr, "env_rain" ) )
	{
		type = WeatherType::RAIN;
	}
	else if( UTIL_FindEntityByClassname( nullptr, "env_snow" ) )
	{
		type = WeatherType::SNOW;
	}

	if( type != WeatherType::NONE )
	{
		MESSAGE_BEGIN( MSG_ONE, gmsgReceiveW, nullptr, this );
			WRITE_BYTE( type );
		MESSAGE_END();
	}
}
// updates all flags which rely on a certain point
void CPointManager::UpdateAllFlags( int iPointId )
{
	const char *szName = STRING(ReturnPointByID(iPointId)->pPoint->pev->targetname);

		// -reseter ent
	CPointModel *pFlag = NULL;
	pFlag = (CPointModel*)UTIL_FindEntityByClassname( pFlag, "env_flag" );

	// -this allows us to reset the ents the mapper wants
	while (pFlag)
	{ 
		if(pFlag)
		{
			if(FStrEq(STRING(pFlag->pev->target),szName))
			{
				pFlag->SetModel((int)(ReturnPointByID(iPointId)->pPoint->GetEngagingTeam()));
			}
		}
		pFlag = (CPointModel*)UTIL_FindEntityByClassname( pFlag, "env_flag" );
	}
}
Esempio n. 24
0
void CGMan :: StartTask( Task_t *pTask )
{
	switch( pTask->iTask )
	{
	case TASK_WAIT:
		if (m_hPlayer == NULL)
		{
			m_hPlayer = UTIL_FindEntityByClassname( NULL, "player" );
		}
		break;
	}
	CBaseMonster::StartTask( pTask );
}
Esempio n. 25
0
void CMultiSource::Register()
{
	m_iTotal = 0;
	Q_memset(m_rgEntities, 0, MS_MAX_TARGETS * sizeof(EHANDLE));

	SetThink(&CMultiSource::SUB_DoNothing);

	// search for all entities which target this multisource (pev->targetname)
#ifdef REGAMEDLL_FIXES
	CBaseEntity *pTarget = nullptr;
	while (m_iTotal < MS_MAX_TARGETS && (pTarget = UTIL_FindEntityByString(pTarget, "target", STRING(pev->targetname)))) {
		m_rgEntities[m_iTotal++] = pTarget;
	}

	pTarget = nullptr;
	while (m_iTotal < MS_MAX_TARGETS && (pTarget = UTIL_FindEntityByClassname(pTarget, "multi_manager")))
	{
		if (pTarget->HasTarget(pev->targetname)) {
			m_rgEntities[m_iTotal++] = pTarget;
		}
	}
#else
	edict_t *pentTarget = FIND_ENTITY_BY_STRING(NULL, "target", STRING(pev->targetname));

	while (!FNullEnt(pentTarget) && m_iTotal < MS_MAX_TARGETS)
	{
		CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget);

		if (pTarget != NULL)
		{
			m_rgEntities[m_iTotal++] = pTarget;
		}

		pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "target", STRING(pev->targetname));
	}

	pentTarget = FIND_ENTITY_BY_STRING(NULL, "classname", "multi_manager");

	while (!FNullEnt(pentTarget) && m_iTotal < MS_MAX_TARGETS)
	{
		CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget);
		if (pTarget != NULL && pTarget->HasTarget(pev->targetname))
		{
			m_rgEntities[m_iTotal++] = pTarget;
		}

		pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "classname", "multi_manager");
	}
#endif
	pev->spawnflags &= ~SF_MULTI_INIT;
}
Esempio n. 26
0
CBaseEntity *CNihilanthHVR::RandomClassname( const char *szName )
{
	int total = 0;

	CBaseEntity *pEntity = NULL;
	CBaseEntity *pNewEntity = NULL;
	while ((pNewEntity = UTIL_FindEntityByClassname( pNewEntity, szName )) != NULL)
	{
		total++;
		if (RANDOM_LONG(0,total-1) < 1)
			pEntity = pNewEntity;
	}
	return pEntity;
}
/*
================
SpectatorImpulseCommand

Called by SpectatorThink if the spectator entered an impulse
================
*/
void CBaseSpectator::SpectatorImpulseCommand(void)
{
	static edict_t	*pGoal		= NULL;
	CBaseEntity		*pPreviousGoal;
	CBaseEntity		*pCurrentGoal;
	BOOL			bFound;
	
	switch (pev->impulse)
	{
	case 1:
		// teleport the spectator to the next spawn point; note that if the spectator is
		// tracking, this doesn't do much
		pPreviousGoal = (CBaseEntity*)GET_PRIVATE(pGoal);
		pCurrentGoal  = (CBaseEntity*)GET_PRIVATE(pGoal);
		// Start at the current goal, skip the world, and stop if we looped back around

		bFound = FALSE;
		while (1)
		{
			pCurrentGoal = UTIL_FindEntityByClassname(pCurrentGoal, "info_player_deathmatch");
			// Looped around, failure
			if (pCurrentGoal == pPreviousGoal)
			{
				ALERT(at_debug, "Could not find a spawn spot.\n");
				break;
			}
			// Found a non-world entity, set success, otherwise, look for the next one.
			if ( pCurrentGoal )
			{
				bFound = TRUE;
				break;
			}
		}

		if (!bFound)  // Didn't find a good spot.
			break;
		
		pGoal = ENT(pCurrentGoal->pev);
		UTIL_SetOrigin( this, pGoal->v.origin );
		pev->angles = pGoal->v.angles;
		pev->fixangle = FALSE;
		break;
	default:
		ALERT(at_debug, "Unknown spectator impulse\n");
		break;
	}

	pev->impulse = 0;
}
Esempio n. 28
0
void CMultiSource :: Register( void )
{ 
	m_iTotal = 0;
	memset( m_rgEntities, 0, MAX_MASTER_TARGETS * sizeof( EHANDLE ));

	SetThink( NULL );

	// search for all entities which target this multisource (pev->target)
	CBaseEntity *pTarget = UTIL_FindEntityByTarget( NULL, GetTargetname( ));

	while( pTarget && ( m_iTotal < MAX_MASTER_TARGETS ))
	{
		m_rgEntities[m_iTotal++] = pTarget;
		pTarget = UTIL_FindEntityByTarget( pTarget, GetTargetname( ));
	}

	// search for all monsters which target this multisource (TriggerTarget)
	pTarget = UTIL_FindEntityByMonsterTarget( NULL, GetTargetname( ));

	while( pTarget && ( m_iTotal < MAX_MASTER_TARGETS ))
	{
		m_rgEntities[m_iTotal++] = pTarget;
		pTarget = UTIL_FindEntityByMonsterTarget( pTarget, GetTargetname( ));
	}

	pTarget = UTIL_FindEntityByClassname( NULL, "multi_manager" );

	while( pTarget && ( m_iTotal < MAX_MASTER_TARGETS ))
	{
		if( pTarget->HasTarget( pev->targetname ))
			m_rgEntities[m_iTotal++] = pTarget;
		pTarget = UTIL_FindEntityByClassname( pTarget, "multi_manager" );
	}

	ClearBits( pev->spawnflags, SF_MULTI_INIT );
}
Esempio n. 29
0
void CGrenade :: UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code )
{
	edict_t *pentOwner;

	if ( !pevOwner )
		return;

	CBaseEntity	*pOwner = CBaseEntity::Instance( pevOwner );

	pentOwner = pOwner->edict();

	CBaseEntity *pEnt = UTIL_FindEntityByClassname( NULL, "grenade" );
	while ( pEnt )
		{
			if ( FBitSet( pEnt->pev->spawnflags, SF_DETONATE ) && pEnt->pev->owner == pentOwner )
			{
				if ( code == SATCHEL_DETONATE )
					pEnt->Use( pOwner, pOwner, USE_ON, 0 );
				else	// SATCHEL_RELEASE
					pEnt->pev->owner = NULL;
			}
		pEnt = UTIL_FindEntityByClassname( pEnt, "grenade" );
	}
}
Esempio n. 30
0
//=========================================================
// CheckRangeAttack2 - check bravery and try to resurect dead comrades
//=========================================================
BOOL CISlave :: CheckRangeAttack2 ( float flDot, float flDist )
{
//	if ( mp_am_movecorpses.value = 0  ) //si DESACTIVADO
//	{
//		return FALSE;
//	}

//SP: regeneracion de colegas activada!
	if (m_flNextAttack > gpGlobals->time)
	{
		return FALSE;
	}

	m_hDead = NULL;
	m_iBravery = 0;

	CBaseEntity *pEntity = NULL;
//	while (pEntity = UTIL_FindEntityByClassname( pEntity, m_IslaveFriends ))

	while ((pEntity = UTIL_FindEntityByClassname( pEntity, "monster_alien_slave" )) != NULL)
	{
		TraceResult tr;

		UTIL_TraceLine( EyePosition( ), pEntity->EyePosition( ), ignore_monsters, ENT(pev), &tr );
		if (tr.flFraction == 1.0 || tr.pHit == pEntity->edict())
		{
			if (pEntity->pev->deadflag == DEAD_DEAD)
			{
				float d = (pev->origin - pEntity->pev->origin).Length();
				if (d < flDist)
				{
					m_hDead = pEntity;
					flDist = d;
				}
				m_iBravery--;
			}
			else
			{
				m_iBravery++;
			}
		}
	}
	if (m_hDead != NULL)
		return TRUE;
	else
		return FALSE;
}